Explorar el Código

Indentation fixes

Maarten van den Berg %!s(int64=6) %!d(string=hace) años
padre
commit
1416ddce17

+ 0 - 45
.rubocop.yml

@@ -22,27 +22,6 @@ Layout/AlignHash:
22 22
     - 'app/views/api/activities/show.rabl'
23 23
     - 'db/seeds.rb'
24 24
 
25
-# Offense count: 2
26
-# Cop supports --auto-correct.
27
-# Configuration parameters: EnforcedStyle, IndentationWidth.
28
-# SupportedStyles: special_inside_parentheses, consistent, align_braces
29
-Layout/IndentHash:
30
-  Exclude:
31
-    - 'config/environments/development.rb'
32
-    - 'config/environments/production.rb'
33
-
34
-# Offense count: 18
35
-# Cop supports --auto-correct.
36
-# Configuration parameters: Width, IgnoredPatterns.
37
-Layout/IndentationWidth:
38
-  Exclude:
39
-    - 'app/controllers/activities_controller.rb'
40
-    - 'app/controllers/api/people_controller.rb'
41
-    - 'app/controllers/groups_controller.rb'
42
-    - 'app/controllers/members_controller.rb'
43
-    - 'app/controllers/people_controller.rb'
44
-    - 'app/models/activity.rb'
45
-
46 25
 # Offense count: 1
47 26
 # Cop supports --auto-correct.
48 27
 Layout/LeadingCommentSpace:
@@ -55,30 +34,6 @@ Layout/MultilineBlockLayout:
55 34
   Exclude:
56 35
     - 'app/models/activity.rb'
57 36
 
58
-# Offense count: 75
59
-# Cop supports --auto-correct.
60
-# Configuration parameters: EnforcedStyle, IndentationWidth.
61
-# SupportedStyles: aligned, indented, indented_relative_to_receiver
62
-Layout/MultilineMethodCallIndentation:
63
-  Exclude:
64
-    - 'app/controllers/activities_controller.rb'
65
-    - 'app/controllers/dashboard_controller.rb'
66
-    - 'app/controllers/groups_controller.rb'
67
-    - 'app/controllers/members_controller.rb'
68
-    - 'app/mailers/participant_mailer.rb'
69
-    - 'app/models/activity.rb'
70
-    - 'app/models/person.rb'
71
-
72
-# Offense count: 7
73
-# Cop supports --auto-correct.
74
-# Configuration parameters: EnforcedStyle, IndentationWidth.
75
-# SupportedStyles: aligned, indented
76
-Layout/MultilineOperationIndentation:
77
-  Exclude:
78
-    - 'app/helpers/authentication_helper.rb'
79
-    - 'app/models/activity.rb'
80
-    - 'app/models/participant.rb'
81
-
82 37
 # Offense count: 2
83 38
 # Cop supports --auto-correct.
84 39
 # Configuration parameters: EnforcedStyle.

+ 24 - 24
app/controllers/activities_controller.rb

@@ -26,14 +26,14 @@ class ActivitiesController < ApplicationController
26 26
   def index
27 27
     if params[:past]
28 28
       @activities = @group.activities
29
-        .where('start < ?', Time.now)
30
-        .order(start: :desc)
31
-        .paginate(page: params[:page], per_page: 25)
29
+                          .where('start < ?', Time.now)
30
+                          .order(start: :desc)
31
+                          .paginate(page: params[:page], per_page: 25)
32 32
     else
33 33
       @activities = @group.activities
34
-        .where('start > ?', Time.now)
35
-        .order(start: :asc)
36
-        .paginate(page: params[:page], per_page: 25)
34
+                          .where('start > ?', Time.now)
35
+                          .order(start: :asc)
36
+                          .paginate(page: params[:page], per_page: 25)
37 37
     end
38 38
   end
39 39
 
@@ -41,26 +41,26 @@ class ActivitiesController < ApplicationController
41 41
   # GET /activities/1.json
42 42
   def show
43 43
     @participants = @activity.participants
44
-      .joins(:person)
45
-      .order(attending: :desc)
46
-      .order('people.first_name ASC')
44
+                             .joins(:person)
45
+                             .order(attending: :desc)
46
+                             .order('people.first_name ASC')
47 47
     @organizers = @activity.participants
