Skip to content

Commit b1375b5

Browse files
committed
added enable_public_submission to event_types model need to implement in views
1 parent 1a7adf8 commit b1375b5

10 files changed

+67
-37
lines changed

app/controllers/admin/event_types_controller.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ def destroy
5050

5151
def event_type_params
5252
params.require(:event_type).permit(:title, :length, :minimum_abstract_length, :maximum_abstract_length,
53-
:submission_template, :color, :conference_id, :description)
53+
:submission_template, :color, :conference_id, :description, :enable_public_submission)
5454
end
5555
end
5656
end

app/controllers/proposals_controller.rb

+6
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,12 @@ def new
3131
@url = conference_program_proposals_path(@conference.short_title)
3232
@languages = @program.languages_list
3333
@superevents = @program.super_events
34+
35+
if current_user.is_admin?
36+
@event_types = @program.event_types
37+
else
38+
@event_types = @program.event_types.available_for_public
39+
end
3440
end
3541

3642
def edit

app/helpers/event_types_helper.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ def event_type_select_options(event_types = {})
1515
{ data: {
1616
min_words: type.minimum_abstract_length,
1717
max_words: type.maximum_abstract_length,
18-
instructions: type.submission_template
18+
template: type.submission_template
1919
} }
2020
]
2121
end

app/models/event_type.rb

+18-11
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,18 @@
44
#
55
# Table name: event_types
66
#
7-
# id :bigint not null, primary key
8-
# color :string
9-
# description :string
10-
# length :integer default(30)
11-
# maximum_abstract_length :integer default(500)
12-
# minimum_abstract_length :integer default(0)
13-
# submission_template :text
14-
# title :string not null
15-
# created_at :datetime
16-
# updated_at :datetime
17-
# program_id :integer
7+
# id :bigint not null, primary key
8+
# color :string
9+
# description :string
10+
# enable_public_submission :boolean default(TRUE), not null
11+
# length :integer default(30)
12+
# maximum_abstract_length :integer default(500)
13+
# minimum_abstract_length :integer default(0)
14+
# submission_template :text
15+
# title :string not null
16+
# created_at :datetime
17+
# updated_at :datetime
18+
# program_id :integer
1819
#
1920
class EventType < ApplicationRecord
2021
belongs_to :program, touch: true
@@ -34,6 +35,8 @@ class EventType < ApplicationRecord
3435

3536
alias_attribute :name, :title
3637

38+
scope :available_for_public, -> { where(enable_public_submission: true) }
39+
3740
private
3841

3942
##
@@ -53,4 +56,8 @@ def capitalize_color
5356
def conference_id
5457
program.conference_id
5558
end
59+
60+
# def self.available_for_public_submission
61+
# is_admin? all : available_for_public
62+
# end
5663
end

app/views/admin/event_types/_form.html.haml

+5
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,11 @@
1515
= f.label :description
1616
= f.text_area :description, class: 'form-control', rows: 5, data: { provide: 'markdown' }
1717
.help-block= markdown_hint
18+
.form-group
19+
= f.label "Allow public submission?", for: :enable_public_submission
20+
= f.check_box :enable_public_submission, class: 'switch-checkbox'
21+
.help-block
22+
Do we need description for explanation?
1823
.form-group
1924
= f.label :minimum_abstract_length
2025
%abbr{title: 'This field is required'} *

app/views/admin/event_types/index.html.haml

+4-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@
1111
%tr
1212
%th Title
1313
%th Description
14-
%th Instructions
14+
%th Enable Public Submission
15+
%th Template
1516
%th Length
1617
%th Abstract Length
1718
%th Color
@@ -23,6 +24,8 @@
2324
= event_type.title
2425
%td
2526
= markdown(event_type.description)
27+
%td
28+
= event_type.enable_public_submission ? 'Yes' : 'No'
2629
%td
2730
= markdown(event_type.submission_template)
2831
%td
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
class AddEnablePublicSubmissionToEventTypes < ActiveRecord::Migration[7.0]
2+
def change
3+
add_column :event_types, :enable_public_submission, :boolean, default: true, null: false
4+
end
5+
end

db/schema.rb

+2-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
#
1111
# It's strongly recommended that you check this file into your version control system.
1212

13-
ActiveRecord::Schema[7.0].define(version: 2024_02_26_175634) do
13+
ActiveRecord::Schema[7.0].define(version: 2024_03_18_164346) do
1414
# These are extensions that must be enabled in order to support this database
1515
enable_extension "pg_stat_statements"
1616
enable_extension "plpgsql"
@@ -234,6 +234,7 @@
234234
t.datetime "created_at", precision: nil
235235
t.datetime "updated_at", precision: nil
236236
t.text "submission_template"
237+
t.boolean "enable_public_submission", default: true, null: false
237238
end
238239

239240
create_table "event_users", force: :cascade do |t|

spec/factories/event_types.rb

+13-11
Original file line numberDiff line numberDiff line change
@@ -4,24 +4,26 @@
44
#
55
# Table name: event_types
66
#
7-
# id :bigint not null, primary key
8-
# color :string
9-
# description :string
10-
# length :integer default(30)
11-
# maximum_abstract_length :integer default(500)
12-
# minimum_abstract_length :integer default(0)
13-
# submission_template :text
14-
# title :string not null
15-
# created_at :datetime
16-
# updated_at :datetime
17-
# program_id :integer
7+
# id :bigint not null, primary key
8+
# color :string
9+
# description :string
10+
# enable_public_submission :boolean default(TRUE), not null
11+
# length :integer default(30)
12+
# maximum_abstract_length :integer default(500)
13+
# minimum_abstract_length :integer default(0)
14+
# submission_template :text
15+
# title :string not null
16+
# created_at :datetime
17+
# updated_at :datetime
18+
# program_id :integer
1819
#
1920

2021
FactoryBot.define do
2122
factory :event_type do
2223
title { 'Example Event Type' }
2324
length { 30 }
2425
description { 'Example Event Description\nThis event type is an example.' }
26+
enable_public_submission { true }
2527
minimum_abstract_length { 0 }
2628
maximum_abstract_length { 500 }
2729
submission_template { 'Example Event Template _with_ **markdown**' }

spec/models/event_type_spec.rb

+12-11
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,18 @@
44
#
55
# Table name: event_types
66
#
7-
# id :bigint not null, primary key
8-
# color :string
9-
# description :string
10-
# length :integer default(30)
11-
# maximum_abstract_length :integer default(500)
12-
# minimum_abstract_length :integer default(0)
13-
# submission_template :text
14-
# title :string not null
15-
# created_at :datetime
16-
# updated_at :datetime
17-
# program_id :integer
7+
# id :bigint not null, primary key
8+
# color :string
9+
# description :string
10+
# enable_public_submission :boolean default(TRUE), not null
11+
# length :integer default(30)
12+
# maximum_abstract_length :integer default(500)
13+
# minimum_abstract_length :integer default(0)
14+
# submission_template :text
15+
# title :string not null
16+
# created_at :datetime
17+
# updated_at :datetime
18+
# program_id :integer
1819
#
1920
require 'spec_helper'
2021

0 commit comments

Comments
 (0)