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,7 +8,10 @@ class ActivitiesController < ApplicationController
8 8
   # GET /groups/:id/activities
9 9
   # GET /activities.json
10 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 15
   end
13 16
 
14 17
   # GET /activities/1

+ 3 - 3
app/models/activity.rb

@@ -117,17 +117,17 @@ class Activity < ApplicationRecord
117 117
 
118 118
       sd            = Date.strptime(row['start_date'])
119 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 122
       if not row['end_date'].blank?
123 123
         ed          = Date.strptime(row['end_date'])
124 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 126
       end
127 127
 
128 128
       dd            = Date.strptime(row['deadline_date'])
129 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 132
       result << a
133 133
     end