tramway-event 1.9.19 → 1.9.19.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (69) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +17 -3
  3. data/Rakefile +3 -5
  4. data/app/assets/stylesheets/tramway/event/events/show.css.sass +1 -1
  5. data/app/controllers/tramway/event/application_controller.rb +2 -0
  6. data/app/controllers/tramway/event/events_controller.rb +2 -0
  7. data/app/controllers/tramway/event/participants_controller.rb +2 -0
  8. data/app/decorators/tramway/event/event_decorator.rb +23 -16
  9. data/app/decorators/tramway/event/event_link_decorator.rb +2 -0
  10. data/app/decorators/tramway/event/events/show/event_decorator.rb +4 -2
  11. data/app/decorators/tramway/event/partaking_decorator.rb +5 -3
  12. data/app/decorators/tramway/event/partaking_feature_decorator.rb +2 -0
  13. data/app/decorators/tramway/event/participant_decorator.rb +7 -5
  14. data/app/decorators/tramway/event/participant_form_field_decorator.rb +3 -1
  15. data/app/decorators/tramway/event/participant_xlsx_decorator.rb +3 -1
  16. data/app/decorators/tramway/event/person_decorator.rb +3 -1
  17. data/app/decorators/tramway/event/place_decorator.rb +2 -0
  18. data/app/decorators/tramway/event/section_decorator.rb +3 -1
  19. data/app/decorators/tramway/event/section_feature_decorator.rb +3 -1
  20. data/app/forms/tramway/event/event_form.rb +9 -7
  21. data/app/forms/tramway/event/partaking_form.rb +4 -2
  22. data/app/forms/tramway/event/participant_extended_form_creator.rb +2 -0
  23. data/app/forms/tramway/event/participant_form.rb +2 -0
  24. data/app/forms/tramway/event/participant_form_field_form.rb +2 -0
  25. data/app/forms/tramway/event/person_form.rb +5 -3
  26. data/app/forms/tramway/event/place_form.rb +6 -4
  27. data/app/forms/tramway/event/section_form.rb +3 -1
  28. data/app/helpers/tramway/event/application_helper.rb +3 -1
  29. data/app/jobs/tramway/event/application_job.rb +2 -0
  30. data/app/mailers/tramway/event/application_mailer.rb +2 -0
  31. data/app/models/tramway/event/application_record.rb +2 -0
  32. data/app/models/tramway/event/event.rb +7 -3
  33. data/app/models/tramway/event/partaking.rb +4 -2
  34. data/app/models/tramway/event/participant.rb +12 -10
  35. data/app/models/tramway/event/participant_form_field.rb +3 -1
  36. data/app/models/tramway/event/person.rb +2 -2
  37. data/app/models/tramway/event/place.rb +2 -0
  38. data/app/models/tramway/event/section.rb +2 -0
  39. data/config/initializers/assets.rb +3 -1
  40. data/config/initializers/tramway.rb +9 -7
  41. data/config/locales/models.yml +1 -0
  42. data/config/routes.rb +2 -0
  43. data/lib/tasks/tramway/event_tasks.rake +2 -0
  44. data/lib/tramway/event.rb +3 -1
  45. data/lib/tramway/event/engine.rb +2 -0
  46. data/lib/tramway/event/generators/install_generator.rb +4 -2
  47. data/lib/tramway/event/generators/templates/add_description_to_tramway_event_people.rb +2 -0
  48. data/lib/tramway/event/generators/templates/add_icon_to_tramway_event_sections.rb +2 -0
  49. data/lib/tramway/event/generators/templates/add_more_fields_to_tramway_event_participants.rb +2 -0
  50. data/lib/tramway/event/generators/templates/add_options_to_tramway_event_participant_form_fields.rb +2 -0
  51. data/lib/tramway/event/generators/templates/add_photo_to_tramway_event_events.rb +2 -0
  52. data/lib/tramway/event/generators/templates/add_position_to_tramway_event_partakings.rb +2 -0
  53. data/lib/tramway/event/generators/templates/add_position_to_tramway_event_participant_form_fields.rb +2 -0
  54. data/lib/tramway/event/generators/templates/add_position_to_tramway_event_sections.rb +2 -0
  55. data/lib/tramway/event/generators/templates/add_request_period_to_tramway_event_events.rb +2 -0
  56. data/lib/tramway/event/generators/templates/add_state_to_tramway_event_partakings.rb +2 -0
  57. data/lib/tramway/event/generators/templates/add_status_to_tramway_event_events.rb +2 -0
  58. data/lib/tramway/event/generators/templates/create_tramway_event_events.rb +2 -0
  59. data/lib/tramway/event/generators/templates/create_tramway_event_events_places.rb +2 -0
  60. data/lib/tramway/event/generators/templates/create_tramway_event_participant_form_fields.rb +2 -0
  61. data/lib/tramway/event/generators/templates/create_tramway_event_participants.rb +2 -0
  62. data/lib/tramway/event/generators/templates/create_tramway_event_people.rb +2 -0
  63. data/lib/tramway/event/generators/templates/create_tramway_event_people_sections.rb +2 -0
  64. data/lib/tramway/event/generators/templates/create_tramway_event_places.rb +2 -0
  65. data/lib/tramway/event/generators/templates/create_tramway_event_sections.rb +2 -0
  66. data/lib/tramway/event/generators/templates/rebuild_association_between_participant_and_partakings_to_polymorphic.rb +2 -0
  67. data/lib/tramway/event/generators/templates/rename_tramway_event_people_sections_to_tramway_event_partakings.rb +2 -0
  68. data/lib/tramway/event/version.rb +3 -1
  69. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 04612e4d92c227210e6f6ef30048df7ab0589c44acec5b622a4fd2443e3781d2
4
- data.tar.gz: c8c976aa58509702a2c1981362043783b20d6601388d5bd959eb852cb20cc679
3
+ metadata.gz: f50e33baf942aae50cdad1e1a81a33e177b155c4cb03fb54fc8019fbdabc8be8
4
+ data.tar.gz: e2be5daa64cc778445d6d1098a0f5662208890c7c6f40a403b67e8165c3c09af
5
5
  SHA512:
6
- metadata.gz: 8ff4bb5e94787ecc29145c5b52c91607092d0f1b5e8d695685fcbea4f4d78a6a06bd854ffc92be29ee4c242973f87a01ed209aff0b05a2651396cdd28bc77fb1
7
- data.tar.gz: 95abf3e86d185b6a0a53c641ed8ac56082f94e234b9e815764dd351f27e28feb55faff67618510882ddcec4d5ae7871bcc69b316fe1d36788330505cc8c56fae
6
+ metadata.gz: 3fb3431866672725cb869ca1925f1a6022463f511363e7d4582b9484b40da6b2aec04b839eb06f0232f4f791cdf010caf666b74460dc114fbd1ed7c19f18fd59
7
+ data.tar.gz: 5345d1e963710e49a66e88e33203eac2e2d77ed6c5f239604d8af968a93880b62c4f37b62e7effc10a751f14a6525fd4e53e14411353b580abfe4f460ad300f8
data/README.md CHANGED
@@ -9,16 +9,30 @@ Add this line to your application's Gemfile:
9
9
 
10
10
  ```ruby
11
11
  gem 'tramway-event'
12
+ gem 'carrierwave'
13
+ gem 'more_html_tags'
12
14
  ```
13
15
 
14
16
  And then execute:
15
17
  ```bash
16
18
  $ bundle
17
19
  ```
20
+ *Gemfile*
21
+ ```ruby
22
+ gem 'tramway-event'
23
+ ```
18
24
 
19
- Or install it yourself as:
20
- ```bash
21
- $ gem install tramway-event
25
+ Then run:
26
+ ```shell
27
+ rails g tramway:event:install
28
+ rails db:migrate
29
+ ```
30
+
31
+ Then make `tramway-landing` installation. [How-to](https://github.com/ulmic/tramway-dev/blob/develop/tramway-landing/README.md#installation)
32
+
33
+ *config/initializers/tramway.rb*
34
+ ```ruby
35
+ Tramway::Admin.set_available_models ::Tramway::Event::Event, ::Tramway::Event::ParticipantFormField, ::Tramway::Event::Participant, project: #{project_which_you_used_in_the_application}
22
36
  ```
23
37
 
24
38
  ## Contributing
data/Rakefile CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  begin
2
4
  require 'bundler/setup'
3
5
  rescue LoadError
@@ -14,14 +16,11 @@ RDoc::Task.new(:rdoc) do |rdoc|
14
16
  rdoc.rdoc_files.include('lib/**/*.rb')
15
17
  end
16
18
 
17
- APP_RAKEFILE = File.expand_path("../test/dummy/Rakefile", __FILE__)
19
+ APP_RAKEFILE = File.expand_path('test/dummy/Rakefile', __dir__)
18
20
  load 'rails/tasks/engine.rake'
19
21
 
20
-
21
22
  load 'rails/tasks/statistics.rake'
22
23
 
23
-
24
-
25
24
  require 'bundler/gem_tasks'
26
25
 
27
26
  require 'rake/testtask'
@@ -32,5 +31,4 @@ Rake::TestTask.new(:test) do |t|
32
31
  t.verbose = false
33
32
  end
34
33
 
35
-
36
34
  task default: :test
@@ -1,7 +1,7 @@
1
1
  @import 'bootstrap'
2
2
  @import 'tramway/core/application'
3
3
  @import 'tramway/landing/application'
4
- @import 'tramway/conference/application'
4
+ // @import 'tramway/conference/application'
5
5
 
6
6
  body
7
7
  margin: 0
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Tramway
2
4
  module Event
3
5
  class ApplicationController < ::Tramway::Core::ApplicationController
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class Tramway::Event::EventsController < Tramway::Event::ApplicationController
2
4
  layout 'tramway/landing/application'
3
5
 
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class Tramway::Event::ParticipantsController < Tramway::Event::ApplicationController
2
4
  def create
3
5
  event = ::Tramway::Event::Event.find params[:tramway_event_participant][:event_id]
@@ -1,25 +1,27 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class Tramway::Event::EventDecorator < ::Tramway::Core::ApplicationDecorator
2
4
  class << self
3
5
  def collections
4
- [ :all ]
6
+ [:all]
5
7
  end
6
8
 
7
9
  def show_attributes
8
- [
9
- :title,
10
- :duration,
11
- :state,
12
- :created_at,
13
- :photo,
14
- :status,
15
- :request_collecting_duration,
16
- :description,
17
- :participants_list
10
+ %i[
11
+ title
12
+ duration
13
+ state
14
+ created_at
15
+ photo
16
+ status
17
+ request_collecting_duration
18
+ description
19
+ participants_list
18
20
  ]
19
21
  end
20
22
 
21
23
  def list_attributes
22
- [ :requested_participants, :approved_participants ]
24
+ %i[requested_participants approved_participants]
23
25
  end
24
26
  end
25
27
 
@@ -56,7 +58,7 @@ class Tramway::Event::EventDecorator < ::Tramway::Core::ApplicationDecorator
56
58
 
57
59
  def duration(begin_date: object.begin_date, end_date: object.end_date)
58
60
  if begin_date.to_date == end_date.to_date
59
- "#{I18n.l(begin_date, format: '%d %B %Y')}"
61
+ I18n.l(begin_date, format: '%d %B %Y').to_s
60
62
  elsif begin_date.month == end_date.month
61
63
  "#{I18n.t('date.from')} #{I18n.l(begin_date, format: '%d')} #{I18n.t('date.to')} #{I18n.l(end_date, format: '%d %B %Y')}"
62
64
  else
@@ -65,6 +67,7 @@ class Tramway::Event::EventDecorator < ::Tramway::Core::ApplicationDecorator
65
67
  end
66
68
 
67
69
  def request_collecting_duration
70
+ return if object.request_collecting_begin_date.nil? || object.request_collecting_end_date.nil?
68
71
  duration begin_date: object.request_collecting_begin_date, end_date: object.request_collecting_end_date
69
72
  end
70
73
 
@@ -73,10 +76,14 @@ class Tramway::Event::EventDecorator < ::Tramway::Core::ApplicationDecorator
73
76
  end
74
77
 
75
78
  def approved_participants
76
- if DateTime.now < object.end_date
77
- I18n.t('activerecord.attributes.tramway/event/event.not_yet_held')
79
+ if object.end_date.present?
80
+ if DateTime.now < object.end_date
81
+ I18n.t('activerecord.attributes.tramway/event/event.not_yet_held')
82
+ else
83
+ object.participants.approved.count
84
+ end
78
85
  else
79
- object.participants.approved.count
86
+ I18n.t('activerecord.attributes.tramway/event/event.does_not_have_end_date')
80
87
  end
81
88
  end
82
89
 
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class Tramway::Event::EventLinkDecorator < ::Tramway::Landing::LinkDecorator
2
4
  delegate :title, to: :object
3
5
 
@@ -1,7 +1,9 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class Tramway::Event::Events::Show::EventDecorator < ::Tramway::Core::ApplicationDecorator
2
4
  class << self
3
5
  def collections
4
- [ :all ]
6
+ [:all]
5
7
  end
6
8
  end
7
9
 
@@ -22,7 +24,7 @@ class Tramway::Event::Events::Show::EventDecorator < ::Tramway::Core::Applicatio
22
24
 
23
25
  def duration
24
26
  if object.begin_date.to_date == object.end_date.to_date
25
- "#{I18n.l(object.begin_date, format: '%d %B %Y')}"
27
+ I18n.l(object.begin_date, format: '%d %B %Y').to_s
26
28
  elsif object.begin_date.month == object.end_date.month
27
29
  "#{I18n.t('date.from')} #{I18n.l(object.begin_date, format: '%d')} #{I18n.t('date.to')} #{I18n.l(object.end_date, format: '%d %B %Y')}"
28
30
  else
@@ -1,11 +1,13 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class Tramway::Event::PartakingDecorator < ::Tramway::Core::ApplicationDecorator
2
4
  class << self
3
5
  def collections
4
- [ :all ]
6
+ [:all]
5
7
  end
6
8
 
7
9
  def show_attributes
8
- [ :part_name, :event_duration, :part_description ]
10
+ %i[part_name event_duration part_description]
9
11
  end
10
12
  end
11
13
 
@@ -14,7 +16,7 @@ class Tramway::Event::PartakingDecorator < ::Tramway::Core::ApplicationDecorator
14
16
  def name
15
17
  "#{object.person.first_name} #{object.person.last_name} - #{object.position}"
16
18
  end
17
-
19
+
18
20
  def part_name
19
21
  part.name
20
22
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class ::Tramway::Event::PartakingFeatureDecorator < ::Tramway::Landing::BlockTypes::FeaturesDecorator
2
4
  def text
3
5
  object.position&.html_safe
@@ -1,8 +1,10 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class Tramway::Event::ParticipantDecorator < ::Tramway::Core::ApplicationDecorator
2
4
  include HTMLTagsHelpers
3
5
  class << self
4
6
  def collections
5
- [ :requested, :waiting, :prev_approved, :without_answer, :approved, :rejected, :reserved, :all ]
7
+ %i[requested waiting prev_approved without_answer approved rejected reserved all]
6
8
  end
7
9
 
8
10
  def list_attributes
@@ -34,11 +36,11 @@ class Tramway::Event::ParticipantDecorator < ::Tramway::Core::ApplicationDecorat
34
36
  end)
35
37
  object.event.participant_form_fields.map do |field|
36
38
  hash = if field.options.is_a?(Hash)
37
- field.options
39
+ field.options
38
40
  else
39
41
  begin
40
42
  JSON.parse(field.options.present? ? field.options : '{}')
41
- rescue => e
43
+ rescue StandardError => e
42
44
  I18n.t('.invalid_field_with_error', e)
43
45
  end
44
46
  end
@@ -49,7 +51,7 @@ class Tramway::Event::ParticipantDecorator < ::Tramway::Core::ApplicationDecorat
49
51
  field.title
50
52
  end)
51
53
  concat(content_tag(:td) do
52
- value = object.values&.dig( field.title )
54
+ value = object.values&.dig(field.title)
53
55
  if russian_phone_number?(value)
54
56
  tel_tag value
55
57
  else
@@ -74,7 +76,7 @@ class Tramway::Event::ParticipantDecorator < ::Tramway::Core::ApplicationDecorat
74
76
  end)
75
77
  concat(content_tag(:td) do
76
78
  concat(if russian_phone_number?(value)
77
- tel_tag value
79
+ tel_tag value
78
80
  else
79
81
  value
80
82
  end)
@@ -1,7 +1,9 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class Tramway::Event::ParticipantFormFieldDecorator < ::Tramway::Core::ApplicationDecorator
2
4
  class << self
3
5
  def collections
4
- [ :all ]
6
+ [:all]
5
7
  end
6
8
 
7
9
  def list_attributes
@@ -1,7 +1,9 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class Tramway::Event::ParticipantXlsxDecorator < Tramway::Export::Xlsx::ApplicationDecorator
2
4
  class << self
3
5
  def columns
4
- [ :full_name, :email, :phone, :organization, :event ].map do |attribute|
6
+ %i[full_name email phone organization event].map do |attribute|
5
7
  { Tramway::Event::Participant.human_attribute_name(attribute).to_sym => attribute }
6
8
  end
7
9
  end
@@ -1,7 +1,9 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class Tramway::Event::PersonDecorator < ::Tramway::Core::ApplicationDecorator
2
4
  class << self
3
5
  def collections
4
- [ :all ]
6
+ [:all]
5
7
  end
6
8
  end
7
9
 
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class Tramway::Event::PlaceDecorator < Tramway::Core::ApplicationDecorator
2
4
  delegate :title, to: :object
3
5
  end
@@ -1,7 +1,9 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class Tramway::Event::SectionDecorator < ::Tramway::Landing::BlockTypes::FeaturesDecorator
2
4
  class << self
3
5
  def collections
4
- [ :all ]
6
+ [:all]
5
7
  end
6
8
  end
7
9
 
@@ -1,10 +1,12 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class ::Tramway::Event::SectionFeatureDecorator < ::Tramway::Landing::BlockTypes::FeaturesDecorator
2
4
  delegate :icon, to: :object
3
5
  delegate :title, to: :object
4
6
  delegate :description, to: :object
5
7
 
6
8
  def text
7
- object.description.scan(/<strong>.*?<\/strong>/).join(' ')
9
+ object.description.scan(%r{<strong>.*?</strong>}).join(' ')
8
10
  end
9
11
 
10
12
  def image
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class Tramway::Event::EventForm < ::Tramway::Core::ApplicationForm
2
4
  properties :title, :description, :begin_date, :end_date, :photo, :status,
3
5
  :request_collecting_begin_date, :request_collecting_end_date
@@ -5,13 +7,13 @@ class Tramway::Event::EventForm < ::Tramway::Core::ApplicationForm
5
7
  def initialize(object)
6
8
  super(object).tap do
7
9
  form_properties title: :string,
8
- description: :ckeditor,
9
- begin_date: :date_picker,
10
- end_date: :date_picker,
11
- request_collecting_begin_date: :date_picker,
12
- request_collecting_end_date: :date_picker,
13
- photo: :file,
14
- status: :default
10
+ description: :ckeditor,
11
+ begin_date: :date_picker,
12
+ end_date: :date_picker,
13
+ request_collecting_begin_date: :date_picker,
14
+ request_collecting_end_date: :date_picker,
15
+ photo: :file,
16
+ status: :default
15
17
  end
16
18
  end
17
19
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class Tramway::Event::PartakingForm < ::Tramway::Core::ApplicationForm
2
4
  properties :part_id, :part_type, :person_id, :position
3
5
  associations :person, :part
@@ -5,8 +7,8 @@ class Tramway::Event::PartakingForm < ::Tramway::Core::ApplicationForm
5
7
  def initialize(object)
6
8
  super(object).tap do
7
9
  form_properties part: :polymorphic_association,
8
- person: :association,
9
- position: :string
10
+ person: :association,
11
+ position: :string
10
12
  end
11
13
  end
12
14
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class Tramway::Event::ParticipantExtendedFormCreator < Tramway::Core::FormCreator
2
4
  def self.create_form_class(uuid, event, **simple_properties)
3
5
  class_name = "ParticipantExtendedForm#{uuid.gsub('-', '')}"
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'securerandom'
2
4
 
3
5
  class Tramway::Event::ParticipantForm < ::Tramway::Core::ApplicationForm
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class Tramway::Event::ParticipantFormFieldForm < ::Tramway::Core::ApplicationForm
2
4
  properties :title, :description, :field_type, :options, :position
3
5
  association :event
@@ -1,12 +1,14 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class Tramway::Event::PersonForm < ::Tramway::Core::ApplicationForm
2
4
  properties :first_name, :last_name, :photo, :description
3
5
 
4
6
  def initialize(object)
5
7
  super(object).tap do
6
8
  form_properties first_name: :string,
7
- last_name: :string,
8
- photo: :file,
9
- description: :ckeditor
9
+ last_name: :string,
10
+ photo: :file,
11
+ description: :ckeditor
10
12
  end
11
13
  end
12
14
  end
@@ -1,13 +1,15 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class Tramway::Event::PlaceForm < Tramway::Core::ApplicationForm
2
4
  properties :title, :description, :coordinates, :photo, :city
3
5
 
4
6
  def initialize(object)
5
7
  super(object).tap do
6
8
  form_properties title: :string,
7
- description: :ckeditor,
8
- coordinates: :string,
9
- photo: :file,
10
- city: :string
9
+ description: :ckeditor,
10
+ coordinates: :string,
11
+ photo: :file,
12
+ city: :string
11
13
  end
12
14
  end
13
15
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class Tramway::Event::SectionForm < ::Tramway::Core::ApplicationForm
2
4
  properties :event, :title, :description, :photo, :icon, :position
3
5
  association :event
@@ -10,6 +12,6 @@ class Tramway::Event::SectionForm < ::Tramway::Core::ApplicationForm
10
12
  photo: :file,
11
13
  icon: :string,
12
14
  position: :numeric
13
- end
15
+ end
14
16
  end
15
17
  end
@@ -1,4 +1,6 @@
1
- require "tramway/collections/helper"
1
+ # frozen_string_literal: true
2
+
3
+ require 'tramway/collections/helper'
2
4
 
3
5
  module Tramway
4
6
  module Event
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Tramway
2
4
  module Event
3
5
  class ApplicationJob < ActiveJob::Base
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Tramway
2
4
  module Event
3
5
  class ApplicationMailer < ActionMailer::Base
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Tramway
2
4
  module Event
3
5
  class ApplicationRecord < ::Tramway::Core::ApplicationRecord
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class Tramway::Event::Event < ::Tramway::Event::ApplicationRecord
2
4
  mount_uploader :photo, PhotoUploader
3
5
 
@@ -9,12 +11,12 @@ class Tramway::Event::Event < ::Tramway::Event::ApplicationRecord
9
11
  has_many :organizations, as: :partners, through: :partnerships, class_name: 'Tramway::Partner::Organization'
10
12
  has_and_belongs_to_many :places
11
13
 
12
- enumerize :status, default: :common, in: [ :common, :main ]
14
+ enumerize :status, default: :common, in: %i[common main]
13
15
 
14
16
  scope :main_event, -> { where(status: :main) }
15
17
  scope :actual, -> { where 'end_date > ?', DateTime.now }
16
18
  scope :past, -> { where 'end_date < ?', DateTime.now }
17
-
19
+
18
20
  def request_collecting_state
19
21
  return :not_initialized unless request_collecting_begin_date.present? || request_collecting_end_date.present?
20
22
  return :will_begin_soon if request_collecting_begin_date > DateTime.now
@@ -22,5 +24,7 @@ class Tramway::Event::Event < ::Tramway::Event::ApplicationRecord
22
24
  return :are_being_right_now if request_collecting_begin_date&.past? && request_collecting_end_date&.future?
23
25
  end
24
26
 
25
- include ::Tramway::Partner::Scopes
27
+ if defined? ::Tramway::Partner
28
+ include ::Tramway::Partner::Scopes
29
+ end
26
30
  end
@@ -1,8 +1,10 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class Tramway::Event::Partaking < ::Tramway::Core::ApplicationRecord
2
4
  belongs_to :part, polymorphic: true
3
- enumerize :part_type, in: [ 'Tramway::Event::Event', 'Tramway::Event::Section' ]
5
+ enumerize :part_type, in: ['Tramway::Event::Event', 'Tramway::Event::Section']
4
6
 
5
7
  belongs_to :person, class_name: 'Tramway::Event::Person'
6
8
 
7
- search_by :position, person: [:first_name, :last_name, :description]
9
+ search_by :position, person: %i[first_name last_name description]
8
10
  end
@@ -1,6 +1,8 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class Tramway::Event::Participant < ::Tramway::Event::ApplicationRecord
2
4
  belongs_to :event, class_name: 'Tramway::Event::Event'
3
-
5
+
4
6
  state_machine :participation_state, initial: :requested do
5
7
  state :requested
6
8
  state :prev_approved
@@ -11,31 +13,31 @@ class Tramway::Event::Participant < ::Tramway::Event::ApplicationRecord
11
13
  state :reserved
12
14
 
13
15
  event :previous_approve do
14
- transition [ :requested, :without_answer, :waiting ] => :prev_approved
16
+ transition %i[requested without_answer waiting] => :prev_approved
15
17
  end
16
18
 
17
19
  event :wait_for_decision do
18
- transition [ :requested, :without_answer ] => :waiting
20
+ transition %i[requested without_answer] => :waiting
21
+ end
22
+
23
+ event :reserve do
24
+ transition %i[requested without_answer waiting] => :reserved
19
25
  end
20
26
 
21
27
  event :reject do
22
- transition [ :requested, :without_answer, :waiting, :prev_approved, :reserved ] => :rejected
28
+ transition %i[requested without_answer waiting prev_approved reserved] => :rejected
23
29
  end
24
30
 
25
31
  event :approve do
26
- transition [ :prev_approved, :reserved, :requested ] => :approved
32
+ transition %i[prev_approved reserved requested] => :approved
27
33
  end
28
34
 
29
35
  event :not_got_answer do
30
36
  transition requested: :without_answer
31
37
  end
32
38
 
33
- event :reserve do
34
- transition [ :requested, :without_answer, :waiting ] => :reserved
35
- end
36
-
37
39
  event :return_to_requested do
38
- transition [ :prev_approved, :rejected ] => :requested
40
+ transition %i[prev_approved rejected] => :requested
39
41
  end
40
42
  end
41
43
 
@@ -1,7 +1,9 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class Tramway::Event::ParticipantFormField < ::Tramway::Event::ApplicationRecord
2
4
  belongs_to :event, class_name: 'Tramway::Event::Event'
3
5
 
4
- enumerize :field_type, in: [ :text, :string, :numeric, :date_picker, :select ], default: :text
6
+ enumerize :field_type, in: %i[text string numeric date_picker select], default: :text
5
7
 
6
8
  scope :inputs_list, -> { active.order(position: :asc) }
7
9
  end
@@ -1,5 +1,5 @@
1
- class Tramway::Event::Person < ::Tramway::Event::ApplicationRecord
2
- has_and_belongs_to_many :sections, class_name: 'Tramway::Event::Section'
1
+ # frozen_string_literal: true
3
2
 
3
+ class Tramway::Event::Person < ::Tramway::Event::ApplicationRecord
4
4
  mount_uploader :photo, PhotoUploader
5
5
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class Tramway::Event::Place < Tramway::Core::ApplicationRecord
2
4
  has_and_belongs_to_many :events
3
5
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class Tramway::Event::Section < ::Tramway::Event::ApplicationRecord
2
4
  mount_uploader :photo, PhotoUploader
3
5
 
@@ -1 +1,3 @@
1
- Rails.application.config.assets.precompile += %w( tramway/event/events/show.css )
1
+ # frozen_string_literal: true
2
+
3
+ Rails.application.config.assets.precompile += %w[tramway/event/events/show.css]
@@ -1,8 +1,10 @@
1
+ # frozen_string_literal: true
2
+
1
3
  ::Tramway::Admin.set_available_models(::Tramway::Event::Event,
2
- ::Tramway::Event::ParticipantFormField,
3
- ::Tramway::Event::Participant,
4
- ::Tramway::Event::Section,
5
- ::Tramway::Event::Person,
6
- ::Tramway::Event::Partaking,
7
- ::Tramway::Event::Place,
8
- project: :event)
4
+ ::Tramway::Event::ParticipantFormField,
5
+ ::Tramway::Event::Participant,
6
+ ::Tramway::Event::Section,
7
+ ::Tramway::Event::Person,
8
+ ::Tramway::Event::Partaking,
9
+ ::Tramway::Event::Place,
10
+ project: :event)
@@ -25,6 +25,7 @@ ru:
25
25
  approved_participants: Количество пришедших
26
26
  not_yet_held: мероприятие ещё не проведено
27
27
  participants_list: Список участников
28
+ does_not_have_end_date: мероприятие не имеет даты окончания
28
29
  tramway/event/participant:
29
30
  comment: Примечание
30
31
  event: Мероприятие
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  Tramway::Event::Engine.routes.draw do
2
4
  resources :events, only: :show
3
5
  resources :participants, only: :create
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # desc "Explaining what the task does"
2
4
  # task :tramway_event do
3
5
  # # Task goes here
@@ -1,4 +1,6 @@
1
- require "tramway/event/engine"
1
+ # frozen_string_literal: true
2
+
3
+ require 'tramway/event/engine'
2
4
  require 'tramway/event/generators/install_generator'
3
5
 
4
6
  module Tramway
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Tramway
2
4
  module Event
3
5
  class Engine < ::Rails::Engine
@@ -1,10 +1,12 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'rails/generators'
2
4
  require 'tramway/core/generators/install_generator'
3
5
 
4
6
  module Tramway::Event::Generators
5
7
  class InstallGenerator < ::Tramway::Core::Generators::InstallGenerator
6
8
  include Rails::Generators::Migration
7
- source_root File.expand_path('../templates', __FILE__)
9
+ source_root File.expand_path('templates', __dir__)
8
10
 
9
11
  def run_other_generators
10
12
  generate 'tramway:partner:install'
@@ -36,7 +38,7 @@ module Tramway::Event::Generators
36
38
  :add_position_to_tramway_event_partakings,
37
39
  :add_state_to_tramway_event_partakings,
38
40
  :add_more_fields_to_tramway_event_participants,
39
-
41
+
40
42
  # NOTE must be removed until tramway-event 2.0
41
43
  :rebuild_association_between_participant_and_partakings_to_polymorphic,
42
44
 
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class AddDescriptionToTramwayEventPeople < ActiveRecord::Migration[5.1]
2
4
  def change
3
5
  add_column :tramway_event_people, :description, :text
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class AddIconToTramwayEventSections < ActiveRecord::Migration[5.1]
2
4
  def change
3
5
  add_column :tramway_event_sections, :icon, :text
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class AddMoreFieldsToTramwayEventParticipants < ActiveRecord::Migration[5.1]
2
4
  def change
3
5
  add_column :tramway_event_participants, :participation_state, :text, default: :requested
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class AddOptionsToTramwayEventParticipantFormFields < ActiveRecord::Migration[5.1]
2
4
  def change
3
5
  add_column :tramway_event_participant_form_fields, :options, :jsonb
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class AddPhotoToTramwayEventEvents < ActiveRecord::Migration[5.1]
2
4
  def change
3
5
  add_column :tramway_event_events, :photo, :text
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class AddPositionToTramwayEventPartakings < ActiveRecord::Migration[5.1]
2
4
  def change
3
5
  add_column :tramway_event_partakings, :position, :text
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class AddPositionToTramwayEventParticipantFormFields < ActiveRecord::Migration[5.1]
2
4
  def change
3
5
  add_column :tramway_event_participant_form_fields, :position, :integer
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class AddPositionToTramwayEventSections < ActiveRecord::Migration[5.1]
2
4
  def change
3
5
  add_column :tramway_event_sections, :position, :integer
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class AddRequestPeriodToTramwayEventEvents < ActiveRecord::Migration[5.1]
2
4
  def change
3
5
  add_column :tramway_event_events, :request_collecting_begin_date, :datetime
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class AddStateToTramwayEventPartakings < ActiveRecord::Migration[5.1]
2
4
  def change
3
5
  add_column :tramway_event_partakings, :state, :text
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class AddStatusToTramwayEventEvents < ActiveRecord::Migration[5.1]
2
4
  def change
3
5
  add_column :tramway_event_events, :status, :text
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class CreateTramwayEventEvents < ActiveRecord::Migration[5.1]
2
4
  def change
3
5
  create_table :tramway_event_events do |t|
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class CreateTramwayEventEventsPlaces < ActiveRecord::Migration[5.1]
2
4
  def change
3
5
  create_table :tramway_event_events_places do |t|
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class CreateTramwayEventParticipantFormFields < ActiveRecord::Migration[5.1]
2
4
  def change
3
5
  create_table :tramway_event_participant_form_fields do |t|
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class CreateTramwayEventParticipants < ActiveRecord::Migration[5.1]
2
4
  def change
3
5
  create_table :tramway_event_participants do |t|
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class CreateTramwayEventPeople < ActiveRecord::Migration[5.1]
2
4
  def change
3
5
  create_table :tramway_event_people do |t|
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class CreateTramwayEventPeopleSections < ActiveRecord::Migration[5.1]
2
4
  def change
3
5
  create_table :tramway_event_people_sections do |t|
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class CreateTramwayEventPlaces < ActiveRecord::Migration[5.1]
2
4
  def change
3
5
  create_table :tramway_event_places do |t|
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class CreateTramwayEventSections < ActiveRecord::Migration[5.1]
2
4
  def change
3
5
  create_table :tramway_event_sections do |t|
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # NOTE must be removed until tramway-event 2.0
2
4
 
3
5
  class RebuildAssociationBetweenParticipantAndPartakingsToPolymorphic < ActiveRecord::Migration[5.1]
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # NOTE must be removed until tramway-event 2.0
2
4
 
3
5
  class RenameTramwayEventPeopleSectionsToTramwayEventPartakings < ActiveRecord::Migration[5.1]
@@ -1,5 +1,7 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Tramway
2
4
  module Event
3
- VERSION = '1.9.19'
5
+ VERSION = '1.9.19.5'
4
6
  end
5
7
  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: 1.9.19
4
+ version: 1.9.19.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: 2019-10-06 00:00:00.000000000 Z
11
+ date: 2020-01-10 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Rails engine for events
14
14
  email: