Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

merged dev back into master

  • Loading branch information...
commit fd04f136081f8ff0a69c279656292a12c5840066 2 parents fbb33ee + 619d741
@adambray adambray authored
Showing with 7,369 additions and 2,117 deletions.
  1. +4 −2 Gemfile
  2. +32 −27 Gemfile.lock
  3. +2 −1  Rakefile
  4. +86 −0 app/controllers/announcements_controller.rb
  5. +143 −53 app/controllers/application_controller.rb
  6. +117 −0 app/controllers/calendar_feeds_controller.rb
  7. +3 −3 app/controllers/calendars_controller.rb
  8. +1 −0  app/controllers/categories_controller.rb
  9. +10 −3 app/controllers/dashboard_controller.rb
  10. +1 −4 app/controllers/data_entries_controller.rb
  11. +1 −1  app/controllers/data_objects_controller.rb
  12. +2 −0  app/controllers/department_configs_controller.rb
  13. +1 −0  app/controllers/first_run_controller.rb
  14. +3 −3 app/controllers/hooks_controller.rb
  15. +74 −0 app/controllers/links_controller.rb
  16. +3 −3 app/controllers/loc_groups_controller.rb
  17. +41 −7 app/controllers/locations_controller.rb
  18. +37 −128 app/controllers/notices_controller.rb
  19. +3 −3 app/controllers/password_resets_controller.rb
  20. +9 −9 app/controllers/payform_item_sets_controller.rb
  21. +32 −102 app/controllers/payform_items_controller.rb
  22. +46 −18 app/controllers/payforms_controller.rb
  23. +12 −0 app/controllers/public_view_controller.rb
  24. +1 −1  app/controllers/punch_clocks_controller.rb
  25. +6 −3 app/controllers/repeating_events_controller.rb
  26. +13 −1 app/controllers/report_items_controller.rb
  27. +30 −13 app/controllers/reports_controller.rb
  28. +156 −0 app/controllers/requested_shifts_controller.rb
  29. +15 −8 app/controllers/restrictions_controller.rb
  30. +119 −0 app/controllers/shift_preferences_controller.rb
  31. +28 −12 app/controllers/shifts_controller.rb
  32. +123 −23 app/controllers/stats_controller.rb
  33. +84 −0 app/controllers/stickies_controller.rb
  34. +91 −53 app/controllers/sub_requests_controller.rb
  35. +1 −1  app/controllers/superusers_controller.rb
  36. +170 −0 app/controllers/tasks_controller.rb
  37. +115 −0 app/controllers/template_time_slots_controller.rb
  38. +113 −0 app/controllers/templates_controller.rb
  39. +31 −32 app/controllers/time_slots_controller.rb
  40. +22 −11 app/controllers/user_configs_controller.rb
  41. +6 −6 app/controllers/user_profiles_controller.rb
  42. +2 −2 app/controllers/user_sessions_controller.rb
  43. +84 −60 app/controllers/users_controller.rb
  44. +2 −0  app/helpers/announcements_helper.rb
  45. +94 −44 app/helpers/application_helper.rb
  46. +2 −0  app/helpers/calendar_feeds_helper.rb
  47. +10 −5 app/helpers/calendars_helper.rb
  48. +2 −0  app/helpers/links_helper.rb
  49. +13 −19 app/helpers/notices_helper.rb
  50. +31 −7 app/helpers/payforms_helper.rb
  51. +32 −2 app/helpers/repeating_events_helper.rb
  52. +26 −0 app/helpers/requested_shifts_helper.rb
  53. +1 −0  app/helpers/restrictions_helper.rb
  54. +16 −0 app/helpers/shift_preferences_helper.rb
  55. +2 −0  app/helpers/shift_tasks_helper.rb
  56. +51 −2 app/helpers/shifts_helper.rb
  57. +2 −0  app/helpers/stickies_helper.rb
  58. +8 −0 app/helpers/sub_requests_helper.rb
  59. +2 −0  app/helpers/tasks_helper.rb
  60. +2 −0  app/helpers/template_time_slots_helper.rb
  61. +25 −0 app/helpers/templates_helper.rb
  62. +62 −17 app/helpers/time_slots_helper.rb
  63. +2 −0  app/helpers/user_shift_preferences_helper.rb
  64. +10 −0 app/models/announcement.rb
  65. +1 −1  app/models/app_config.rb
  66. +5 −5 app/models/app_mailer.rb
  67. +60 −20 app/models/ar_mailer.rb
  68. +40 −24 app/models/calendar.rb
  69. +20 −8 app/models/department.rb
  70. +1 −2  app/models/department_config.rb
  71. +3 −1 app/models/department_observer.rb
  72. +18 −0 app/models/link.rb
  73. +5 −1 app/models/loc_group.rb
  74. +101 −11 app/models/location.rb
  75. +4 −0 app/models/locations_requested_shift.rb
  76. +4 −0 app/models/locations_shift_preference.rb
  77. +32 −45 app/models/notice.rb
  78. +23 −5 app/models/payform.rb
  79. +25 −35 app/models/payform_item.rb
  80. +4 −0 app/models/payform_item_set.rb
  81. +21 −18 app/models/repeating_event.rb
  82. +6 −2 app/models/report.rb
  83. +5 −2 app/models/report_item.rb
  84. +99 −0 app/models/requested_shift.rb
  85. +12 −2 app/models/restriction.rb
  86. +11 −0 app/models/role.rb
  87. +123 −53 app/models/shift.rb
  88. +36 −0 app/models/shift_preference.rb
  89. +7 −0 app/models/shifts_task.rb
  90. +44 −0 app/models/stat.rb
  91. +15 −0 app/models/sticky.rb
  92. +68 −48 app/models/sub_request.rb
  93. +201 −0 app/models/task.rb
  94. +51 −0 app/models/template.rb
  95. +21 −0 app/models/template_time_slot.rb
  96. +26 −6 app/models/time_slot.rb
  97. +136 −31 app/models/user.rb
  98. +5 −1 app/models/user_config.rb
  99. +1 −1  app/models/user_sinks_user_source.rb
  100. +41 −0 app/views/announcements/_form.html.erb
  101. +13 −0 app/views/announcements/create.js.rjs
  102. 0  app/views/{notices/new.html.erb → announcements/edit.html.erb}
  103. +1 −1  app/views/{notices/edit.html.erb → announcements/new.html.erb}
  104. +2 −2 app/views/{notices → announcements}/update.js.rjs
  105. +32 −31 app/views/app_configs/_form.html.erb
  106. +7 −6 app/views/app_mailer/payform_item_deletion_notification.html.erb
  107. +12 −0 app/views/app_mailer/payform_item_modify_notification.html.erb
  108. +31 −0 app/views/ar_mailer/email_stats.erb
  109. +10 −0 app/views/ar_mailer/stale_shift.erb
  110. +0 −1  app/views/{app_mailer/sub_taken_notification.html.erb → ar_mailer/sub_taken_notification.erb}
  111. +10 −0 app/views/ar_mailer/sub_taken_watch.erb
  112. +31 −0 app/views/calendar_feeds/index.html.erb
  113. +1 −2  app/views/calendars/_form.html.erb
  114. +8 −8 app/views/calendars/index.html.erb
  115. +20 −21 app/views/calendars/schedule/_day.html.erb
  116. +10 −0 app/views/calendars/schedule/_header.html.erb
  117. +6 −1 app/views/calendars/schedule/_hour.html.erb
  118. +2 −1  app/views/calendars/schedule/_loc_group.html.erb
  119. +1 −1  app/views/calendars/schedule/_loc_group_row.html.erb
  120. +2 −0  app/views/calendars/schedule/_location.html.erb
  121. +1 −2  app/views/calendars/schedule/_shift.html.erb
  122. +23 −7 app/views/dashboard/index.html.erb
  123. +42 −8 app/views/department_configs/_form.html.erb
  124. +7 −0 app/views/first_run/new_app_config.html.erb
  125. +17 −3 app/views/layouts/access_denied.html.erb
  126. +27 −0 app/views/layouts/announcements.html.erb
  127. +7 −3 app/views/layouts/application.html.erb
  128. +2 −1  app/views/layouts/calendar.html.erb
  129. +33 −21 app/views/layouts/dashboard.html.erb
  130. +3 −16 app/views/layouts/include/_chooser.html.erb
  131. +3 −2 app/views/layouts/include/main_header.html.erb
  132. +23 −0 app/views/layouts/links.html.erb
  133. +1 −0  app/views/layouts/loc_groups.html.erb
  134. +1 −0  app/views/layouts/locations.html.erb
  135. +6 −4 app/views/layouts/notices.html.erb
  136. +14 −12 app/views/layouts/payforms.html.erb
  137. +1 −1  app/views/layouts/reports.html.erb
  138. +14 −0 app/views/layouts/requested_shifts.html.erb
  139. +17 −0 app/views/layouts/shift_tasks.html.erb
  140. +1 −0  app/views/layouts/shifts.html.erb
  141. +1 −1  app/views/layouts/stats.html.erb
  142. +27 −0 app/views/layouts/stickies.html.erb
  143. +1 −0  app/views/layouts/tasks.html.erb
  144. +17 −0 app/views/layouts/template_time_slots.html.erb
  145. +23 −0 app/views/layouts/templates.html.erb
  146. +17 −0 app/views/layouts/user_shift_preferences.html.erb
  147. +9 −0 app/views/links/_dashboard_links.html.erb
  148. +48 −0 app/views/links/_links_index.html.erb
  149. +6 −12 app/views/{notices/_report_useful_links.html.erb → links/_report_links.html.erb}
  150. +14 −0 app/views/links/create.js.rjs
  151. +12 −0 app/views/links/edit.html.erb
  152. +4 −0 app/views/links/index.html.erb
  153. +24 −0 app/views/links/new.html.erb
  154. +13 −0 app/views/locations/_report_items.html.erb
  155. +20 −0 app/views/locations/display_report_items.html.erb
  156. +1 −0  app/views/locations/display_report_items.js.rjs
  157. +6 −3 app/views/locations/index.html.erb
  158. +7 −0 app/views/locations/toggle.js.rjs
  159. +0 −28 app/views/notices/_advanced_options.html.erb
  160. +19 −16 app/views/notices/_all_notices.html.erb
  161. +11 −6 app/views/notices/_announcement.html.erb
  162. +6 −0 app/views/notices/_dashboard.html.erb
  163. +0 −16 app/views/notices/_dashboard_useful_links.html.erb
  164. +1 −1  app/views/notices/_error_messages.html.erb
  165. +8 −0 app/views/notices/_for_category.html.erb
  166. +0 −9 app/views/notices/_for_others.html.erb
  167. +0 −9 app/views/notices/_for_you.html.erb
  168. +0 −69 app/views/notices/_form.html.erb
  169. +29 −0 app/views/notices/_locations.html.erb
  170. +4 −4 app/views/notices/_notice.html.erb
  171. +9 −5 app/views/notices/_sticky.html.erb
  172. +9 −4 app/views/notices/archive.html.erb
  173. +0 −21 app/views/notices/create.js.rjs
  174. +1 −0  app/views/notices/index.html.erb
  175. +0 −62 app/views/notices/show.html.erb
  176. +1 −1  app/views/notices/update_message_center.js.rjs
  177. +13 −5 app/views/payform_item_sets/_form.html.erb
  178. +19 −0 app/views/payform_item_sets/_payform_item_set.html.erb
  179. +6 −16 app/views/payform_item_sets/index.html.erb
  180. +0 −38 app/views/payform_item_sets/show.html.erb
  181. +5 −5 app/views/payform_items/_form.html.erb
  182. +0 −5 app/views/payform_items/index.html.erb
  183. +2 −2 app/views/payform_items/new.html.erb
  184. +9 −3 app/views/payforms/_category.html.erb
  185. +3 −8 app/views/payforms/_date_select.html.erb
  186. +8 −5 app/views/payforms/_payform.html.erb
  187. +1 −0  app/views/payforms/_payform_buttons.html.erb
  188. +28 −16 app/views/payforms/_payform_item.html.erb
  189. +15 −1 app/views/payforms/_payform_list.html.erb
  190. +7 −0 app/views/payforms/_status.html.erb
  191. +8 −4 app/views/payforms/index.html.erb
  192. +20 −20 app/views/payforms/show.html.erb
  193. +1 −1  app/views/payforms/show.pdf.prawn
  194. +1 −0  app/views/public_view/index.html.erb
  195. +4 −0 app/views/punch_clocks/_dashboard_clock.html.erb
  196. +73 −16 app/views/repeating_events/_form.html.erb
  197. +24 −4 app/views/repeating_events/show.html.erb
  198. +1 −1  app/views/reports/_report.html.erb
  199. 0  app/views/reports/create.js.rjs
  200. +28 −25 app/views/reports/show.html.erb
  201. +4 −0 app/views/reports/update_reports.js.rjs
  202. +34 −0 app/views/requested_shifts/_all_requests.html.erb
  203. +11 −0 app/views/requested_shifts/_day.html.erb
  204. +1 −0  app/views/requested_shifts/_error_messages.html.erb
  205. +78 −0 app/views/requested_shifts/_form.html.erb
  206. +8 −0 app/views/requested_shifts/_left_day.html.erb
  207. +7 −0 app/views/requested_shifts/_requested_shift.html.erb
  208. +22 −0 app/views/requested_shifts/_week.html.erb
  209. +14 −0 app/views/requested_shifts/create.js.rjs
  210. +12 −0 app/views/requested_shifts/edit.html.erb
  211. +42 −0 app/views/requested_shifts/index.html.erb
  212. +37 −0 app/views/requested_shifts/new.html.erb
  213. +13 −0 app/views/requested_shifts/schedule/_day.html.erb
  214. +7 −0 app/views/requested_shifts/schedule/_event.html.erb
  215. +12 −0 app/views/requested_shifts/schedule/_event_group.html.erb
  216. +33 −0 app/views/requested_shifts/show.html.erb
  217. +41 −6 app/views/restrictions/_form.html.erb
  218. +50 −0 app/views/shift_preferences/_form.html.erb
  219. +12 −0 app/views/shift_preferences/edit.html.erb
  220. +58 −0 app/views/shift_preferences/index.html.erb
  221. +11 −0 app/views/shift_preferences/new.html.erb
  222. +43 −0 app/views/shift_preferences/show.html.erb
  223. +72 −19 app/views/shifts/_form.html.erb
  224. +56 −20 app/views/shifts/_form_repeating.html.erb
  225. +2 −3 app/views/shifts/_form_unscheduled.html.erb
  226. +4 −2 app/views/shifts/_shifts_layout.html.erb
  227. +2 −0  app/views/shifts/_upcoming_shift.html.erb
  228. +3 −6 app/views/shifts/_view_preferences.html.erb
  229. +6 −0 app/views/shifts/index.html.erb
  230. +18 −21 app/views/shifts/schedule/_day.html.erb
  231. +0 −3  app/views/shifts/schedule/_footer.html.erb
  232. +1 −1  app/views/shifts/schedule/_header.html.erb
  233. +11 −0 app/views/shifts/schedule/_hour_header.html.erb
  234. +3 −0  app/views/shifts/schedule/_left_loc_group.html.erb
  235. +17 −0 app/views/shifts/schedule/_left_location.html.erb
  236. +1 −1  app/views/shifts/schedule/_loc_group_row.html.erb
  237. +0 −3  app/views/shifts/schedule/_shift.html.erb
  238. +1 −1  app/views/shifts/schedule/_sub.html.erb
  239. +11 −3 app/views/shifts/show.html.erb
  240. +24 −60 app/views/shifts/tooltips/_new.html.erb
  241. +29 −51 app/views/shifts/tooltips/_show.html.erb
  242. +8 −0 app/views/stats/_stats_summary.html.erb
  243. +92 −0 app/views/stats/for_location.html.erb
  244. +93 −0 app/views/stats/for_user.html.erb
  245. +91 −35 app/views/stats/index.html.erb
  246. +36 −0 app/views/stats/show.html.erb
  247. +1 −0  app/views/stats/show.js.rjs
  248. +179 −0 app/views/stats/tooltips/_show.html.erb
  249. +13 −0 app/views/stickies/create.js.rjs
  250. +12 −0 app/views/stickies/edit.html.erb
  251. +29 −0 app/views/stickies/new.html.erb
  252. +57 −12 app/views/sub_requests/_form.html.erb
  253. +20 −0 app/views/sub_requests/_list_user_sources.html.erb
  254. +4 −4 app/views/sub_requests/get_take_info.html.erb
  255. +41 −20 app/views/sub_requests/index.html.erb
  256. +22 −53 app/views/sub_requests/show.html.erb
  257. +58 −0 app/views/tasks/_form.html.erb
  258. +17 −0 app/views/tasks/_report_tasks.html.erb
  259. +22 −0 app/views/tasks/_task.html.erb
  260. +63 −0 app/views/tasks/_task_items.html.erb
  261. +27 −0 app/views/tasks/completed_tasks.html.erb
  262. +11 −0 app/views/tasks/edit.html.erb
  263. +27 −0 app/views/tasks/index.html.erb
  264. +17 −0 app/views/tasks/make_entry.js.rjs
  265. +27 −0 app/views/tasks/missed_tasks.html.erb
  266. +10 −0 app/views/tasks/new.html.erb
  267. +49 −0 app/views/tasks/show.html.erb
  268. +179 −0 app/views/tasks/tooltips/_show.html.erb
  269. +12 −0 app/views/tasks/update_tasks.js.rjs
  270. +24 −0 app/views/template_time_slots/_all_time_slots.html.erb
  271. +1 −0  app/views/template_time_slots/_error_messages.html.erb
  272. +44 −0 app/views/template_time_slots/_form.html.erb
  273. +10 −0 app/views/template_time_slots/create.js.rjs
  274. +39 −0 app/views/template_time_slots/edit.html.erb
  275. +55 −0 app/views/template_time_slots/index.html.erb
  276. +4 −0 app/views/template_time_slots/new.html.erb
  277. +18 −0 app/views/template_time_slots/show.html.erb
  278. +49 −0 app/views/templates/_form.html.erb
  279. +25 −0 app/views/templates/_location_and_time_slots.html.erb
  280. +24 −0 app/views/templates/_template_time_slot_form.html.erb
  281. +5 −0 app/views/templates/edit.html.erb
  282. +48 −0 app/views/templates/index.html.erb
  283. +3 −0  app/views/templates/new.html.erb
  284. +13 −0 app/views/templates/schedule/_day.html.erb
  285. +7 −0 app/views/templates/schedule/_event.html.erb
  286. +26 −0 app/views/templates/schedule/_event_group.html.erb
  287. +136 −0 app/views/templates/show.html.erb
  288. +1 −0  app/views/templates/update_locations.js.rjs
  289. +59 −32 app/views/time_slots/_form.html.erb
  290. +66 −28 app/views/time_slots/_form_repeating.html.erb
  291. +3 −2 app/views/time_slots/{_hour.html.erb → _hour_header.html.erb}
  292. +23 −21 app/views/time_slots/_location.html.erb
  293. +1 −1  app/views/time_slots/_time_slot.html.erb
  294. +1 −1  app/views/time_slots/_time_slot_day.html.erb
  295. +4 −5 app/views/time_slots/create.js.rjs
  296. +7 −2 app/views/time_slots/edit.html.erb
  297. +19 −22 app/views/time_slots/index.html.erb
  298. +7 −2 app/views/time_slots/new.html.erb
  299. +4 −44 app/views/time_slots/tooltips/_new.html.erb
  300. +6 −25 app/views/time_slots/tooltips/_show.html.erb