48
-      .joins(:person)
49
-      .where(is_organizer: true)
50
-      .order('people.first_name ASC')
51
-      .map{|p| p.person.full_name}
52
-      .join(', ')
48
+                           .joins(:person)
49
+                           .where(is_organizer: true)
50
+                           .order('people.first_name ASC')
51
+                           .map{|p| p.person.full_name}
52
+                           .join(', ')
53 53
     @ownparticipant = @activity.participants
54
-      .find_by(person: current_person)
54
+                               .find_by(person: current_person)
55 55
     @counts = @activity.state_counts
56 56
     @num_participants = @counts.values.sum
57 57
     @assignable_subgroups = @activity.subgroups
58
-      .where(is_assignable: true)
59
-      .order(name: :asc)
60
-      .pluck(:name)
58
+                                     .where(is_assignable: true)
59
+                                     .order(name: :asc)
60
+                                     .pluck(:name)
61 61
     @subgroup_ids = @activity.subgroups
62
-      .order(name: :asc)
63
-      .pluck(:name, :id)
62
+                             .order(name: :asc)
63
+                             .pluck(:name, :id)
64 64
     @subgroup_ids.prepend( [I18n.t('activities.subgroups.filter_nofilter'), 'all'] )
65 65
     @subgroup_ids.append( [I18n.t('activities.subgroups.filter_nogroup'), 'withoutgroup'] )
66 66
   end
@@ -88,10 +88,10 @@ class ActivitiesController < ApplicationController
88 88
     @subgroup_options.prepend(['--', 'nil'])
89 89
 
90 90
     @participants = @activity.participants
91
-      .joins(:person)
92
-      .where.not(attending: false)
93
-      .order(:subgroup_id)
94
-      .order('people.first_name', 'people.last_name')
91
+                             .joins(:person)
92
+                             .where.not(attending: false)
93
+                             .order(:subgroup_id)
94
+                             .order('people.first_name', 'people.last_name')
95 95
   end
96 96
 
97 97
   # POST /activities/1/update_subgroups

+ 9 - 9
app/controllers/dashboard_controller.rb

@@ -3,18 +3,18 @@ class DashboardController < ApplicationController
3 3
 
4 4
   def home
5 5
     @upcoming = current_person
6
-      .participants
7
-      .joins(:activity)
8
-      .where('activities.end >= ? OR (activities.end IS NULL AND activities.start >= ?)', DateTime.now, DateTime.now)
9
-      .order('activities.start ASC')
6
+                .participants
7
+                .joins(:activity)
8
+                .where('activities.end >= ? OR (activities.end IS NULL AND activities.start >= ?)', DateTime.now, DateTime.now)
9
+                .order('activities.start ASC')
10 10
     @user_organized = @upcoming
11
-      .where(is_organizer: true)
12
-      .limit(3)
11
+                      .where(is_organizer: true)
12
+                      .limit(3)
13 13
     @upcoming = @upcoming
14
-      .paginate(page: params[:upage], per_page: 10)
14
+                .paginate(page: params[:upage], per_page: 10)
15 15
     @need_response = @upcoming
16
-      .where(attending: nil)
17
-      .paginate(page: params[:nrpage], per_page: 5)
16
+                     .where(attending: nil)
17
+                     .paginate(page: params[:nrpage], per_page: 5)
18 18
   end
19 19
 
20 20
   def set_settings_params!

+ 10 - 10
app/controllers/groups_controller.rb

@@ -22,10 +22,10 @@ class GroupsController < ApplicationController
22 22
   # GET /groups/1.json
23 23
   def show
24 24
     @organized_activities = current_person
25
-      .organized_activities
26
-      .joins(:activity)
27
-      .where('activities.group_id': @group.id)
28
-      .where('start > ?', Date.today)
25
+                            .organized_activities
26
+                            .joins(:activity)
27
+                            .where('activities.group_id': @group.id)
28
+                            .where('start > ?', Date.today)
29 29
 
30 30
     if @organized_activities.any?
31 31
       @groupmenu = 'col-md-6'
@@ -34,13 +34,13 @@ class GroupsController < ApplicationController
34 34
     end
35 35
 
36 36
     @upcoming = @group.activities
37
-      .where('start > ?', Date.today)
38
-      .order('start ASC')
37
+                      .where('start > ?', Date.today)
38
+                      .order('start ASC')
39 39
     @upcoming_ps = Participant
40
-      .where(person: current_person)
41
-      .where(activity: @upcoming)
42
-      .map{ |p| [p.activity_id, p]}
43
-      .to_h
40
+                   .where(person: current_person)
41
+                   .where(activity: @upcoming)
42
+                   .map{ |p| [p.activity_id, p]}
43
+                   .to_h
44 44
   end
45 45
 
46 46
   # GET /groups/new

+ 2 - 2
app/controllers/members_controller.rb

@@ -9,8 +9,8 @@ class MembersController < ApplicationController
9 9
   def index
10 10
     @admin = @group.is_leader?(current_person)
11 11
     @members = @group.members
12
-      .joins(:person)
13
-      .order('members.is_leader DESC, people.first_name ASC')
12
+                     .joins(:person)
13
+                     .order('members.is_leader DESC, people.first_name ASC')
14 14
   end
15 15
 
16 16
   # GET /members/1

+ 2 - 2
app/helpers/authentication_helper.rb

@@ -70,7 +70,7 @@ module AuthenticationHelper
70 70
       # Case 2: User is returning and has a remember token saved.
71 71
       # We get the Session, check the token and expiry, and log the user in.
72 72
       if cookies.signed.permanent[:remember_token] && cookies.signed.permanent[:user_id] &&
73
-          cookies.signed.permanent[:session_id]
73
+         cookies.signed.permanent[:session_id]
74 74
 
75 75
         get_user_session
76 76
 
@@ -81,7 +81,7 @@ module AuthenticationHelper
81 81
         session_password = BCrypt::Password.new @user_session.remember_digest
82 82
 
83 83
         if @user_session.expires > DateTime.now &&
84
-            session_password == cookies.signed.permanent[:remember_token]
84
+           session_password == cookies.signed.permanent[:remember_token]
85 85
           log_in @user_session.user, false, false
86 86
           return true
87 87
         end

+ 11 - 11
app/mailers/participant_mailer.rb

@@ -21,21 +21,21 @@ class ParticipantMailer < ApplicationMailer
21 21
     @subgroup = participant.subgroup.name
22 22
 
23 23
     @others = participant
24
-      .subgroup
25
-      .participants
26
-      .where.not(person: @person)
27
-      .map { |pp| pp.person.full_name }
28
-      .sort
29
-      .join(', ')
24
+              .subgroup
25
+              .participants
26
+              .where.not(person: @person)
27
+              .map { |pp| pp.person.full_name }
28
+              .sort
29
+              .join(', ')
30 30
 
31 31
     @subgroups = @activity
32
-      .subgroups
33
-      .order(name: :asc)
32
+                 .subgroups
33
+                 .order(name: :asc)
34 34
 
35 35
     @organizers = @activity
36
-      .organizer_names
37
-      .sort
38
-      .join(', ')
36
+                  .organizer_names
37
+                  .sort
38
+                  .join(', ')
39 39
 
40 40
     subject = I18n.t('activities.emails.subgroup_notification.subject', subgroup: @subgroup, activity: @activity.name)
41 41
 

+ 20 - 20
app/models/activity.rb

@@ -79,8 +79,8 @@ class Activity < ApplicationRecord
79 79
   after_commit :schedule_subgroup_division,
80 80
                if: Proc.new { |a| (a.previous_changes['deadline'] ||
81 81
                                    a.previous_changes['subgroup_division_enabled']) &&
82
-                                  !a.subgroup_division_done &&
83
-                                  a.subgroup_division_enabled
82
+                 !a.subgroup_division_done &&
83
+                 a.subgroup_division_enabled
84 84
                    }
85 85
 
86 86
   # Get all people (not participants) that are organizers. Does not include
@@ -127,8 +127,8 @@ class Activity < ApplicationRecord
127 127
   # Determine whether the passed Person may change this activity.
128 128
   def may_change?(person)
129 129
     person.is_admin ||
130
-    self.is_organizer?(person) ||
131
-    self.group.is_leader?(person)
130
+      self.is_organizer?(person) ||
131
+      self.group.is_leader?(person)
132 132
   end
133 133
 
134 134
   # Create Participants for all People that
@@ -244,19 +244,19 @@ class Activity < ApplicationRecord
244 244
 
245 245
     # Get participants in random order
246 246
     ps = self
247
-      .participants
248
-      .where(attending: true)
249
-      .where(subgroup: nil)
250
-      .to_a
247
+         .participants
248
+         .where(attending: true)
249
+         .where(subgroup: nil)
250
+         .to_a
251 251
 
252 252
     ps.shuffle!
253 253
 
254 254
     # Get groups, link to participant count
255 255
     groups = self
256
-      .subgroups
257
-      .where(is_assignable: true)
258
-      .to_a
259
-      .map { |sg| [sg.participants.count, sg] }
256
+             .subgroups
257
+             .where(is_assignable: true)
258
+             .to_a
259
+             .map { |sg| [sg.participants.count, sg] }
260 260
 
261 261
     ps.each do |p|
262 262
       # Sort groups so the group with the least participants gets the following participant
@@ -277,16 +277,16 @@ class Activity < ApplicationRecord
277 277
 
278 278
   def clear_subgroups!(only_assignable = true)
279 279
     sgs = self
280
-      .subgroups
280
+          .subgroups
281 281
 
282 282
     if only_assignable
283
-    sgs = sgs
284
-      .where(is_assignable: true)
283
+      sgs = sgs
284
+            .where(is_assignable: true)
285 285
     end
286 286
 
287 287
     ps = self
288
-      .participants
289
-      .where(subgroup: sgs)
288
+         .participants
289
+         .where(subgroup: sgs)
290 290
 
291 291
     ps.each do |p|
292 292
       p.subgroup = nil
@@ -297,9 +297,9 @@ class Activity < ApplicationRecord
297 297
   # Notify participants of the current subgroups, if any.
298 298
   def notify_subgroups!
299 299
     ps = self
300
-      .participants
301
-      .joins(:person)
302
-      .where.not(subgroup: nil)
300
+         .participants
301
+         .joins(:person)
302
+         .where.not(subgroup: nil)
303 303
 
304 304
     ps.each do |pp|
305 305
       pp.send_subgroup_notification

+ 1 - 1
app/models/participant.rb

@@ -66,7 +66,7 @@ class Participant < ApplicationRecord
66 66
 
67 67
   def may_change?(person)
68 68
     self.activity.may_change?(person) ||
69
-    self.person == person
69
+      self.person == person
70 70
   end
71 71
 
72 72
   # Set attending to true if nil, and notify the Person via email.

+ 4 - 4
app/models/person.rb

@@ -112,13 +112,13 @@ class Person < ApplicationRecord
112 112
     tzid = 1.seconds.since.time_zone.tzinfo.name
113 113
 
114 114
     selection = self
115
-      .participants
116
-      .joins(:activity)
117
-      .where('"end" > ?', 3.months.ago)
115
+                .participants
116
+                .joins(:activity)
117
+                .where('"end" > ?', 3.months.ago)
118 118
 
119 119
     if skip_absent
120 120
       selection = selection
121
-        .where.not(attending: false)
121
+                  .where.not(attending: false)
122 122
     end
123 123
 
124 124
     selection.each do |p|

+ 2 - 2
config/environments/development.rb

@@ -60,7 +60,7 @@ Rails.application.configure do
60 60
     authentication: :plain
61 61
   }
62 62
   config.action_mailer.mailgun_settings = {
63
-        api_key: ENV['MAILGUN_API_KEY'],
64
-        domain: ENV['MAILGUN_DOMAIN']
63
+    api_key: ENV['MAILGUN_API_KEY'],
64
+    domain: ENV['MAILGUN_DOMAIN']
65 65
   }
66 66
 end

+ 2 - 2
config/environments/production.rb

@@ -92,7 +92,7 @@ Rails.application.configure do
92 92
     authentication: :plain
93 93
   }
94 94
   config.action_mailer.mailgun_settings = {
95
-        api_key: ENV['MAILGUN_API_KEY'],
96
-        domain: ENV['MAILGUN_DOMAIN']
95
+    api_key: ENV['MAILGUN_API_KEY'],
96
+    domain: ENV['MAILGUN_DOMAIN']
97 97
   }
98 98
 end