Navigation Menu

Skip to content
This repository has been archived by the owner on Nov 29, 2017. It is now read-only.

Commit

Permalink
merged master back
Browse files Browse the repository at this point in the history
  • Loading branch information
njlxyaoxinwei committed Apr 3, 2015
2 parents 147f53c + ae4526d commit 43b86ec
Show file tree
Hide file tree
Showing 48 changed files with 1,429 additions and 264 deletions.
2 changes: 1 addition & 1 deletion Gemfile
Expand Up @@ -2,7 +2,7 @@ source 'https://rubygems.org'

ruby '2.1.2' # Version in .ruby-version must match

gem 'rails', '3.2.19'
gem 'rails', '3.2.21'
gem 'mysql2'

gem 'jquery-rails'
Expand Down
60 changes: 30 additions & 30 deletions Gemfile.lock
@@ -1,33 +1,33 @@
GEM
remote: https://rubygems.org/
specs:
actionmailer (3.2.19)
actionpack (= 3.2.19)
actionmailer (3.2.21)
actionpack (= 3.2.21)
mail (~> 2.5.4)
actionpack (3.2.19)
activemodel (= 3.2.19)
activesupport (= 3.2.19)
actionpack (3.2.21)
activemodel (= 3.2.21)
activesupport (= 3.2.21)
builder (~> 3.0.0)
erubis (~> 2.7.0)
journey (~> 1.0.4)
rack (~> 1.4.5)
rack-cache (~> 1.2)
rack-test (~> 0.6.1)
sprockets (~> 2.2.1)
activemodel (3.2.19)
activesupport (= 3.2.19)
activemodel (3.2.21)
activesupport (= 3.2.21)
builder (~> 3.0.0)
activerecord (3.2.19)
activemodel (= 3.2.19)
activesupport (= 3.2.19)
activerecord (3.2.21)
activemodel (= 3.2.21)
activesupport (= 3.2.21)
arel (~> 3.0.2)
tzinfo (~> 0.3.29)
activerecord-import (0.7.0)
activerecord (>= 3.0)
activeresource (3.2.19)
activemodel (= 3.2.19)
activesupport (= 3.2.19)
activesupport (3.2.19)
activeresource (3.2.21)
activemodel (= 3.2.21)
activesupport (= 3.2.21)
activesupport (3.2.21)
i18n (~> 0.6, >= 0.6.4)
multi_json (~> 1.0)
addressable (2.3.6)
Expand Down Expand Up @@ -138,7 +138,7 @@ GEM
hike (1.2.3)
hitimes (1.2.2)
htmlentities (4.3.2)
i18n (0.6.11)
i18n (0.7.0)
icalendar (2.2.0)
jcrop-rails-v2 (0.9.12.3)
journey (1.0.4)
Expand All @@ -149,7 +149,7 @@ GEM
railties (>= 3.1, < 5)
jquery-ui-rails (5.0.1)
railties (>= 3.2.16)
json (1.8.1)
json (1.8.2)
launchy (2.4.2)
addressable (~> 2.3)
letter_opener (1.2.0)
Expand Down Expand Up @@ -198,24 +198,24 @@ GEM
rack
rack-ssl (1.3.4)
rack
rack-test (0.6.2)
rack-test (0.6.3)
rack (>= 1.0)
rails (3.2.19)
actionmailer (= 3.2.19)
actionpack (= 3.2.19)
activerecord (= 3.2.19)
activeresource (= 3.2.19)
activesupport (= 3.2.19)
rails (3.2.21)
actionmailer (= 3.2.21)
actionpack (= 3.2.21)
activerecord (= 3.2.21)
activeresource (= 3.2.21)
activesupport (= 3.2.21)
bundler (~> 1.0)
railties (= 3.2.19)
railties (3.2.19)
actionpack (= 3.2.19)
activesupport (= 3.2.19)
railties (= 3.2.21)
railties (3.2.21)
actionpack (= 3.2.21)
activesupport (= 3.2.21)
rack-ssl (~> 1.3.2)
rake (>= 0.8.7)
rdoc (~> 3.4)
thor (>= 0.14.6, < 2.0)
rake (10.3.2)
rake (10.4.2)
rb-fsevent (0.9.4)
rb-inotify (0.9.5)
ffi (>= 0.5.0)
Expand Down Expand Up @@ -295,7 +295,7 @@ GEM
treetop (1.4.15)
polyglot
polyglot (>= 0.3.1)
tzinfo (0.3.41)
tzinfo (0.3.43)
uglifier (2.5.3)
execjs (>= 0.3.0)
json (>= 1.8.0)
Expand Down Expand Up @@ -345,7 +345,7 @@ DEPENDENCIES
paperclip
pry-byebug
pry-rails
rails (= 3.2.19)
rails (= 3.2.21)
rspec
rspec-rails (~> 3.0.0)
ruby-net-ldap
Expand Down
1 change: 1 addition & 0 deletions app/assets/javascripts/application.js
Expand Up @@ -6,6 +6,7 @@
//= require jquery.Jcrop
//= require hoverIntent
//= require bootstrap-hover-dropdown
//= require jquery.tokeninput
//= require_tree .

