Browse Source

Make mass_add for activities visible

Maarten van den Berg 7 years ago
parent
commit
e3f26e3335

+ 20 - 4
app/models/activity.rb

@@ -176,15 +176,31 @@ class Activity < ApplicationRecord
176 176
       st            = Time.strptime(row['start_time'], '%H:%M')
177 177
       a.start       = Time.zone.local(sd.year, sd.month, sd.day, st.hour, st.min)
178 178
 
179
-      if not row['end_date'].blank?
179
+      unless row['end_date'].blank?
180 180
         ed          = Date.strptime(row['end_date'])
181 181
         et          = Time.strptime(row['end_time'], '%H:%M')
182 182
         a.end       = Time.zone.local(ed.year, ed.month, ed.day, et.hour, et.min)
183 183
       end
184 184
 
185
-      dd            = Date.strptime(row['deadline_date'])
186
-      dt            = Time.strptime(row['deadline_time'], '%H:%M')
187
-      a.deadline    = Time.zone.local(dd.year, dd.month, dd.day, dt.hour, dt.min)
185
+      unless row['deadline_date'].blank?
186
+        dd            = Date.strptime(row['deadline_date'])
187
+        dt            = Time.strptime(row['deadline_time'], '%H:%M')
188
+        a.deadline    = Time.zone.local(dd.year, dd.month, dd.day, dt.hour, dt.min)
189
+      end
190
+
191
+      unless row['reminder_at_date'].blank?
192
+        rd            = Date.strptime(row['reminder_at_date'])
193
+        rt            = Time.strptime(row['reminder_at_time'], '%H:%M')
194
+        a.reminder_at = Time.zone.local(rd.year, rd.month, rd.day, rt.hour, rt.min)
195
+      end
196
+
197
+      unless row['subgroup_division_enabled'].blank?
198
+        a.subgroup_division_enabled = row['subgroup_division_enabled'].downcase == 'y'
199
+      end
200
+
201
+      unless row['no_response_action'].blank?
202
+        a.no_response_action = row['no_response_action'].downcase == 'p'
203
+      end
188 204
 
189 205
       result << a
190 206
     end

+ 2 - 2
app/views/activities/mass_new.html.haml

@@ -11,6 +11,6 @@
11 11
     .col-md-12
12 12
       = form_tag(group_activities_mass_new_path(@group), method: 'post', multipart: true) do
13 13
         .form-group
14
-          = file_field_tag 'spreadsheet'
14
+          = file_field_tag 'spreadsheet', required: true
15 15
         .form-group
16
-          = submit_tag
16
+          = submit_tag("Go!", class: 'btn btn-warning', confirm: t(:areyousure))

+ 4 - 2
app/views/groups/edit.html.haml

@@ -55,5 +55,7 @@
55 55
         = submit_tag(t('defaultsubgroups.destroy'), class: 'btn btn-danger')
56 56
 
57 57
 .row
58
-  .col-xs-12
59
-    = link_to t(:back), @group, class: 'btn btn-default'
58
+  .col-md-12
59
+    .btn-group
60
+      = link_to t(:back), @group, class: 'btn btn-default'
61
+      = link_to t('activities.mass_import_short'), group_activities_mass_new_path(@group), class: 'btn btn-default'

+ 1 - 0
config/locales/activities/en.yml

@@ -8,6 +8,7 @@ en:
8 8
     edit: "Edit activity"
9 9
     updated: "Activity updated."
10 10
     destroyed: "Activity destroyed."
11
+    mass_import_short: "Import activities"
11 12
     mass_import: "Create multiple activities in %{group}"
12 13
     mass_imported: "%{count} activities created!"
13 14
 

+ 1 - 0
config/locales/activities/nl.yml

@@ -8,6 +8,7 @@ nl:
8 8
     edit: "Activiteit bewerken"
9 9
     updated: "Activiteit bijgewerkt."
10 10
     destroyed: "Activiteit verwijderd."
11
+    mass_import_short: "Activiteiten importeren"
11 12
     mass_import: "Meerdere activiteiten aanmaken in %{group}"
12 13
     mass_imported: "%{count} activiteiten aangemaakt!"
13 14
 

+ 2 - 1
db/seeds.rb

@@ -22,7 +22,8 @@ u = User.create!(
22 22
   email: 'maarten@maartenberg.nl',
23 23
   person: p,
24 24
   password: 'aardbei123',
25
-  password_confirmation: 'aardbei123'
25
+  password_confirmation: 'aardbei123',
26
+  confirmed: true
26 27
 )
27 28
 
28 29
 p2 = Person.create!(

+ 2 - 2
public/batch_activities.csv

@@ -1,2 +1,2 @@
1
-name,description,location,start_date,start_time,end_date,end_time,deadline_date,deadline_time
2
-Name,Description,Location,2017-12-31,12:34:00,2017-12-31,12:43:00,2017-12-28,13:37:00
1
+name,description,location,start_date,start_time,end_date,end_time,deadline_date,deadline_time,reminder_at_date,reminder_at_time,subgroup_division_enabled,no_response_action
2
+Name,Description,Where,2017-12-31,12:34,2017-12-31,12:43,2017-12-28,13:37,2017-12-27,23:59,Y(es)/N(o),P(resent)/A(bsent)