Browse Source

Make 'no response action' configurable per activity

Maarten van den Berg 7 years ago
parent
commit
5dc36f7b77

+ 1 - 1
app/controllers/activities_controller.rb

317
 
317
 
318
     # Never trust parameters from the scary internet, only allow the white list through.
318
     # Never trust parameters from the scary internet, only allow the white list through.
319
     def activity_params
319
     def activity_params
320
-      params.require(:activity).permit(:name, :description, :location, :start, :end, :deadline, :reminder_at, :subgroup_division_enabled)
320
+      params.require(:activity).permit(:name, :description, :location, :start, :end, :deadline, :reminder_at, :subgroup_division_enabled, :no_response_action)
321
     end
321
     end
322
 
322
 
323
     def subgroup_params
323
     def subgroup_params

+ 7 - 1
app/mailers/participant_mailer.rb

3
     @person = person
3
     @person = person
4
     @activity = activity
4
     @activity = activity
5
 
5
 
6
-    subject = I18n.t('activities.emails.attendance_reminder.subject', activity: @activity.name)
6
+    if activity.no_response_action # is true
7
+      key = 'activities.emails.attendance_reminder.subject_present'
8
+    else
9
+      key = 'activities.emails.attendance_reminder.subject_absent'
10
+    end
11
+
12
+    subject = I18n.t(key, activity: @activity.name)
7
 
13
 
8
     mail(to: @person.email, subject: subject)
14
     mail(to: @person.email, subject: subject)
9
   end
15
   end

+ 6 - 0
app/models/activity.rb

46
   # @!attribute subgroup_division_done
46
   # @!attribute subgroup_division_done
47
   #   @return [Boolean]
47
   #   @return [Boolean]
48
   #     whether subgroup division has been performed.
48
   #     whether subgroup division has been performed.
49
+  #
50
+  # @!attribute no_response_action
51
+  #   @return [Boolean]
52
+  #     what action to take when a participant has not responded and the
53
+  #     reminder is being sent. True to set the participant to attending, false
54
+  #     to set to absent.
49
 
55
 
50
   belongs_to :group
56
   belongs_to :group
51
 
57
 

+ 1 - 1
app/models/participant.rb

61
   def send_reminder
61
   def send_reminder
62
     return unless self.attending.nil?
62
     return unless self.attending.nil?
63
 
63
 
64
-    self.attending = true
64
+    self.attending = self.activity.no_response_action
65
     notes = self.notes || ""
65
     notes = self.notes || ""
66
     notes << '[auto]'
66
     notes << '[auto]'
67
     self.notes = notes
67
     self.notes = notes

+ 13 - 3
app/views/activities/_form.html.erb

40
       <%= f.label :deadline %>
40
       <%= f.label :deadline %>
41
       <%= f.datetime_field :deadline, class: 'form-control' %>
41
       <%= f.datetime_field :deadline, class: 'form-control' %>
42
     </div>
42
     </div>
43
-    <div class="form-group">
43
+    <div class="form-group row">
44
-      <%= f.label :reminder_at %>
44
+      <div class="col-md-6">
45
-      <%= f.datetime_field :reminder_at, class: 'form-control' %>
45
+        <%= f.label :reminder_at %>
46
+        <%= f.datetime_field :reminder_at, class: 'form-control' %>
47
+      </div>
48
+      <div class="col-md-6">
49
+        <%= f.label :no_response_action %>
50
+        <%= f.select(:no_response_action, options_for_select([
51
+          [I18n.t('activities.no_response_action.auto_present'), 'true'],
52
+          [I18n.t('activities.no_response_action.auto_absent'), 'false']
53
+        ], selected: @activity.no_response_action.to_s), {}, {class: 'form-control'}) %>
54
+      </div>
46
     </div>
55
     </div>
47
     <div class="form-group">
56
     <div class="form-group">
48
       <div class="check-box">
57
       <div class="check-box">
49
         <%= f.check_box(:subgroup_division_enabled) %>
58
         <%= f.check_box(:subgroup_division_enabled) %>
50
         <%= t 'activerecord.attributes.activity.subgroup_division_enabled' %>
