Created
August 22, 2017 17:59
-
-
Save klyonrad/60aaa46c1f0bf5bbf330e20fe6a1b449 to your computer and use it in GitHub Desktop.
frab event classifier form
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
= simple_form_for(@event, html: {multipart: true}) do |f| | |
%fieldset.inputs | |
%legend Basic information | |
= f.input :title | |
= f.input :subtitle | |
- @event.build_ticket unless @event.ticket | |
= f.simple_fields_for :ticket do |ticket| | |
= ticket.input :remote_ticket_id | |
= f.input :event_type, collection: Event::TYPES | |
= f.association :track, collection: @conference.tracks | |
= f.input :time_slots, as: :select, collection: timeslots | |
= f.input :language, as: :language_select, only: @conference.language_codes | |
= f.input :public, as: :inline_boolean, hint: "Is this event visible in the public schedule?" | |
= image_input_box(f.object.logo) | |
= f.input :logo | |
%fieldset.inputs | |
%legend State | |
= f.input :state, collection: Event.state_machine.states.map { |st| [st.display_name, st.name.to_s] } | |
%fieldset.inputs | |
%legend Time and place | |
= f.input :start_time do | |
= f.select :start_time, grouped_options_for_select(@start_time_options, @event.start_time), { include_blank: true } | |
= f.association :room, collection: @conference.rooms | |
%fieldset.inputs | |
%legend Detailed description | |
-# render 'event_classifiers', f: classifier_form | |
-# TODO: these simple fields do not show up when no associated event_classifier exists yet | |
= f.simple_fields_for :event_classifiers do |classifier_form| | |
= classifier_form.association :classifier, collection: @event.conference.classifiers | |
= classifier_form.input :value | |
= f.input :abstract, input_html: {rows: 4}, hint: "One short paragraph that succinctly describes the event. (HTML)" | |
= f.input :description,input_html: {rows: 4}, hint: "A longer description of the event. Use this to give additional details that did not fit in the abstract. Both, abstract and description, will be shown on the conference website. (HTML)" | |
%fieldset.inputs | |
%legend Notes | |
= f.input :note, input_html: {rows: 2}, hint: "visibility: admin only." | |
= f.input :submission_note, input_html: {rows: 2}, hint: "visibiliy: admin and user; additional information." | |
%fieldset.inputs | |
%legend Additional Resources | |
= f.input :do_not_record, as: :inline_boolean, hint: "Will this event be recorded?" | |
= f.input :tech_rider, input_html: {rows: 2}, hint: "What is needed for this event?" | |
= f.input :recording_license, hint: "Recording license for this talk" | |
= dynamic_association :links, "Links", f | |
= dynamic_association :event_attachments, "Uploaded files", f | |
.actions | |
= f.button :submit, class: 'primary' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# frozen_string_literal: true | |
class Event < ApplicationRecord | |
include ActionView::Helpers::TextHelper | |
include EventState | |
include HasEventConflicts | |
before_create :generate_guid | |
TYPES = %i(lecture workshop podium lightning_talk meeting film concert djset performance other).freeze | |
ACCEPTED = %w(accepting unconfirmed confirmed scheduled).freeze | |
has_one :ticket, as: :object, dependent: :destroy | |
has_many :event_attachments, dependent: :destroy | |
has_many :event_feedbacks, dependent: :destroy | |
has_many :event_people, dependent: :destroy | |
has_many :event_ratings, dependent: :destroy | |
has_many :event_classifiers, dependent: :destroy | |
has_many :links, as: :linkable, dependent: :destroy | |
has_many :people, through: :event_people | |
has_many :videos, dependent: :destroy | |
belongs_to :conference | |
belongs_to :track, optional: true | |
belongs_to :room, optional: true | |
has_attached_file :logo, | |
styles: { tiny: '16x16>', small: '32x32>', large: '128x128>' }, | |
default_url: 'event_:style.png' | |
accepts_nested_attributes_for :event_people, allow_destroy: true, reject_if: proc { |attr| attr[:person_id].blank? } | |
accepts_nested_attributes_for :links, allow_destroy: true, reject_if: :all_blank | |
accepts_nested_attributes_for :event_attachments, allow_destroy: true, reject_if: :all_blank | |
accepts_nested_attributes_for :ticket, allow_destroy: true, reject_if: :all_blank | |
accepts_nested_attributes_for :event_classifiers, allow_destroy: true | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class EventClassifier < ActiveRecord::Base | |
belongs_to :classifier | |
belongs_to :event, inverse_of: :event_classifiers | |
validates :value, presence: true | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def event_params | |
params.require(:event).permit( | |
:id, :title, :subtitle, :event_type, :time_slots, :state, :start_time, :public, :language, :abstract, :description, :logo, :track_id, :room_id, :note, :submission_note, :do_not_record, :recording_license, :tech_rider, | |
event_attachments_attributes: %i(id title attachment public _destroy), | |
ticket_attributes: %i(id remote_ticket_id), | |
links_attributes: %i(id title url _destroy), | |
event_classifiers_attributes: %i(id classifier_id value _destroy), | |
event_people_attributes: %i(id person_id event_role role_state notification_subject notification_body _destroy) | |
) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment