Browse Source

QOL and TZ fix

Maarten van den Berg 7 years ago
parent
commit
b4942d7269
2 changed files with 7 additions and 4 deletions
  1. 4 1
      app/controllers/activities_controller.rb
  2. 3 3
      app/models/activity.rb

+ 4 - 1
app/controllers/activities_controller.rb

8
   # GET /groups/:id/activities
8
   # GET /groups/:id/activities
9
   # GET /activities.json
9
   # GET /activities.json
10
   def index
10
   def index
11
-    @activities = @group.activities.paginate(page: params[:page], per_page: 5)
11
+    @activities = @group.activities
12
+      .where('start > ?', Time.now)
13
+      .order(start: :asc)
14
+      .paginate(page: params[:page], per_page: 25)
12
   end
15
   end
13
 
16
 
14
   # GET /activities/1
17
   # GET /activities/1

+ 3 - 3
app/models/activity.rb

117
 
117
 
118
       sd            = Date.strptime(row['start_date'])
118
       sd            = Date.strptime(row['start_date'])
119
       st            = Time.strptime(row['start_time'], '%H:%M')
119
       st            = Time.strptime(row['start_time'], '%H:%M')
120
-      a.start       = DateTime.new(sd.year, sd.month, sd.day, st.hour, st.min)
120
+      a.start       = Time.zone.local(sd.year, sd.month, sd.day, st.hour, st.min)
121
 
121
 
122
       if not row['end_date'].blank?
122
       if not row['end_date'].blank?
123
         ed          = Date.strptime(row['end_date'])
123
         ed          = Date.strptime(row['end_date'])
124
         et          = Time.strptime(row['end_time'], '%H:%M')
124
         et          = Time.strptime(row['end_time'], '%H:%M')
125
-        a.end       = DateTime.new(ed.year, ed.month, ed.day, et.hour, et.min)
125
+        a.end       = Time.zone.local(ed.year, ed.month, ed.day, et.hour, et.min)
126
       end
126
       end
127
 
127
 
128
       dd            = Date.strptime(row['deadline_date'])
128
       dd            = Date.strptime(row['deadline_date'])
129
       dt            = Time.strptime(row['deadline_time'], '%H:%M')
129
       dt            = Time.strptime(row['deadline_time'], '%H:%M')
130
-      a.deadline    = DateTime.new(dd.year, dd.month, dd.day, dt.hour, dt.min)
130
+      a.deadline    = Time.zone.local(dd.year, dd.month, dd.day, dt.hour, dt.min)
131
 
131
 
132
       result << a
132
       result << a
133
     end
133
     end