Skip to content

Commit c3c4479

Browse files
authored
Merge pull request #338 from minnestar/mdecuir/participant-coc-cleanup
Participant required fields + CoC checkbox cleanup
2 parents 0c3fa12 + 0bece08 commit c3c4479

File tree

13 files changed

+55
-81
lines changed

13 files changed

+55
-81
lines changed

app/assets/stylesheets/formtastic.css

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ form.formtastic fieldset ol li ul.errors li { padding:0; border:none; display:li
8484
/* STRING & NUMERIC OVERRIDES
8585
--------------------------------------------------------------------------------------------------*/
8686
form.formtastic fieldset ol li.string input { width:74%; }
87+
form.formtastic fieldset ol li.email input { width: 74%; }
8788
form.formtastic fieldset ol li.password input { width:74%; }
8889
form.formtastic fieldset ol li.numeric input { width:74%; }
8990

app/controllers/admin/legacy/sessions_controller.rb

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,6 @@ def edit
1111
respond_with(@session)
1212
end
1313

14-
def new
15-
respond_with(@session)
16-
end
17-
1814
def update
1915
if @session.update(session_params)
2016
redirect_to admin_legacy_sessions_path
@@ -23,29 +19,6 @@ def update
2319
end
2420
end
2521

26-
def build_presenter
27-
name = params[:session].delete(:name)
28-
# find exact match by name
29-
Participant.where(name: name).first_or_initialize do |p|
30-
p.save(validate: false) if p.new_record?
31-
end
32-
end
33-
34-
def create
35-
@session.participant = build_presenter
36-
@session.attributes = session_params
37-
@session.event = Event.current_event
38-
@session.timeslot_id = params[:session][:timeslot_id]
39-
@session.room_id = params[:session][:room_id]
40-
41-
if @session.save
42-
flash[:notice] = "Presentation added"
43-
redirect_to admin_legacy_sessions_path
44-
else
45-
render :new
46-
end
47-
end
48-
4922
def destroy
5023
@session.destroy!
5124
flash[:notice] = "Session has been deleted"

app/controllers/participants_controller.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ def send_confirmation_email
7979

8080
def confirm_email
8181
@participant = Participant.find_using_perishable_token(params[:token])
82-
if @participant.update!(email_confirmed_at: Time.now)
82+
if @participant.update!(email_confirmed_at: Time.current)
8383
flash[:notice] = "Email confirmed. Thank you!"
8484
redirect_to root_path
8585
else

app/models/event.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ class Event < ActiveRecord::Base
44
has_many :rooms, dependent: :destroy
55

66
has_many :presenter_timeslot_restrictions, :through => :timeslots
7+
has_many :code_of_conduct_agreements, dependent: :destroy
78

89
# Careful! Large joins here; use with caution:
910
has_many :attendances, through: :sessions

app/models/participant.rb

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,12 @@ class Participant < ActiveRecord::Base
55
has_many :presentations
66
has_many :sessions_presenting, :through => :presentations, :source => :session
77
has_many :presenter_timeslot_restrictions, dependent: :destroy
8+
has_many :code_of_conduct_agreements, dependent: :destroy
89

9-
validates_presence_of :name
10-
validates_uniqueness_of :email, :case_sensitive => false, :allow_blank => true
10+
validates :name, presence: true
11+
validates :email, presence: true
12+
validates_uniqueness_of :email, :case_sensitive => false
13+
validates :password, presence: true, on: :create
1114
validate :bio_does_not_include_example_links
1215

1316
# used for formtastic form to allow sending a field related to a separate model

app/views/admin/legacy/sessions/index.html.erb

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
<% title('Admin: All sessions') %>
22

3-
<h2><%= link_to 'Add a session', new_admin_legacy_session_path %></h2>
4-
53
<div class="row">
64
<div class="column grid_6" style="margin-left:0px">
75
<ul class="sessionsList">

app/views/participants/new.html.erb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
<%=
1515
f.input :code_of_conduct_agreement,
1616
as: :boolean,
17+
required: true, # this only adds an asterisk to the label, it doesn't make the field required
1718
label: ("I agree to the #{link_to 'Code of Conduct', 'https://minnestar.org/code-of-conduct'} governing this event.").html_safe,
1819
input_html: {
1920
checked: @participant.signed_code_of_conduct_for_current_event?,

app/views/sessions/_form.html.erb

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,10 @@
1616
as: :boolean,
1717
required: true,
1818
label: ("I agree to the #{link_to 'Code of Conduct', 'https://minnestar.org/code-of-conduct'} governing this event.").html_safe,
19-
input_html: { checked: current_participant.signed_code_of_conduct_for_current_event? }
19+
input_html: {
20+
checked: current_participant.signed_code_of_conduct_for_current_event?,
21+
disabled: current_participant.signed_code_of_conduct_for_current_event?
22+
}
2023
%>
2124
<% end %>
2225

config/routes.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
get '/legacy', to: 'legacy/admin#show', as: :legacy
4646
namespace :legacy do
4747
resource :config, only: [:show, :create]
48-
resources :sessions
48+
resources :sessions, except: [:new, :create]
4949
resources :markdown_contents, path: 'markdown-contents'
5050
resources :events do
5151
resources :timeslots, only: [:index, :new, :create]
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
class AddNotNullConstraintsToParticipants < ActiveRecord::Migration[7.1]
2+
def change
3+
# update any existing NULL values, just in case
4+
Participant.where(email: nil).update_all(email: 'INVALID')
5+
Participant.where(crypted_password: nil).update_all(crypted_password: 'INVALID')
6+
7+
change_column_null :participants, :email, false
8+
change_column_null :participants, :crypted_password, false
9+
end
10+
11+
def down
12+
change_column_null :participants, :email, true
13+
change_column_null :participants, :crypted_password, true
14+
end
15+
end

0 commit comments

Comments
 (0)