Sorry, we could not display the entire diff because too many files (684) changed.
View
6 Gemfile
@@ -1,5 +1,5 @@
source :rubygems
-gem "rails", "2.3.11"
+gem "rails", "2.3.12"
gem "ruby-net-ldap", :require => "net/ldap"
gem "fastercsv"
gem "icalendar"
@@ -10,4 +10,6 @@ gem "authlogic"
gem "ar_mailer", :require => "action_mailer/ar_mailer"
gem "whenever"
gem "hoptoad_notifier"
-gem "mysql"
+gem "mysql"
+gem "vestal_versions"
+gem "rdoc", "~> 3.6.1"
View
59 Gemfile.lock
@@ -1,48 +1,51 @@
GEM
remote: http://rubygems.org/
specs:
+ Ascii85 (1.0.1)
aaronh-chronic (0.3.9)
- actionmailer (2.3.11)
- actionpack (= 2.3.11)
- actionpack (2.3.11)
- activesupport (= 2.3.11)
+ actionmailer (2.3.12)
+ actionpack (= 2.3.12)
+ actionpack (2.3.12)
+ activesupport (= 2.3.12)
rack (~> 1.1.0)
- activerecord (2.3.11)
- activesupport (= 2.3.11)
- activeresource (2.3.11)
- activesupport (= 2.3.11)
- activesupport (2.3.11)
+ activerecord (2.3.12)
+ activesupport (= 2.3.12)
+ activeresource (2.3.12)
+ activesupport (= 2.3.12)
+ activesupport (2.3.12)
ar_mailer (1.5.1)
authlogic (2.1.6)
activesupport
builder (3.0.0)
- chronic (0.3.0)
+ chronic (0.5.0)
fastercsv (1.5.4)
has_many_polymorphs (2.13)
activerecord
- hoptoad_notifier (2.4.9)
+ hoptoad_notifier (2.4.11)
activesupport
builder
icalendar (1.1.6)
mysql (2.8.1)
- prawn (0.8.4)
- prawn-core (< 0.9, >= 0.8.4)
- prawn-layout (< 0.9, >= 0.8.4)
- prawn-security (< 0.9, >= 0.8.4)
- prawn-core (0.8.4)
- prawn-layout (0.8.4)
- prawn-security (0.8.4)
+ pdf-reader (0.10.0)
+ Ascii85 (~> 1.0.0)
+ prawn (0.11.1)
+ pdf-reader (>= 0.9.0)
+ ttfunk (~> 1.0.0)
rack (1.1.2)
- rails (2.3.11)
- actionmailer (= 2.3.11)
- actionpack (= 2.3.11)
- activerecord (= 2.3.11)
- activeresource (= 2.3.11)
- activesupport (= 2.3.11)
+ rails (2.3.12)
+ actionmailer (= 2.3.12)
+ actionpack (= 2.3.12)
+ activerecord (= 2.3.12)
+ activeresource (= 2.3.12)
+ activesupport (= 2.3.12)
rake (>= 0.8.3)
- rake (0.8.7)
+ rake (0.9.2)
+ rdoc (3.6.1)
ruby-net-ldap (0.0.4)
- whenever (0.6.7)
+ ttfunk (1.0.1)
+ vestal_versions (1.0.2)
+ activerecord (>= 2.1.0)
+ whenever (0.6.8)
aaronh-chronic (>= 0.3.9)
activesupport (>= 2.3.4)
@@ -59,6 +62,8 @@ DEPENDENCIES
icalendar
mysql
prawn
- rails (= 2.3.11)
+ rails (= 2.3.12)
+ rdoc (~> 3.6.1)
ruby-net-ldap
+ vestal_versions
whenever
View
3  Rakefile
@@ -3,8 +3,9 @@
require(File.join(File.dirname(__FILE__), 'config', 'boot'))
+require 'rake/dsl_definition'
require 'rake'
require 'rake/testtask'
-require 'rake/rdoctask'
+require 'rdoc/task'
require 'tasks/rails'
View
86 app/controllers/announcements_controller.rb
@@ -0,0 +1,86 @@
+class AnnouncementsController < NoticesController
+ before_filter :require_any_loc_group_admin, :except => [:index, :show]
+
+ def index
+ redirect_to(notices_path)
+ end
+
+ def show
+ redirect_to(notices_path)
+ end
+
+ 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
+
+ def create
+ @announcement = Announcement.new(params[:announcement])
+ set_author_dept_and_time
+ begin
+ Announcement.transaction do
+ @announcement.save(false)
+ set_sources(@announcement)
+ @announcement.save!
+ end
+ rescue Exception
+ respond_to do |format|
+ format.html { render :action => "new" }
+ format.js #create.js.rjs
+ end
+ else
+ flash[:notice] = 'Announcement was successfully created.'
+ respond_to do |format|
+ format.html {
+ redirect_to announcements_path
+ }
+ format.js #create.js.rjs
+ end
+ end
+ end
+
+ def update
+ @announcement = Announcement.find_by_id(params[:id]) || Announcement.new
+ @announcement.update_attributes(params[:announcement])
+ set_author_dept_and_time
+ begin
+ Announcement.transaction do
+ @announcement.save(false)
+ set_sources(@announcement)
+ @announcement.save!
+ end
+ rescue Exception
+ respond_to do |format|
+ format.html { render :action => "new" }
+ format.js
+ end
+ else
+ respond_to do |format|
+ format.html {
+ flash[:notice] = 'Announcement was successfully saved.'
+ redirect_to :action => "index"
+ }
+ format.js
+ end
+ end
+ end
+
+ private
+ def set_author_dept_and_time
+ @announcement.author = current_user
+ @announcement.department = current_department
+ @announcement.start = Time.now if params[:start_time_choice] == "now"
+ if params[:end_time_choice] == "indefinite"
+ @announcement.end = nil
+ @announcement.indefinite = true
+ end
+ end
+end
View
196 app/controllers/application_controller.rb 100755 → 100644
@@ -11,9 +11,10 @@ class ApplicationController < ActionController::Base
before_filter :login_check, :except => :access_denied
before_filter :load_department
before_filter :prepare_mail_url
-# before_filter :load_user
+ #before_filter :load_user
- helper :layout # include all helpers, all the time
+
+ helper :layout # include all helpers, all the time (whyy? -Nathan)
helper_method :current_user
helper_method :current_department
@@ -25,12 +26,8 @@ def load_app_config
@appconfig = AppConfig.first
end
- # We should improve this page, probably on the actual template -ben
def access_denied
- text = "Access denied"
- text += "<br>Maybe you want to <a href=\"#{login_path}\">try logging in with built-in authentication</a>?" if @appconfig.login_options.include?('built-in')
- text += "<br>Maybe you want to go <a href=\"#{department_path(current_user.departments.first)}/users\">here</a>?" if current_user && current_user.departments
- render :text => text, :layout => true
+ render :file => "layouts/access_denied.html.erb", :layout => true
end
def using_CAS?
@@ -40,7 +37,6 @@ def using_CAS?
protected
def current_user
@current_user ||= (
-# raise @user_session.login.to_s
if @user_session
@user_session.user
elsif session[:cas_user]
@@ -63,21 +59,6 @@ def current_department
@current_department
end
-
-# if params[:department_id] or session[:department_id]
-# @department ||= Department.find(params[:department_id] || session[:department_id])
-# elsif current_user and current_user.departments
-# @department = current_user.user_config.default_dept ? Department.find(current_user.user_config.default_dept) : current_user.departments[0]
-# elsif current_user and current_user.is_superuser?
-# @department = Department.first
-# end
-# end
-
- # Application-wide settings are stored in the only record in the app_configs table
-# def app_config
-# AppConfig.first
-# end
-
def load_department
if (params[:department_id])
@department = Department.find_by_id(params[:department_id])
@@ -86,17 +67,6 @@ def load_department
end
end
@department ||= current_department
-
- # update department id in session if neccessary so that we can use shallow routes properly
-# if params[:department_id]
-# session[:department_id] = params[:department_id]
-# @department = Department.find_by_id(session[:department_id])
-# elsif session[:department_id]
-# @department = Department.find_by_id(session[:department_id])
-# elsif current_user and current_user.departments
-# @department = current_user.departments[0]
-# end
- # load @department variable, no need ||= because it's only called once at the start of controller
end
def load_user
@@ -107,8 +77,8 @@ def load_user_session
@user_session = UserSession.find
end
-# These are the authorization before_filters to use under controllers
-# These all return nil
+ # These are the authorization before_filters to use under controllers
+ # These all return nil
def require_department_admin
unless current_user.is_admin_of?(current_department)
error_message = "That action is restricted to department administrators."
@@ -149,6 +119,26 @@ def require_loc_group_admin(current_loc_group)
return true
end
+ def require_any_loc_group_admin
+ unless current_user.is_loc_group_admin?(current_department)
+ error_message = "That action is restricted to location group administrators."
+ 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
+ return false
+ end
+ end
+ end
+ return true
+ end
+
def require_superuser
unless current_user.is_superuser?
error_message = "That action is only available to superusers."
@@ -169,11 +159,21 @@ def require_superuser
return true
end
-# These three methods all return true/false, so they can be tested to trigger return statements
-# Takes a department, location, or loc_group
+ def require_proper_template_role
+ unless current_user.has_proper_role_for?(Template.find(params[:template_id])) || current_user.is_admin_of?(Template.find(params[:template_id]).department)
+ error_message = "This page is only availabe to the following roles: #{Template.find(params[:template_id]).roles.to_sentence}"
+ flash[:error] = error_message
+ redirect_to access_denied_path
+ end
+ return true
+ end
+
+ # These three methods all return true/false, so they can be tested to trigger return statements
+ # Takes a department, location, or loc_group
+ # TODO: This is mixing model logic!!!
def user_is_admin_of(thing)
unless current_user.is_admin_of?(thing)
- error_message = "You are not authorized to administer this #{thing.class.name.decamelize}"
+ error_message = "You are not authorized to administer this #{thing.class.name.decamelize}."
respond_to do |format|
format.html do
flash[:error] = error_message
@@ -192,10 +192,11 @@ def user_is_admin_of(thing)
end
-# Takes any object that has a user method and checks against current_user
+ # Takes any object that has a user method and checks against current_user
+ #TODO: This is mixing model logic!!!
def user_is_owner_of(thing)
unless current_user.is_owner_of?(thing)
- error_message = "You are not the owner of this #{thing.class.name.decamelize}"
+ error_message = "You are not the owner of this #{thing.class.name.decamelize}."
respond_to do |format|
format.html do
flash[:error] = error_message
@@ -213,7 +214,8 @@ def user_is_owner_of(thing)
return true
end
-# Takes any object that has a user method and its department
+ # Takes any object that has a user method and its department
+ #TODO: This is mixing model logic!!!
def user_is_owner_or_admin_of(thing, dept)
unless current_user.is_owner_of?(thing) || current_user.is_admin_of?(dept)
error_message = "You are not the owner of this #{thing.class.name.decamelize}, nor are you the department administrator."
@@ -234,7 +236,7 @@ def user_is_owner_or_admin_of(thing, dept)
return true
end
-# Takes a department; intended to be passed some_thing.department
+ # Takes a department; intended to be passed some_thing.department
def require_department_membership(dept)
unless current_user.departments.include?(dept)
error_message = "You are not a member of the appropriate department."
@@ -255,9 +257,9 @@ def require_department_membership(dept)
end
def login_check
- if !User.first
- redirect_to first_app_config_path
- elsif !current_user
+ if !User.first
+ redirect_to first_app_config_path
+ elsif !current_user
if @appconfig.login_options==['built-in'] #AppConfig.first.login_options_array.include?('built-in')
redirect_to login_path
else
@@ -266,12 +268,100 @@ def login_check
end
end
- def redirect_with_flash(msg = nil, options = {:action => :index})
- if msg
- msg = msg.join("<br/>") if msg.is_a?(Array)
- flash[:notice] = msg
+# def redirect_with_flash(msg = nil, options = {:action => :index})
+# if msg
+# msg = msg.join("<br/>") if msg.is_a?(Array)
+# flash[:notice] = msg
+# end
+# redirect_to options
+# end
+
+ def parse_date_and_time_output(form_output)
+ time_attribute_names = ["start", "end", "mandatory_start", "mandatory_end"]
+ time_attribute_names.each do |field_name|
+ ## Simple Time Select Input
+ if !form_output["#{field_name}_time(5i)"].blank? && form_output["#{field_name}_time(4i)"].blank?
+ form_output["#{field_name}_time"] = Time.parse( form_output["#{field_name}_time(5i)"] )
+ end
+
+ ## Date Input - Hidden Field
+ unless form_output["#{field_name}_date"].blank?
+ form_output["#{field_name}_date"] = Date.parse( form_output["#{field_name}_date"] )
+ end
+
+ ## Date Input - Select (Rails default)
+ unless (form_output["#{field_name}_date(1i)"].blank? || form_output["#{field_name}_date(2i)"].blank? || form_output["#{field_name}_date(3i)"].blank?)
+ join_date = [ form_output["#{field_name}_date(1i)"], form_output["#{field_name}_date(2i)"], form_output["#{field_name}_date(3i)"] ].join('-')
+ form_output["#{field_name}_date"] = Date.parse( join_date )
+ end
+ end
+
+
+ #when there is no end_date (such as shifts, time_slots, and sub_requests)
+ form_output["end_date"] ||= form_output["start_date"] if form_output["start_date"]
+ form_output["mandatory_end_date"] ||= form_output["mandatory_start_date"] if form_output["mandatory_start_date"]
+
+ #Midnight?
+ time_attribute_names.each do |field_name|
+ unless form_output["#{field_name}_time(5i)"].nil?
+ unless form_output["#{field_name}_time(5i)"].scan(/\+$/).empty?
+ form_output["#{field_name}_date"] += 1.day
+ end
+ end
+ end
+
+ #cleanup
+ time_attribute_names.each do |field_name|
+ form_output.delete("#{field_name}_date(1i)")
+ form_output.delete("#{field_name}_date(2i)")
+ form_output.delete("#{field_name}_date(3i)")
+ form_output.delete("#{field_name}_time(5i)") if form_output["#{field_name}_time(4i)"].blank?
+ end
+
+ form_output
+ end
+
+ def set_payform_item_hours(model_name)
+ if params[:calculate_hours] == 'user_input'
+ params[model_name.to_sym][:hours] = params[:other][:hours].to_f + params[:other][:minutes].to_f/60
+ else
+ start_params = []
+ end_params = []
+ for num in (1..7)
+ unless num == 6 #we skip seconds; meridian is stored in 7
+ start_params << params[:time_input]["start(#{num}i)"].to_i
+ end_params << params[:time_input]["end(#{num}i)"].to_i
+ end
+ end
+ start_time = convert_to_time(start_params)
+ end_time = convert_to_time(end_params)
+ params[model_name.to_sym][:hours] = (end_time-start_time) / 3600.0
+ end
+ end
+
+ def convert_to_time(date_array)
+ # 0 = year, 1 = month, 2 = day, 3 = hour, 4 = minute, 5 = meridiem(am/pm)
+ if date_array[3] == 12 #if noon or midnight
+ date_array[3] -= 12
+ end
+ if date_array[5] == -2 #if pm
+ date_array[3] += 12
+ end
+ Time.utc(date_array[0], nil, nil, date_array[3], date_array[4])
+ end
+
+
+ def join_date_and_time(form_output)
+ #join date and time
+ %w{start end mandatory_start mandatory_end}.each do |field_name|
+ if form_output["#{field_name}_date"] && form_output["#{field_name}_time"]
+ form_output["#{field_name}"] ||= form_output["#{field_name}_date"].beginning_of_day + form_output["#{field_name}_time"].seconds_since_midnight
+ form_output.delete("#{field_name}_date")
+ form_output.delete("#{field_name}_time")
+ end
+ form_output["start"] ||= Time.now
+ form_output
end
- redirect_to options
end
private
@@ -280,7 +370,7 @@ def department_chooser
if (params[:su_mode] && current_user.superuser?)
current_user.update_attribute(:supermode, params[:su_mode]=='ON')
flash[:notice] = "Supermode is now #{current_user.supermode? ? 'ON' : 'OFF'}"
- redirect_to(root_path) and return
+ redirect_to :action => "index" and return
end
if (params["chooser"] && params["chooser"]["dept_id"])
session[:department_id] = params["chooser"]["dept_id"]
@@ -308,4 +398,4 @@ def prepare_mail_url
end
-end
+end
View
117 app/controllers/calendar_feeds_controller.rb
@@ -0,0 +1,117 @@
+class CalendarFeedsController < ApplicationController
+ skip_before_filter filter_chain, :except => [:index]
+
+ def index
+ @source_types = %w[User Department LocGroup Location]
+ shift_source = Struct.new( :type, :name, :token )
+ @shift_sources=[]
+ @sub_sources=[]
+
+ @source_types.each do |source_type|
+ current_user.send(source_type.underscore.concat('s')).each do |source|
+ @shift_sources << shift_source.new(source.class.name, source.name, generate_token(source, "Shift"))
+ @sub_sources << shift_source.new(source.class.name, source.name, generate_token(source, "SubRequest"))
+ end
+ end
+ end
+
+ def reset
+ current_user.calendar_feed_hash = nil
+ current_user.save!
+ flash[:notice] = 'All calendars reset. NOTE: Your old feeds are now inactive'
+ redirect_to :action => "index"
+ end
+
+ def grab
+ begin
+ @token_array = resolve_token(params[:token], params[:user_id])
+ @user = User.find(params[:user_id])
+ rescue Exception => e
+ redirect_to :action => "index"
+ flash[:error] = 'Could not load calendar feed. This feed may be invalid, inactive, or disabled.'
+ return
+ end
+ @shifts = []
+ @source = @token_array[0]
+ @type = @token_array[1]
+ if @type == "SubRequest"
+ @shifts = @user.available_sub_requests(@source)
+ elsif @type == "Shift"
+ case
+ when @source.class.name == "Department" && @user.departments.include?(@source) && @user.is_active?(@source)
+ @shifts = Shift.in_locations(@source.loc_groups.select {|lg| @user.can_view?(lg)}.collect(&:locations).flatten).after_date(Time.now.utc - 3.weeks).not_for_user(@user).flatten
+ when @source.class.name == "LocGroup" && @user.can_view?(@source)
+ @shifts = Shift.in_locations(@source.locations).after_date(Time.now.utc - 3.weeks).not_for_user(@user).flatten
+ when @source.class.name == "Location" && @user.can_view?(@source.loc_group)
+ @shifts = Shift.not_for_user(@user).find(:all, :conditions => ["location_id = ? AND end >= ?", @source.id, Time.now.utc - 3.weeks])
+ when @source.class.name == "User"
+ @shifts = Shift.in_departments(@source.active_departments).for_user(@source).after_date(Time.now.utc - 3.weeks).flatten
+ end
+ end
+ render :text => generate_ical
+ end
+
+ private
+
+ def generate_token(source, type)
+ if !current_user.calendar_feed_hash
+ current_user.calendar_feed_hash = ActiveSupport::SecureRandom.hex(32) #must be 32 characters
+ current_user.save!
+ end
+ require 'openssl'
+ require 'digest/sha2'
+ cipher = OpenSSL::Cipher::Cipher.new("aes-256-cbc")
+ cipher.encrypt
+ cipher.key = AppConfig.first.calendar_feed_hash
+ cipher.iv = current_user.calendar_feed_hash
+ @token = cipher.update(source.class.name.to_s + ',' + source.id.to_s + ',' + type) #creates cipher from string
+ @token << cipher.final
+ @token.unpack("H*").to_s #makes cipher alpa-numeric pretty
+ end
+
+ def resolve_token(token, user_id)
+ require 'openssl'
+ require 'digest/sha2'
+ cipher = OpenSSL::Cipher::Cipher.new("aes-256-cbc")
+ cipher.decrypt
+ cipher.key = AppConfig.first.calendar_feed_hash
+ cipher.iv = User.find(user_id).calendar_feed_hash
+ @source_string = cipher.update(token.to_a.pack("H*")) #unpacks cipher and decrpts to original string
+ @source_string << cipher.final
+ @source = @source_string.split(',')[0].constantize.find(@source_string.split(',')[1]) #gets shift_source from string
+ @feed_type=@source_string.split(',')[2] #is it for Shifts or for Sub_Requests
+ return @source, @feed_type
+ #This block will fail with bad data -- but it is handled in the grab function.
+ end
+
+ def generate_ical
+ cal = Icalendar::Calendar.new
+ cal.custom_property("METHOD","PUBLISH")
+ cal.custom_property("x-wr-calname", @type + "s: " + @source.name)
+ cal.custom_property("X-WR-CALDESC", @type + "s Calendar Feed for user: " + @user.name + ". The feed is " + @source.class.name.downcase + ": " + @source.name)
+ cal.custom_property("X-PUBLISHED-TTL", "PT1H") #default refresh rate
+ @shifts.each do |shift|
+ @event = Icalendar::Event.new
+ @event.dtstart = shift.start.utc.to_s(:us_icaldate_utc)
+ @event.dtend = shift.end.utc.to_s(:us_icaldate_utc)
+ if @type == "Shift"
+ @event.summary = "Shift" + (@source.class.name != "User" ? " for #{shift.user.name}" : "") + " in #{shift.location.short_name}"
+ @event.summary << " (sub requested!)" if shift.has_sub?
+ @event.description = shift.user.name + " has requested a sub for this shift!"
+ elsif @type == "SubRequest"
+ @event.description = "\nMandatory: " + shift.mandatory_start.to_s(:twelve_hour) + " - " + shift.mandatory_end.to_s(:twelve_hour)
+ @event.description << "\n\n" + shift.reason
+ @event.summary = "Sub for #{shift.user.name} in #{shift.location.short_name}"
+ end
+ @event.location = shift.location.name
+ cal.add @event
+ end
+ headers['Content-Type'] = "text/calendar; charset=UTF-8"
+ headers['Content-Disposition'] = "inline; filename=" + User.find(params[:user_id]).name + "_calendar_feed.ics"
+ # cal.publish #not necessary...
+ cal.to_ical
+ end
+
+
+end
+
View
6 app/controllers/calendars_controller.rb
@@ -59,7 +59,7 @@ def index
def show
@calendar = Calendar.find(params[:id])
unless current_user.is_admin_of?(@department) or @calendar.public?
- flash[:notice] = "Only an administrator may view a private calendar"
+ flash[:notice] = "Only an administrator may view a private calendar."
redirect_to shifts_path
return
end
@@ -211,7 +211,7 @@ def index_prep
@loc_group_select[@department.id] = @department.loc_groups #{}
@visible_loc_groups = current_user.user_config.view_loc_groups
@selected_loc_groups = @visible_loc_groups.collect{|l| l.id}
- @visible_locations = current_user.user_config.view_loc_groups.collect{|l| l.locations}.flatten
+ @visible_locations = current_user.user_config.view_loc_groups.collect{|l| l.locations}.flatten.select{|l| l.active?}
# now all this stuff is collected in day_preprocessing helper
# @shifts = []
@@ -233,7 +233,7 @@ def index_prep
@blocks_per_hour = 60/@time_increment.to_f
#get calendar colors
- @color_array = ["9f9", "9ff", "ff9", "f9f", "f99", "99f"]
+ @color_array = ["9f9", "9ff", "ff9", "f9f", "f99", "99f","9f9", "9ff", "ff9", "f9f", "f99", "99f","9f9", "9ff", "ff9", "f9f", "f99", "99f","9f9", "9ff", "ff9", "f9f", "f99", "99f"]
@color = {}
@calendars.each_with_index{ |calendar, i| @color[calendar] ||= @color_array[i]}
end
View
1  app/controllers/categories_controller.rb
@@ -1,4 +1,5 @@
class CategoriesController < ApplicationController
+ helper "payforms"
layout "payforms"
before_filter :require_department_admin
View
13 app/controllers/dashboard_controller.rb
@@ -4,14 +4,22 @@ class DashboardController < ApplicationController
helper :punch_clocks
def index
+ if params[:date].blank?
+ @current_date = Date.today
+ else
+ @current_date = params[:date]
+ @current_date = Date.parse(params[:date])
+ end
+ @user = current_user
@signed_in_shifts = Shift.signed_in(current_department).sort_by(&:start).group_by(&:loc_group)
@upcoming_shifts = Shift.find(:all, :conditions => ["#{:user_id} = ? and #{:end} > ? and #{:department_id} = ? and #{:scheduled} = ? and #{:active} = ?", current_user, Time.now.utc, current_department.id, true, true], :order => :start, :limit => 5)
@subs_you_requested = SubRequest.find(:all, :conditions => ["end > ? AND user_id = ?", Time.now.utc, current_user.id]).sort_by(&:start)
- @subs_you_can_take = current_user.available_sub_requests([@department]).select{|sub| sub.end > Time.now.utc}.sort_by(&:start)
+ @subs_you_can_take = current_user.available_sub_requests(@department).sort_by{|sub| sub.start}
@watched_objects = DataObject.find(current_user.user_config.watched_data_objects.split(', ')).group_by(&:data_type)
-
+ @current_notices = current_department.current_notices
+
@dept_start_hour = current_department.department_config.schedule_start / 60
@dept_end_hour = current_department.department_config.schedule_end / 60
@hours_per_day = (@dept_end_hour - @dept_start_hour)
@@ -24,4 +32,3 @@ def index
end
end
-
View
5 app/controllers/data_entries_controller.rb
@@ -23,10 +23,7 @@ def create
if @report = current_user.current_shift.report
content = []
@data_entry.data_fields_with_contents.each {|entry| content.push("#{DataField.find(entry.first).name.humanize}: #{entry.second}")}
- @report.report_items << ReportItem.new(:time => Time.now, :content => "Updated #{@data_entry.data_object.name}. #{content.join(', ')}.", :ip_address => request.remote_ip)
- else
- #TODO Remove after fixing #213
- raise "Error raised in finding current_user.current_shift.report. This is probably related to bug #213. If you see this message, please email a report to adam.bray@yale.edu with your Browser, OS, and Date/Time that you saw this message"
+ @report.report_items << ReportItem.new(:time => Time.now, :content => "Updated #{@data_entry.data_object.name}: #{"\n"} #{content.join("\n")}", :ip_address => request.remote_ip)
end
else
flash[:error] = "Could not update #{@data_entry.data_object.name}."
View
2  app/controllers/data_objects_controller.rb
@@ -126,7 +126,7 @@ def options_for_location_select
def check_data_object_admin_permission(obj)
if (current_user.loc_groups_to_admin(current_department).map{|lg| lg.locations}.flatten & obj.locations).empty?
- flash[:notice] = "You do not have permission to administer this data object"
+ flash[:notice] = "You do not have permission to administer this data object."
redirect_to access_denied_path
end
end
View
2  app/controllers/department_configs_controller.rb
@@ -6,6 +6,7 @@ class DepartmentConfigsController < ApplicationController
def edit
@time_choices = (0..1440).step(60).map{|t| [t.min_to_am_pm, t]}
@time_choices2 = (0..1380).step(60).map{|t| [t.min_to_am_pm, t]} + (1440..2160).step(60).map{|t| ["*"+t.min_to_am_pm, t]}
+ @rounding_choices = [1, 15, 30, 60].map{|r| ["#{r} min", r]}
@department_config = DepartmentConfig.find(params[:id])
@select_dept = @department_config.department.name
#@time_choices = (0..1440).step(@department_config.time_increment).map{|t| [t.min_to_am_pm, t]}
@@ -21,6 +22,7 @@ def update
else
@time_choices = (0..1440).step(60).map{|t| [t.min_to_am_pm, t]}
@time_choices2 = (0..1380).step(60).map{|t| [t.min_to_am_pm, t]} + (1440..2160).step(60).map{|t| ["*"+t.min_to_am_pm, t]}
+ @rounding_choices = [1, 15, 30, 60].map{|r| ["#{r} min", r]}
render :action => 'edit'
end
end
View
1  app/controllers/first_run_controller.rb
@@ -9,6 +9,7 @@ def new_app_config
def create_app_config
AppConfig.first.destroy if AppConfig.first
@app_config=AppConfig.new(params[:app_config])
+ @app_config.calendar_feed_hash = ActiveSupport::SecureRandom.hex(32) #must be 32 characters
@app_config.use_ldap = params[:app_config][:use_ldap] && params[:app_config][:use_ldap] == "1" ? true : false
if @app_config.save
flash[:notice] = "App Settings have been configured."
View
6 app/controllers/hooks_controller.rb
@@ -63,13 +63,13 @@ def add_job_after
redirect_to p[:url] and return
end
else
- flash[:error] = "Please report to Admin. ERROR: Could not save to payform"
+ flash[:error] = "Please report to Admin. ERROR: Could not save to payform."
end
else
- flash[:error] = "Please report to Admin. ERROR: Department not found"
+ flash[:error] = "Please report to Admin. ERROR: Department not found."
end
else
- flash[:error] = "Please report to Admin. ERROR: Invalid Params"
+ flash[:error] = "Please report to Admin. ERROR: Invalid Params."
end
# FAIL
View
74 app/controllers/links_controller.rb
@@ -0,0 +1,74 @@
+class LinksController < NoticesController
+ before_filter :require_any_loc_group_admin, :except => [:index, :show, :destroy]
+
+ def new
+ @current_shift_location = current_user.current_shift.location if current_user.current_shift
+ @link = Link.new
+ layout_check
+ end
+
+ def edit
+ @link = Link.find(params[:id])
+ end
+
+ def create
+ @link = Link.new(params[:link])
+ @link.author = current_user
+ @link.department = current_department
+ @link.url = "http://" << params[:link][:url] if @link.url[0,7] != "http://" && @link.url[0,8] != "https://"
+ @link.url.strip!
+ @link.start = Time.now
+ @link.end = nil
+ @link.indefinite = true
+ begin
+ Link.transaction do
+ @link.save(false)
+ set_sources(@link)
+ @link.save!
+ end
+ rescue ActiveRecord::RecordInvalid
+ respond_to do |format|
+ format.html { render :action => "new" }
+ format.js #create.js.rjs
+ end
+ else
+ respond_to do |format|
+ flash[:notice] = 'Link was successfully created.'
+ format.html {
+ redirect_to links_path
+ }
+ format.js #create.js.rjs
+ end
+ end
+ end
+
+ def update
+ @link = Link.find_by_id(params[:id]) || Link.new
+ @link.update_attributes(params[:link])
+ @link.author = current_user
+ @link.department = current_department
+ @link.url = "http://" << params[:link][:url] if @link.url[0,7] != "http://" && @link.url[0,8] != "https://"
+ @link.url.strip!
+ @link.start = Time.now
+ @link.end = nil
+ @link.indefinite = true
+ begin
+ Link.transaction do
+ @link.save(false)
+ set_sources(@link)
+ @link.save!
+ end
+ rescue ActiveRecord::RecordInvalid
+ respond_to do |format|
+ format.html { render :action => "new" }
+ end
+ else
+ respond_to do |format|
+ format.html {
+ flash[:notice] = 'Link was successfully created.'
+ redirect_to links_path
+ }
+ end
+ end
+ end
+end
View
6 app/controllers/loc_groups_controller.rb
@@ -18,7 +18,7 @@ def new
def create
@loc_group = LocGroup.new(params[:loc_group])
if @loc_group.save
- flash[:notice] = "Successfully created Location Group."
+ flash[:notice] = "Successfully created location group."
redirect_to @loc_group
else
render :action => 'new'
@@ -30,7 +30,7 @@ def edit
def update
if @loc_group.update_attributes(params[:loc_group])
- flash[:notice] = "Successfully updated loc group."
+ flash[:notice] = "Successfully updated Location group."
redirect_to @loc_group
else
render :action => 'edit'
@@ -40,7 +40,7 @@ def update
def destroy
@loc_group = LocGroup.find(params[:id])
@loc_group.destroy
- flash[:notice] = "Successfully destroyed loc group."
+ flash[:notice] = "Successfully destroyed Location group."
redirect_to department_loc_groups_path(current_department)
end
View
48 app/controllers/locations_controller.rb
@@ -43,17 +43,51 @@ def update
render :action => 'edit'
end
end
-
+
+ def toggle
+ @location = Location.find(params[:id])
+ ActiveRecord::Base.transaction do
+ if @location.active
+ @location.deactivate
+ else
+ @location.activate
+ end
+ end
+ flash[:notice] = "Changed activation status of " + @location.name.to_s + "."
+ respond_to do |format|
+ format.js
+ format.html {redirect_to notices_path}
+ end
+ end
+
def destroy
+ @location = Location.find(params[:id])
+ redirect_to access_denied_path unless @locations.include?(@location)
+ @location.destroy
+ flash[:notice] = "Successfully destroyed location."
+ redirect_to department_locations_path(current_department)
+ end
+
+
+ def display_report_items
@location = Location.find(params[:id])
- redirect_to access_denied_path unless @locations.include?(@location)
- @location.destroy
- flash[:notice] = "Successfully destroyed location."
- redirect_to department_locations_path(current_department)
+ if params[:more_items] == nil
+ session[:items] = 0
+ end
+ item_number = find_item_number + 5
+ session[:items] = item_number
+ @report_items = ReportItem.in_location(@location).last(item_number).reverse
+ respond_to do |format|
+ format.js { @report_items }
+ format.html { } #this is necessary!
+ end
end
-
-private
+private
+ def find_item_number
+ session[:items] ||= 0
+ end
+
def find_allowed_locations
@locations = current_user.loc_groups_to_admin(@department).map{|lg| lg.locations}.flatten
end
View
165 app/controllers/notices_controller.rb
@@ -1,118 +1,26 @@
class NoticesController < ApplicationController
- def index
- @notices = Notice.active
- end
-
def archive
require_department_admin
@notices = Notice.inactive
end
- def show
- @notice = Notice.find(params[:id])
- end
-
- def new
- @notice_type = params[:type]
- @current_shift_location = current_user.current_shift.location if current_user.current_shift
- @notice = Notice.new
- layout_check
- end
-
- def edit
- require_department_admin
- @current_shift_location = current_user.current_shift.location if current_user.current_shift
- @notice = Notice.find(params[:id])
- layout_check
- end
-
- def create
- @report = current_user.current_shift.report if current_user.current_shift
- @notice = Notice.new(params[:notice])
- @notice.author = current_user
- @notice.department = current_department
- @notice.sticky = true if params[:type] == "sticky"
- @notice.announcement = true if params[:type] == "announcement" && current_user.is_admin_of?(current_department)
- if params[:type] == "link"
- @notice.useful_link = true if params[:type] == "link"
- @notice.content = params[:link_label] + "|$|" + "http://" + params[:url]
- @notice.content.gsub!("http://http://", "http://")
- @notice.start_time = Time.now
- @notice.end_time = nil
- @notice.indefinite = true
- else
- @notice.start_time = Time.now if params[:start_time_choice] == 'now' || @notice.sticky
- @notice.end_time = nil if params[:end_time_choice] == "indefinite" || @notice.sticky
- @notice.indefinite = true if params[:end_time_choice] == "indefinite" || @notice.sticky
- end
- begin
- Notice.transaction do
- @notice.save(false) #polymorphic associations require a saved database record
- set_sources #setting polymorphic user and location sources
- @notice.save! #saving again to run validations
- end
- rescue Exception
- respond_to do |format|
- format.html { render :action => "new" }
- format.js #create.js.rjs
- end
- else
- respond_to do |format|
- format.html {
- flash[:notice] = 'Notice was successfully created.'
- redirect_to notices_path
- }
- format.js #create.js.rjs
- end
- end
- end
-
- def update
- @notice = Notice.find_by_id(params[:id]) || Notice.new
- @notice.update_attributes(params[:notice])
- @notice.sticky = true if params[:type] == "sticky"
- @notice.sticky = false if params[:type] == "announcement" && current_user.is_admin_of?(current_department)
- @notice.author = current_user
- @notice.department = current_department
- @notice.start_time = Time.now if @notice.is_sticky
- @notice.end_time = nil if params[:end_time_choice] == "indefinite" || @notice.is_sticky
- @notice.indefinite = true if params[:end_time_choice] == "indefinite" || @notice.is_sticky
-# raise params.to_yaml
- begin
- Notice.transaction do
- @notice.save(false)
- set_sources
- @notice.save!
- end
- rescue Exception
- respond_to do |format|
- format.html { render :action => "edit" }
- format.js #update.js.rjs
- end
- else
- respond_to do |format|
- format.html {
- flash[:notice] = 'Notice was successfully saved.'
- redirect_to :action => "index"
- }
- format.js #update.js.rjs
- end
- end
- end
-
def destroy
- @notice = Notice.find(params[:id])
- unless @notice.is_sticky || current_user.is_admin_of?(current_department)
- redirect_with_flash("You are not authorized to remove this notice", :back) and return
+ @notice = Notice.find_by_id(params[:id])
+ unless @notice.class.name == "Sticky" || current_user.is_admin_of?(current_department) || current_user == @notice.author
+ flash[:error] = "You are not authorized to remove this #{@notice.type.downcase}"
+ redirect_to :back and return
end
- unless @notice.is_current?
- redirect_with_flash("This notice was already removed on #{@notice.end_time}", :back) and return
+ unless @notice.active? || @notice.start > Time.now
+ flash[:error] = "This #{@notice.type.downcase} was already removed on #{@notice.end}"
+ redirect_to :back and return
end
if @notice.remove(current_user) && @notice.save
- redirect_with_flash("Notice successfully removed", :back)
+ flash[:notice] = "#{@notice.type} successfully removed"
+ redirect_to :back
else
- redirect_with_flash("Error removing notice", :back)
+ flash[:error] = "Error removing #{@notice.type.downcase}"
+ redirect_to :back
end
end
@@ -124,36 +32,37 @@ def update_message_center
protected
- 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)
- @notice.user_sources << user_source if user_source
- else
- l = l.split("||")
- @notice.user_sources << l[0].constantize.find(l[1]) if l.length == 2 #javascript or not javascript
- end
- end
- end
+ def set_sources(notice)
+
+ #Removed user_sources as an option. (Not removing them from the database though -- at least not yet)
+# if params[:for_users] && notice.type == "Sticky"
+# 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)
+# notice.user_sources << user_source if user_source
+# else
+# l = l.split("||")
+# notice.user_sources << l[0].constantize.find(l[1]) if l.length == 2 #javascript or not javascript
+# end
+# end
+# end
if params[:department_wide_locations] && current_user.is_admin_of?(current_department)
- @notice.location_sources << current_department
- @notice.departments << current_department
- @notice.loc_groups << current_department.loc_groups
- @notice.locations << current_department.locations
- elsif params[:for_location_groups]
+ notice.user_sources << current_department
+ end
+ if params[:for_location_groups]
params[:for_location_groups].each do |loc_group|
- lg = LocGroup.find(loc_group)
- @notice.loc_groups << lg
- @notice.locations << lg.locations
- end
+ @loc_group = LocGroup.find_by_id(loc_group)
+ if current_user.is_admin_of?(@loc_group) || notice.class.name == "Sticky"
+ notice.location_sources << @loc_group
+ notice.location_sources << @loc_group.locations
+ end
+ end
+
end
if params[:for_locations]
params[:for_locations].each do |loc|
- @notice.locations << Location.find_by_id(loc)
+ notice.location_sources << Location.find_by_id(loc)
end
end
end
View
6 app/controllers/password_resets_controller.rb
@@ -16,7 +16,7 @@ def create
flash[:notice] = "Instructions to reset the password have been emailed. "
redirect_to login_path
else
- flash[:notice] = "No user using built-in authentication was found with that email address"
+ flash[:notice] = "No user using built-in authentication was found with that email address."
render :action => :new
end
end
@@ -29,7 +29,7 @@ def update
@user.password = params[:user][:password]
@user.password_confirmation = params[:user][:password_confirmation]
if @user.save
- flash[:notice] = "Password successfully updated"
+ flash[:notice] = "Password successfully updated."
redirect_to login_path
else
render :action => :edit
@@ -49,7 +49,7 @@ def load_user_using_perishable_token
end
def require_no_user
if current_user
- flash[:notice] = "You\'re logged in. Someone resetting their password shouldn\'t be logged in."
+ flash[:notice] = "You are logged in. Someone resetting their password should not be logged in."
redirect_to root_url
end
View
18 app/controllers/payform_item_sets_controller.rb
@@ -1,16 +1,13 @@
class PayformItemSetsController < ApplicationController
layout "payforms"
+ helper 'payforms'
before_filter :require_department_admin
# Shouldn't this filter by department?
def index
- @payform_item_sets = PayformItemSet.all
- end
-
- def show
- @payform_item_set = PayformItemSet.find(params[:id])
- @payform_items = @payform_item_set.payform_items.select{|p| p.payform_id}
+ @active_sets = PayformItemSet.active
+ @expired_sets = PayformItemSet.expired
end
def new
@@ -20,7 +17,9 @@ def new
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
date = build_date_from_params(:date, params[:payform_item_set])
begin
@@ -33,10 +32,11 @@ def create
payform_item.payform = Payform.build(current_department, user, date)
@payform_items << payform_item
end
-
+
+
if @payform_item_set.save and @payform_item_set.payform_items << @payform_items
flash[:notice] = "Successfully created payform item set."
- redirect_to @payform_item_set
+ redirect_to payform_item_sets_path
else
flash[:error] = @payform_item_set.errors.full_messages.to_sentence
@users_select = current_department.users.sort_by(&:name)
@@ -102,7 +102,7 @@ def update
if @payform_item_set.update_attributes(params[:payform_item_set])
flash[:notice] = "Successfully updated payform item set."
- redirect_to @payform_item_set
+ redirect_to payform_item_sets_path
else
flash[:error] = @payform_item_set.errors.full_messages.to_sentence
@users_select = current_department.users.sort_by(&:name)
View
134 app/controllers/payform_items_controller.rb
@@ -3,26 +3,25 @@ class PayformItemsController < ApplicationController
helper 'payforms'
def new
- @payform = Payform.find(params[:payform_id])
- return unless user_is_owner_or_admin_of(@payform, @payform.department)
@payform_item = PayformItem.new
+ @payform_item.payform = Payform.find(params[:payform_id])
+ #TODO: These return lines really only work with the ajax -- we should come up with a better solution.
+ return unless user_is_owner_or_admin_of(@payform_item.payform, @payform_item.department)
layout_check
end
def create
- get_hours
+ set_payform_item_hours("payform_item")
@payform_item = PayformItem.new(params[:payform_item])
- if params[:payform_id]
- @payform = Payform.find(params[:payform_id])
- else
- @payform = @payform_item.parent.payform
- end
- return unless user_is_owner_or_admin_of(@payform, @payform.department)
- @payform_item.payform = @payform
- @payform.submitted = nil
- if @payform_item.save and @payform.save
+ @payform_item.payform = Payform.find(params[:payform_id])
+ return unless user_is_owner_or_admin_of(@payform_item.payform, @payform_item.department)
+ @payform_item.source = current_user.name
+ if @payform_item.save
flash[:notice] = "Successfully created payform item."
- redirect_to @payform
+ if @payform_item.user != current_user
+ AppMailer.deliver_payform_item_modify_notification(@payform_item, @payform_item.payform.department)
+ end
+ redirect_to @payform_item.payform
else
render :action => 'new'
end
@@ -30,117 +29,48 @@ def create
def edit
@payform_item = PayformItem.find(params[:id])
- @payform = @payform_item.payform
- return unless user_is_owner_or_admin_of(@payform, @payform.department)
+ @payform_item.reason = nil #need a new reason each edit
+ return unless user_is_owner_or_admin_of(@payform_item.payform, @payform_item.department)
layout_check
end
def update
- get_hours
- @payform_item = PayformItem.new(params[:payform_item])
- @payform_item.parent = PayformItem.find(params[:id])
- @payform_item.parent.reason = @payform_item.reason
- @payform_item.reason = nil
- @payform = @payform_item.payform = @payform_item.parent.payform
- @payform_item.parent.payform = nil # this line caused headaches!
- @payform_item.source = current_user.name
-
- return unless user_is_owner_or_admin_of(@payform, @payform.department)
-
- begin
-# unfortunately the only way I could get this to work was such that if there are
-# errors in both (ie with the reason and something else), it'll tell you about
-# the reason, then, when you've fixed that, it'll tell you about the rest.
-# errors = []
- PayformItem.transaction do
- @payform_item.save(false)
- @payform_item.parent.save!
- @payform_item.save!
- @payform.submitted = nil
- @errors = "Failed to unsubmit payform" unless @payform.save
- end
+ set_payform_item_hours("payform_item")
+ @payform_item = PayformItem.find(params[:id])
+ return unless user_is_owner_or_admin_of(@payform_item.payform, @payform_item.department)
+ @payform_item.attributes = params[:payform_item]
+ @payform_item.updated_by = current_user.name
+ if @payform_item.save
if @payform_item.user != current_user
- AppMailer.deliver_payform_item_change_notification(@payform_item.parent, @payform_item, @payform.department)
+ AppMailer.deliver_payform_item_modify_notification(@payform_item, @payform_item.payform.department)
end
flash[:notice] = "Successfully edited payform item."
redirect_to @payform_item.payform
-
- rescue Exception => e
- @payform = @payform_item.payform
- @payform_item = PayformItem.find(params[:id])
- @payform_item.add_errors(e)
- @payform_item.attributes = params[:payform_item]
- @payform_item.payform = @payform
- flash[:error].now = @errors.to_s if @errors
+ else
render :action => 'edit'
end
end
-
+
def delete
@payform_item = PayformItem.find(params[:id])
- @payform = @payform_item.payform
- return unless user_is_owner_or_admin_of(@payform, @payform.department)
+ @payform_item.reason = nil
+ return unless user_is_owner_or_admin_of(@payform_item.payform, @payform_item.department)
layout_check
end
def destroy
@payform_item = PayformItem.find(params[:id])
- @payform_item.reason = params[:payform_item][:reason]
- @payform = @payform_item.payform
- return unless user_is_owner_or_admin_of(@payform, @payform.department)
- @payform_item.active = false
- @payform_item.source = current_user.name
-
- begin
- PayformItem.transaction do
- @payform_item.save!
+ return unless user_is_owner_or_admin_of(@payform_item.payform, @payform_item.department)
+ if @payform_item.update_attributes(:reason => params[:payform_item][:reason], :active => false, :updated_by => current_user.name)
+ if @payform_item.payform.user != current_user
+ AppMailer.deliver_payform_item_deletion_notification(@payform_item, @payform_item.department)
end
- if @payform_item.payform.user != current_user # just for testing; should be != instead
- AppMailer.deliver_payform_item_deletion_notification(@payform_item, @payform.department)
- end
- flash[:notice] = "Payform item deleted." if @payform_item.payform.submitted == false
- redirect_to @payform
-
- rescue
- @payform = @payform_item.payform
- if !@payform_item.payform.save
- flash.now[:error] = "Error unsubmitting payform. "
- else
- flash.now[:error] = @payform_item.errors.to_sentence
- end
- render :action => 'delete'
- end
- end
-
- protected
-
- def get_hours
- if params[:calculate_hours] == 'user_input'
- params[:payform_item][:hours] = params[:other][:hours].to_f + params[:other][:minutes].to_f/60
+ flash[:notice] = "Payform item deleted."
+ redirect_to @payform_item.payform
else
- start_params = []
- end_params = []
- for num in (1..6)
- start_params << params[:time_input]["start(#{num}i)"].to_i
- end_params << params[:time_input]["end(#{num}i)"].to_i
- end
- start_time = convert_to_time(start_params)
- end_time = convert_to_time(end_params)
- params[:payform_item][:hours] = (end_time-start_time) / 3600.0
+ render :action => 'delete'
end
end
-
- def convert_to_time(date_array)
- # 0 = year, 1 = month, 2 = day, 3 = hour, 4 = minute, 5 = meridiem
- if date_array[3] == 12
- date_array[3] -= 12
- end
- if date_array[5] == 1
- date_array[3] += 12
- end
- Time.utc(date_array[0], nil, nil, date_array[3], date_array[4])
- end
-
end
View
64 app/controllers/payforms_controller.rb
@@ -5,7 +5,7 @@ def index
@payforms = narrow_down(current_user.is_admin_of?(current_department) ?
current_department.payforms :
current_department.payforms && current_user.payforms)
- @payforms = @payforms.sort_by{|payform| payform.user.last_name}
+ @payforms = @payforms.sort_by{|payform| [payform.user.reverse_name, Date.today - payform.date]}
end
def show
@@ -47,7 +47,9 @@ def submit
@payform = Payform.find(params[:id])
return unless user_is_owner_or_admin_of(@payform, @payform.department)
@payform.submitted = Time.now
- if @payform.save
+ if @payform.save && @payform.hours > current_department.department_config.payform_time_limit
+ flash[:notice] = "Successfully submitted payform, however, you have submitted more than the allowed #{current_department.department_config.payform_time_limit} hours this week."
+ elsif @payform.save && @payform.hours <= current_department.department_config.payform_time_limit
flash[:notice] = "Successfully submitted payform."
end
respond_to do |format|
@@ -67,15 +69,36 @@ def unsubmit
end
def approve
- @payform = Payform.find(params[:id])
- @payform.approved = Time.now
- @payform.approved_by = current_user
- if @payform.save
- flash[:notice] = "Successfully approved payform. #{Payform.unapproved.select{|p| p.date == @payform.date}.size} payform(s) left for this week."
- end
- @next_unapproved_payform = Payform.unapproved.select{|p| p.date == @payform.date}.sort_by(&:submitted).last
- @next_unapproved_payform ? (redirect_to @next_unapproved_payform and return) : (redirect_to :action => "index" and return)
- end
+ @payform = Payform.find(params[:id])
+ @payform.approved = Time.now
+ @payform.approved_by = current_user
+ if @payform.save
+ flash[:notice] = "Successfully approved payform. #{Payform.unapproved.unskipped.select{|p| p.date == @payform.date}.size} payform(s) left for the week of #{@payform.date.strftime("%b %d %Y")}."
+ end
+ @next_unapproved_payform = Payform.unapproved.unskipped.sort_by(&:date).last
+ @next_unapproved_payform ? (redirect_to @next_unapproved_payform and return) : (redirect_to :action => "index" and return)
+ end
+
+ def skip
+ @payform = Payform.find(params[:id])
+ @payform.skipped = Time.now
+ if @payform.save
+ flash[:notice] = "Sucessfully skipped payform. #{Payform.unapproved.unskipped.select{|p| p.date == @payform.date}.size} payform(s) left for the week of #{@payform.date.strftime("%b %d %Y")}."
+ end
+ @next_unapproved_payform = Payform.unapproved.unskipped.sort_by(&:date).last
+ @next_unapproved_payform ? (redirect_to @next_unapproved_payform and return) : (redirect_to :action => "index" and return)
+ end
+
+ def unskip
+ @payform = Payform.find(params[:id])
+ @payform.skipped = nil
+ if @payform.save
+ flash[:notice] = "Sucessfully unskipped payform."
+ end
+ @next_unapproved_payform = Payform.unapproved.unskipped.sort_by(&:date).last
+ @next_unapproved_payform ? (redirect_to @next_unapproved_payform and return) : (redirect_to :action => "index" and return)
+ end
+
def unapprove
@payform = Payform.find(params[:id])
@@ -124,7 +147,8 @@ def search
def email_reminders
if !params[:id] or params[:id].to_i != @department.id
- redirect_to :action => :email_reminders, :id => @department.id and return
+ redirect_to :email_reminders and return
+##originally we also had :id => @department.id ~Casey
end
@default_reminder_msg = current_department.department_config.reminder_message
@default_warning_msg = current_department.department_config.warning_message
@@ -137,10 +161,11 @@ def send_reminders
admin_user = current_user
users_reminded = []
for user in @users
- ArMailer.deliver(ArMailer.create_due_payform_reminder(admin_user, user, message))
+ ArMailer.deliver(ArMailer.create_due_payform_reminder(user, message, current_department))
users_reminded << "#{user.name} (#{user.login})"
end
- redirect_with_flash "E-mail reminders sent to the following: #{users_reminded.to_sentence}", :action => :email_reminders, :id => @department.id
+ flash[:notice] = "E-mail reminders sent to the following: #{users_reminded.to_sentence}"
+ redirect_to :email_reminders
end
def send_warnings
@@ -159,24 +184,27 @@ def send_warnings
for payform in unsubmitted_payforms
weeklist += payform.date.strftime("\t%b %d, %Y\n")
end
- email = ArMailer.create_late_payform_warning(user, message.gsub("@weeklist@", weeklist), @department)
- ArMailer.deliver(email)
+ ArMailer.deliver(ArMailer.create_late_payform_warning(user, message.gsub("@weeklist@", weeklist), @department))
users_warned << "#{user.name} (#{user.login}) <pre>#{email.encoded}</pre>"
end
end
- redirect_with_flash "E-mail warnings sent to the following: <br/><br/>#{users_warned.join}", :action => :email_reminders, :id => @department.id
+ flash[:notice] = "E-mail warnings sent to the following: <br/><br/>#{users_warned.join}"
+ redirect_to :email_reminders
end
protected
def narrow_down(payforms)
- if ( !params[:unsubmitted] and !params[:submitted] and !params[:approved] and !params[:printed] )
+ if ( !params[:unsubmitted] and !params[:submitted] and !params[:approved] and !params[:skipped] and !params[:printed] )
params[:unsubmitted] = params[:submitted] = params[:approved] = true
end
scope = []
if params[:unsubmitted]
scope += payforms.unsubmitted
end
+ if params[:skipped]
+ scope += payforms.skipped
+ end
if params[:submitted]
scope += payforms.unapproved
end
View
12 app/controllers/public_view_controller.rb
@@ -0,0 +1,12 @@
+class PublicViewController < ApplicationController
+
+ skip_before_filter :login_check
+ skip_before_filter CASClient::Frameworks::Rails::Filter
+
+ def index
+ @date = params[:date].to_date
+ @cluster = Location.find_by_short_name(params[:cluster])
+ end
+
+end
+
View
2  app/controllers/punch_clocks_controller.rb
@@ -38,7 +38,7 @@ def update
if @punch_clock && @punch_clock.save && !error
flash[:notice] = message
else
- flash[:error] = "Could not modify punch clock: #{message}"
+ flash[:error] = "Could not modify punch clock: #{message}."
end
redirect_to current_user == @punch_clock.user ? dashboard_path : punch_clocks_path
end
View
9 app/controllers/repeating_events_controller.rb
@@ -18,11 +18,12 @@ def new
def create
#TODO: persistent calendar selection? it would be nice...
- session[:calendar] = params[:repeating_event][:calendar_id]
+ parse_date_and_time_output(params[:repeating_event])
+ session[:calendar] = params[:repeating_event][:calendar_id]
params[:repeating_event][:days] = params[:days]
if params[:repeating_event][:slot_or_shift] == "time_slot"
- params[:repeating_event][:location_ids] = params[:location_ids]
+ params[:repeating_event][:location_ids] = params[:for_locations]
else
params[:repeating_event][:location_ids] = [params[:shift][:location_id]]
end
@@ -63,9 +64,10 @@ def edit
def update
@old_repeating_event = RepeatingEvent.find(params[:id])
+ parse_date_and_time_output(params[:repeating_event])
params[:repeating_event][:days] = params[:days]