//Don't load anything before the document is ready.
Expand Down
12 changes: 12 additions & 0 deletions app/assets/javascripts/token_input.js.coffee
@@ -0,0 +1,12 @@
@set_up_autocomplete = (id, data, pre) ->
$ ->
$("##{id}").tokenInput data,
theme: "facebook"
hintText: "Type to search for names, logins, departments and roles"
preventDuplicates: true
prePopulate: pre

@autocomplete_add = (id, data) ->
field = $("##{id}")
$.each data, (index, user)->
field.tokenInput "add", user
2 changes: 1 addition & 1 deletion app/assets/stylesheets/_token-input.css.scss
@@ -1,4 +1,4 @@
s/* Example tokeninput style #1: Token vertical list*/
/* Example tokeninput style #1: Token vertical list*/
ul.token-input-list {
overflow: hidden;
height: auto !important;
Expand Down
4 changes: 2 additions & 2 deletions app/assets/stylesheets/application.css.scss
Expand Up @@ -43,7 +43,7 @@ body { padding-top: 60px; }
@import 'shift_view_refactoring';
@import 'templates_show';
@import 'timeline';
@import 'token-input';
@import 'tokeninput-facebook';
@import 'user_profile';
@import 'verify_import';
@import 'token-input';
@import 'tokeninput-facebook'
2 changes: 0 additions & 2 deletions app/controllers/announcements_controller.rb
Expand Up @@ -15,13 +15,11 @@ def show

def new
@current_shift_location = current_user.current_shift.location if current_user.current_shift
@disable_locations = false
@announcement = Announcement.new
layout_check
end

def edit
@disable_locations = true
@announcement = Announcement.find(params[:id])
layout_check
end
Expand Down
18 changes: 13 additions & 5 deletions app/controllers/application_controller.rb
Expand Up @@ -86,16 +86,14 @@ def load_user_session
def require_department_admin
unless current_user.is_admin_of?(current_department)
error_message = "That action is restricted to department administrators."
flash[:error] = error_message
respond_to do |format|
format.html do
flash[:error] = error_message
redirect_to access_denied_path
end
format.js do
render :update do |page|
# display alert
ajax_alert(page, "<strong>error:</strong> "+error_message);
end
@ajax_error_message = "<strong>Error:</strong>" + error_message
render :update
return false
end
end
Expand Down Expand Up @@ -385,6 +383,16 @@ def join_date_and_time(form_output)
end
end


def parse_users_autocomplete(token_output)
result = []
list = token_output.split(',').map{|l| l.split("||")}
list.each do |tokens|
result += tokens[0].safe_constantize.find(tokens[1]).users
end
return result.uniq
end

def department_day_start_time
DateTime.now.in_time_zone(Time.zone).beginning_of_day + current_department.department_config.schedule_start.minutes
end
Expand Down
6 changes: 3 additions & 3 deletions app/controllers/calendars_controller.rb
Expand Up @@ -48,7 +48,7 @@ def update
end

def prepare_copy
@calendar = Calendar.find(params[:id]).clone
@calendar = Calendar.find(params[:id]).dup
end

def copy
Expand All @@ -66,7 +66,7 @@ def copy
end
rescue Exception => e
@errors = e.message.gsub("Validation failed:", "").split(",")
@calendar = @new_calendar.clone
@calendar = @new_calendar.dup
render action: 'prepare_copy'
end
end
Expand Down Expand Up @@ -111,7 +111,7 @@ def toggle
@calendar.deactivate
@problems = false
else
@problems = @calendar.activate(wipe)
@problems = @calendar.activate(wipe)
end
end
if @problems
Expand Down
28 changes: 9 additions & 19 deletions app/controllers/payform_item_sets_controller.rb
Expand Up @@ -16,7 +16,6 @@ def new
end

def create
params[:user_ids].delete("")
set_payform_item_hours("payform_item_set")
@payform_item_set = PayformItemSet.new(params[:payform_item_set])
@payform_item_set.active = true #TODO: set this as a default in the database
Expand All @@ -25,16 +24,16 @@ def create
begin
PayformItemSet.transaction do
@payform_items = []

users = User.find(params[:user_ids])
users = parse_users_autocomplete(params[:auto_ids])
users.each do |user|
payform_item = PayformItem.new(params[:payform_item_set])
payform_item.payform = Payform.build(current_department, user, date)
@payform_items << payform_item
end
@payform_item_set.payform_items = @payform_items


if @payform_item_set.save and @payform_item_set.payform_items << @payform_items
if @payform_item_set.save
flash[:notice] = "Successfully created payform item set."
redirect_to payform_item_sets_path
else
Expand All @@ -53,13 +52,14 @@ def create
def edit
@payform_item_set = PayformItemSet.find(params[:id])
@users_select = current_department.users.sort_by(&:name)
@users_selected = @payform_item_set.users
end

def update
@payform_item_set = PayformItemSet.find(params[:id])
params[:user_ids].delete("")
set_payform_item_hours("payform_item_set")
date = build_date_from_params(:date, params[:payform_item_set])
@new_users = params[:user_ids].collect {|id| User.find(id) }
@new_users = parse_users_autocomplete(params[:auto_ids])
@old_users = @payform_item_set.users
@old_payform_items = @payform_item_set.payform_items.dup # .dup is crucial here!
# otherwise the loop below
Expand All @@ -78,19 +78,10 @@ def update
old_payform_item.save!
@payform_item_set.payform_items.delete(old_payform_item)
else #update with new values
new_item = PayformItem.new(params[:payform_item_set])
new_item.payform = Payform.build(current_department, old_payform_item.user, date)
new_item.source = current_user.name
new_item.parent = old_payform_item

old_payform_item.assign_attributes(params[:payform_item_set])
old_payform_item.payform = Payform.build(current_department, old_payform_item.user, date)
old_payform_item.reason = "#{current_user.name} changed this group job."
old_payform_item.payform = nil

new_item.save(validate: false)
old_payform_item.save!
new_item.save!
@payform_item_set.payform_items.delete(old_payform_item)
@payform_item_set.payform_items << new_item
end
end

Expand All @@ -99,7 +90,6 @@ def update
payform_item.payform = Payform.build(current_department, user, date)
@payform_item_set.payform_items << payform_item
end

if @payform_item_set.update_attributes(params[:payform_item_set])
flash[:notice] = "Successfully updated payform item set."
redirect_to payform_item_sets_path
Expand Down
22 changes: 5 additions & 17 deletions app/controllers/restrictions_controller.rb
Expand Up @@ -69,32 +69,20 @@ def destroy
# Can't do this until we decide what to do with restrictions
def set_sources
if params[:for_users]
params[:for_users].split(",").each do |l|
if l == l.split("||").first #This is for if javascript is disabled
l = l.strip
user_source = User.search(l) || Role.find_by_name(l)
find_dept = Department.find_by_name(l)
user_source = find_dept if find_dept && current_user.is_admin_of?(find_dept)
@restriction.users << user_source if user_source
else
l = l.split("||")
@restriction.users << l[0].constantize.find(l[1]) if l.length == 2 #javascript or not javascript
end
end
@restriction.users = parse_users_autocomplete(params[:for_users])
end
if params[:department_wide_locations] && current_user.is_admin_of?(current_department)
# Do we allow department wide actions? -Hugh
# @restriction.location_sources << current_department
@restriction.loc_groups << current_department.loc_groups
@restriction.locations << current_department.locations
@restriction.loc_groups = current_department.loc_groups
@restriction.locations = current_department.locations
elsif params[:for_location_groups]
params[:for_location_groups].each do |loc_group|
lg = LocGroup.find(loc_group)
@restriction.loc_groups << lg
@restriction.locations << lg.locations
@restriction.locations += lg.locations
end
end
if params[:for_locations]
elsif params[:for_locations]
params[:for_locations].each do |loc|
@restriction.locations << Location.find_by_id(loc)
end
Expand Down
11 changes: 5 additions & 6 deletions app/controllers/shifts_controller.rb
Expand Up @@ -151,13 +151,12 @@ def create
respond_to do |format|
format.html{ render action: 'new' }
format.js do
render :update do |page|
error_string = ""
@shift.errors.each do |attr_name, message|
error_string += "<br><br>#{attr_name}: #{message}"
end
ajax_alert(page, "<strong>Error:</strong> shift could not be saved."+error_string, 2.5 + (@shift.errors.size))
error_string = ""
@shift.errors.each do |attr_name, message|
error_string += "<br><br>#{attr_name}: #{message}"
end
@ajax_error_message = "<strong>Error:</strong> shift could not be saved."+error_string
render :update
end
end
end
Expand Down
8 changes: 6 additions & 2 deletions app/controllers/stats_controller.rb
Expand Up @@ -23,7 +23,7 @@ def index

users.each do |u|
user_stats = {}
if params[:calendar]
if params[:calendar] && !params[:calendar].empty?
shifts = u.shifts.on_days(@start_date, @end_date).in_calendars(params[:calendar].split(","))
else
shifts = u.shifts.on_days(@start_date, @end_date).active
Expand Down Expand Up @@ -52,7 +52,11 @@ def index

locations.each do |l|
location_stats = {}
shifts = l.shifts.on_days(@start_date, @end_date).active
if params[:calendar] && !params[:calendar].empty?
shifts = l.shifts.on_days(@start_date, @end_date).in_calendars(params[:calendar].split(","))
else
shifts = l.shifts.on_days(@start_date, @end_date).active
end

location_stats[:l_id] = l.id
location_stats[:name] = l.name
Expand Down

0 comments on commit 43b86ec

Please sign in to comment.