59
         <%= t 'activerecord.attributes.activity.subgroup_division_enabled' %>
51
       </div>
60
       </div>
61
+    </div>
52
     <div class="form-group btn-group">
62
     <div class="form-group btn-group">
53
       <%= f.submit class: 'btn btn-primary' %>
63
       <%= f.submit class: 'btn btn-primary' %>
54
       <% unless activity.new_record? %>
64
       <% unless activity.new_record? %>

+ 4 - 1
app/views/participant_mailer/attendance_reminder.html.haml

1
 %p= t 'authentication.emails.greeting', name: @person.first_name
1
 %p= t 'authentication.emails.greeting', name: @person.first_name
2
 
2
 
3
-%p= t 'activities.emails.attendance_reminder.havenot_responded', activity: @activity.name
3
+- if @activity.no_response_action
4
+  %p= t 'activities.emails.attendance_reminder.set_to_present', activity: @activity.name
5
+- else
6
+  %p= t 'activities.emails.attendance_reminder.set_to_absent', activity: @activity.name
4
 
7
 
5
 %p= t 'activities.emails.attendance_reminder.if_cannot', deadline: l(@activity.deadline, format: :short)
8
 %p= t 'activities.emails.attendance_reminder.if_cannot', deadline: l(@activity.deadline, format: :short)
6
 
9
 

+ 5 - 1
app/views/participant_mailer/attendance_reminder.text.erb

1
 <%= t 'authentication.emails.greeting', name: @person.first_name %>
1
 <%= t 'authentication.emails.greeting', name: @person.first_name %>
2
 
2
 
3
-<%= t 'activities.emails.attendance_reminder.havenot_responded', activity: @activity.name %>
3
+<% if @activity.no_response_action %>
4
+<%= t 'activities.emails.attendance_reminder.set_to_present', activity: @activity.name %>
5
+<% else %>
6
+<%= t 'activities.emails.attendance_reminder.set_to_absent', activity: @activity.name %>
7
+<% end %>
4
 
8
 
5
 <%= t 'activities.emails.attendance_reminder.if_cannot', deadline: l(@activity.deadline, format: :short) %>
9
 <%= t 'activities.emails.attendance_reminder.if_cannot', deadline: l(@activity.deadline, format: :short) %>
6
 
10
 

+ 1 - 0
config/locales/aardbei_en.yml

83
         end: "End"
83
         end: "End"
84
         description: "Description"
84
         description: "Description"
85
         deadline: "Deadline"
85
         deadline: "Deadline"
86
+        no_response_action: "Action when no response"

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

75
         - "Cheers,"
75
         - "Cheers,"
76
       attendance_reminder:
76
       attendance_reminder:
77
         subject: "You are now listed as 'attending' for %{activity}"
77
         subject: "You are now listed as 'attending' for %{activity}"
78
-        havenot_responded: "You have not yet indicated if you will be at %{activity}. Because we assume that you're present if you don't respond, your response has been set to 'attending'."
78
+        set_to_present: "You have not yet indicated if you will be at %{activity}. Because we assume that you're present if you don't respond, your response has been set to 'attending'."
79
+        set_to_absent: "You have not yet indicated if you will be at %{activity}. This activity is set to assume to set you to absent if you don't respond, so your response has been set to 'absent'."
79
         if_cannot: "If you wish to change this, you can change your response until %{deadline} using the following link:"
80
         if_cannot: "If you wish to change this, you can change your response until %{deadline} using the following link:"
80
 
81
 
81
       subgroup_notification:
82
       subgroup_notification:

+ 9 - 3
config/locales/activities/nl.yml

67
       description: "Omschrijving"
67
       description: "Omschrijving"
68
       deadline: "Deadline"
68
       deadline: "Deadline"
69
 
69
 
70
+    no_response_action:
71
+      auto_present: 'Automatisch aanmelden'
72
+      auto_absent: 'Automatisch afmelden'
73
+
70
     emails:
74
     emails:
71
       open_activity: "Activiteit openen"
75
       open_activity: "Activiteit openen"
72
       open_settings: "Instellingen"
76
       open_settings: "Instellingen"
81
         - "Doi,"
