tramway-event 0.4.1 → 0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8e33326369ab761aa21580c75842ac5007ab3b49054581dfdeb7d8cfa2240e8f
4
- data.tar.gz: 392bba36179f07f272ea7df083277faf7235b88c1389bbf50876c546f9de4feb
3
+ metadata.gz: 30a66f92c1d8f181b1620aa1a024178e479066e2dd015ab9994809ebeaca04f8
4
+ data.tar.gz: e1b97b81a35c3f3ce092f6e5a7ee2280637463947506d789a683e03e78916c6b
5
5
  SHA512:
6
- metadata.gz: 76635da6d5f2ff0e5211e52f679178cb6179320d5e9a0531d8a4bd5554eb6db43b524922cd9ecb833dd38e1f3b0962c8499617a6c1c2f1b7af300a499dde2678
7
- data.tar.gz: a06d71b328e1c734050fcc9eaf054bfdff394f231171bca8fd3101e45d38564bb73db83ba60d126e75c5a67ed8eca405929c656df81dd237b2559145b4f71208
6
+ metadata.gz: 92b4b9d04b5bebd1f748caca9e94a7760bd41774cd79163d80ed1fe94f9f7084dfa223354b0375b66cb814b500d7ccdb961071daa186bdf41f704acb14f28d61
7
+ data.tar.gz: b11ca2ea6fdb17a8f5f7bd8e3c7b52bf04ee2a9cad08f6091fc62c26b5a05f399affc6a3912dd535bd3feeb01d35f3b135bf8ee0c53bec58a276e954cce3d6b3
@@ -3,5 +3,7 @@ class Tramway::Event::EventsController < Tramway::Event::ApplicationController
3
3
 
4
4
  def show
5
5
  @event = ::Tramway::Event::EventDecorator.decorate ::Tramway::Event::Event.find params[:id]
6
+ form_class = ::Tramway::Core::ExtendableForm.new "ParticipantExtendedForm#{request.uuid.gsub('-', '')}", *@event.participant_form_fields.map(&:title).map(&:to_sym)
7
+ @participant_form = form_class.new ::Tramway::Event::Participant.new
6
8
  end
7
9
  end
@@ -6,6 +6,7 @@ class Tramway::Event::EventDecorator < ::Tramway::Core::ApplicationDecorator
6
6
  end
7
7
 
8
8
  delegate :title, to: :object
9
+ delegate :participant_form_fields, to: :object
9
10
 
10
11
  def background
11
12
  object.photo
@@ -0,0 +1,7 @@
1
+ class Tramway::Event::ParticipantDecorator < ::Tramway::Core::ApplicationDecorator
2
+ class << self
3
+ def collections
4
+ [ :all ]
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,7 @@
1
+ class Tramway::Event::ParticipantFormFieldDecorator < ::Tramway::Core::ApplicationDecorator
2
+ class << self
3
+ def collections
4
+ [ :all ]
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,9 @@
1
+ class Tramway::Event::ParticipantForm < ::Tramway::Core::ApplicationForm
2
+ properties :event_id, :values
3
+
4
+ def initialize(object, event)
5
+ form_object = super object
6
+ form_properties event_id: :default
7
+ form_object
8
+ end
9
+ end
@@ -0,0 +1,16 @@
1
+ class Tramway::Event::ParticipantFormFieldForm < ::Tramway::Core::ApplicationForm
2
+ properties :title, :description, :field_type, :event
3
+
4
+ def initialize(object)
5
+ form_object = super object
6
+ form_properties event: :association,
7
+ title: :string,
8
+ description: :string,
9
+ field_type: :default
10
+ form_object
11
+ end
12
+
13
+ def event=(value)
14
+ super ::Tramway::Event::Event.find value
15
+ end
16
+ end
@@ -1,3 +1,6 @@
1
1
  class Tramway::Event::Event < ::Tramway::Event::ApplicationRecord
2
2
  mount_uploader :photo, PhotoUploader
3
+
4
+ has_many :participants, class_name: 'Tramway::Event::Participant'
5
+ has_many :participant_form_fields, class_name: 'Tramway::Event::ParticipantFormField'
3
6
  end
@@ -0,0 +1,3 @@
1
+ class Tramway::Event::Participant < ::Tramway::Event::ApplicationRecord
2
+ belongs_to :event, class_name: 'Tramway::Event::Event'
3
+ end
@@ -0,0 +1,5 @@
1
+ class Tramway::Event::ParticipantFormField < ::Tramway::Event::ApplicationRecord
2
+ belongs_to :event, class_name: 'Tramway::Event::Event'
3
+
4
+ enumerize :field_type, in: [ :text, :numeric ], default: :text
5
+ end
@@ -3,3 +3,5 @@
3
3
  - content_for :body_content do
4
4
  = stylesheet_link_tag 'tramway/event/events/show'
5
5
  = render 'tramway/landing/blocks/templates/full_page', block: @event, buttons: []
6
+ .container
7
+ = render 'tramway/event/participants/form'
@@ -0,0 +1,5 @@
1
+ .row
2
+ .col-lg-12
3
+ = simple_form_for @participant_form, url: { controller: 'tramway/event/participants', action: :create } do |f|
4
+ - @event.participant_form_fields.each do |field|
5
+ = f.input field.title.to_sym
@@ -1 +1,4 @@
1
- ::Tramway::Admin.set_available_models(::Tramway::Event::Event, project: :event)
1
+ ::Tramway::Admin.set_available_models(::Tramway::Event::Event,
2
+ ::Tramway::Event::ParticipantFormField,
3
+ ::Tramway::Event::Participant,
4
+ project: :event)
@@ -2,6 +2,8 @@ ru:
2
2
  activerecord:
3
3
  models:
4
4
  tramway/event/event: Мероприятие
5
+ tramway/event/participant: Участник
6
+ tramway/event/participant_form_field: Поле анкеты
5
7
  attributes:
6
8
  tramway/event/event:
7
9
  title: Название
@@ -12,3 +14,9 @@ ru:
12
14
  tramway/event/event:
13
15
  plural: мероприятия
14
16
  genitive: мероприятие
17
+ tramway/event/participant:
18
+ plural: участники
19
+ genitive: участника
20
+ tramway/event/participant_form_field:
21
+ plural: поля анкеты
22
+ genitive: поле анкеты
data/config/routes.rb CHANGED
@@ -1,3 +1,4 @@
1
1
  Tramway::Event::Engine.routes.draw do
2
2
  resources :events, only: :show
3
+ resources :participants, only: :create
3
4
  end
@@ -17,6 +17,8 @@ module Tramway::Event::Generators
17
17
  def copy_migrations
18
18
  migration_template 'create_tramway_event_events.rb', 'db/migrate/create_tramway_event_events.rb'
19
19
  migration_template 'add_photo_to_tramway_event_events.rb', 'db/migrate/add_photo_to_tramway_event_events.rb'
20
+ migration_template 'create_tramway_event_participant_form_fields.rb', 'db/migrate/create_tramway_event_participant_form_fields.rb'
21
+ migration_template 'create_tramway_event_participants.rb', 'db/migrate/create_tramway_event_participants.rb'
20
22
  end
21
23
  end
22
24
  end
@@ -0,0 +1,13 @@
1
+ class CreateTramwayEventParticipantFormFields < ActiveRecord::Migration[5.1]
2
+ def change
3
+ create_table :tramway_event_participant_form_fields do |t|
4
+ t.text :title
5
+ t.text :description
6
+ t.text :field_type, default: :text
7
+ t.integer :event_id
8
+ t.text :state, default: :active
9
+
10
+ t.timestamps
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,11 @@
1
+ class CreateTramwayEventParticipants < ActiveRecord::Migration[5.1]
2
+ def change
3
+ create_table :tramway_event_participants do |t|
4
+ t.integer :event_id
5
+ t.jsonb :values
6
+ t.text :state, default: :active
7
+
8
+ t.timestamps
9
+ end
10
+ end
11
+ end
@@ -1,5 +1,5 @@
1
1
  module Tramway
2
2
  module Event
3
- VERSION = '0.4.1'
3
+ VERSION = '0.5'
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tramway-event
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.1
4
+ version: '0.5'
5
5
  platform: ruby
6
6
  authors:
7
7
  - Pavel Kalashnikov
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-09-04 00:00:00.000000000 Z
11
+ date: 2018-09-10 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Rails engine for events
14
14
  email:
@@ -28,13 +28,20 @@ files:
28
28
  - app/controllers/tramway/event/events_controller.rb
29
29
  - app/decorators/tramway/event/event_decorator.rb
30
30
  - app/decorators/tramway/event/event_link_decorator.rb
31
+ - app/decorators/tramway/event/participant_decorator.rb
32
+ - app/decorators/tramway/event/participant_form_field_decorator.rb
31
33
  - app/forms/tramway/event/event_form.rb
34
+ - app/forms/tramway/event/participant_form.rb
35
+ - app/forms/tramway/event/participant_form_field_form.rb
32
36
  - app/helpers/tramway/event/application_helper.rb
33
37
  - app/jobs/tramway/event/application_job.rb
34
38
  - app/mailers/tramway/event/application_mailer.rb
35
39
  - app/models/tramway/event/application_record.rb
36
40
  - app/models/tramway/event/event.rb
41
+ - app/models/tramway/event/participant.rb
42
+ - app/models/tramway/event/participant_form_field.rb
37
43
  - app/views/tramway/event/events/show.html.haml
44
+ - app/views/tramway/event/participants/_form.html.haml
38
45
  - config/initializers/assets.rb
39
46
  - config/initializers/tramway.rb
40
47
  - config/locales/models.yml
@@ -45,6 +52,8 @@ files:
45
52
  - lib/tramway/event/generators/install_generator.rb
46
53
  - lib/tramway/event/generators/templates/add_photo_to_tramway_event_events.rb
47
54
  - lib/tramway/event/generators/templates/create_tramway_event_events.rb
55
+ - lib/tramway/event/generators/templates/create_tramway_event_participant_form_fields.rb
56
+ - lib/tramway/event/generators/templates/create_tramway_event_participants.rb
48
57
  - lib/tramway/event/version.rb
49
58
  homepage: https://github.com/ulmic/tramway-event
50
59
  licenses: