Browse Source

Indentation fixes

Maarten van den Berg 6 years ago
parent
commit
1416ddce17

+ 0 - 45
.rubocop.yml

22
     - 'app/views/api/activities/show.rabl'
22
     - 'app/views/api/activities/show.rabl'
23
     - 'db/seeds.rb'
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
 # Offense count: 1
25
 # Offense count: 1
47
 # Cop supports --auto-correct.
26
 # Cop supports --auto-correct.
48
 Layout/LeadingCommentSpace:
27
 Layout/LeadingCommentSpace:
55
   Exclude:
34
   Exclude:
56
     - 'app/models/activity.rb'
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
 # Offense count: 2
37
 # Offense count: 2
83
 # Cop supports --auto-correct.
38
 # Cop supports --auto-correct.
84
 # Configuration parameters: EnforcedStyle.
39
 # Configuration parameters: EnforcedStyle.

+ 24 - 24
app/controllers/activities_controller.rb

26
   def index
26
   def index
27
     if params[:past]
27
     if params[:past]
28
       @activities = @group.activities
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
     else
32
     else
33
       @activities = @group.activities
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
     end
37
     end
38
   end
38
   end
39
 
39
 
41
   # GET /activities/1.json
41
   # GET /activities/1.json
42
   def show
42
   def show
43
     @participants = @activity.participants
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
     @organizers = @activity.participants
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
     @ownparticipant = @activity.participants
53
     @ownparticipant = @activity.participants
54
-      .find_by(person: current_person)
54
+                               .find_by(person: current_person)
55
     @counts = @activity.state_counts
55
     @counts = @activity.state_counts
56
     @num_participants = @counts.values.sum
56
     @num_participants = @counts.values.sum
57
     @assignable_subgroups = @activity.subgroups
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
     @subgroup_ids = @activity.subgroups
61
     @subgroup_ids = @activity.subgroups
62
-      .order(name: :asc)
63
-      .pluck(:name, :id)
62
+                             .order(name: :asc)
63
+                             .pluck(:name, :id)
64
     @subgroup_ids.prepend( [I18n.t('activities.subgroups.filter_nofilter'), 'all'] )
64
     @subgroup_ids.prepend( [I18n.t('activities.subgroups.filter_nofilter'), 'all'] )
65
     @subgroup_ids.append( [I18n.t('activities.subgroups.filter_nogroup'), 'withoutgroup'] )
65
     @subgroup_ids.append( [I18n.t('activities.subgroups.filter_nogroup'), 'withoutgroup'] )
66
   end
66
   end
88
     @subgroup_options.prepend(['--', 'nil'])
88
     @subgroup_options.prepend(['--', 'nil'])
89
 
89
 
90
     @participants = @activity.participants
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
   end
95
   end
96
 
96
 
97
   # POST /activities/1/update_subgroups
97
   # POST /activities/1/update_subgroups

+ 9 - 9
app/controllers/dashboard_controller.rb

3
 
3
 
4
   def home
4
   def home
5
     @upcoming = current_person
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
     @user_organized = @upcoming
10
     @user_organized = @upcoming
11
-      .where(is_organizer: true)
12
-      .limit(3)
11
+                      .where(is_organizer: true)
12
+                      .limit(3)
13
     @upcoming = @upcoming
13
     @upcoming = @upcoming
14
-      .paginate(page: params[:upage], per_page: 10)
14
+                .paginate(page: params[:upage], per_page: 10)
15
     @need_response = @upcoming
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
   end
18
   end
19
 
19
 
20
   def set_settings_params!
20
   def set_settings_params!

+ 10 - 10
app/controllers/groups_controller.rb

22
   # GET /groups/1.json
22
   # GET /groups/1.json
23
   def show
23
   def show
24
     @organized_activities = current_person
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
     if @organized_activities.any?
30
     if @organized_activities.any?
31
       @groupmenu = 'col-md-6'
31
       @groupmenu = 'col-md-6'
34
     end
34
     end
35
 
35
 
36
     @upcoming = @group.activities
36
     @upcoming = @group.activities
37
-      .where('start > ?', Date.today)
38
-      .order('start ASC')
37
+                      .where('start > ?', Date.today)
38
+                      .order('start ASC')
39
     @upcoming_ps = Participant
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
   end
44
   end
45
 
45
 
46
   # GET /groups/new
46
   # GET /groups/new

+ 2 - 2
app/controllers/members_controller.rb

9
   def index
9
   def index
10
     @admin = @group.is_leader?(current_person)
10
     @admin = @group.is_leader?(current_person)
11
     @members = @group.members
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
   end
14
   end
15
 
15
 
16
   # GET /members/1
16
   # GET /members/1

+ 2 - 2
app/helpers/authentication_helper.rb

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

+ 11 - 11
app/mailers/participant_mailer.rb

21
     @subgroup = participant.subgroup.name
21
     @subgroup = participant.subgroup.name
22
 
22
 
23
     @others = participant
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
     @subgroups = @activity
31
     @subgroups = @activity
32
-      .subgroups
33
-      .order(name: :asc)
32
+                 .subgroups
33
+                 .order(name: :asc)
34
 
34
 
35
     @organizers = @activity
35
     @organizers = @activity
36
-      .organizer_names
37
-      .sort
38
-      .join(', ')
36
+                  .organizer_names
37
+                  .sort
38
+                  .join(', ')
39
 
39
 
40
     subject = I18n.t('activities.emails.subgroup_notification.subject', subgroup: @subgroup, activity: @activity.name)
40
     subject = I18n.t('activities.emails.subgroup_notification.subject', subgroup: @subgroup, activity: @activity.name)
41
 
41
 

+ 20 - 20
app/models/activity.rb

79
   after_commit :schedule_subgroup_division,
79
   after_commit :schedule_subgroup_division,
80
                if: Proc.new { |a| (a.previous_changes['deadline'] ||
80
                if: Proc.new { |a| (a.previous_changes['deadline'] ||
81
                                    a.previous_changes['subgroup_division_enabled']) &&
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
   # Get all people (not participants) that are organizers. Does not include
86
   # Get all people (not participants) that are organizers. Does not include
127
   # Determine whether the passed Person may change this activity.
127
   # Determine whether the passed Person may change this activity.
128
   def may_change?(person)
128
   def may_change?(person)
129
     person.is_admin ||
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
   end
132
   end
133
 
133
 
134
   # Create Participants for all People that
134
   # Create Participants for all People that
244
 
244
 
245
     # Get participants in random order
245
     # Get participants in random order
246
     ps = self
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
     ps.shuffle!
252
     ps.shuffle!
253
 
253
 
254
     # Get groups, link to participant count
254
     # Get groups, link to participant count
255
     groups = self
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
     ps.each do |p|
261
     ps.each do |p|
262
       # Sort groups so the group with the least participants gets the following participant
262
       # Sort groups so the group with the least participants gets the following participant
277
 
277
 
278
   def clear_subgroups!(only_assignable = true)
278
   def clear_subgroups!(only_assignable = true)
279
     sgs = self
279
     sgs = self
280
-      .subgroups
280
+          .subgroups
281
 
281
 
282
     if only_assignable
282
     if only_assignable
283
-    sgs = sgs
284
-      .where(is_assignable: true)
283
+      sgs = sgs
284
+            .where(is_assignable: true)
285
     end
285
     end
286
 
286
 
287
     ps = self
287
     ps = self
288
-      .participants
289
-      .where(subgroup: sgs)
288
+         .participants
289
+         .where(subgroup: sgs)
290
 
290
 
291
     ps.each do |p|
291
     ps.each do |p|
292
       p.subgroup = nil
292
       p.subgroup = nil
297
   # Notify participants of the current subgroups, if any.
297
   # Notify participants of the current subgroups, if any.
298
   def notify_subgroups!
298
   def notify_subgroups!
299
     ps = self
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
     ps.each do |pp|
304
     ps.each do |pp|
305
       pp.send_subgroup_notification
305
       pp.send_subgroup_notification

+ 1 - 1
app/models/participant.rb

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

+ 4 - 4
app/models/person.rb

112
     tzid = 1.seconds.since.time_zone.tzinfo.name
112
     tzid = 1.seconds.since.time_zone.tzinfo.name
113
 
113
 
114
     selection = self
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
     if skip_absent
119
     if skip_absent
120
       selection = selection
120
       selection = selection
121
-        .where.not(attending: false)
121
+                  .where.not(attending: false)
122
     end
122
     end
123
 
123
 
124
     selection.each do |p|
124
     selection.each do |p|

+ 2 - 2
config/environments/development.rb

60
     authentication: :plain
60
     authentication: :plain
61
   }
61
   }
62
   config.action_mailer.mailgun_settings = {
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
 end
66
 end

+ 2 - 2
config/environments/production.rb

92
     authentication: :plain
92
     authentication: :plain
93
   }
93
   }
94
   config.action_mailer.mailgun_settings = {
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
 end
98
 end