85
         - "Doi,"
82
         - "Talla,"
86
         - "Talla,"
83
       attendance_reminder:
87
       attendance_reminder:
84
-        subject: "Je bent automatisch aangemeld voor %{activity}"
88
+        subject_present: "Je bent automatisch aangemeld voor %{activity}"
85
-        havenot_responded: "Je hebt nog niet aangegeven of je bij %{activity} kunt zijn. Omdat we ervan uitgaan dat je er bent als je niks aangeeft, is je reactie automatisch op 'aanwezig' gezet."
89
+        subject_absent: "Je bent automatisch afgemeld voor %{activity}"
86
-        if_cannot: "Als je toch niet aanwezig kunt zijn, kan je dit tot %{deadline} aangeven via de volgende link:"
90
+        set_to_present: "Je hebt nog niet aangegeven of je bij %{activity} kunt zijn. De organisatoreen van deze activiteit gaan ervan uit dat je er wel bent als je niets aangeeft,  dus je reactie is op 'aanwezig' gezet."
91
+        set_to_absent: "Je hebt nog niet aangegeven of je bij %{activity} kan zijn. De organisatoren van deze activiteit gaan ervan uit dat je er niet bent als je niets aangeeft, dus je reactie is op 'afwezig' gezet."
92
+        if_cannot: "Als je dit nog wilt veranderen kan je dit tot %{deadline} aangeven via de volgende link:"
87
 
93
 
88
       subgroup_notification:
94
       subgroup_notification:
89
         subject: "Je bent ingedeeld in subgroep %{subgroup} voor %{activity}"
95
         subject: "Je bent ingedeeld in subgroep %{subgroup} voor %{activity}"

+ 1 - 0
config/locales/translation_nl.yml

48
         subgroups: :activerecord.models.subgroup.other
48
         subgroups: :activerecord.models.subgroup.other
49
         subgroup_division_enabled: Subgroepen indelen
49
         subgroup_division_enabled: Subgroepen indelen
50
         subgroup_division_done: Subgroepen ingedeeld
50
         subgroup_division_done: Subgroepen ingedeeld
51
+        no_response_action: Actie bij geen reactie
51
 
52
 
52
       group:
53
       group:
53
         activities: Activiteiten  #g
54
         activities: Activiteiten  #g

+ 5 - 0
db/migrate/20180206181016_add_no_response_action_to_activities.rb

1
+class AddNoResponseActionToActivities < ActiveRecord::Migration[5.0]
2
+  def change
3
+    add_column :activities, :no_response_action, :boolean, default: true
4
+  end
5
+end

+ 4 - 3
db/schema.rb

10
 #
10
 #
11
 # It's strongly recommended that you check this file into your version control system.
11
 # It's strongly recommended that you check this file into your version control system.
12
 
12
 
13
-ActiveRecord::Schema.define(version: 20171023080215) do
13
+ActiveRecord::Schema.define(version: 20180206181016) do
14
 
14
 
15
   create_table "activities", force: :cascade do |t|
15
   create_table "activities", force: :cascade do |t|
16
     t.string   "name"
16
     t.string   "name"
20
     t.datetime "end"
20
     t.datetime "end"
21
     t.datetime "deadline"
21
     t.datetime "deadline"
22
     t.integer  "group_id"
22
     t.integer  "group_id"
23
-    t.datetime "created_at",                null: false
23
+    t.datetime "created_at",                               null: false
24
-    t.datetime "updated_at",                null: false
24
+    t.datetime "updated_at",                               null: false
25
     t.datetime "reminder_at"
25
     t.datetime "reminder_at"
26
     t.boolean  "reminder_done"
26
     t.boolean  "reminder_done"
27
     t.boolean  "subgroup_division_enabled"
27
     t.boolean  "subgroup_division_enabled"
28
     t.boolean  "subgroup_division_done"
28
     t.boolean  "subgroup_division_done"
29
+    t.boolean  "no_response_action",        default: true
29
     t.index ["group_id"], name: "index_activities_on_group_id"
30
     t.index ["group_id"], name: "index_activities_on_group_id"
30
   end
31
   end
31
 
32