Sfoglia il codice sorgente

Add support for viewing past activities

Maarten van den Berg 7 anni fa
parent
commit
6068e048da

+ 11 - 4
app/controllers/activities_controller.rb

24
   # GET /groups/:id/activities
24
   # GET /groups/:id/activities
25
   # GET /activities.json
25
   # GET /activities.json
26
   def index
26
   def index
27
-    @activities = @group.activities
28
-      .where('start > ?', Time.now)
29
-      .order(start: :asc)
30
-      .paginate(page: params[:page], per_page: 25)
27
+    if params[:past]
28
+      @activities = @group.activities
29
+        .where('start < ?', Time.now)
30
+        .order(start: :desc)
31
+        .paginate(page: params[:page], per_page: 25)
32
+    else
33
+      @activities = @group.activities
34
+        .where('start > ?', Time.now)
35
+        .order(start: :asc)
36
+        .paginate(page: params[:page], per_page: 25)
37
+    end
31
   end
38
   end
32
 
39
 
33
   # GET /activities/1
40
   # GET /activities/1

+ 17 - 6
app/views/activities/index.html.haml

1
 %h1
1
 %h1
2
-  = t 'activerecord.models.activity.other'
3
-
4
-= link_to new_group_activity_path(@group), class: 'btn btn-default pull-right' do
5
-  %i.fa.fa-plus
6
-  = t 'activities.new'
2
+  - if params[:past]
3
+    = t 'activities.past'
4
+  - else
5
+    = t 'activities.upcoming'
7
 
6
 
8
 - isleader = @group.leaders.include?(current_person) || current_person.is_admin?
7
 - isleader = @group.leaders.include?(current_person) || current_person.is_admin?
8
+.btn-group.pull-right
9
+  - if params[:past]
10
+    = link_to group_activities_path(@group), class: 'btn btn-default' do
11
+      %i.fa.fa-history
12
+      = t 'activities.upcoming'
13
+  - else
14
+    = link_to group_activities_path(@group, past: true), class: 'btn btn-default' do
15
+      %i.fa.fa-history
16
+      = t 'activities.past'
17
+  - if isleader
18
+    = link_to new_group_activity_path(@group), class: 'btn btn-default' do
19
+      %i.fa.fa-plus
20
+      = t 'activities.new'
9
 
21
 
10
 %table.table
22
 %table.table
11
   %thead
23
   %thead
40
               %i.fa.fa-pencil
52
               %i.fa.fa-pencil
41
 
53
 
42
 = will_paginate @activities
54
 = will_paginate @activities
43
-

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

12
     mass_import: "Create multiple activities in %{group}"
12
     mass_import: "Create multiple activities in %{group}"
13
     mass_imported: "%{count} activities created!"
13
     mass_imported: "%{count} activities created!"
14
 
14
 
15
+    upcoming: 'Upcoming activities'
16
+    past: 'Past activities'
17
+
15
     mass_import_explanation: "Download the example file using the link below, fill in the fields (end and deadline are optional), and upload the file using the upload form."
18
     mass_import_explanation: "Download the example file using the link below, fill in the fields (end and deadline are optional), and upload the file using the upload form."
16
 
19
 
17
     upcoming_yours: "Upcoming activities organized by you"
20
     upcoming_yours: "Upcoming activities organized by you"

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

12
     mass_import: "Meerdere activiteiten aanmaken in %{group}"
12
     mass_import: "Meerdere activiteiten aanmaken in %{group}"
13
     mass_imported: "%{count} activiteiten aangemaakt!"
13
     mass_imported: "%{count} activiteiten aangemaakt!"
14
 
14
 
15
+    upcoming: 'Aankomende activiteiten'
16
+    past: 'Afgelopen activiteiten'
17
+
15
     mass_import_explanation: "Download het voorbeeldbestand via de link hieronder, vul de velden in in het formaat zoals het staat aangegeven (einde en deadline zijn niet verplicht), en upload het via de knop onderaan."
18
     mass_import_explanation: "Download het voorbeeldbestand via de link hieronder, vul de velden in in het formaat zoals het staat aangegeven (einde en deadline zijn niet verplicht), en upload het via de knop onderaan."
16
 
19
 
17
     upcoming_yours: "Aankomende activiteiten georganiseerd door jou"
20
     upcoming_yours: "Aankomende activiteiten georganiseerd door jou"