Browse Source

Fix upcoming view to actually be future activities, hide if empty

Maarten van den Berg 7 years ago
parent
commit
23b877188e
2 changed files with 22 additions and 19 deletions
  1. 7 5
      app/controllers/groups_controller.rb
  2. 15 14
      app/views/dashboard/home.html.haml

+ 7 - 5
app/controllers/groups_controller.rb

@@ -19,11 +19,13 @@ class GroupsController < ApplicationController
19 19
   # GET /groups/1
20 20
   # GET /groups/1.json
21 21
   def show
22
-    @organized_activities = current_person.organized_activities.
23
-      joins(:activity).where(
24
-        'activities.group_id': @group.id
25
-    )
26
-    if @organized_activities.count > 0
22
+    @organized_activities = current_person
23
+      .organized_activities
24
+      .joins(:activity)
25
+      .where('activities.group_id': @group.id)
26
+      .where('start > ?', Date.today)
27
+
28
+    if @organized_activities.any?
27 29
       @groupmenu = 'col-md-6'
28 30
     else
29 31
       @groupmenu = 'col-md-12'

+ 15 - 14
app/views/dashboard/home.html.haml

@@ -90,21 +90,22 @@
90 90
                     = link_to group do
91 91
                       = group.name
92 92
 
93
-    .col-md-6
94
-      .panel.panel-default
95
-        .panel-heading
96
-          = t 'dashboard.organized_you'
93
+    - if @user_organized.any?
94
+      .col-md-6
95
+        .panel.panel-default
96
+          .panel-heading
97
+            = t 'dashboard.organized_you'
97 98
 
98
-        .panel-body
99
-          %table.table.table-striped.table-bordered
100
-            %tbody
101
-              - @user_organized.each do |p|
102
-                - a = p.activity
103
-                %tr
104
-                  %td
105
-                    = link_to group_activity_url(a.group, a) do
106
-                      = a.name
107
-                      = "(#{a.human_state_counts})"
99
+          .panel-body
100
+            %table.table.table-striped.table-bordered
101
+              %tbody
102
+                - @user_organized.each do |p|
103
+                  - a = p.activity
104
+                  %tr
105
+                    %td
106
+                      = link_to group_activity_url(a.group, a) do
107
+                        = a.name
108
+                        = "(#{a.human_state_counts})"
108 109
 
109 110
   .row
110 111
     .col-md-12