From a5a2db407720afad72ac6a0d1eaca26572d402f3 Mon Sep 17 00:00:00 2001 From: Aditya Chatterjee Date: Sat, 27 Feb 2016 17:03:43 +0530 Subject: [PATCH 1/2] update --- .rubocop.yml | 14 +- .rubocop_todo.yml | 685 +++++++++++++++--- .travis.yml | 9 +- Gemfile | 48 +- Gemfile.lock | 225 +++--- INSTALL.md | 2 +- app/assets/javascripts/application.js | 14 +- app/assets/javascripts/osem-dashboard.js | 130 ++++ app/controllers/admin/cfps_controller.rb | 58 ++ app/controllers/admin/comments_controller.rb | 2 +- .../admin/conference_controller.rb | 14 +- .../admin/difficulty_levels_controller.rb | 17 +- .../admin/event_types_controller.rb | 19 +- app/controllers/admin/events_controller.rb | 49 +- app/controllers/admin/programs_controller.rb | 32 + app/controllers/admin/rooms_controller.rb | 19 +- app/controllers/admin/schedules_controller.rb | 16 +- app/controllers/admin/tracks_controller.rb | 15 +- .../api/v1/conferences_controller.rb | 12 +- app/controllers/api/v1/events_controller.rb | 7 +- app/controllers/api/v1/rooms_controller.rb | 3 +- app/controllers/api/v1/speakers_controller.rb | 12 +- app/controllers/api/v1/tracks_controller.rb | 9 +- app/controllers/application_controller.rb | 11 +- app/controllers/commercials_controller.rb | 8 +- app/controllers/conference_controller.rb | 5 +- .../conference_registrations_controller.rb | 5 + app/controllers/proposal_controller.rb | 31 +- app/helpers/application_helper.rb | 20 +- app/mailers/mailbot.rb | 10 +- app/models/ability.rb | 52 +- app/models/ahoy/program.rb | 113 +++ app/models/cfp.rb | 71 ++ app/models/conference.rb | 136 +--- app/models/difficulty_level.rb | 2 +- app/models/email_settings.rb | 6 +- app/models/event.rb | 30 +- app/models/event_type.rb | 2 +- app/models/program.rb | 97 +++ app/models/registration.rb | 7 + app/models/registration_period.rb | 21 +- app/models/room.rb | 4 +- app/models/target.rb | 2 +- app/models/track.rb | 2 +- app/models/user.rb | 2 +- app/models/venue.rb | 5 +- app/serializers/conference_serializer.rb | 66 +- app/views/admin/cfps/_form.html.haml | 11 + app/views/admin/cfps/show.html.haml | 58 ++ .../admin/comments/_all_comments.html.haml | 2 +- .../admin/comments/_posted_comments.html.haml | 2 +- .../admin/comments/_unread_comments.html.haml | 2 +- .../conference/_recent_submissions.html.haml | 4 +- .../admin/conference/_todo_list.html.haml | 20 +- app/views/admin/conference/edit.html.haml | 3 +- .../admin/difficulty_levels/_form.html.haml | 2 +- .../admin/difficulty_levels/index.html.haml | 10 +- app/views/admin/emails/_help.html.haml | 4 +- app/views/admin/emails/index.html.haml | 16 +- app/views/admin/event_types/_form.html.haml | 2 +- app/views/admin/event_types/index.html.haml | 8 +- .../events/_change_state_dropdown.html.haml | 16 +- .../admin/events/_nested_comments.html.haml | 2 +- app/views/admin/events/_proposal.html.haml | 16 +- app/views/admin/events/_voting.html.haml | 14 +- app/views/admin/events/index.html.haml | 22 +- app/views/admin/programs/_form.html.haml | 12 + app/views/admin/programs/show.html.haml | 61 ++ app/views/admin/rooms/_form.html.haml | 6 +- app/views/admin/rooms/index.html.haml | 10 +- app/views/admin/tracks/_form.html.haml | 2 +- app/views/admin/tracks/index.html.haml | 10 +- app/views/admin/tracks/show.html.haml | 2 +- app/views/admin/users/_submissions.html.haml | 8 +- app/views/admin/venues/show.html.haml | 6 +- app/views/commercials/edit.html.haml | 9 + app/views/commercials/new.html.haml | 9 + app/views/conference/_all_events.html.erb | 6 +- .../conference/_call_for_paper.html.haml | 16 +- .../conference/_conference_details.html.haml | 12 +- app/views/conference/_program.html.haml | 40 + app/views/conference/_registration.html.haml | 29 +- app/views/conference/_schedule_item.html.haml | 2 +- .../conference/_schedule_splashpage.html.haml | 12 +- app/views/conference/_venue.html.haml | 3 +- app/views/conference/schedule.html.erb | 4 +- app/views/conference/show.html.haml | 13 +- .../_registration_info.html.haml | 4 +- .../conference_registrations/show.html.haml | 8 +- app/views/layouts/_admin_sidebar.html.haml | 44 +- app/views/layouts/_navigation.html.haml | 2 +- app/views/layouts/_user_menu.html.haml | 4 +- app/views/layouts/application.html.haml | 2 +- app/views/layouts/schedule.html.haml | 2 +- .../proposal/_encouragement_text.html.haml | 14 +- app/views/proposal/_form.html.haml | 8 +- app/views/proposal/_proposal_form.html.haml | 12 +- app/views/proposal/_tooltip.html.haml | 17 +- app/views/proposal/index.html.haml | 16 +- app/views/proposal/new.html.haml | 6 +- app/views/proposal/show.html.haml | 4 +- app/views/users/show.html.haml | 4 +- bin/rspec | 7 + bin/spring | 18 + config/environments/test.rb | 1 + config/routes.rb | 61 +- .../20151018152439_create_programs_table.rb | 76 ++ ...m_id_in_events_tracks_difficulty_levels.rb | 99 +++ ...ame_email_settings_with_cfp_and_program.rb | 10 + ...ange_conference_id_to_venue_id_in_rooms.rb | 56 ++ ...1_add_registration_limit_to_conferences.rb | 5 + db/schema.rb | 62 +- public/javascripts/schedule/schedule.js | 2 +- .../admin/comments_controller_spec.rb | 4 +- .../admin/conferences_controller_spec.rb | 7 +- .../admin/programs_controller_spec.rb | 33 + .../registration_periods_controller_spec.rb | 2 +- spec/factories/cfps.rb | 9 + spec/factories/conferences.rb | 23 +- spec/factories/difficulty_levels.rb | 3 +- spec/factories/email_settings.rb | 12 +- spec/factories/event_types.rb | 2 +- spec/factories/events.rb | 13 +- spec/factories/programs.rb | 9 + spec/factories/rooms.rb | 2 +- spec/factories/tracks.rb | 2 +- spec/factories/venues.rb | 1 + spec/features/ability_spec.rb | 69 +- spec/features/cfp_spec.rb | 27 +- spec/features/commercials_spec.rb | 10 +- spec/features/difficulty_levels_spec.rb | 6 +- spec/features/event_types_spec.rb | 2 +- spec/features/omniauth_spec.rb | 2 +- spec/features/program_spec.rb | 30 + spec/features/proposal_spec.rb | 26 +- spec/features/registration_periods_spec.rb | 4 +- spec/features/rooms_spec.rb | 7 +- spec/features/tickets_spec.rb | 6 +- spec/features/tracks_spec.rb | 10 +- spec/models/ability_spec.rb | 147 ++-- spec/models/cfp_spec.rb | 90 ++- spec/models/conference_spec.rb | 451 +++++++----- spec/models/program_spec.rb | 61 ++ spec/models/registration_period_spec.rb | 74 ++ spec/models/registration_spec.rb | 25 + spec/models/target_spec.rb | 8 +- spec/models/ticket_spec.rb | 8 +- spec/views/admin/cfps/show.html.haml_spec.rb | 17 + .../admin/conference/show.html.haml_spec.rb | 1 + .../difficulty_levels/index.html.haml_spec.rb | 5 +- .../admin/event_types/index.html.haml_spec.rb | 5 +- .../admin/events/index.html.haml_spec.rb | 14 +- .../admin/programs/show.html.haml_spec.rb | 16 + .../views/admin/rooms/index.html.haml_spec.rb | 8 +- .../admin/tracks/index.html.haml_spec.rb | 6 +- spec/views/conference/show.html.haml_spec.rb | 3 +- 156 files changed, 3203 insertions(+), 1206 deletions(-) create mode 100644 app/assets/javascripts/osem-dashboard.js create mode 100644 app/controllers/admin/cfps_controller.rb create mode 100644 app/controllers/admin/programs_controller.rb create mode 100644 app/models/ahoy/program.rb create mode 100644 app/models/cfp.rb create mode 100644 app/models/program.rb create mode 100644 app/views/admin/cfps/_form.html.haml create mode 100644 app/views/admin/cfps/show.html.haml create mode 100644 app/views/admin/programs/_form.html.haml create mode 100644 app/views/admin/programs/show.html.haml create mode 100644 app/views/commercials/edit.html.haml create mode 100644 app/views/commercials/new.html.haml create mode 100644 app/views/conference/_program.html.haml create mode 100644 bin/rspec create mode 100644 bin/spring create mode 100644 db/migrate/20151018152439_create_programs_table.rb create mode 100644 db/migrate/20151018154513_rename_conference_id_to_program_id_in_events_tracks_difficulty_levels.rb create mode 100644 db/migrate/20151021113015_rename_email_settings_with_cfp_and_program.rb create mode 100644 db/migrate/20151031092713_change_conference_id_to_venue_id_in_rooms.rb create mode 100644 db/migrate/20160201221411_add_registration_limit_to_conferences.rb create mode 100644 spec/controllers/admin/programs_controller_spec.rb create mode 100644 spec/factories/cfps.rb create mode 100644 spec/factories/programs.rb create mode 100644 spec/features/program_spec.rb create mode 100644 spec/models/program_spec.rb create mode 100644 spec/models/registration_period_spec.rb create mode 100644 spec/models/registration_spec.rb create mode 100644 spec/views/admin/cfps/show.html.haml_spec.rb create mode 100644 spec/views/admin/programs/show.html.haml_spec.rb diff --git a/.rubocop.yml b/.rubocop.yml index a7e5fc01..512bef00 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -1,3 +1,5 @@ +Rails: + Enabled: true inherit_from: .rubocop_todo.yml Style/HashSyntax: @@ -24,10 +26,6 @@ Style/EmptyLines: Style/EmptyLinesAroundAccessModifier: Enabled: true -# Do not insert empty line after class definition and before closing class -Style/EmptyLinesAroundBody: - Enabled: true - # Use hash literal {} instead of Hash.new Style/EmptyLiteral: Enabled: true @@ -93,12 +91,11 @@ Style/AndOr: Enabled: true # avoid deep blocks nesting -Style/BlockNesting: +Metrics/BlockNesting: Max: 4 -# use do instead of {...} in multiline blocks -Style/Blocks: - Enabled: true +Metrics/ClassLength: + Max: 550 # avoid redundunt curly braces when it is obvious that hash is used Style/BracesAroundHashParameters: @@ -129,3 +126,4 @@ AllCops: - 'vendor/bundle/**/*' - 'bundle/**/*' - 'config/**/*' + - 'bin/*' diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 9624f5f8..a42515c3 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -1,137 +1,471 @@ -# This configuration was generated by `rubocop --auto-gen-config` -# on 2014-07-21 12:48:09 +0200 using RuboCop version 0.24.1. +# This configuration was generated by +# `rubocop --auto-gen-config` +# on 2016-02-08 14:42:45 +0100 using RuboCop version 0.37.0. # The point is for the user to remove these configuration records # one by one as the offenses are removed from the code base. # Note that changes in the inspected code, or installation of new # versions of RuboCop, may require this file to be generated again. -# Offense count: 3 +# Offense count: 2 +Lint/DuplicatedKey: + Exclude: + - 'db/migrate/20140801164901_move_conference_media_to_commercial.rb' + - 'db/migrate/20140801170430_move_event_media_to_commercial.rb' + +# Offense count: 4 +Lint/IneffectiveAccessModifier: + Exclude: + - 'app/models/commercial.rb' + - 'app/models/conference.rb' + +# Offense count: 84 +Metrics/AbcSize: + Max: 75 + +# Offense count: 12 +Metrics/CyclomaticComplexity: + Max: 12 + +# Offense count: 956 +# Configuration parameters: AllowHeredoc, AllowURI, URISchemes. +# URISchemes: http, https +Metrics/LineLength: + Max: 208 + +# Offense count: 100 +# Configuration parameters: CountComments. +Metrics/MethodLength: + Max: 56 + +# Offense count: 1 +# Configuration parameters: CountComments. +Metrics/ModuleLength: + Max: 256 + +# Offense count: 7 +Metrics/PerceivedComplexity: + Max: 15 + +# Offense count: 1 # Cop supports --auto-correct. +Performance/StringReplacement: + Exclude: + - 'spec/support/save_feature_failures.rb' + +# Offense count: 13 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle, SupportedStyles, Include. +# SupportedStyles: action, filter +# Include: app/controllers/**/*.rb +Rails/ActionFilter: + Exclude: + - 'app/controllers/admin/base_controller.rb' + - 'app/controllers/admin/registrations_controller.rb' + - 'app/controllers/admin/schedules_controller.rb' + - 'app/controllers/application_controller.rb' + - 'app/controllers/conference_controller.rb' + - 'app/controllers/conference_registrations_controller.rb' + - 'app/controllers/proposal_controller.rb' + - 'app/controllers/subscriptions_controller.rb' + - 'app/controllers/ticket_purchases_controller.rb' + - 'app/controllers/tickets_controller.rb' + - 'app/controllers/users/omniauth_callbacks_controller.rb' + +# Offense count: 101 # Configuration parameters: EnforcedStyle, SupportedStyles. -Style/ClassCheck: +# SupportedStyles: strict, flexible +Rails/Date: Enabled: false -# Offense count: 8 -# Configuration parameters: CountComments. -Style/ClassLength: - Max: 524 +# Offense count: 1 +# Cop supports --auto-correct. +Rails/Delegate: + Exclude: + - 'app/serializers/speaker_serializer.rb' + +# Offense count: 10 +# Cop supports --auto-correct. +# Configuration parameters: Include. +# Include: app/models/**/*.rb +Rails/FindBy: + Exclude: + - 'app/models/conference.rb' + - 'app/models/event.rb' + - 'app/models/openid.rb' + - 'app/models/ticket.rb' + - 'app/models/ticket_purchase.rb' + - 'app/models/user.rb' + +# Offense count: 1 +# Cop supports --auto-correct. +# Configuration parameters: Include. +# Include: app/models/**/*.rb +Rails/FindEach: + Exclude: + - 'app/models/conference.rb' + +# Offense count: 12 +# Configuration parameters: Include. +# Include: app/models/**/*.rb +Rails/HasAndBelongsToMany: + Exclude: + - 'app/models/conference.rb' + - 'app/models/event.rb' + - 'app/models/qanswer.rb' + - 'app/models/question.rb' + - 'app/models/registration.rb' + - 'app/models/role.rb' + - 'app/models/social_event.rb' + - 'app/models/user.rb' + - 'app/models/vchoice.rb' + +# Offense count: 10 +# Cop supports --auto-correct. +Rails/PluralizationGrammar: + Exclude: + - 'spec/models/conference_spec.rb' + +# Offense count: 47 +# Configuration parameters: EnforcedStyle, SupportedStyles. +# SupportedStyles: strict, flexible +Rails/TimeZone: + Exclude: + - 'app/helpers/application_helper.rb' + - 'app/models/comment.rb' + - 'app/models/conference.rb' + - 'spec/controllers/admin/comments_controller_spec.rb' + - 'spec/controllers/admin/programs_controller_spec.rb' + - 'spec/factories/users.rb' + - 'spec/models/campaign_spec.rb' + - 'spec/models/conference_spec.rb' + +# Offense count: 16 +# Configuration parameters: Include. +# Include: app/models/**/*.rb +Rails/Validation: + Exclude: + - 'app/models/call_for_paper.rb' + - 'app/models/comment.rb' + - 'app/models/conference.rb' + - 'app/models/photo.rb' + - 'app/models/registration.rb' + - 'app/models/sponsor.rb' + - 'app/models/sponsorship_level.rb' + - 'app/models/subscription.rb' + - 'app/models/ticket.rb' + - 'app/models/ticket_purchase.rb' + - 'app/models/vposition.rb' + +# Offense count: 18 +Style/AccessorMethodName: + Exclude: + - 'app/controllers/admin/events_controller.rb' + - 'app/controllers/application_controller.rb' + - 'app/models/campaign.rb' + - 'app/models/conference.rb' + - 'app/models/target.rb' + - 'app/models/user.rb' + +# Offense count: 4 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle, SupportedStyles. +# SupportedStyles: is_a?, kind_of? +Style/ClassCheck: + Exclude: + - 'app/helpers/application_helper.rb' + - 'app/models/email_settings.rb' + - 'app/models/revision_observer.rb' # Offense count: 1 Style/ClassVars: - Enabled: false + Exclude: + - 'spec/support/kneet_connections.rb' + +# Offense count: 6 +# Cop supports --auto-correct. +Style/ClosingParenthesisIndentation: + Exclude: + - 'app/controllers/conference_registrations_controller.rb' + - 'spec/support/omniauth_macros.rb' + - 'spec/views/admin/sponsors/index.html.haml_spec.rb' # Offense count: 2 # Cop supports --auto-correct. -# Configuration parameters: PreferredMethods. -Style/CollectionMethods: - Enabled: false +Style/ColonMethodCall: + Exclude: + - 'app/models/commercial.rb' + - 'app/models/contact.rb' # Offense count: 1 # Cop supports --auto-correct. -Style/ColonMethodCall: - Enabled: false - -# Offense count: 4 # Configuration parameters: Keywords. +# Keywords: TODO, FIXME, OPTIMIZE, HACK, REVIEW Style/CommentAnnotation: - Enabled: false + Exclude: + - 'app/models/event_user.rb' -# Offense count: 4 +# Offense count: 17 # Cop supports --auto-correct. Style/CommentIndentation: - Enabled: false + Exclude: + - 'app/controllers/admin/comments_controller.rb' + - 'app/controllers/admin/difficulty_levels_controller.rb' + - 'app/controllers/admin/programs_controller.rb' + - 'app/models/ahoy/program.rb' + - 'app/models/conference.rb' + - 'app/models/program.rb' + - 'app/models/track.rb' + - 'spec/features/volunteers_spec.rb' -# Offense count: 10 -Style/CyclomaticComplexity: - Max: 16 - -# Offense count: 5 +# Offense count: 7 # Cop supports --auto-correct. -Style/DeprecatedHashMethods: - Enabled: false +# Configuration parameters: SingleLineConditionsOnly. +Style/ConditionalAssignment: + Exclude: + - 'app/controllers/admin/schedules_controller.rb' + - 'app/controllers/admin/volunteers_controller.rb' + - 'app/controllers/conference_controller.rb' + - 'app/controllers/conference_registrations_controller.rb' + - 'app/controllers/admin/conference_controller.rb' + - 'app/helpers/application_helper.rb' + - 'app/models/ticket_purchase.rb' + - 'app/models/conference.rb' + - 'db/migrate/20140610165551_migrate_data_person_to_user.rb' + - 'db/migrate/20140820124117_undo_wrong_migration20140801080705_add_users_to_events.rb' -# Offense count: 228 +# Offense count: 366 Style/Documentation: Enabled: false -# Offense count: 150 +# Offense count: 74 +# Cop supports --auto-correct. # Configuration parameters: EnforcedStyle, SupportedStyles. +# SupportedStyles: leading, trailing Style/DotPosition: Enabled: false -# Offense count: 9 +# Offense count: 5 Style/DoubleNegation: + Exclude: + - 'app/models/conference.rb' + +# Offense count: 1 +# Cop supports --auto-correct. +Style/ElseAlignment: + Exclude: + - 'app/helpers/application_helper.rb' + +# Offense count: 1 +# Cop supports --auto-correct. +# Configuration parameters: AllowAdjacentOneLineDefs. +Style/EmptyLineBetweenDefs: + Exclude: + - 'app/models/call_for_paper.rb' + +# Offense count: 98 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle, SupportedStyles. +# SupportedStyles: empty_lines, no_empty_lines +Style/EmptyLinesAroundBlockBody: Enabled: false # Offense count: 1 -# Configuration parameters: Exclude. -Style/FileName: +# Cop supports --auto-correct. +Style/EmptyLiteral: + Exclude: + - 'spec/models/conference_spec.rb' + +# Offense count: 17 +# Cop supports --auto-correct. +# Configuration parameters: AllowForAlignment, ForceEqualSignAlignment. +Style/ExtraSpacing: + Exclude: + - 'Guardfile' + - 'app/controllers/conference_registrations_controller.rb' + - 'app/models/conference.rb' + - 'app/models/event.rb' + - 'app/models/target.rb' + - 'app/models/ticket.rb' + - 'bin/rails' + - 'config.ru' + - 'db/migrate/20140623101032_create_ahoy_events.rb' + - 'db/migrate/20140701123203_add_events_per_week_to_conference.rb' + - 'db/migrate/20140719160903_create_delayed_jobs.rb' + - 'spec/controllers/conference_controller_spec.rb' + - 'spec/factories/splashpages.rb' + - 'spec/models/conference_spec.rb' + +# Offense count: 38 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle, SupportedStyles, IndentationWidth. +# SupportedStyles: consistent, special_for_inner_method_call, special_for_inner_method_call_in_parentheses +Style/FirstParameterIndentation: Enabled: false -# Offense count: 8 +# Offense count: 6 # Configuration parameters: MinBodyLength. Style/GuardClause: - Enabled: false + Exclude: + - 'app/helpers/application_helper.rb' + - 'app/models/commercial.rb' + - 'app/models/conference.rb' + - 'app/models/user.rb' + - 'app/models/registration.rb' + - 'app/models/ticket.rb' + - 'app/serializers/conference_serializer.rb' + - 'app/controllers/conference_registrations_controller.rb' + - 'app/controllers/tickets_controller.rb' + - 'app/controllers/admin/questions_controller.rb' -# Offense count: 27 +# Offense count: 14 +Style/IdenticalConditionalBranches: + Exclude: + - 'app/controllers/admin/campaigns_controller.rb' + - 'app/controllers/admin/difficulty_levels_controller.rb' + - 'app/controllers/admin/event_types_controller.rb' + - 'app/controllers/admin/rooms_controller.rb' + - 'app/controllers/admin/tracks_controller.rb' + - 'app/controllers/subscriptions_controller.rb' + +# Offense count: 1 +Style/IfInsideElse: + Exclude: + - 'app/helpers/application_helper.rb' + +# Offense count: 29 +# Cop supports --auto-correct. # Configuration parameters: MaxLineLength. Style/IfUnlessModifier: Enabled: false # Offense count: 2 # Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle, SupportedStyles, IndentationWidth. +# SupportedStyles: special_inside_parentheses, consistent, align_brackets Style/IndentArray: Enabled: false -# Offense count: 8 +# Offense count: 5 # Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle, SupportedStyles. +# Configuration parameters: IndentationWidth. +Style/IndentAssignment: + Exclude: + - 'app/helpers/application_helper.rb' + - 'app/models/ability.rb' + - 'app/models/conference.rb' + +# Offense count: 4 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle, SupportedStyles, IndentationWidth. +# SupportedStyles: special_inside_parentheses, consistent, align_braces Style/IndentHash: Enabled: false -# Offense count: 2 +# Offense count: 3 # Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle, SupportedStyles. +# SupportedStyles: normal, rails Style/IndentationConsistency: - Enabled: false + Exclude: + - 'app/controllers/users_controller.rb' + - 'app/models/event.rb' + - 'spec/controllers/subscriptions_controller_spec.rb' -# Offense count: 5 +# Offense count: 10 # Cop supports --auto-correct. +# Configuration parameters: Width. Style/IndentationWidth: - Enabled: false + Exclude: + - 'app/helpers/application_helper.rb' + - 'db/migrate/20140701123203_add_events_per_week_to_conference.rb' + - 'db/migrate/20141031225545_add_require_handicapped_access_to_questions.rb' + - 'db/migrate/20141031225606_add_attending_with_partner_to_questions.rb' + - 'db/migrate/20141031225620_add_staying_at_suggested_hotel_to_questions.rb' + - 'db/migrate/20141031225635_add_attending_social_events_to_questions.rb' + - 'db/migrate/20141118162030_change_lodging_association_to_conference.rb' + - 'spec/features/event_types_spec.rb' + - 'spec/models/ability_spec.rb' + - 'app/serializers/conference_serializer.rb' + +# Offense count: 1 +# Cop supports --auto-correct. +Style/InfiniteLoop: + Exclude: + - 'app/models/datatable.rb' + +# Offense count: 4 +# Cop supports --auto-correct. +Style/LeadingCommentSpace: + Exclude: + - 'Guardfile' + - 'app/models/comment.rb' + +# Offense count: 8 +# Cop supports --auto-correct. +Style/LineEndConcatenation: + Exclude: + - 'spec/features/cfp_spec.rb' + - 'spec/features/conference_spec.rb' + - 'spec/features/registration_periods_spec.rb' # Offense count: 7 # Cop supports --auto-correct. -Style/LeadingCommentSpace: - Enabled: false - -# Offense count: 5 -# Cop supports --auto-correct. -Style/LineEndConcatenation: - Enabled: false - -# Offense count: 515 -# Configuration parameters: AllowURI. -Style/LineLength: - Max: 217 - -# Offense count: 5 -# Cop supports --auto-correct. # Configuration parameters: EnforcedStyle, SupportedStyles. +# SupportedStyles: require_parentheses, require_no_parentheses, require_no_parentheses_except_multiline Style/MethodDefParentheses: Enabled: false -# Offense count: 68 -# Configuration parameters: CountComments. -Style/MethodLength: - Max: 134 - -# Offense count: 14 +# Offense count: 5 # Cop supports --auto-correct. -Style/NegatedIf: +Style/MultilineBlockLayout: + Exclude: + - 'app/serializers/conference_serializer.rb' + +# Offense count: 58 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle, SupportedStyles, IndentationWidth. +# SupportedStyles: aligned, indented +Style/MultilineMethodCallIndentation: Enabled: false -# Offense count: 18 -# Configuration parameters: EnforcedStyle, SupportedStyles. +# Offense count: 26 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle, SupportedStyles, IndentationWidth. +# SupportedStyles: aligned, indented +Style/MultilineOperationIndentation: + Enabled: false + +# Offense count: 3 +# Cop supports --auto-correct. +Style/MutableConstant: + Exclude: + - 'app/models/event_user.rb' + - 'app/models/role.rb' + +# Offense count: 16 +# Cop supports --auto-correct. +Style/NegatedIf: + Exclude: + - 'app/controllers/admin/events_controller.rb' + - 'app/controllers/application_controller.rb' + - 'app/controllers/conference_registrations_controller.rb' + - 'app/controllers/proposal_controller.rb' + - 'app/models/conference.rb' + - 'app/models/datatable.rb' + - 'app/models/event.rb' + - 'app/models/venue.rb' + - 'db/migrate/20140820093735_migrating_supporter_registrations_to_ticket_users.rb' + +# Offense count: 4 +Style/NestedParenthesizedCalls: + Exclude: + - 'spec/features/conference_spec.rb' + - 'spec/models/conference_spec.rb' + +# Offense count: 21 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle, MinBodyLength, SupportedStyles. +# SupportedStyles: skip_modifier_ifs, always Style/Next: Enabled: false @@ -140,132 +474,249 @@ Style/Next: Style/NumericLiterals: MinDigits: 15 -# Offense count: 1 +# Offense count: 3 +Style/OptionalArguments: + Exclude: + - 'app/models/event.rb' + +# Offense count: 3 # Cop supports --auto-correct. # Configuration parameters: AllowSafeAssignment. Style/ParenthesesAroundCondition: - Enabled: false + Exclude: + - 'app/controllers/admin/base_controller.rb' + - 'app/controllers/application_controller.rb' + - 'app/helpers/application_helper.rb' -# Offense count: 11 +# Offense count: 1 # Cop supports --auto-correct. # Configuration parameters: PreferredDelimiters. Style/PercentLiteralDelimiters: - Enabled: false + Exclude: + - 'app/serializers/event_serializer.rb' # Offense count: 2 -# Configuration parameters: NamePrefixBlacklist. +# Configuration parameters: NamePrefix, NamePrefixBlacklist, NameWhitelist. +# NamePrefix: is_, has_, have_ +# NamePrefixBlacklist: is_, has_, have_ +# NameWhitelist: is_a? Style/PredicateName: - Enabled: false + Exclude: + - 'app/models/comment.rb' + - 'app/models/contact.rb' -# Offense count: 3 +# Offense count: 6 # Configuration parameters: SupportedStyles. +# SupportedStyles: compact, exploded Style/RaiseArgs: EnforcedStyle: compact -# Offense count: 3 +# Offense count: 1 # Cop supports --auto-correct. Style/RedundantBegin: - Enabled: false + Exclude: + - 'app/models/revision_observer.rb' -# Offense count: 3 +# Offense count: 1 +# Cop supports --auto-correct. +Style/RedundantParentheses: + Exclude: + - 'app/controllers/admin/base_controller.rb' + +# Offense count: 4 # Cop supports --auto-correct. # Configuration parameters: AllowMultipleReturnValues. Style/RedundantReturn: - Enabled: false + Exclude: + - 'app/helpers/application_helper.rb' -# Offense count: 8 +# Offense count: 61 # Cop supports --auto-correct. Style/RedundantSelf: - Enabled: false + Exclude: + - 'app/models/ahoy/program.rb' + - 'app/models/call_for_paper.rb' + - 'app/models/cfp.rb' + - 'app/models/comment.rb' + - 'app/models/conference.rb' + - 'app/models/event.rb' + - 'app/models/program.rb' + - 'app/models/question.rb' + - 'app/models/ticket.rb' + - 'app/models/user.rb' + - 'app/models/venue.rb' -# Offense count: 10 -# Configuration parameters: MaxSlashes. +# Offense count: 2 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle, SupportedStyles, AllowInnerSlashes. +# SupportedStyles: slashes, percent_r, mixed Style/RegexpLiteral: - Enabled: false - -# Offense count: 1 -Style/SelfAssignment: - Enabled: false + Exclude: + - 'Guardfile' # Offense count: 3 # Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle, SupportedStyles. -Style/SignalException: - Enabled: false +Style/SelfAssignment: + Exclude: + - 'app/models/event.rb' + - 'db/migrate/20141104131625_generate_username.rb' + - 'spec/support/save_feature_failures.rb' # Offense count: 1 -# Configuration parameters: Methods. -Style/SingleLineBlockParams: - Enabled: false +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle, SupportedStyles. +# SupportedStyles: only_raise, only_fail, semantic +Style/SignalException: + Exclude: + - 'spec/support/flash.rb' # Offense count: 1 # Cop supports --auto-correct. # Configuration parameters: AllowIfMethodIsEmpty. Style/SingleLineMethods: - Enabled: false + Exclude: + - 'Guardfile' -# Offense count: 285 +# Offense count: 1 # Cop supports --auto-correct. -Style/SingleSpaceBeforeFirstArg: - Enabled: false - -# Offense count: 4 -# Cop supports --auto-correct. -Style/SpaceAfterComma: - Enabled: false +# Configuration parameters: EnforcedStyleInsidePipes, SupportedStyles. +# SupportedStyles: space, no_space +Style/SpaceAroundBlockParameters: + Exclude: + - 'app/helpers/application_helper.rb' # Offense count: 4 # Cop supports --auto-correct. # Configuration parameters: EnforcedStyle, SupportedStyles. +# SupportedStyles: space, no_space Style/SpaceAroundEqualsInParameterDefault: Enabled: false -# Offense count: 5 +# Offense count: 12 # Cop supports --auto-correct. +# Configuration parameters: AllowForAlignment. Style/SpaceAroundOperators: + Exclude: + - 'app/controllers/application_controller.rb' + - 'app/models/conference.rb' + - 'app/models/datatable.rb' + - 'app/models/event.rb' + - 'app/models/target.rb' + - 'app/models/ticket.rb' + - 'db/migrate/20141128073306_migrate_data_remove_column_include_cfp_in_splash_add_column_include_cfp.rb' + - 'db/migrate/20150417050953_add_url_to_commercial.rb' + - 'db/migrate/20151018152439_create_programs_table.rb' + - 'spec/models/conference_spec.rb' + +# Offense count: 223 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle, SupportedStyles. +# SupportedStyles: space, no_space +Style/SpaceBeforeBlockBraces: Enabled: false # Offense count: 2 # Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle, SupportedStyles. -Style/SpaceBeforeBlockBraces: - Enabled: false +# Configuration parameters: AllowForAlignment. +Style/SpaceBeforeFirstArg: + Exclude: + - 'app/controllers/conference_registrations_controller.rb' + - 'spec/factories/splashpages.rb' # Offense count: 1 # Cop supports --auto-correct. Style/SpaceBeforeSemicolon: - Enabled: false + Exclude: + - 'Guardfile' -# Offense count: 6 +# Offense count: 36 # Cop supports --auto-correct. # Configuration parameters: EnforcedStyle, SupportedStyles, EnforcedStyleForEmptyBraces, SpaceBeforeBlockParameters. +# SupportedStyles: space, no_space Style/SpaceInsideBlockBraces: Enabled: false -# Offense count: 4 +# Offense count: 17 # Cop supports --auto-correct. Style/SpaceInsideBrackets: - Enabled: false + Exclude: + - 'app/controllers/admin/schedules_controller.rb' + - 'app/models/conference.rb' + - 'app/models/user.rb' + - 'spec/controllers/admin/conferences_controller_spec.rb' + - 'spec/views/admin/events/index.html.haml_spec.rb' -# Offense count: 6 +# Offense count: 14 # Cop supports --auto-correct. # Configuration parameters: EnforcedStyle, EnforcedStyleForEmptyBraces, SupportedStyles. +# SupportedStyles: space, no_space Style/SpaceInsideHashLiteralBraces: Enabled: false # Offense count: 1 -Style/Tab: - Enabled: false +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle, SupportedStyles. +# SupportedStyles: space, no_space +Style/SpaceInsideStringInterpolation: + Exclude: + - 'app/models/user.rb' -# Offense count: 24 +# Offense count: 10 +# Cop supports --auto-correct. +# Configuration parameters: IgnoredMethods. +# IgnoredMethods: respond_to +Style/SymbolProc: + Exclude: + - 'app/controllers/admin/comments_controller.rb' + - 'app/controllers/admin/questions_controller.rb' + - 'app/helpers/application_helper.rb' + - 'app/models/ability.rb' + - 'db/migrate/20140730104658_migrate_roles_for_cancancan.rb' + - 'spec/controllers/admin/conferences_controller_spec.rb' + - 'spec/support/flash.rb' + +# Offense count: 23 +# Cop supports --auto-correct. +Style/Tab: + Exclude: + - 'db/migrate/20141031225545_add_require_handicapped_access_to_questions.rb' + - 'db/migrate/20141031225606_add_attending_with_partner_to_questions.rb' + - 'db/migrate/20141031225620_add_staying_at_suggested_hotel_to_questions.rb' + - 'db/migrate/20141031225635_add_attending_social_events_to_questions.rb' + - 'db/migrate/20141118162030_change_lodging_association_to_conference.rb' + - 'spec/features/campaign_spec.rb' + - 'spec/features/event_types_spec.rb' + +# Offense count: 26 +# Cop supports --auto-correct. # Configuration parameters: EnforcedStyleForMultiline, SupportedStyles. -Style/TrailingComma: - Enabled: false +# SupportedStyles: comma, consistent_comma, no_comma +Style/TrailingCommaInLiteral: + Exclude: + - 'Guardfile' + - 'app/models/target.rb' + - 'db/migrate/20140701123203_add_events_per_week_to_conference.rb' + - 'spec/controllers/admin/conferences_controller_spec.rb' + - 'spec/models/conference_spec.rb' # Offense count: 8 # Cop supports --auto-correct. -Style/WordArray: - MinSize: 5 +Style/UnneededInterpolation: + Exclude: + - 'app/controllers/admin/events_controller.rb' + - 'app/helpers/application_helper.rb' + - 'spec/controllers/admin/conferences_controller_spec.rb' + - 'spec/views/admin/volunteers/index.html.haml_spec.rb' -Style/AccessorMethodName: - Enabled: false +# Offense count: 3 +# Cop supports --auto-correct. +# Configuration parameters: SupportedStyles, WordRegex. +# SupportedStyles: percent, brackets +Style/WordArray: + EnforcedStyle: percent + MinSize: 3 + +# Offense count: 1 +Style/ZeroLengthPredicate: + Exclude: + - 'app/models/conference.rb' diff --git a/.travis.yml b/.travis.yml index 28860e03..6e213414 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,16 +1,19 @@ language: ruby +cache: bundler rvm: - 2.1.1 before_install: - "echo 'gem: --no-ri --no-rdoc' > ~/.gemrc" - "echo `phantomjs -v`" -branches: - only: - - master notifications: email: on_success: change on_failure: change + irc: + channels: + - "chat.freenode.net#osem" + on_success: change + on_failure: change before_script: - cp config/database.yml.example config/database.yml - cp config/config.yml.example config/config.yml diff --git a/Gemfile b/Gemfile index 9ce2873c..1b6f1b60 100644 --- a/Gemfile +++ b/Gemfile @@ -1,7 +1,11 @@ source 'https://rubygems.org' # as web framework -gem 'rails', '~> 4.1' +gem 'rails', '~> 4.2' + +# respond_to methods have been extracted to the responders gem +# http://edgeguides.rubyonrails.org/upgrading_ruby_on_rails.html#responders +gem 'responders', '~> 2.0' # as the database for Active Record gem 'mysql2' @@ -49,20 +53,44 @@ gem 'bootstrap-sass', '~> 3.3.4.1' gem 'autoprefixer-rails' gem 'formtastic-bootstrap' gem 'formtastic', '~> 2.3.0.rc3' -gem 'momentjs-rails', '>= 2.8.1' -gem 'bootstrap3-datetimepicker-rails', '~> 3.0.2' +gem 'cocoon' + +# frontend javascripts # as the JavaScript library gem 'jquery-rails' -gem 'cocoon' + +source 'https://rails-assets.org' do + # for placeholder images + gem 'rails-assets-holderjs' + # for formating dates + gem 'rails-assets-date.format' + # for or parsing, validating, manipulating, and formatting dates. + gem 'rails-assets-momentjs' + # for smooth scrolling + gem 'rails-assets-jquery-smooth-scroll' + # as color picker + gem 'rails-assets-spectrum' + # for color manipulation + gem 'rails-assets-tinycolor' + # for drawing triangle backgrounds + gem 'rails-assets-trianglify' + # for scroll way points + gem 'rails-assets-waypoints' + # for displaying maps + gem 'rails-assets-leaflet' +end + +# as date picker +gem 'bootstrap3-datetimepicker-rails', '~> 3.0.2' gem 'jquery-datatables-rails', '~> 2.2.1' +# for charts +gem 'd3_rails' +gem 'chart-js-rails' # for user avatars gem 'gravtastic' -# for maps -gem 'leaflet-rails', '~> 0.7.4' - # for country selects gem 'country_select', github: 'stefanpenner/country_select' @@ -75,10 +103,6 @@ gem 'prawn_rails' # to render XLS spreadsheets gem 'axlsx_rails' -# for charts -gem 'd3_rails' -gem 'chart-js-rails' - # as error catcher gem 'hoptoad_notifier', '~> 2.3' @@ -121,6 +145,7 @@ gem 'acts_as_list' # for switch checkboxes gem 'bootstrap-switch-rails', '~> 3.0.0' +# for parsing OEmbed data gem 'ruby-oembed' # Use guard and spring for testing in development @@ -138,6 +163,7 @@ group :development do gem 'letter_opener' # mina is a blazing fast deployment system gem 'mina' + gem 'web-console', '~> 2.0' end # Use rspec and capybara as testing framework diff --git a/Gemfile.lock b/Gemfile.lock index 63921579..ef40e3bf 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -7,36 +7,46 @@ GIT GEM remote: https://rubygems.org/ + remote: https://rails-assets.org/ specs: - actionmailer (4.1.14) - actionpack (= 4.1.14) - actionview (= 4.1.14) + actionmailer (4.2.5.1) + actionpack (= 4.2.5.1) + actionview (= 4.2.5.1) + activejob (= 4.2.5.1) mail (~> 2.5, >= 2.5.4) - actionpack (4.1.14) - actionview (= 4.1.14) - activesupport (= 4.1.14) - rack (~> 1.5.2) + rails-dom-testing (~> 1.0, >= 1.0.5) + actionpack (4.2.5.1) + actionview (= 4.2.5.1) + activesupport (= 4.2.5.1) + rack (~> 1.6) rack-test (~> 0.6.2) - actionview (4.1.14) - activesupport (= 4.1.14) + rails-dom-testing (~> 1.0, >= 1.0.5) + rails-html-sanitizer (~> 1.0, >= 1.0.2) + actionview (4.2.5.1) + activesupport (= 4.2.5.1) builder (~> 3.1) erubis (~> 2.7.0) + rails-dom-testing (~> 1.0, >= 1.0.5) + rails-html-sanitizer (~> 1.0, >= 1.0.2) active_model_serializers (0.8.1) activemodel (>= 3.0) - activemodel (4.1.14) - activesupport (= 4.1.14) + activejob (4.2.5.1) + activesupport (= 4.2.5.1) + globalid (>= 0.3.0) + activemodel (4.2.5.1) + activesupport (= 4.2.5.1) builder (~> 3.1) - activerecord (4.1.14) - activemodel (= 4.1.14) - activesupport (= 4.1.14) - arel (~> 5.0.0) - activesupport (4.1.14) - i18n (~> 0.6, >= 0.6.9) + activerecord (4.2.5.1) + activemodel (= 4.2.5.1) + activesupport (= 4.2.5.1) + arel (~> 6.0) + activesupport (4.2.5.1) + i18n (~> 0.7) json (~> 1.7, >= 1.7.7) minitest (~> 5.1) - thread_safe (~> 0.1) + thread_safe (~> 0.3, >= 0.3.4) tzinfo (~> 1.1) - activeuuid (0.5.0) + activeuuid (0.6.1) activerecord (>= 3.1) uuidtools acts_as_commentable_with_threading (1.2.0) @@ -54,8 +64,8 @@ GEM request_store user_agent_parser uuidtools - arel (5.0.1.20140414130214) - ast (2.0.0) + arel (6.0.3) + ast (2.2.0) autoprefixer-rails (5.1.9) execjs json @@ -69,6 +79,8 @@ GEM axlsx (>= 2.0.1) rails (>= 3.1) bcrypt (3.1.10) + binding_of_caller (0.7.2) + debug_inspector (>= 0.0.1) bootstrap-sass (3.3.4.1) autoprefixer-rails (>= 5.0.0.1) sass (>= 3.2.19) @@ -102,13 +114,13 @@ GEM climate_control (>= 0.0.3, < 1.0) cocoon (1.2.6) coderay (1.1.0) - coffee-rails (4.0.1) + coffee-rails (4.1.1) coffee-script (>= 2.2.0) - railties (>= 4.0.0, < 5.0) - coffee-script (2.2.0) + railties (>= 4.0.0, < 5.1.x) + coffee-script (2.4.1) coffee-script-source execjs - coffee-script-source (1.7.0) + coffee-script-source (1.10.0) columnize (0.8.9) countries (0.9.3) currencies (~> 0.4.2) @@ -123,13 +135,14 @@ GEM railties (>= 3.1.0) daemons (1.1.9) database_cleaner (1.3.0) + debug_inspector (0.0.2) debugger-linecache (1.2.0) - delayed_job (4.0.2) - activesupport (>= 3.0, < 4.2) - delayed_job_active_record (4.0.1) - activerecord (>= 3.0, < 4.2) - delayed_job (>= 3.0, < 4.1) - devise (3.5.4) + delayed_job (4.1.1) + activesupport (>= 3.0, < 5.0) + delayed_job_active_record (4.1.0) + activerecord (>= 3.0, < 5) + delayed_job (>= 3.0, < 5) + devise (3.5.5) bcrypt (~> 3.0) orm_adapter (~> 0.1) railties (>= 3.2.6, < 5) @@ -141,11 +154,11 @@ GEM diff-lcs (1.2.5) docile (1.1.3) erubis (2.7.0) - execjs (2.5.2) - factory_girl (4.4.0) + execjs (2.6.0) + factory_girl (4.5.0) activesupport (>= 3.0.0) - factory_girl_rails (4.4.1) - factory_girl (~> 4.4.0) + factory_girl_rails (4.6.0) + factory_girl (~> 4.5.0) railties (>= 3.0.0) faraday (0.9.0) multipart-post (>= 1.2, < 3) @@ -158,6 +171,8 @@ GEM formtastic-bootstrap (3.0.0) formtastic (>= 2.2) geocoder (1.2.2) + globalid (0.3.6) + activesupport (>= 4.1.0) gravtastic (3.2.6) guard (2.6.0) formatador (>= 0.2.4) @@ -181,7 +196,7 @@ GEM activesupport builder htmlentities (4.3.1) - i18n (0.6.11) + i18n (0.7.0) inversion (0.12.3) loggability (~> 0.4) jquery-datatables-rails (2.2.3) @@ -194,7 +209,6 @@ GEM jwt (1.0.0) launchy (2.4.2) addressable (~> 2.3) - leaflet-rails (0.7.4) letter_opener (1.2.0) launchy (~> 2.2) listen (2.7.2) @@ -203,36 +217,39 @@ GEM rb-fsevent (>= 0.9.3) rb-inotify (>= 0.9) loggability (0.11.0) + loofah (2.0.3) + nokogiri (>= 1.5.9) lumberjack (1.0.5) mail (2.6.3) mime-types (>= 1.16, < 3) method_source (0.8.2) mime-types (2.99) mimemagic (0.3.0) - mina (0.3.0) - open4 + mina (0.3.8) + open4 (~> 1.3.4) rake - mini_portile (0.6.0) - minitest (5.8.3) + mini_portile2 (2.0.0) + minitest (5.8.4) momentjs-rails (2.8.1) railties (>= 3.1) - monetize (0.3.0) - money (~> 6.1.0.beta1) - money (6.1.1) - i18n (~> 0.6.4) - money-rails (0.12.0) + monetize (1.4.0) + money (~> 6.7) + money (6.7.0) + i18n (>= 0.6.4, <= 0.7.0) + sixarm_ruby_unaccent (>= 1.1.1, < 2) + money-rails (1.6.0) activesupport (>= 3.0) - monetize (~> 0.3.0) - money (~> 6.1.1) + monetize (~> 1.4.0) + money (~> 6.7) railties (>= 3.0) multi_json (1.11.2) multi_xml (0.5.5) multipart-post (2.0.0) - mysql2 (0.3.16) + mysql2 (0.4.2) netrc (0.10.3) nio4r (1.1.0) - nokogiri (1.6.2.1) - mini_portile (= 0.6.0) + nokogiri (1.6.7.2) + mini_portile2 (~> 2.0.0.rc2) oauth2 (0.9.4) faraday (>= 0.8, < 0.10) jwt (~> 1.0) @@ -258,7 +275,7 @@ GEM omniauth-openid (1.0.1) omniauth (~> 1.0) rack-openid (~> 1.3.1) - open4 (1.3.3) + open4 (1.3.4) orm_adapter (0.5.0) paper_trail (3.0.1) activerecord (>= 3.0, < 5.0) @@ -269,9 +286,8 @@ GEM cocaine (~> 0.5.5) mime-types mimemagic (= 0.3.0) - parser (2.2.0.pre.3) - ast (>= 1.1, < 3.0) - slop (~> 3.4, >= 3.4.5) + parser (2.3.0.3) + ast (~> 2.2) pdf-core (0.2.5) phantomjs (1.9.7.1) piwik_analytics (1.0.2) @@ -283,7 +299,7 @@ GEM cliver (~> 0.3.1) multi_json (~> 1.0) websocket-driver (>= 0.2.0) - powerpack (0.0.9) + powerpack (0.1.1) prawn (1.0.0) pdf-core (~> 0.2.2) ttfunk (~> 1.1.1) @@ -296,30 +312,51 @@ GEM slop (~> 3.4) quiet_assets (1.0.2) railties (>= 3.1, < 5.0) - rack (1.5.5) + rack (1.6.4) rack-openid (1.3.1) rack (>= 1.1.0) ruby-openid (>= 2.1.8) rack-test (0.6.3) rack (>= 1.0) - rails (4.1.14) - actionmailer (= 4.1.14) - actionpack (= 4.1.14) - actionview (= 4.1.14) - activemodel (= 4.1.14) - activerecord (= 4.1.14) - activesupport (= 4.1.14) + rails (4.2.5.1) + actionmailer (= 4.2.5.1) + actionpack (= 4.2.5.1) + actionview (= 4.2.5.1) + activejob (= 4.2.5.1) + activemodel (= 4.2.5.1) + activerecord (= 4.2.5.1) + activesupport (= 4.2.5.1) bundler (>= 1.3.0, < 2.0) - railties (= 4.1.14) - sprockets-rails (~> 2.0) + railties (= 4.2.5.1) + sprockets-rails + rails-assets-date.format (1.2.3) + rails-assets-holderjs (2.9.1) + rails-assets-jquery (2.2.0) + rails-assets-jquery-smooth-scroll (1.7.2) + rails-assets-jquery (>= 1.4.2) + rails-assets-leaflet (0.7.7) + rails-assets-momentjs (2.11.2) + rails-assets-spectrum (1.8.0) + rails-assets-jquery (>= 1.7.2) + rails-assets-tinycolor (1.3.0) + rails-assets-trianglify (0.4.0) + rails-assets-waypoints (4.0.0) + rails-deprecated_sanitizer (1.0.3) + activesupport (>= 4.2.0.alpha) + rails-dom-testing (1.0.7) + activesupport (>= 4.2.0.beta, < 5.0) + nokogiri (~> 1.6.0) + rails-deprecated_sanitizer (>= 1.0.1) + rails-html-sanitizer (1.0.3) + loofah (~> 2.0) rails-observers (0.1.2) activemodel (~> 4.0) - railties (4.1.14) - actionpack (= 4.1.14) - activesupport (= 4.1.14) + railties (4.2.5.1) + actionpack (= 4.2.5.1) + activesupport (= 4.2.5.1) rake (>= 0.8.7) thor (>= 0.18.1, < 2.0) - rainbow (2.0.0) + rainbow (2.1.0) rake (10.5.0) rb-fsevent (0.9.4) rb-inotify (0.9.4) @@ -334,8 +371,8 @@ GEM redcarpet (3.2.3) referer-parser (0.2.1) request_store (1.0.6) - responders (1.1.2) - railties (>= 3.2, < 4.2) + responders (2.1.1) + railties (>= 4.2.0, < 5.1) rest-client (1.7.3) mime-types (>= 1.16, < 3.0) netrc (~> 0.7) @@ -364,15 +401,15 @@ GEM rspec-mocks (~> 3.0.0) rspec-support (~> 3.0.0) rspec-support (3.0.2) - rubocop (0.24.1) - json (>= 1.7.7, < 2) - parser (>= 2.2.0.pre.3, < 3.0) - powerpack (~> 0.0.6) + rubocop (0.37.0) + parser (>= 2.3.0.2, < 3.0) + powerpack (~> 0.1) rainbow (>= 1.99.1, < 3.0) - ruby-progressbar (~> 1.4) + ruby-progressbar (~> 1.7) + unicode-display_width (~> 0.3) ruby-oembed (0.8.14) ruby-openid (2.5.0) - ruby-progressbar (1.5.1) + ruby-progressbar (1.7.5) rubyzip (1.0.0) sass (3.2.19) sass-rails (4.0.4) @@ -387,9 +424,10 @@ GEM multi_json simplecov-html (~> 0.8.0) simplecov-html (0.8.0) + sixarm_ruby_unaccent (1.1.1) slop (3.6.0) - spring (1.1.2) - spring-commands-rspec (1.0.2) + spring (1.6.3) + spring-commands-rspec (1.0.4) spring (>= 0.9.1) sprockets (2.11.3) hike (~> 1.2) @@ -411,17 +449,23 @@ GEM tins (1.1.0) transitions (0.1.12) ttfunk (1.1.1) - turbolinks (2.2.2) + turbolinks (2.5.3) coffee-rails tzinfo (1.2.2) thread_safe (~> 0.1) uglifier (2.5.0) execjs (>= 0.3.0) json (>= 1.8.0) + unicode-display_width (0.3.1) user_agent_parser (2.1.5) - uuidtools (2.1.4) + uuidtools (2.1.5) warden (1.2.4) rack (>= 1.0) + web-console (2.2.1) + activemodel (>= 4.0) + binding_of_caller (>= 0.7.2) + railties (>= 4.0) + sprockets-rails (>= 2.0, < 4.0) websocket-driver (0.3.3) whenever (0.9.2) activesupport (>= 2.3.4) @@ -468,10 +512,8 @@ DEPENDENCIES hoptoad_notifier (~> 2.3) jquery-datatables-rails (~> 2.2.1) jquery-rails - leaflet-rails (~> 0.7.4) letter_opener mina - momentjs-rails (>= 2.8.1) money-rails mysql2 omniauth @@ -486,10 +528,20 @@ DEPENDENCIES poltergeist prawn_rails quiet_assets - rails (~> 4.1) + rails (~> 4.2) + rails-assets-date.format! + rails-assets-holderjs! + rails-assets-jquery-smooth-scroll! + rails-assets-leaflet! + rails-assets-momentjs! + rails-assets-spectrum! + rails-assets-tinycolor! + rails-assets-trianglify! + rails-assets-waypoints! rails-observers rdoc-generator-fivefish redcarpet + responders (~> 2.0) rolify rspec-activemodel-mocks rspec-rails @@ -503,7 +555,8 @@ DEPENDENCIES transitions turbolinks uglifier (>= 1.3.0) + web-console (~> 2.0) whenever BUNDLED WITH - 1.10.6 + 1.11.2 diff --git a/INSTALL.md b/INSTALL.md index 7ef120ac..a44ac3a6 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -29,7 +29,7 @@ We are using [Vagrant](https://www.vagrantup.com/) to create our development env 7. Start your OSEM rails app: ``` - vagrant exec rails s + vagrant exec rails server -b 0.0.0.0 ``` 8. Check out your OSEM rails app: diff --git a/app/assets/javascripts/application.js b/app/assets/javascripts/application.js index 6c6c8e9a..7cac4c52 100644 --- a/app/assets/javascripts/application.js +++ b/app/assets/javascripts/application.js @@ -12,7 +12,7 @@ // //= require jquery //= require jquery_ujs -//= require waypoints +//= require waypoints/jquery.waypoints //= require dataTables/jquery.dataTables //= require dataTables/bootstrap/3/jquery.dataTables.bootstrap //= require cocoon @@ -20,15 +20,15 @@ //= require Chart //= require d3 //= require osem -//= require dashboard +//= require osem-dashboard //= require ahoy -//= require smoothscroll -//= require trianglify.min +//= require jquery-smooth-scroll +//= require trianglify //= require tinycolor //= require bootstrap-markdown //= require to-markdown //= require markdown -//= require moment +//= require momentjs //= require leaflet //= require bootstrap-datetimepicker //= require osem-datepickers @@ -43,4 +43,8 @@ $(document).ready(function() { $('a[disabled=disabled]').click(function(event){ return false; }); + + $('body').smoothScroll({ + delegateSelector: 'a.smoothscroll' + }); }); diff --git a/app/assets/javascripts/osem-dashboard.js b/app/assets/javascripts/osem-dashboard.js new file mode 100644 index 00000000..c8d5b853 --- /dev/null +++ b/app/assets/javascripts/osem-dashboard.js @@ -0,0 +1,130 @@ +$(function() { + var t; + function size(animate){ + if (animate == undefined){ + animate = false; + } + clearTimeout(t); + t = setTimeout(function(){ + $("canvas").each(function(i,el){ + $(el).attr({ + "width":$(el).parent().width() + }); + }); + + $(".line_chart").each(function(){ + draw_line_chart(animate, $(this)); + }); + + $(".doughnut_chart").each(function(){ + if($(this).is(":visible")){ + draw_doughnut_chart(animate, $(this)); + } + }); + + }, 30); + } + + function draw_doughnut_chart(animation, $this){ + var options = get_animation({}, animation); + var tmp = $this.data('chart'); + + if(jQuery.isEmptyObject(tmp)){ + // Append error message if there is no data + $this.parent().append("

No data!

"); + // Remove canvas + $this.remove(); + }else{ + var data = []; + for (var key in tmp) { + data.push(tmp[key]); + } + + var ctx = $this.get(0).getContext("2d"); + new Chart(ctx).Doughnut(data, options); + } + } + + function get_animation(options, animation){ + if (!animation){ + options.animation = false; + } else { + options.animation = true; + } + return options; + } + + function draw_line_chart(animation, $canvas){ + var options = get_animation({}, animation); + var chart_data = create_dataset($canvas); + var weeks = $canvas.parent().data('weeks'); + var data = { + labels : weeks, + datasets : chart_data + } + + var ctx = $canvas.get(0).getContext("2d"); + new Chart(ctx).Line(data, options); + } + + function create_dataset($canvas){ + var selected = getSelectedConferences($canvas); + var chart_data = $canvas.parent().data('chart'); + var conferences = $canvas.parent().data('conferences'); + var result = []; + + for(var i in conferences){ + if(selected.indexOf(conferences[i].short_title) >= 0){ + var options = {}; + options.fillColor = "rgba(255,255,255,0.0)"; + options.strokeColor = conferences[i].color; + options.data = chart_data[conferences[i].short_title]; + if(options.data == null || options.data.length == 0){ + options.data = [0]; + } + result.push(options) + } + } + return result + } + + function getSelectedConferences($canvas){ + var name = $canvas.data('name'); + var id = '#' + name + 'Checkboxes' + var selected = []; + var $checkboxes = $(id + ' input'); + // If there are checkboxes -> get selected + // Else -> use the active conference + if($checkboxes.length){ + $(id + ' input').each(function(){ + if($(this).is(":checked")) { + selected.push($(this).attr('name')); + } + }); + }else{ + var active = $canvas.parent().data('active'); + for(i in active){ + selected.push(active[i].short_title) + } + } + return selected; + } + + $('.conferenceCheckboxes input').change(function(){ + var chart_name = $(this).parent().data('chart'); + var $canvas = $('#line_chart_' + chart_name); + draw_line_chart(false, $canvas); + }); + + $(window).on('resize', function(){ + size(false); + }); + + $('#doughnut_tabs a').click(function (e) { + e.preventDefault(); + $(this).tab('show'); + size(false); + }); + + size(true); +}); diff --git a/app/controllers/admin/cfps_controller.rb b/app/controllers/admin/cfps_controller.rb new file mode 100644 index 00000000..76d2f63a --- /dev/null +++ b/app/controllers/admin/cfps_controller.rb @@ -0,0 +1,58 @@ +module Admin + class CfpsController < Admin::BaseController + load_and_authorize_resource :conference, find_by: :short_title + load_and_authorize_resource :program, through: :conference, singleton: true + load_and_authorize_resource through: :program, singleton: true + + def show; end + + def new + @cfp = @program.build_cfp + end + + def edit; end + + def create + @cfp = @program.build_cfp(cfp_params) + + if @cfp.save + redirect_to admin_conference_program_cfp_path, + notice: 'Call for papers successfully created.' + else + flash[:error] = "Creating the call for papers failed. #{@cfp.errors.full_messages.join('. ')}." + render :new + end + end + + def update + @cfp = @program.cfp + @cfp.assign_attributes(cfp_params) + + send_mail_on_cfp_dates_updates = @cfp.notify_on_cfp_date_update? + + if @cfp.update_attributes(cfp_params) + Mailbot.delay.send_on_cfps_dates_updates(@conference) if send_mail_on_cfp_dates_updates + redirect_to(admin_conference_program_cfp_path(@conference.short_title), + notice: 'Call for papers successfully updated.') + else + flash[:error] = "Updating call for papers failed. #{@cfp.errors.to_a.join('. ')}." + render :new + end + end + + def destroy + if @cfp.destroy + redirect_to admin_conference_program_cfp_path, notice: 'Call for Papers was successfully deleted.' + else + redirect_to admin_conference_program_cfp_path, error: 'An error prohibited this Call for Papers from being destroyed: '\ + "#{@cfp.errors.full_messages.join('. ')}." + end + end + + private + + def cfp_params + params.require(:cfp).permit(:start_date, :end_date) + end + end +end diff --git a/app/controllers/admin/comments_controller.rb b/app/controllers/admin/comments_controller.rb index 874439df..cb57464d 100644 --- a/app/controllers/admin/comments_controller.rb +++ b/app/controllers/admin/comments_controller.rb @@ -22,7 +22,7 @@ module Admin # Grouping all comments by conference, and by event. It returns {:conference => {:event => [{comment_2}, {comment_1 }]}} def grouped_comments(remarks) - remarks.group_by{ |comment| comment.commentable.conference }.map {|conference, comments| [conference, comments.group_by{|comment| comment.commentable}]}.to_h + remarks.group_by{ |comment| comment.commentable.program.conference }.map {|conference, comments| [conference, comments.group_by{|comment| comment.commentable}]}.to_h end end end diff --git a/app/controllers/admin/conference_controller.rb b/app/controllers/admin/conference_controller.rb index abaaae38..4ef6b883 100644 --- a/app/controllers/admin/conference_controller.rb +++ b/app/controllers/admin/conference_controller.rb @@ -1,6 +1,7 @@ module Admin class ConferenceController < Admin::BaseController load_and_authorize_resource :conference, find_by: :short_title + load_resource :program, through: :conference, singleton: true, except: :index load_resource :user, only: [:remove_user] def index @@ -94,14 +95,17 @@ module Admin end def show - @conference = Conference.find_by(short_title: params[:id]) + @program = @conference.program + unless @conference.program + @program = Program.new(conference_id: @conference.id) + end # Overview and since last login information @total_reg = @conference.registrations.count @new_reg = @conference.registrations.where('created_at > ?', current_user.last_sign_in_at).count - @total_submissions = @conference.events.count - @new_submissions = @conference.events. + @total_submissions = @program.events.count + @new_submissions = @program.events. where('created_at > ?', current_user.last_sign_in_at).count @program_length = @conference.current_program_hours @@ -141,7 +145,7 @@ module Admin @tracks_distribution_confirmed = @conference.tracks_distribution(:confirmed) # Recent actions information - @recent_events = @conference.events.limit(5).order(created_at: :desc) + @recent_events = @conference.program.events.limit(5).order(created_at: :desc) @recent_registrations = @conference.registrations.limit(5).order(created_at: :desc) @top_submitter = @conference.get_top_submitter @@ -207,7 +211,7 @@ module Admin :vpositions_attributes, :use_volunteers, :color, :sponsorship_levels_attributes, :sponsors_attributes, :photos_attributes, :targets, :targets_attributes, - :campaigns, :campaigns_attributes) + :campaigns, :campaigns_attributes, :registration_limit) end def get_users(role_name) diff --git a/app/controllers/admin/difficulty_levels_controller.rb b/app/controllers/admin/difficulty_levels_controller.rb index 2ebcb2e4..154fd3b6 100644 --- a/app/controllers/admin/difficulty_levels_controller.rb +++ b/app/controllers/admin/difficulty_levels_controller.rb @@ -1,23 +1,24 @@ module Admin class DifficultyLevelsController < Admin::BaseController load_and_authorize_resource :conference, find_by: :short_title - load_and_authorize_resource :difficulty_level, through: :conference + load_and_authorize_resource :program, through: :conference, singleton: true + load_and_authorize_resource through: :program def index - authorize! :index, DifficultyLevel.new(conference_id: @conference.id) +# authorize! :index, DifficultyLevel.new(program_id: @program.id) end def edit; end def new - @difficulty_level = @conference.difficulty_levels.new + @difficulty_level = @conference.program.difficulty_levels.new end def create - @difficulty_level = @conference.difficulty_levels.new(difficulty_level_params) + @difficulty_level = @conference.program.difficulty_levels.new(difficulty_level_params) if @difficulty_level.save flash[:notice] = 'Difficulty level successfully created.' - redirect_to(admin_conference_difficulty_levels_path(conference_id: @conference.short_title)) + redirect_to(admin_conference_program_difficulty_levels_path(conference_id: @conference.short_title)) else flash[:error] = "Creating difficulty level failed: #{@difficulty_level.errors.full_messages.join('. ')}." render :new @@ -27,7 +28,7 @@ module Admin def update if @difficulty_level.update_attributes(difficulty_level_params) flash[:notice] = 'Difficulty level successfully updated.' - redirect_to(admin_conference_difficulty_levels_path(conference_id: @conference.short_title)) + redirect_to(admin_conference_program_difficulty_levels_path(conference_id: @conference.short_title)) else flash[:error] = "Update difficulty level failed: #{@difficulty_level.errors.full_messages.join('. ')}." render :edit @@ -37,11 +38,11 @@ module Admin def destroy if @difficulty_level.destroy flash[:notice] = 'Difficulty level successfully deleted.' - redirect_to(admin_conference_difficulty_levels_path(conference_id: @conference.short_title)) + redirect_to(admin_conference_program_difficulty_levels_path(conference_id: @conference.short_title)) else flash[:error] = 'Deleting difficulty level type failed! ' \ "#{@difficulty_level.errors.full_messages.join('. ')}." - redirect_to(admin_conference_difficulty_levels_path(conference_id: @conference.short_title)) + redirect_to(admin_conference_program_difficulty_levels_path(conference_id: @conference.short_title)) end end diff --git a/app/controllers/admin/event_types_controller.rb b/app/controllers/admin/event_types_controller.rb index 38f0ed91..18077040 100644 --- a/app/controllers/admin/event_types_controller.rb +++ b/app/controllers/admin/event_types_controller.rb @@ -1,23 +1,22 @@ module Admin class EventTypesController < Admin::BaseController load_and_authorize_resource :conference, find_by: :short_title - load_and_authorize_resource :event_type, through: :conference + load_and_authorize_resource :program, through: :conference, singleton: true + load_and_authorize_resource :event_type, through: :program - def index - authorize! :index, EventType.new(conference_id: @conference.id) - end + def index; end def edit; end def new - @event_type = @conference.event_types.new + @event_type = @conference.program.event_types.new end def create - @event_type = @conference.event_types.new(event_type_params) + @event_type = @conference.program.event_types.new(event_type_params) if @event_type.save flash[:notice] = 'Event type successfully created.' - redirect_to(admin_conference_event_types_path(conference_id: @conference.short_title)) + redirect_to(admin_conference_program_event_types_path(conference_id: @conference.short_title)) else flash[:error] = "Creating event type failed: #{@event_type.errors.full_messages.join('. ')}." render :new @@ -27,7 +26,7 @@ module Admin def update if @event_type.update_attributes(event_type_params) flash[:notice] = 'Event type successfully updated.' - redirect_to(admin_conference_event_types_path(conference_id: @conference.short_title)) + redirect_to(admin_conference_program_event_types_path(conference_id: @conference.short_title)) else flash[:error] = "Update event type failed: #{@event_type.errors.full_messages.join('. ')}." render :edit @@ -37,11 +36,11 @@ module Admin def destroy if @event_type.destroy flash[:notice] = 'Event type successfully deleted.' - redirect_to(admin_conference_event_types_path(conference_id: @conference.short_title)) + redirect_to(admin_conference_program_event_types_path(conference_id: @conference.short_title)) else flash[:error] = 'Destroying event type failed! ' \ "#{@event_type.errors.full_messages.join('. ')}." - redirect_to(admin_conference_event_types_path(conference_id: @conference.short_title)) + redirect_to(admin_conference_program_event_types_path(conference_id: @conference.short_title)) end end diff --git a/app/controllers/admin/events_controller.rb b/app/controllers/admin/events_controller.rb index d25f610a..c131943a 100644 --- a/app/controllers/admin/events_controller.rb +++ b/app/controllers/admin/events_controller.rb @@ -1,7 +1,8 @@ module Admin class EventsController < Admin::BaseController load_and_authorize_resource :conference, find_by: :short_title - load_and_authorize_resource :event, through: :conference + load_and_authorize_resource :program, through: :conference, singleton: true + load_and_authorize_resource :event, through: :program before_action :get_event, except: [:index, :create] @@ -14,13 +15,11 @@ module Admin end def index - authorize! :index, @conference.events.build - @conference = Conference.find_by(short_title: params[:conference_id]) - @events = @conference.events - @tracks = @conference.tracks - @difficulty_levels = @conference.difficulty_levels + @events = @program.events + @tracks = @program.tracks + @difficulty_levels = @program.difficulty_levels @machine_states = @events.state_machine.states.map - @event_types = @conference.event_types + @event_types = @program.event_types @mystates = [] @mytypes = [] @@ -72,26 +71,26 @@ module Admin respond_to do |format| format.html # Explicity call #to_json to avoid the use of EventSerializer - format.json { render json: Event.where(state: :confirmed, conference: @conference).to_json } + format.json { render json: Event.where(state: :confirmed, program: @program).to_json } end end def show - @tracks = @conference.tracks - @event_types = @conference.event_types + @tracks = @program.tracks + @event_types = @program.event_types @comments = @event.root_comments @comment_count = @event.comment_threads.count @ratings = @event.votes.includes(:user) - @difficulty_levels = @conference.difficulty_levels + @difficulty_levels = @program.difficulty_levels end def edit - @event_types = @conference.event_types + @event_types = @program.event_types @tracks = Track.all @comments = @event.root_comments @comment_count = @event.comment_threads.count @user = @event.submitter - @url = admin_conference_event_path(@conference.short_title, @event) + @url = admin_conference_program_event_path(@conference.short_title, @event) end def comment @@ -101,7 +100,7 @@ module Admin comment.move_to_child_of(params[:parent]) end - redirect_to admin_conference_event_path(conference_id: @conference.short_title) + redirect_to admin_conference_program_event_path(@conference.short_title, @event) end def update @@ -111,10 +110,10 @@ module Admin render js: 'index' else flash[:notice] = "Successfully updated event with ID #{@event.id}." - redirect_back_or_to(admin_conference_event_path(@conference.short_title, @event)) + redirect_back_or_to(admin_conference_program_event_path(@conference.short_title, @event)) end else - @url = admin_conference_event_path(@conference.short_title, @event) + @url = admin_conference_program_event_path(@conference.short_title, @event) flash[:notice] = 'Update not successful. ' + @event.errors.full_messages.to_sentence render :edit end @@ -123,8 +122,8 @@ module Admin def create; end def accept - send_mail = @event.conference.email_settings.send_on_accepted - subject = @event.conference.email_settings.accepted_subject.blank? + send_mail = @event.program.conference.email_settings.send_on_accepted + subject = @event.program.conference.email_settings.accepted_subject.blank? update_state(:accept, 'Event accepted!', true, subject, send_mail) end @@ -137,8 +136,8 @@ module Admin end def reject - send_mail = @event.conference.email_settings.send_on_rejected - subject = @event.conference.email_settings.rejected_subject.blank? + send_mail = @event.program.conference.email_settings.send_on_rejected + subject = @event.program.conference.email_settings.rejected_subject.blank? update_state(:reject, 'Event rejected!', true, subject, send_mail) end @@ -159,7 +158,7 @@ module Admin end respond_to do |format| - format.html { redirect_to admin_conference_event_path(@conference.short_title, @event) } + format.html { redirect_to admin_conference_program_event_path(@conference.short_title, @event) } format.js end end @@ -181,9 +180,9 @@ module Admin end def get_event - @event = @conference.events.find_by_id(params[:id]) + @event = @conference.program.events.find(params[:id]) if !@event - redirect_to(admin_conference_events_path(conference_id: @conference.short_title), + redirect_to(admin_conference_program_events_path(conference_id: @conference.short_title), alert: 'Error! Could not find event!') && return end @event @@ -194,10 +193,10 @@ module Admin if alert.blank? flash[:notice] = notice - redirect_back_or_to(admin_conference_events_path(conference_id: @conference.short_title)) && return + redirect_back_or_to(admin_conference_program_events_path(conference_id: @conference.short_title)) && return else flash[:error] = alert - return redirect_back_or_to(admin_conference_events_path(conference_id: @conference.short_title)) && return + return redirect_back_or_to(admin_conference_program_events_path(conference_id: @conference.short_title)) && return end end end diff --git a/app/controllers/admin/programs_controller.rb b/app/controllers/admin/programs_controller.rb new file mode 100644 index 00000000..d527a8aa --- /dev/null +++ b/app/controllers/admin/programs_controller.rb @@ -0,0 +1,32 @@ +module Admin + class ProgramsController < Admin::BaseController + load_and_authorize_resource :conference, find_by: :short_title + load_and_authorize_resource through: :conference, singleton: true + + def show; end + + def edit; end + + def update + authorize! :update, @conference.program + @program = @conference.program + @program.assign_attributes(program_params) +# send_mail_on_schedule_public = @program.notify_on_schedule_public? + + if @program.update_attributes(program_params) +# Mailbot.delay.send_on_schedule_public(@conference) if send_mail_on_schedule_public + redirect_to(admin_conference_program_path(@conference.short_title), + notice: 'The program was successfully updated.') + else + flash[:error] = "Updating program failed. #{@program.errors.to_a.join('. ')}." + render :new + end + end + + private + + def program_params + params.require(:program).permit(:rating, :schedule_public, :schedule_fluid) + end + end +end diff --git a/app/controllers/admin/rooms_controller.rb b/app/controllers/admin/rooms_controller.rb index 1e4029f7..2fda73d6 100644 --- a/app/controllers/admin/rooms_controller.rb +++ b/app/controllers/admin/rooms_controller.rb @@ -1,23 +1,22 @@ module Admin class RoomsController < Admin::BaseController load_and_authorize_resource :conference, find_by: :short_title - load_and_authorize_resource through: :conference + load_and_authorize_resource :venue, through: :conference, singleton: true + load_and_authorize_resource through: :venue - def index - authorize! :index, Room.new(conference_id: @conference.id) - end + def index; end def edit; end def new - @room = @conference.rooms.new + @room = @venue.rooms.new end def create - @room = @conference.rooms.new(room_params) + @room = @venue.rooms.new(room_params) if @room.save flash[:notice] = 'Room successfully created.' - redirect_to(admin_conference_rooms_path(conference_id: @conference.short_title)) + redirect_to(admin_conference_venue_rooms_path(conference_id: @conference.short_title)) else flash[:error] = "Creating Room failed: #{@room.errors.full_messages.join('. ')}." render :new @@ -27,7 +26,7 @@ module Admin def update if @room.update_attributes(room_params) flash[:notice] = 'Room successfully updated.' - redirect_to(admin_conference_rooms_path(conference_id: @conference.short_title)) + redirect_to(admin_conference_venue_rooms_path(conference_id: @conference.short_title)) else flash[:error] = "Update Room failed: #{@room.errors.full_messages.join('. ')}." render :edit @@ -37,10 +36,10 @@ module Admin def destroy if @room.destroy flash[:notice] = 'Room successfully deleted.' - redirect_to(admin_conference_rooms_path(conference_id: @conference.short_title)) + redirect_to(admin_conference_venue_rooms_path(conference_id: @conference.short_title)) else flash[:error] = "Destroying room failed! #{@room.errors.full_messages.join('. ')}." - redirect_to(admin_conference_rooms_path(conference_id: @conference.short_title)) + redirect_to(admin_conference_venue_rooms_path(conference_id: @conference.short_title)) end end diff --git a/app/controllers/admin/schedules_controller.rb b/app/controllers/admin/schedules_controller.rb index 4b8de9f3..90f319e6 100644 --- a/app/controllers/admin/schedules_controller.rb +++ b/app/controllers/admin/schedules_controller.rb @@ -3,23 +3,29 @@ module Admin # By authorizing 'conference' resource, we can ensure there will be no unauthorized access to # the schedule of a conference, which should not be accessed in the first place load_and_authorize_resource :conference, find_by: :short_title + load_and_authorize_resource :program, through: :conference, singleton: true + load_resource :venue, through: :conference, singleton: true skip_before_filter :verify_authenticity_token, only: [:update] layout 'schedule' def show - authorize! :update, @conference.events.new + authorize! :update, @program.events.new if @conference.nil? redirect_to admin_conference_index_path return end @dates = @conference.start_date..@conference.end_date - @rooms = @conference.rooms + if @venue && @venue.rooms.any? + @rooms = @venue.rooms + else + @rooms = [ Room.new(name: 'No Rooms!', size: 0) ] + end end def update - authorize! :update, @conference.events.new - event = Event.where(guid: event_params).first + authorize! :update, @program.events.new + event = Event.where(guid: params[:event]).first error_message = nil if event.nil? error_message = "Could not find event GUID: #{params[:event]}" @@ -63,7 +69,7 @@ module Admin end def room_params - params.require(:room).permit(:guid) + params.require(:room) end end end diff --git a/app/controllers/admin/tracks_controller.rb b/app/controllers/admin/tracks_controller.rb index db69b574..68777913 100644 --- a/app/controllers/admin/tracks_controller.rb +++ b/app/controllers/admin/tracks_controller.rb @@ -1,7 +1,8 @@ module Admin class TracksController < Admin::BaseController load_and_authorize_resource :conference, find_by: :short_title - load_and_authorize_resource :track, through: :conference + load_and_authorize_resource :program, through: :conference, singleton: true + load_and_authorize_resource through: :program def index; end @@ -13,14 +14,14 @@ module Admin end def new - @track = @conference.tracks.new + @track = @program.tracks.new end def create - @track = @conference.tracks.new(track_params) + @track = @program.tracks.new(track_params) if @track.save flash[:notice] = 'Track successfully created.' - redirect_to(admin_conference_tracks_path(conference_id: @conference.short_title)) + redirect_to(admin_conference_program_tracks_path(conference_id: @conference.short_title)) else flash[:error] = "Creating Track failed: #{@track.errors.full_messages.join('. ')}." render :new @@ -32,7 +33,7 @@ module Admin def update if @track.update_attributes(track_params) flash[:notice] = 'Track successfully updated.' - redirect_to(admin_conference_tracks_path(conference_id: @conference.short_title)) + redirect_to(admin_conference_program_tracks_path(conference_id: @conference.short_title)) else flash[:error] = "Track update failed: #{@track.errors.full_messages.join('. ')}." render :edit @@ -42,10 +43,10 @@ module Admin def destroy if @track.destroy flash[:notice] = 'Track successfully deleted.' - redirect_to(admin_conference_tracks_path(conference_id: @conference.short_title)) + redirect_to(admin_conference_program_tracks_path(conference_id: @conference.short_title)) else flash[:error] = "Track couldn't be deleted. #{@track.errors.full_messages.join('. ')}." - redirect_to(admin_conference_tracks_path(conference_id: @conference.short_title)) + redirect_to(admin_conference_program_tracks_path(conference_id: @conference.short_title)) end end diff --git a/app/controllers/api/v1/conferences_controller.rb b/app/controllers/api/v1/conferences_controller.rb index 4b6b5239..e37c6d55 100644 --- a/app/controllers/api/v1/conferences_controller.rb +++ b/app/controllers/api/v1/conferences_controller.rb @@ -1,15 +1,15 @@ module Api module V1 class ConferencesController < Api::BaseController + load_resource find_by: :short_title respond_to :json def index - if params[:conference_id].blank? - conferences = Conference.all - else - conferences = Conference.find_all_by_guid(params[:conference_id]) - end - render json: conferences, serializer: ConferencesArraySerializer + render json: @conferences, serializer: ConferencesArraySerializer + end + + def show + render json: [@conference], serializer: ConferencesArraySerializer end end end diff --git a/app/controllers/api/v1/events_controller.rb b/app/controllers/api/v1/events_controller.rb index 229c264a..bfcf9705 100644 --- a/app/controllers/api/v1/events_controller.rb +++ b/app/controllers/api/v1/events_controller.rb @@ -1,13 +1,16 @@ module Api module V1 class EventsController < Api::BaseController + load_resource :conference, find_by: :short_title respond_to :json def index events = Event.includes(:conference, :track, :room, :event_type, event_users: :user) - unless params[:conference_id].blank? - events = events.where(conferences: { guid: params[:conference_id] }) + + if @conference + events = events.where(conference: @conference) end + respond_with events.confirmed end end diff --git a/app/controllers/api/v1/rooms_controller.rb b/app/controllers/api/v1/rooms_controller.rb index 5b88b343..7ffd67c8 100644 --- a/app/controllers/api/v1/rooms_controller.rb +++ b/app/controllers/api/v1/rooms_controller.rb @@ -1,6 +1,7 @@ module Api module V1 class RoomsController < Api::BaseController + load_resource :conference, find_by: :short_title respond_to :json def index @@ -8,7 +9,7 @@ module Api rooms = Room.all else conference = Conference.find_by_guid(params[:conference_id]) - rooms = conference.rooms + rooms = conference.venue.rooms if conference.venue end respond_with rooms end diff --git a/app/controllers/api/v1/speakers_controller.rb b/app/controllers/api/v1/speakers_controller.rb index 5166ed71..b240fb82 100644 --- a/app/controllers/api/v1/speakers_controller.rb +++ b/app/controllers/api/v1/speakers_controller.rb @@ -1,16 +1,18 @@ module Api module V1 class SpeakersController < Api::BaseController + load_resource :conference, find_by: :short_title respond_to :json def index - if params[:conference_id].blank? - users = User.joins(:event_users) - else + if @conference users = User.joins(event_users: { event: :conference }) - users = users.where(conferences: { guid: params[:conference_id] }) + users = users.where(conferences: { short_title: @conference.short_title }) + else + users = User.joins(:event_users) end - users = users.where(event_users: {event_role: :speaker}) + + users = users.where(event_users: {event_role: :speaker}).uniq render json: users, each_serializer: SpeakerSerializer end end diff --git a/app/controllers/api/v1/tracks_controller.rb b/app/controllers/api/v1/tracks_controller.rb index ba09bb59..f477cc0c 100644 --- a/app/controllers/api/v1/tracks_controller.rb +++ b/app/controllers/api/v1/tracks_controller.rb @@ -1,15 +1,12 @@ module Api module V1 class TracksController < Api::BaseController + load_resource :conference, find_by: :short_title respond_to :json def index - if params[:conference_id].blank? - tracks = Track.all - else - tracks = Track.joins(:conference) - tracks = tracks.where(conferences: { guid: params[:conference_id] }) - end + @conference ? (tracks = @conference.tracks) : (tracks = Track.all) + respond_with tracks end end diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 49fdc6fa..a0d87498 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -71,6 +71,8 @@ class ApplicationController < ActionController::Base ## # Returns a string build from the start and end date of the given conference. # + # If the conference is only one day long + # * %B %d %Y (January 17 2014) # If the conference starts and ends in the same month and year # * %B %d - %d, %Y (January 17 - 21 2014) # If the conference ends in another month but in the same year @@ -82,8 +84,13 @@ class ApplicationController < ActionController::Base endstr = 'Unknown' # When the conference in the same month if start_date.month == end_date.month && start_date.year == end_date.year - startstr = start_date.strftime('%B %d - ') - endstr = end_date.strftime('%d, %Y') + if start_date.day == end_date.day + startstr = start_date.strftime('%B %d') + endstr = end_date.strftime(' %Y') + else + startstr = start_date.strftime('%B %d - ') + endstr = end_date.strftime('%d, %Y') + end elsif start_date.month != end_date.month && start_date.year == end_date.year startstr = start_date.strftime('%B %d - ') endstr = end_date.strftime('%B %d, %Y') diff --git a/app/controllers/commercials_controller.rb b/app/controllers/commercials_controller.rb index cf9b2ca3..c36feedc 100644 --- a/app/controllers/commercials_controller.rb +++ b/app/controllers/commercials_controller.rb @@ -8,7 +8,7 @@ class CommercialsController < ApplicationController authorize! :create, @commercial if @commercial.save - redirect_to edit_conference_proposal_path(conference_id: @conference.short_title, id: @event.id, anchor: 'commercials-content'), + redirect_to edit_conference_program_proposal_path(conference_id: @conference.short_title, id: @event.id, anchor: 'commercials-content'), notice: 'Commercial was successfully created.' else flash[:error] = "An error prohibited this Commercial from being saved: #{@commercial.errors.full_messages.join('. ')}." @@ -18,7 +18,7 @@ class CommercialsController < ApplicationController def update if @commercial.update(commercial_params) - redirect_to edit_conference_proposal_path(conference_id: @conference.short_title, id: @event.id, anchor: 'commercials-content'), + redirect_to edit_conference_program_proposal_path(conference_id: @conference.short_title, id: @event.id, anchor: 'commercials-content'), notice: 'Commercial was successfully updated.' else flash[:error] = "An error prohibited this Commercial from being saved: #{@commercial.errors.full_messages.join('. ')}." @@ -28,7 +28,7 @@ class CommercialsController < ApplicationController def destroy @commercial.destroy - redirect_to edit_conference_proposal_path(conference_id: @conference.short_title, id: @event.id, anchor: 'commercials-content'), + redirect_to edit_conference_program_proposal_path(conference_id: @conference.short_title, id: @event.id), notice: 'Commercial was successfully destroyed.' end @@ -44,7 +44,7 @@ class CommercialsController < ApplicationController private def set_event - @event = @conference.events.find(params[:proposal_id]) + @event = @conference.program.events.find(params[:proposal_id]) end def commercial_params diff --git a/app/controllers/conference_controller.rb b/app/controllers/conference_controller.rb index 3923d6e7..64e55e6a 100644 --- a/app/controllers/conference_controller.rb +++ b/app/controllers/conference_controller.rb @@ -1,6 +1,7 @@ class ConferenceController < ApplicationController before_filter :respond_to_options load_and_authorize_resource find_by: :short_title + load_resource :program, through: :conference, singleton: true, except: :index def index @current = Conference.where('end_date >= ?', Date.current).order('start_date ASC') @@ -10,8 +11,8 @@ class ConferenceController < ApplicationController def show; end def schedule - @rooms = @conference.rooms - @events = @conference.events + @rooms = @conference.venue.rooms if @conference.venue + @events = @conference.program.events @dates = @conference.start_date..@conference.end_date if @dates == Date.current diff --git a/app/controllers/conference_registrations_controller.rb b/app/controllers/conference_registrations_controller.rb index 23e3cf1a..c9d7d216 100644 --- a/app/controllers/conference_registrations_controller.rb +++ b/app/controllers/conference_registrations_controller.rb @@ -20,6 +20,11 @@ class ConferenceRegistrationsController < ApplicationController redirect_to edit_conference_conference_registrations_path(@conference.short_title) end + if @conference.registration_limit_exceeded? + redirect_to root_path, alert: "Sorry, registration limit exceeded for #{@conference.title}" + return + end + @registration = Registration.new # @user variable needs to be set so that _sign_up_form_embedded works properly diff --git a/app/controllers/proposal_controller.rb b/app/controllers/proposal_controller.rb index 18d985b3..95042af5 100644 --- a/app/controllers/proposal_controller.rb +++ b/app/controllers/proposal_controller.rb @@ -1,7 +1,8 @@ class ProposalController < ApplicationController before_filter :authenticate_user!, except: [:show, :new, :create] load_resource :conference, find_by: :short_title - load_and_authorize_resource :event, parent: false, through: :conference + load_resource :program, through: :conference, singleton: true + load_and_authorize_resource :event, parent: false, through: :program def index @events = current_user.proposals(@conference) @@ -14,16 +15,16 @@ class ProposalController < ApplicationController def new @user = User.new - @url = conference_proposal_index_path(@conference.short_title) + @url = conference_program_proposal_index_path(@conference.short_title) end def edit authorize! :edit, @event - @url = conference_proposal_path(@conference.short_title, params[:id]) + @url = conference_program_proposal_path(@conference.short_title, params[:id]) end def create - @url = conference_proposal_index_path(@conference.short_title) + @url = conference_program_proposal_index_path(@conference.short_title) unless current_user @user = User.new(user_params) @@ -39,7 +40,7 @@ class ProposalController < ApplicationController params[:event].delete :user @event = Event.new(event_params) - @event.conference = @conference + @event.program = @program @event.event_users.new(user: current_user, event_role: 'submitter') @@ -55,12 +56,12 @@ class ProposalController < ApplicationController ahoy.track 'Event submission', title: 'New submission' flash[:notice] = 'Proposal was successfully submitted.' - redirect_to conference_proposal_index_path(@conference.short_title) + redirect_to conference_program_proposal_index_path(@conference.short_title) end def update authorize! :update, @event - @url = conference_proposal_path(@conference.short_title, params[:id]) + @url = conference_program_proposal_path(@conference.short_title, params[:id]) if !@event.update(event_params) flash[:error] = "Could not update proposal: #{@event.errors.full_messages.join(', ')}" @@ -68,13 +69,13 @@ class ProposalController < ApplicationController return end - redirect_to(conference_proposal_index_path(conference_id: @conference.short_title), + redirect_to(conference_program_proposal_index_path(conference_id: @conference.short_title), notice: 'Proposal was successfully updated.') end def destroy authorize! :destroy, @event - @url = conference_proposal_path(@conference.short_title, params[:id]) + @url = conference_program_proposal_path(@conference.short_title, params[:id]) begin @event.withdraw @@ -84,13 +85,13 @@ class ProposalController < ApplicationController end @event.save(validate: false) - redirect_to(conference_proposal_index_path(conference_id: @conference.short_title), + redirect_to(conference_program_proposal_index_path(conference_id: @conference.short_title), notice: 'Proposal was successfully withdrawn.') end def confirm authorize! :update, @event - @url = conference_proposal_path(@conference.short_title, params[:id]) + @url = conference_program_proposal_path(@conference.short_title, params[:id]) begin @event.confirm! @@ -106,7 +107,7 @@ class ProposalController < ApplicationController end if @conference.user_registered?(current_user) - redirect_to(conference_proposal_index_path(@conference.short_title), + redirect_to(conference_program_proposal_index_path(@conference.short_title), notice: 'The proposal was confirmed.') else redirect_to(new_conference_conference_registrations_path(conference_id: @conference.short_title), @@ -116,12 +117,12 @@ class ProposalController < ApplicationController def restart authorize! :update, @event - @url = conference_proposal_path(@conference.short_title, params[:id]) + @url = conference_program_proposal_path(@conference.short_title, params[:id]) begin @event.restart rescue Transitions::InvalidTransition - redirect_to(conference_proposal_index_path(conference_id: @conference.short_title), + redirect_to(conference_program_proposal_index_path(conference_id: @conference.short_title), error: "The proposal can't be re-submitted.") return end @@ -132,7 +133,7 @@ class ProposalController < ApplicationController return end - redirect_to(conference_proposal_index_path(conference_id: @conference.short_title), + redirect_to(conference_program_proposal_index_path(conference_id: @conference.short_title), notice: "The proposal was re-submitted. The #{@conference.short_title} organizers will review it again.") end diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 4c72b3dc..35f127b9 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -159,7 +159,7 @@ module ApplicationHelper end def pre_registered(event) - @conference.events.joins(:registrations).where('events.id = ?', event.id) + @conference.program.events.joins(:registrations).where('events.id = ?', event.id) end def add_association_link(association_name, form_builder, div_class, html_options = {}) @@ -184,7 +184,7 @@ module ApplicationHelper end def event_types(conference) - all = conference.event_types.map { |et | et.title.pluralize } + all = conference.program.event_types.map { |et | et.title.pluralize } first = all[0...-1] last = all[-1] ets = '' @@ -198,7 +198,21 @@ module ApplicationHelper end def tracks(conference) - all = conference.tracks.map {|t| t.name} + all = conference.program.tracks.map {|t| t.name} + first = all[0...-1] + last = all[-1] + ts = '' + if all.length > 1 + ts << first.join(', ') + ts << " and #{last}" + else + ts = all.join + end + return ts + end + + def difficulty_levels(conference) + all = conference.program.difficulty_levels.map {|t| t.title} first = all[0...-1] last = all[-1] ts = '' diff --git a/app/mailers/mailbot.rb b/app/mailers/mailbot.rb index bdf47d0b..5c378e09 100644 --- a/app/mailers/mailbot.rb +++ b/app/mailers/mailbot.rb @@ -66,17 +66,17 @@ class Mailbot < ActionMailer::Base User.joins(:subscriptions).merge(conference.subscriptions) do |user| build_email(conference, user.email, - conference.email_settings.call_for_papers_schedule_public_subject, - conference.email_settings.generate_email_on_conf_updates(conference, user, conference.email_settings.call_for_papers_schedule_public_body)) + conference.email_settings.program_schedule_public_subject, + conference.email_settings.generate_email_on_conf_updates(conference, user, conference.email_settings.program_schedule_public_body)) end end - def send_on_call_for_papers_dates_updated(conference) + def send_on_cfp_dates_updates(conference) User.joins(:subscriptions).merge(conference.subscriptions) do |user| build_email(conference, user.email, - conference.email_settings.call_for_papers_dates_updated_subject, - conference.email_settings.generate_email_on_conf_updates(conference, user, conference.email_settings.call_for_papers_dates_updated_body)) + conference.email_settings.cfp_dates_updated_subject, + conference.email_settings.generate_email_on_conf_updates(conference, user, conference.email_settings.cfp_dates_updated_body)) end end diff --git a/app/models/ability.rb b/app/models/ability.rb index bd30a8fd..58cbed92 100644 --- a/app/models/ability.rb +++ b/app/models/ability.rb @@ -39,7 +39,7 @@ class Ability end # Can view the schedule can [:schedule], Conference do |conference| - conference.call_for_paper && conference.call_for_paper.schedule_public + conference.program.cfp && conference.program.schedule_public end can :show, Event do |event| @@ -53,9 +53,13 @@ class Ability can [:show, :create], Registration do |registration| registration.new_record? end - can [:show, :create], Event do |event| + can :show, Event do |event| event.new_record? end + + can [:new, :create], Event do |event| + event.program.cfp_open? && event.new_record? + end end end @@ -77,7 +81,7 @@ class Ability event.users.include?(user) end # can create an event until the last day of a conference - can :create, Event, conference_id: Conference.where('end_date >= ?', Date.today).pluck(:id) + can :create, Event, program_id: Conference.where('end_date >= ?', Date.today).map { |conference| conference.program.id}.compact # can manage the commercials of their own events can :manage, Commercial, commercialable_type: 'Event', commercialable_id: user.events.pluck(:id) @@ -100,6 +104,12 @@ class Ability cannot [:edit, :update, :destroy], Question, global: true # for admins can :manage, :all if user.is_admin + + cannot :destroy, Program + # Do not delete venue, when there are rooms being used + cannot :destroy, Venue do |venue| + venue.conference.program.events.where.not(room_id: nil).any? + end end def signed_in_with_organizer_role(user) @@ -125,21 +135,22 @@ class Ability end can :manage, Vposition, conference_id: conf_ids_for_organizer can :manage, Vday, conference_id: conf_ids_for_organizer - can :manage, CallForPaper, conference_id: conf_ids_for_organizer - can :manage, Event, conference_id: conf_ids_for_organizer - can :manage, EventType, conference_id: conf_ids_for_organizer - can :manage, Track, conference_id: conf_ids_for_organizer - can :manage, DifficultyLevel, conference_id: conf_ids_for_organizer + can :manage, Program, conference_id: conf_ids_for_organizer + can :manage, Cfp, program: { conference_id: conf_ids_for_organizer} + can :manage, Event, program: { conference_id: conf_ids_for_organizer} + can :manage, EventType, program: { conference_id: conf_ids_for_organizer} + can :manage, Track, program: { conference_id: conf_ids_for_organizer} + can :manage, DifficultyLevel, program: { conference_id: conf_ids_for_organizer} can :manage, Commercial, commercialable_type: 'Event', - commercialable_id: Event.where(conference_id: conf_ids_for_organizer).pluck(:id) + commercialable_id: Event.where(program_id: Program.where(conference_id: conf_ids_for_organizer).pluck(:id)).pluck(:id) can :manage, Venue, conference_id: conf_ids_for_organizer can :manage, Lodging, conference_id: conf_ids_for_organizer - can :manage, Room, conference_id: conf_ids_for_organizer + can :manage, Room, venue: { conference_id: conf_ids_for_organizer} can :manage, Sponsor, conference_id: conf_ids_for_organizer can :manage, SponsorshipLevel, conference_id: conf_ids_for_organizer can :manage, Ticket, conference_id: conf_ids_for_organizer can :index, Comment, commentable_type: 'Event', - commentable_id: Event.where(conference_id: conf_ids_for_organizer).pluck(:id) + commentable_id: Event.where(program_id: Program.where(conference_id: conf_ids_for_organizer).pluck(:id)).pluck(:id) end def signed_in_with_cfp_role(user) @@ -148,18 +159,19 @@ class Ability conf_ids_for_cfp = Conference.with_role(:cfp, user).pluck(:id) if user.has_role? :cfp, :any - can :manage, Event, conference_id: conf_ids_for_cfp - can :manage, EventType, conference_id: conf_ids_for_cfp - can :manage, Track, conference_id: conf_ids_for_cfp - can :manage, DifficultyLevel, conference_id: conf_ids_for_cfp + can :manage, Event, program: { conference_id: conf_ids_for_cfp } + can :manage, EventType, program: { conference_id: conf_ids_for_cfp } + can :manage, Track, program: { conference_id: conf_ids_for_cfp } + can :manage, DifficultyLevel, program: { conference_id: conf_ids_for_cfp } can :manage, EmailSettings, conference_id: conf_ids_for_cfp - can :manage, Room, conference_id: conf_ids_for_cfp - can :index, Venue, conference_id: conf_ids_for_cfp - can :manage, CallForPaper, conference_id: conf_ids_for_cfp + can :manage, Room, venue: { conference_id: conf_ids_for_cfp } + can :show, Venue, conference_id: conf_ids_for_cfp + can :manage, Cfp, program: { conference_id: conf_ids_for_cfp } + can :manage, Program, conference_id: conf_ids_for_cfp can :manage, Commercial, commercialable_type: 'Event', - commercialable_id: Event.where(conference_id: conf_ids_for_cfp).pluck(:id) + commercialable_id: Event.where(program_id: Program.where(conference_id: conf_ids_for_cfp).pluck(:id)).pluck(:id) can :index, Comment, commentable_type: 'Event', - commentable_id: Event.where(conference_id: conf_ids_for_cfp).pluck(:id) + commentable_id: Event.where(program_id: Program.where(conference_id: conf_ids_for_cfp).pluck(:id)).pluck(:id) end def signed_in_with_info_desk_role(user) diff --git a/app/models/ahoy/program.rb b/app/models/ahoy/program.rb new file mode 100644 index 00000000..ef321377 --- /dev/null +++ b/app/models/ahoy/program.rb @@ -0,0 +1,113 @@ +# cannot delete program if there are events submitted + +class Program < ActiveRecord::Base + belongs_to :conference + + has_one :cfp, dependent: :destroy + has_many :event_types, dependent: :destroy + has_many :tracks, dependent: :destroy + has_many :difficulty_levels, dependent: :destroy + has_many :rooms, dependent: :destroy + has_many :events, dependent: :destroy do + def workshops + where(require_registration: true, state: :confirmed) + end + + def confirmed + where(state: :confirmed) + end + + def scheduled + where.not(start_time: nil) + end + + def highlights + where(state: :confirmed, is_highlight: true) + end + end + + has_many :event_users, through: :events + has_many :speakers, -> { distinct }, through: :event_users, source: :user do + def confirmed + joins(:events).where(events: { state: :confirmed }) + end + end + + accepts_nested_attributes_for :event_types, allow_destroy: true + accepts_nested_attributes_for :tracks, reject_if: proc { |r| r['name'].blank? }, allow_destroy: true + accepts_nested_attributes_for :difficulty_levels, allow_destroy: true + accepts_nested_attributes_for :rooms, reject_if: proc { |r| r['name'].blank? }, allow_destroy: true + +# validates :conference_id, presence: true, uniqueness: true + validates :rating, numericality: { greater_than_or_equal_to: 0, less_than_or_equal_to: 10 } + + before_create :create_event_types + before_create :create_difficulty_levels + + ## + # Checcks if the program has rating enabled + # + # ====Returns + # * +false+ -> If rating is not enabled + # * +true+ -> If rating is enabled + def rating_enabled? + self.rating && self.rating > 0 + end + + ## + # Checks if the call for papers for the conference is currently open + # + # ====Returns + # * +false+ -> If the CFP is not set or today isn't in the CFP period. + # * +true+ -> If today is in the CFP period. + def cfp_open? + cfp = self.cfp + + cfp.present? && (cfp.start_date..cfp.end_date).cover?(Date.current) + end + + ## + # Checks whether cfp dates is updated + # + # ====Returns + # * +True+ -> If cfp dates is updated and all other parameters are set + # * +False+ -> Either cfp date is not updated or one or more parameter is not set + def notify_on_schedule_public? + self.cfp && !self.cfp.end_date.blank? && !self.cfp.start_date.blank?\ + && (self.cfp.start_date_changed? || self.cfp.end_date_changed?)\ + && self.conference.email_settings.send_on_cfp_dates_updates\ + && !self.conference.email_settings.cfp_dates_updates_subject.blank?\ + && !self.conference.email_settings.cfp_dates_updates_template.blank? + end + + private + + ## + # Creates default EventTypes for this Conference. Used as before_create. + # + def create_event_types + event_types << EventType.create(title: 'Talk', length: 30, color: '#FF0000', description: 'Presentation in lecture format', + minimum_abstract_length: 0, + maximum_abstract_length: 500) + event_types << EventType.create(title: 'Workshop', length: 60, color: '#0000FF', description: 'Interactive hands-on practice', + minimum_abstract_length: 0, + maximum_abstract_length: 500) + true + end + + ## + # Creates default DifficultyLevels for this Conference. Used as before_create. + # + def create_difficulty_levels + difficulty_levels << DifficultyLevel.create(title: 'Easy', + description: 'Events are understandable for everyone without knowledge of the topic.', + color: '#70EF69') + difficulty_levels << DifficultyLevel.create(title: 'Medium', + description: 'Events require a basic understanding of the topic.', + color: '#EEEF69') + difficulty_levels << DifficultyLevel.create(title: 'Hard', + description: 'Events require expert knowledge of the topic.', + color: '#EF6E69') + true + end +end diff --git a/app/models/cfp.rb b/app/models/cfp.rb new file mode 100644 index 00000000..706e376b --- /dev/null +++ b/app/models/cfp.rb @@ -0,0 +1,71 @@ +# cannot delete program if there are events submitted + +class Cfp < ActiveRecord::Base + belongs_to :program + + validates :program_id, presence: true, uniqueness: true + validates :start_date, :end_date, presence: true + validate :before_end_of_conference + validate :start_after_end_date + + ## + # Checks whether cfp date is updated + # + # ====Returns + # * +True+ -> If cfp dates is updated and all other parameters are set + # * +False+ -> Either cfp date is not updated or one or more parameter is not set + def notify_on_cfp_date_update? + !self.end_date.blank? && !self.start_date.blank?\ + && (self.start_date_changed? || self.end_date_changed?)\ + && self.program.conference.email_settings.send_on_cfp_dates_updated\ + && !self.program.conference.email_settings.cfp_dates_updated_subject.blank?\ + && !self.program.conference.email_settings.cfp_dates_updated_body.blank? + end + + ## + # Calculates how many weeks the call for paper is. + # + # ====Returns + # * +Integer+ -> start week + def weeks + result = end_week - start_week + 1 + weeks = Date.new(start_date.year, 12, 31).strftime('%W').to_i + result < 0 ? result + weeks : result + end + + ## + # Calculates the end week of the cfp + # + # ====Returns + def start_week + start_date.strftime('%W').to_i + end + + ## + # Calculates the end week of the cfp + # + # ====Returns + def end_week + end_date.strftime('%W').to_i + end + + def remaining_days(date = Date.today) + result = (self.end_date - date).to_i + result > 0 ? result : 0 + end + + private + + def before_end_of_conference + errors. + add(:end_date, "can't be after the conference end date (#{program.conference.end_date})") if program.conference && program.conference.end_date && end_date && (end_date > program.conference.end_date) + + errors. + add(:start_date, "can't be after the conference end date (#{program.conference.end_date})") if program.conference && program.conference.end_date && start_date && (start_date > program.conference.end_date) + end + + def start_after_end_date + errors. + add(:start_date, "can't be after the end date") if start_date && end_date && start_date > end_date + end +end diff --git a/app/models/conference.rb b/app/models/conference.rb index 2b3526b2..ac0a849f 100644 --- a/app/models/conference.rb +++ b/app/models/conference.rb @@ -1,6 +1,5 @@ ## # This class represents a conference -# rubocop:disable Style/ClassLength class Conference < ActiveRecord::Base require 'uri' serialize :events_per_week, Hash @@ -16,40 +15,14 @@ class Conference < ActiveRecord::Base has_one :contact, dependent: :destroy has_one :registration_period, dependent: :destroy has_one :email_settings, dependent: :destroy - has_one :call_for_paper, dependent: :destroy + has_one :program, dependent: :destroy has_one :venue, dependent: :destroy has_many :social_events, dependent: :destroy has_many :ticket_purchases, dependent: :destroy has_many :supporters, through: :ticket_purchases, source: :user has_many :tickets, dependent: :destroy has_many :dietary_choices, dependent: :destroy - has_many :events, dependent: :destroy do - def workshops - where(require_registration: true, state: :confirmed) - end - def confirmed - where(state: :confirmed) - end - - def scheduled - where.not(start_time: nil) - end - - def highlights - where(state: :confirmed, is_highlight: true) - end - end - has_many :event_users, through: :events - has_many :speakers, -> { distinct }, through: :event_users, source: :user do - def confirmed - joins(:events).where(events: { state: :confirmed }) - end - end - has_many :event_types, dependent: :destroy - has_many :tracks, dependent: :destroy - has_many :difficulty_levels, dependent: :destroy - has_many :rooms, dependent: :destroy has_many :lodgings, dependent: :destroy has_many :registrations, dependent: :destroy has_many :participants, through: :registrations, source: :user @@ -63,16 +36,12 @@ class Conference < ActiveRecord::Base has_many :commercials, as: :commercialable, dependent: :destroy has_many :subscriptions, dependent: :destroy - accepts_nested_attributes_for :rooms, reject_if: proc { |r| r['name'].blank? }, allow_destroy: true - accepts_nested_attributes_for :tracks, reject_if: proc { |r| r['name'].blank? }, allow_destroy: true - accepts_nested_attributes_for :difficulty_levels, allow_destroy: true accepts_nested_attributes_for :social_events, allow_destroy: true accepts_nested_attributes_for :venue accepts_nested_attributes_for :dietary_choices, allow_destroy: true accepts_nested_attributes_for :tickets, allow_destroy: true accepts_nested_attributes_for :sponsorship_levels, allow_destroy: true accepts_nested_attributes_for :sponsors, allow_destroy: true - accepts_nested_attributes_for :event_types, allow_destroy: true accepts_nested_attributes_for :email_settings accepts_nested_attributes_for :questions, allow_destroy: true accepts_nested_attributes_for :vdays, allow_destroy: true @@ -95,14 +64,13 @@ class Conference < ActiveRecord::Base validates_uniqueness_of :short_title validates_format_of :short_title, with: /\A[a-zA-Z0-9_-]*\z/ + validates :registration_limit, numericality: { only_integer: true, greater_than_or_equal_to: 0 } # This validation is needed since a conference with a start date greater than the end date is not possible validate :valid_date_range? before_create :generate_guid - before_create :create_event_types - before_create :create_difficulty_levels - before_create :create_email_settings before_create :add_color + before_create :create_email_settings def date_range_string startstr = 'Unknown - ' @@ -158,18 +126,6 @@ class Conference < ActiveRecord::Base registration_period.end_date.present? end - ## - # Checks if the call for papers for the conference is currently open - # - # ====Returns - # * +false+ -> If the CFP is not set or today isn't in the CFP period. - # * +true+ -> If today is in the CFP period. - def cfp_open? - cfp = self.call_for_paper - - cfp.present? && (cfp.start_date..cfp.end_date).cover?(Date.current) - end - ## # Returns an array with the summarized event submissions per week. # @@ -178,10 +134,10 @@ class Conference < ActiveRecord::Base def get_submissions_per_week result = [] - if call_for_paper && events - submissions = events.group(:week).count - start_week = call_for_paper.start_week - weeks = call_for_paper.weeks + if program && program.cfp && program.events + submissions = program.events.group(:week).count + start_week = program.cfp.start_week + weeks = program.cfp.weeks result = calculate_items_per_week(start_week, weeks, submissions) end result @@ -195,10 +151,10 @@ class Conference < ActiveRecord::Base # * +Array+ -> e.g. 'Submitted' => [0, 3, 3, 5] -> first week 0 events, second week 3 events. def get_submissions_data result = {} - if call_for_paper && events + if program && program.cfp && program.events result = get_events_per_week_by_state - start_week = call_for_paper.start_week + start_week = program.cfp.start_week end_week = end_date.strftime('%W').to_i weeks = weeks(start_week, end_week) @@ -260,8 +216,8 @@ class Conference < ActiveRecord::Base # ====Returns # * +Integer+ -> weeks def cfp_weeks - if call_for_paper - call_for_paper.weeks + if program + program.cfp.weeks else 0 end @@ -344,7 +300,7 @@ class Conference < ActiveRecord::Base # * +hash+ -> user: submissions def get_top_submitter(limit = 5) submitter = EventUser.joins(:event). - where('event_role = ? and conference_id = ?', 'submitter', id). + where('event_role = ? and program_id = ?', 'submitter', Conference.find(id).program.id). limit(limit).group(:user_id) counter = submitter.order('count_all desc').count Conference.calculate_user_submission_hash(submitter, counter) @@ -366,7 +322,7 @@ class Conference < ActiveRecord::Base # ====Returns # * +hash+ -> hash def event_distribution - Conference.calculate_event_distribution_hash(events.select(:state).group(:state).count) + Conference.calculate_event_distribution_hash(program.events.select(:state).group(:state).count) end ## @@ -391,7 +347,7 @@ class Conference < ActiveRecord::Base # ====Returns # * +hash+ -> Fixnum minutes def current_program_minutes - events_grouped = events.select(:event_type_id).group(:event_type_id) + events_grouped = program.events.select(:event_type_id).group(:event_type_id) events_counted = events_grouped.count calculate_program_minutes(events_grouped, events_counted) end @@ -411,7 +367,7 @@ class Conference < ActiveRecord::Base # ====Returns # * +hash+ -> Fixnum minutes def new_program_minutes(date) - events_grouped = events.select(:event_type_id).where('created_at > ?', date).group(:event_type_id) + events_grouped = program.events.select(:event_type_id).where('created_at > ?', date).group(:event_type_id) events_counted = events_grouped.count calculate_program_minutes(events_grouped, events_counted) end @@ -450,9 +406,9 @@ class Conference < ActiveRecord::Base # * +hash+ -> track => {color, value} def tracks_distribution(state = nil) if state - tracks_grouped = events.select(:track_id).where('state = ?', state).group(:track_id) + tracks_grouped = program.events.select(:track_id).where('state = ?', state).group(:track_id) else - tracks_grouped = events.select(:track_id).group(:track_id) + tracks_grouped = program.events.select(:track_id).group(:track_id) end tracks_counted = tracks_grouped.count @@ -539,7 +495,7 @@ class Conference < ActiveRecord::Base Conference.where('end_date > ?', Date.today).each do |conference| result = {} Event.state_machine.states.each do |state| - count = conference.events.where('state = ?', state.name).count + count = conference.program.events.where('state = ?', state.name).count result[state.name] = count end @@ -580,10 +536,15 @@ class Conference < ActiveRecord::Base email_settings.conference_registration_dates_updated_body end + def registration_limit_exceeded? + registration_limit > 0 && registrations.count >= registration_limit + end + private after_create do self.create_contact + self.create_program end ## @@ -631,10 +592,10 @@ class Conference < ActiveRecord::Base # Actual week this_week = Date.today.end_of_week.strftime('%W').to_i - result['Confirmed'][this_week] = events.where('state = ?', :confirmed).count - result['Unconfirmed'][this_week] = events.where('state = ?', :unconfirmed).count - result['Submitted'] = events.select(:week).group(:week).count - result['Submitted'][this_week] = events.where(week: this_week).count + result['Confirmed'][this_week] = program.events.where('state = ?', :confirmed).count + result['Unconfirmed'][this_week] = program.events.where('state = ?', :unconfirmed).count + result['Submitted'] = program.events.select(:week).group(:week).count + result['Submitted'][this_week] = program.events.where(week: this_week).count result end @@ -720,7 +681,7 @@ class Conference < ActiveRecord::Base # * +True+ -> One difficulty level or more # * +False+ -> No diffculty level def difficulty_levels_set? - difficulty_levels.count > 0 + program.difficulty_levels.count > 0 end ## @@ -730,7 +691,7 @@ class Conference < ActiveRecord::Base # * +True+ -> One difficulty level or more # * +False+ -> No diffculty level def event_types_set? - event_types.count > 0 + program.event_types.count > 0 end ## @@ -740,7 +701,7 @@ class Conference < ActiveRecord::Base # * +True+ -> One track or more # * +False+ -> No track def tracks_set? - tracks.count > 0 + program.tracks.count > 0 end ## @@ -750,7 +711,7 @@ class Conference < ActiveRecord::Base # * +True+ -> One room or more # * +False+ -> No room def rooms_set? - rooms.count > 0 + venue.present? && venue.rooms.count > 0 end # Checks if the conference has a venue object. @@ -769,7 +730,7 @@ class Conference < ActiveRecord::Base # * +True+ -> If conference has a cfp object. # * +False+ -> If conference has no cfp object. def cfp_set? - !!call_for_paper + !!program.cfp end ## @@ -788,9 +749,9 @@ class Conference < ActiveRecord::Base # * +hash+ -> object_type => {color, value} def calculate_event_distribution(group_by_id, association_symbol, state = nil) if state - grouped = events.select(group_by_id).where('state = ?', 'confirmed').group(group_by_id) + grouped = program.events.select(group_by_id).where('state = ?', 'confirmed').group(group_by_id) else - grouped = events.select(group_by_id).group(group_by_id) + grouped = program.events.select(group_by_id).group(group_by_id) end counted = grouped.count @@ -910,35 +871,6 @@ class Conference < ActiveRecord::Base result end - ## - # Creates default EventTypes for this Conference. Used as before_create. - # - def create_event_types - event_types << EventType.create(title: 'Talk', length: 30, color: '#FF0000', description: 'Presentation in lecture format', - minimum_abstract_length: 0, - maximum_abstract_length: 500) - event_types << EventType.create(title: 'Workshop', length: 60, color: '#0000FF', description: 'Interactive hands-on practice', - minimum_abstract_length: 0, - maximum_abstract_length: 500) - true - end - - ## - # Creates default DifficultyLevels for this Conference. Used as before_create. - # - def create_difficulty_levels - difficulty_levels << DifficultyLevel.create(title: 'Easy', - description: 'Events are understandable for everyone without knowledge of the topic.', - color: '#70EF69') - difficulty_levels << DifficultyLevel.create(title: 'Medium', - description: 'Events require a basic understanding of the topic.', - color: '#EEEF69') - difficulty_levels << DifficultyLevel.create(title: 'Hard', - description: 'Events require expert knowledge of the topic.', - color: '#EF6E69') - true - end - ## # Creates a EmailSettings association proxy. Used as before_create. # diff --git a/app/models/difficulty_level.rb b/app/models/difficulty_level.rb index 58f9862c..b544c8d6 100644 --- a/app/models/difficulty_level.rb +++ b/app/models/difficulty_level.rb @@ -1,5 +1,5 @@ class DifficultyLevel < ActiveRecord::Base - belongs_to :conference + belongs_to :program has_many :events, dependent: :nullify validates :title, presence: true diff --git a/app/models/email_settings.rb b/app/models/email_settings.rb index 60889a15..be1fc1cb 100644 --- a/app/models/email_settings.rb +++ b/app/models/email_settings.rb @@ -15,9 +15,9 @@ class EmailSettings < ActiveRecord::Base conference.short_title, host: CONFIG['url_for_emails']) } - if conference.call_for_paper - h['cfp_start_date'] = conference.call_for_paper.start_date - h['cfp_end_date'] = conference.call_for_paper.end_date + if conference.program.cfp + h['cfp_start_date'] = conference.program.cfp.start_date + h['cfp_end_date'] = conference.program.cfp.end_date else h['cfp_start_date'] = 'Unknown' h['cfp_end_date'] = 'Unknown' diff --git a/app/models/event.rb b/app/models/event.rb index ed67b07b..780e65b9 100644 --- a/app/models/event.rb +++ b/app/models/event.rb @@ -19,7 +19,7 @@ class Event < ActiveRecord::Base belongs_to :track belongs_to :room belongs_to :difficulty_level - belongs_to :conference + belongs_to :program accepts_nested_attributes_for :event_users, allow_destroy: true accepts_nested_attributes_for :users @@ -31,7 +31,7 @@ class Event < ActiveRecord::Base validates :title, presence: true validates :abstract, presence: true validates :event_type, presence: true - validates :conference, presence: true + validates :program, presence: true scope :confirmed, -> { where(state: 'confirmed') } scope :highlighted, -> { where(is_highlight: true) } @@ -108,19 +108,19 @@ class Event < ActiveRecord::Base end def process_confirmation - if conference.email_settings.send_on_confirmed_without_registration? && - conference.email_settings.confirmed_without_registration_body && - conference.email_settings.confirmed_without_registration_subject - if conference.registrations.where(user_id: submitter.id).first.nil? + if program.conference.email_settings.send_on_confirmed_without_registration? && + program.conference.email_settings.confirmed_without_registration_body && + program.conference.email_settings.confirmed_without_registration_subject + if program.conference.registrations.where(user_id: submitter.id).first.nil? Mailbot.delay.confirm_reminder_mail(self) end end end def process_acceptance(options) - if conference.email_settings.send_on_accepted && - conference.email_settings.accepted_body && - conference.email_settings.accepted_subject && + if program.conference.email_settings.send_on_accepted && + program.conference.email_settings.accepted_body && + program.conference.email_settings.accepted_subject && !options[:send_mail].blank? Rails.logger.debug 'Sending event acceptance mail' Mailbot.delay.acceptance_mail(self) @@ -128,9 +128,9 @@ class Event < ActiveRecord::Base end def process_rejection(options) - if conference.email_settings.send_on_rejected && - conference.email_settings.rejected_body && - conference.email_settings.rejected_subject && + if program.conference.email_settings.send_on_rejected && + program.conference.email_settings.rejected_body && + program.conference.email_settings.rejected_subject && !options[:send_mail].blank? Rails.logger.debug 'Sending rejected mail' Mailbot.delay.rejection_mail(self) @@ -190,7 +190,7 @@ class Event < ActiveRecord::Base # Returns +Hash+ def progress_status { - registered: self.conference.user_registered?(self.submitter), + registered: self.program.conference.user_registered?(self.submitter), commercials: self.commercials.any?, biography: !self.submitter.biography.blank?, subtitle: !self.subtitle.blank?, @@ -241,7 +241,7 @@ class Event < ActiveRecord::Base def before_end_of_conference errors. - add(:created_at, "can't be after the conference end date!") if conference.end_date && - (Date.today > conference.end_date) + add(:created_at, "can't be after the conference end date!") if program.conference && program.conference.end_date && + (Date.today > program.conference.end_date) end end diff --git a/app/models/event_type.rb b/app/models/event_type.rb index d0a4a8f3..69a54d10 100644 --- a/app/models/event_type.rb +++ b/app/models/event_type.rb @@ -1,5 +1,5 @@ class EventType < ActiveRecord::Base - belongs_to :conference + belongs_to :program has_many :events, dependent: :restrict_with_error validates :title, presence: true diff --git a/app/models/program.rb b/app/models/program.rb new file mode 100644 index 00000000..dbc64b91 --- /dev/null +++ b/app/models/program.rb @@ -0,0 +1,97 @@ +# cannot delete program if there are events submitted + +class Program < ActiveRecord::Base + belongs_to :conference + + has_one :cfp, dependent: :destroy + has_many :event_types, dependent: :destroy + has_many :tracks, dependent: :destroy + has_many :difficulty_levels, dependent: :destroy + has_many :events, dependent: :destroy do + def workshops + where(require_registration: true, state: :confirmed) + end + + def confirmed + where(state: :confirmed) + end + + def scheduled + where.not(start_time: nil) + end + + def highlights + where(state: :confirmed, is_highlight: true) + end + end + + has_many :event_users, through: :events + has_many :speakers, -> { distinct }, through: :event_users, source: :user do + def confirmed + joins(:events).where(events: { state: :confirmed }) + end + end + + accepts_nested_attributes_for :event_types, allow_destroy: true + accepts_nested_attributes_for :tracks, reject_if: proc { |r| r['name'].blank? }, allow_destroy: true + accepts_nested_attributes_for :difficulty_levels, allow_destroy: true + +# validates :conference_id, presence: true, uniqueness: true + validates :rating, numericality: { greater_than_or_equal_to: 0, less_than_or_equal_to: 10 } + + before_create :create_event_types + before_create :create_difficulty_levels + + ## + # Checcks if the program has rating enabled + # + # ====Returns + # * +false+ -> If rating is not enabled + # * +true+ -> If rating is enabled + def rating_enabled? + self.rating && self.rating > 0 + end + + ## + # Checks if the call for papers for the conference is currently open + # + # ====Returns + # * +false+ -> If the CFP is not set or today isn't in the CFP period. + # * +true+ -> If today is in the CFP period. + def cfp_open? + cfp = self.cfp + + cfp.present? && (cfp.start_date..cfp.end_date).cover?(Date.current) + end + + private + + ## + # Creates default EventTypes for this Conference. Used as before_create. + # + def create_event_types + event_types << EventType.create(title: 'Talk', length: 30, color: '#FF0000', description: 'Presentation in lecture format', + minimum_abstract_length: 0, + maximum_abstract_length: 500) + event_types << EventType.create(title: 'Workshop', length: 60, color: '#0000FF', description: 'Interactive hands-on practice', + minimum_abstract_length: 0, + maximum_abstract_length: 500) + true + end + + ## + # Creates default DifficultyLevels for this Conference. Used as before_create. + # + def create_difficulty_levels + difficulty_levels << DifficultyLevel.create(title: 'Easy', + description: 'Events are understandable for everyone without knowledge of the topic.', + color: '#70EF69') + difficulty_levels << DifficultyLevel.create(title: 'Medium', + description: 'Events require a basic understanding of the topic.', + color: '#EEEF69') + difficulty_levels << DifficultyLevel.create(title: 'Hard', + description: 'Events require expert knowledge of the topic.', + color: '#EF6E69') + true + end +end diff --git a/app/models/registration.rb b/app/models/registration.rb index 1866c430..2f2d5c68 100644 --- a/app/models/registration.rb +++ b/app/models/registration.rb @@ -26,6 +26,7 @@ class Registration < ActiveRecord::Base validates :user, presence: true validates_uniqueness_of :user_id, scope: :conference_id, message: 'already Registered!' + validate :registration_limit_not_exceed, on: :create after_create :set_week, :subscribe_to_conference, :send_registration_mail @@ -49,4 +50,10 @@ class Registration < ActiveRecord::Base self.week = created_at.strftime('%W') save! end + + def registration_limit_not_exceed + if conference.registration_limit > 0 && conference.registrations(:reload).count >= conference.registration_limit + errors.add(:base, 'Registration limit exceeded') + end + end end diff --git a/app/models/registration_period.rb b/app/models/registration_period.rb index 6a87b4f7..b4e04a95 100644 --- a/app/models/registration_period.rb +++ b/app/models/registration_period.rb @@ -1,5 +1,22 @@ class RegistrationPeriod < ActiveRecord::Base - validates :start_date, :end_date, presence: true - belongs_to :conference + + validates :start_date, :end_date, presence: true + validate :before_end_of_conference + validate :start_date_before_end_date + + private + + def before_end_of_conference + errors. + add(:start_date, "can't be after the conference end date (#{conference.end_date})") if conference && conference.end_date && start_date && (start_date > conference.end_date) + + errors. + add(:end_date, "can't be after the conference end date (#{conference.end_date})") if conference && conference.end_date && end_date && (end_date > conference.end_date) + end + + def start_date_before_end_date + errors. + add(:start_date, "can't be after the end date") if start_date && end_date && start_date > end_date + end end diff --git a/app/models/room.rb b/app/models/room.rb index 5fee24ee..02e6ea7f 100644 --- a/app/models/room.rb +++ b/app/models/room.rb @@ -1,10 +1,10 @@ class Room < ActiveRecord::Base - belongs_to :conference + belongs_to :venue has_many :events, dependent: :nullify before_create :generate_guid - validates :name, presence: true + validates :name, :venue_id, presence: true validates :size, numericality: { only_integer: true, greater_than: 0 }, allow_nil: true diff --git a/app/models/target.rb b/app/models/target.rb index 9045a792..a1b496a2 100644 --- a/app/models/target.rb +++ b/app/models/target.rb @@ -29,7 +29,7 @@ class Target < ActiveRecord::Base numerator = case unit when Target.units[:submissions] - conference.events.where('created_at < ?', due_date).count + conference.program.events.where('created_at < ?', due_date).count when Target.units[:registrations] conference.registrations.where('created_at < ?', due_date).count when Target.units[:program_minutes] diff --git a/app/models/track.rb b/app/models/track.rb index c1c774a2..6949ebdb 100644 --- a/app/models/track.rb +++ b/app/models/track.rb @@ -1,5 +1,5 @@ class Track < ActiveRecord::Base - belongs_to :conference + belongs_to :program has_many :events, dependent: :nullify before_create :generate_guid diff --git a/app/models/user.rb b/app/models/user.rb index fff4b120..567b0e41 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -177,7 +177,7 @@ class User < ActiveRecord::Base end def proposals(conference) - events.where('conference_id = ? AND event_users.event_role=?', conference.id, 'submitter') + events.where('program_id = ? AND event_users.event_role=?', conference.program.id, 'submitter') end def proposal_count(conference) diff --git a/app/models/venue.rb b/app/models/venue.rb index b88a1806..b0cd2b0e 100644 --- a/app/models/venue.rb +++ b/app/models/venue.rb @@ -1,9 +1,10 @@ class Venue < ActiveRecord::Base belongs_to :conference - has_many :lodgings + has_many :rooms, dependent: :destroy before_create :generate_guid validates :name, :street, :city, :country, presence: true + validates :conference_id, presence: true, uniqueness: true has_attached_file :photo, styles: { thumb: '100x100>', large: '300x300>' } @@ -11,8 +12,6 @@ class Venue < ActiveRecord::Base content_type: [/jpg/, /jpeg/, /png/, /gif/], size: { in: 0..500.kilobytes } - accepts_nested_attributes_for :lodgings, allow_destroy: true - after_update :send_mail_notification def address diff --git a/app/serializers/conference_serializer.rb b/app/serializers/conference_serializer.rb index 1566e9da..1bed92d9 100644 --- a/app/serializers/conference_serializer.rb +++ b/app/serializers/conference_serializer.rb @@ -1,5 +1,53 @@ class ConferenceSerializer < ActiveModel::Serializer - attributes :guid, :name, :description, :year, :socialtag, :date_range, :url, :revision + attributes :short_title, :title, :description, :start_date, :end_date, :logo, + :difficulty_levels, :event_types, :rooms, :tracks, + :date_range, :revision + + def difficulty_levels + object.difficulty_levels.map do |difficulty_level| { id: difficulty_level.id, + title: difficulty_level.title, + description: difficulty_level.description + } + end + end + + def event_types + object.event_types.map do |event_type| { id: event_type.id, + title: event_type.title, + length: event_type.length, + description: event_type.description + } + end + end + + def rooms + object.rooms.includes(:events).map do |room| { id: room.id, + size: room.size, + events: room.events.map do |event| { guid: event.title, + title: event.title, + subtitle: event.subtitle, + abstract: event.abstract, + description: event.description, + is_highlight: event.is_highlight, + require_registration: event.require_registration, + start_time: event.start_time, + event_type_id: event.event_type.id, + difficulty_level_id: event.difficulty_level_id, + track_id: event.track_id, + speaker_names: event.speaker_names + } + end + } + end + end + + def tracks + object.tracks.map do |track| { 'id' => track.id, + 'name' => track.name, + 'description' => track.description + } + end + end def name object.title @@ -17,19 +65,9 @@ class ConferenceSerializer < ActiveModel::Serializer object.revision || 0 end - # FIXME: adjusting the format the DIRTY way, for oSC13. - # If you think this is ugly, don't look at the methods below def date_range - object.date_range_string.try(:split, ',').try(:first) - end - - # FIXME: just giving suseconferenceclient something to play with - def description - 'openSUSE Conference 2013 - Power to the Geeko' - end - - # FIXME: same than the former - def url - 'https://conference.opensuse.org/' + if defined? object.date_range_string + object.date_range_string.try(:split, ',').try(:first) + end end end diff --git a/app/views/admin/cfps/_form.html.haml b/app/views/admin/cfps/_form.html.haml new file mode 100644 index 00000000..c216c422 --- /dev/null +++ b/app/views/admin/cfps/_form.html.haml @@ -0,0 +1,11 @@ +.row + .col-md-12 + .page-header + %h1 Call for Papers +.row + .col-md-8 + = semantic_form_for(@cfp, :url => admin_conference_program_cfp_path(@conference.short_title),:html => {:multipart => true}) do |f| + = f.input :start_date, :as => :string, :input_html => { :id => "conference-start-datepicker", :readonly => "readonly" } + = f.input :end_date, :as => :string, :input_html => { :id => "conference-end-datepicker", :readonly => "readonly" } + %p.text-right + = f.action :submit, :as => :button, :button_html => {:class => "btn btn-primary"} diff --git a/app/views/admin/cfps/show.html.haml b/app/views/admin/cfps/show.html.haml new file mode 100644 index 00000000..af7a2415 --- /dev/null +++ b/app/views/admin/cfps/show.html.haml @@ -0,0 +1,58 @@ +.row + .col-md-12 + .page-header + %h1 Call for Papers + %p.text-muted + Call for people to submit events to your conference +- if @cfp + .row + .col-md-8 + %dl.dl-horizontal + %dt + Start Date: + %dd#start_date + = @cfp.start_date.strftime('%A, %B %-d. %Y') + %dt + End Date: + %dd#end_date + = @cfp.end_date.strftime('%A, %B %-d. %Y') + %dt + Days Left: + %dd + = pluralize(@cfp.remaining_days, 'day') + %dt + Event types: + %dd + = event_types(@conference) + %dt + Tracks: + %dd + = tracks(@conference) + %dt + Public Schedule + %dd#schedule_public + - if @program.schedule_public + Yes + - else + No + %dt + Schedule changeable? + %dd#schedule_changes + - if @program.schedule_fluid + Yes + - else + No + %dt + Rating Levels + %dd#rating + = @program.rating + .row + .col-md-12.text-right + = link_to(edit_admin_conference_program_cfp_path(@conference.short_title), class: 'btn btn-primary') do + Edit + = link_to(admin_conference_program_cfp_path(@conference.short_title), method: 'delete', class: 'btn btn-danger', data: { confirm: 'Are you sure you want to delete the CfP?' }) do + Delete +-else + .row + .col-md-12.text-right + = link_to 'Create Call for Papers', new_admin_conference_program_cfp_path(@conference.short_title), class: 'btn btn-primary' diff --git a/app/views/admin/comments/_all_comments.html.haml b/app/views/admin/comments/_all_comments.html.haml index 02ad15e8..eb3a8093 100644 --- a/app/views/admin/comments/_all_comments.html.haml +++ b/app/views/admin/comments/_all_comments.html.haml @@ -5,7 +5,7 @@ .panel-body - events.each do |event, comments| .notifications - %h4.title= link_to event.title, admin_conference_event_path(event.conference.short_title, event) + %h4.title= link_to event.title, admin_conference_program_event_path(event.program.conference.short_title, event) %hr - comments.each do |comment| %h5.strong Posted by: #{comment.user.name} | Created at: #{comment.created_at} diff --git a/app/views/admin/comments/_posted_comments.html.haml b/app/views/admin/comments/_posted_comments.html.haml index 89c90519..d274f929 100644 --- a/app/views/admin/comments/_posted_comments.html.haml +++ b/app/views/admin/comments/_posted_comments.html.haml @@ -5,7 +5,7 @@ .panel-body - events.each do |event, comments| .notifications - %h4.title= link_to event.title, admin_conference_event_path(event.conference.short_title, event) + %h4.title= link_to event.title, admin_conference_program_event_path(event.program.conference.short_title, event) %hr - comments.each do |comment| %h5.strong Created at: #{comment.created_at} diff --git a/app/views/admin/comments/_unread_comments.html.haml b/app/views/admin/comments/_unread_comments.html.haml index 9291aa83..5facdc4b 100644 --- a/app/views/admin/comments/_unread_comments.html.haml +++ b/app/views/admin/comments/_unread_comments.html.haml @@ -5,7 +5,7 @@ .panel-body - events.each do |event, comments| .notifications - %h4.title= link_to event.title, admin_conference_event_path(event.conference.short_title, event) + %h4.title= link_to event.title, admin_conference_program_event_path(event.program.conference.short_title, event) %hr - comments.each do |comment| %h5.strong Posted by: #{comment.user.name} | Created at: #{comment.created_at} diff --git a/app/views/admin/conference/_recent_submissions.html.haml b/app/views/admin/conference/_recent_submissions.html.haml index 08823ff8..0f6c0037 100644 --- a/app/views/admin/conference/_recent_submissions.html.haml +++ b/app/views/admin/conference/_recent_submissions.html.haml @@ -16,8 +16,8 @@ %td= link_to event.submitter.name, admin_user_path(event.submitter.id) - else %td Unknown Submitter - %td= link_to event.title, admin_conference_event_path(event.conference.short_title, event) - %td= link_to event.conference.title, admin_conference_path(event.conference.short_title) + %td= link_to event.title, admin_conference_program_event_path(event.program.conference.short_title, event) + %td= link_to event.program.conference.title, admin_conference_path(event.program.conference.short_title) %td .span{'class'=>label_for(event.state)} #{event.state.humanize} - else diff --git a/app/views/admin/conference/_todo_list.html.haml b/app/views/admin/conference/_todo_list.html.haml index 1ed13f51..387a47c7 100644 --- a/app/views/admin/conference/_todo_list.html.haml +++ b/app/views/admin/conference/_todo_list.html.haml @@ -17,8 +17,8 @@ Set up registration period %li{'class'=>"list-group-item #{class_for_todo(conference_progress['cfp'])}"} %span{'class'=>icon_for_todo(conference_progress['cfp'])} - - if can? :update, CallForPaper.new(conference_id: @conference.id) - = link_to 'Set up call for papers', admin_conference_call_for_paper_path(conference_progress['short_title']) + - if can? :update, Cfp.new(program_id: @program.id) + = link_to 'Set up call for papers', admin_conference_program_cfp_path(conference_progress['short_title']) - else Set up call for papers %li{'class'=>"list-group-item #{class_for_todo(conference_progress['venue'])}"} @@ -32,26 +32,26 @@ Add venue %li{'class'=>"list-group-item #{class_for_todo(conference_progress['rooms'])}"} %span{'class'=>icon_for_todo(conference_progress['rooms'])} - - if can? :update, @conference.rooms.build - = link_to 'Add rooms', admin_conference_rooms_path(conference_progress['short_title']) + - if @conference.venue && (can? :update, @conference.venue.rooms.build) + = link_to 'Add rooms', admin_conference_venue_rooms_path(conference_progress['short_title']) - else Add rooms %li{'class'=>"list-group-item #{class_for_todo(conference_progress['tracks'])}"} %span{'class'=>icon_for_todo(conference_progress['tracks'])} - - if can? :update, @conference.tracks.build - = link_to 'Add tracks', admin_conference_tracks_path(conference_progress['short_title']) + - if can? :update, @conference.program.tracks.build + = link_to 'Add tracks', admin_conference_program_tracks_path(conference_progress['short_title']) - else Add tracks %li{'class'=>"list-group-item #{class_for_todo(conference_progress['event_types'])}"} %span{'class'=>icon_for_todo(conference_progress['event_types'])} - - if can? :update, @conference.event_types.build - = link_to 'Add event types', admin_conference_event_types_path(conference_progress['short_title']) + - if can? :update, @conference.program.event_types.build + = link_to 'Add event types', admin_conference_program_event_types_path(conference_progress['short_title']) - else Add event types %li{'class'=>"list-group-item #{class_for_todo(conference_progress['difficulty_levels'])}"} %span{'class'=>icon_for_todo(conference_progress['difficulty_levels'])} - - if can? :update, @conference.difficulty_levels.build - = link_to 'Add difficulty levels', admin_conference_difficulty_levels_path(conference_progress['short_title']) + - if can? :update, @conference.program.difficulty_levels.build + = link_to 'Add difficulty levels', admin_conference_program_difficulty_levels_path(conference_progress['short_title']) - else Add difficulty levels %li{class: "list-group-item #{class_for_todo(conference_progress['splashpage'])}"} diff --git a/app/views/admin/conference/edit.html.haml b/app/views/admin/conference/edit.html.haml index 5a931d1e..cbbfb3e7 100644 --- a/app/views/admin/conference/edit.html.haml +++ b/app/views/admin/conference/edit.html.haml @@ -18,5 +18,6 @@ = f.input :timezone, :as => :time_zone, :hint => "The conference time zone" = f.input :start_date, :as => :string, :input_html => { :id => "conference-start-datepicker", :readonly => "readonly" } = f.input :end_date, :as => :string, :input_html => { :id => "conference-end-datepicker", :readonly => "readonly" } + = f.inputs name: "Registrations" do + = f.input :registration_limit, as: :number, in: 0..9999, hint: "Limit the number of registrations to the conference (0 no limit)" = f.action :submit, :as => :button, :button_html => {:class => "btn btn-primary"} - diff --git a/app/views/admin/difficulty_levels/_form.html.haml b/app/views/admin/difficulty_levels/_form.html.haml index f0b43cd0..534fa179 100644 --- a/app/views/admin/difficulty_levels/_form.html.haml +++ b/app/views/admin/difficulty_levels/_form.html.haml @@ -8,7 +8,7 @@ = @difficulty_level.title .row .col-md-8 - = semantic_form_for(@difficulty_level, :url => (@difficulty_level.new_record? ? admin_conference_difficulty_levels_path : admin_conference_difficulty_level_path(@conference.short_title, @difficulty_level))) do |f| + = semantic_form_for(@difficulty_level, :url => (@difficulty_level.new_record? ? admin_conference_program_difficulty_levels_path : admin_conference_program_difficulty_level_path(@conference.short_title, @difficulty_level))) do |f| = f.input :title, :required => true = f.input :description, :input_html => {:rows => 3, :class => "span6"} = f.input :color, :input_html => {:size => 6, :type => "color"} diff --git a/app/views/admin/difficulty_levels/index.html.haml b/app/views/admin/difficulty_levels/index.html.haml index 1b02d446..70d6e2d8 100644 --- a/app/views/admin/difficulty_levels/index.html.haml +++ b/app/views/admin/difficulty_levels/index.html.haml @@ -3,7 +3,7 @@ .page-header %h1 Difficulty Levels %p.text-muted - Classify your conference events by difficulty + Classify your conference.program.events by difficulty .row .col-md-12 %table.table.table-hover#difficulty_levels @@ -13,7 +13,7 @@ %th Color %th Actions %tbody - - @conference.difficulty_levels.each do |difficulty_level| + - @conference.program.difficulty_levels.each do |difficulty_level| %tr %td = difficulty_level.title @@ -24,11 +24,11 @@ = difficulty_level.color %td .btn-group{role: "group"} - = link_to 'Edit', edit_admin_conference_difficulty_level_path(@conference.short_title, difficulty_level.id), + = link_to 'Edit', edit_admin_conference_program_difficulty_level_path(@conference.short_title, difficulty_level.id), method: :get, class: 'btn btn-primary' - = link_to 'Delete', admin_conference_difficulty_level_path(@conference.short_title, difficulty_level.id), + = link_to 'Delete', admin_conference_program_difficulty_level_path(@conference.short_title, difficulty_level.id), method: :delete, class: 'btn btn-danger', data: { confirm: "Do you really want to delete #{difficulty_level.title}? Attention: This difficulty level will be removed from all Events that have it set" } .row .col-md-12.text-right - = link_to 'Add Difficulty Level', new_admin_conference_difficulty_level_path(@conference.short_title), class: 'btn btn-primary' + = link_to 'Add Difficulty Level', new_admin_conference_program_difficulty_level_path(@conference.short_title), class: 'btn btn-primary' diff --git a/app/views/admin/emails/_help.html.haml b/app/views/admin/emails/_help.html.haml index 5555988d..d71b6f9e 100644 --- a/app/views/admin/emails/_help.html.haml +++ b/app/views/admin/emails/_help.html.haml @@ -41,14 +41,14 @@ %tr %td {venue_address} %td The address of the venue - - unless @conference.call_for_paper.blank? || @conference.call_for_paper.start_date.blank? || @conference.call_for_paper.end_date.blank? + - unless @conference.program.cfp.blank? || @conference.program.cfp.start_date.blank? || @conference.program.cfp.end_date.blank? %tr %td {cfp_start_date} %td The call for papers start date %tr %td {cfp_end_date} %td The call for papers end date - -if @conference.call_for_paper.schedule_public + -if @conference.program.schedule_public %td {schedule_link} %td The link to complete schedule of the conference - if @conference.splashpage && @conference.splashpage.public diff --git a/app/views/admin/emails/index.html.haml b/app/views/admin/emails/index.html.haml index 9f96e761..fa5010d1 100644 --- a/app/views/admin/emails/index.html.haml +++ b/app/views/admin/emails/index.html.haml @@ -69,18 +69,18 @@ %a.btn.btn-link.control_label.template_help_link{"data-name"=>"updated_venue_help"} Show Help = render partial: 'help', locals: {id: 'updated_venue_help', show_event_variables: false} #cfp.tab-pane{:role => "tabpanel"} - = f.input :send_on_call_for_papers_schedule_public, hint: "This will notify all participants when the dates are updated or when the schedule is made public" - = f.input :call_for_papers_schedule_public_subject, hint: "This subject will used whenever dates are updated or when the schedule is made public" - = f.input :call_for_papers_schedule_public_body, :input_html => { :rows => 10, :cols => 20 } + = f.input :send_on_program_schedule_public, hint: "This will notify all participants when the dates are updated or when the schedule is made public" + = f.input :program_schedule_public_subject, hint: "This subject will used whenever dates are updated or when the schedule is made public" + = f.input :program_schedule_public_body, :input_html => { :rows => 10, :cols => 20 } %a.btn.btn-link.control_label.load_template{"data-template"=>"Dear {name},\n\nThe Conference Call for Papers Details of {conference} has changed.The schedule is being made public.\n Link to Schedule {schedule_link} \n\nBest wishes\n\n{conference} Team", - "data-name"=>"email_settings_call_for_papers_schedule_public_body"} Load Template + "data-name"=>"email_settings_program_schedule_public_body"} Load Template %a.btn.btn-link.control_label.template_help_link{"data-name"=>"updated_cfp_help"} Show Help = render partial: 'help', locals: {id: 'updated_cfp_help', show_event_variables: false} - = f.input :send_on_call_for_papers_dates_updated, hint: "This will notify all participants when the dates are updated or when the schedule is made public" - = f.input :call_for_papers_dates_updated_subject, hint: "This subject will used whenever dates are updated or when the schedule is made public" - = f.input :call_for_papers_dates_updated_body, :input_html => { :rows => 10, :cols => 20 } + = f.input :send_on_cfp_dates_updated, hint: "This will notify all participants when the dates are updated or when the schedule is made public" + = f.input :cfp_dates_updated_subject, hint: "This subject will used whenever dates are updated or when the schedule is made public" + = f.input :cfp_dates_updated_body, :input_html => { :rows => 10, :cols => 20 } %a.btn.btn-link.control_label.load_template{"data-template"=>"Dear {name},\n\nThe Conference Call for Papers Details of {conference} has changed.\nNew Dates : {cfp_start_date} - {cfp_end_date}.\n Link to Schedule {schedule_link} \n\nBest wishes\n\n{conference} Team", - "data-name"=>"email_settings_call_for_papers_dates_updated_body"} Load Template + "data-name"=>"email_settings_cfp_dates_updated_body"} Load Template %a.btn.btn-link.control_label.template_help_link{"data-name"=>"updated_cfp_help"} Show Help = render partial: 'help', locals: {id: 'updated_cfp_help', show_event_variables: false} .row diff --git a/app/views/admin/event_types/_form.html.haml b/app/views/admin/event_types/_form.html.haml index 0e0db179..397e9871 100644 --- a/app/views/admin/event_types/_form.html.haml +++ b/app/views/admin/event_types/_form.html.haml @@ -8,7 +8,7 @@ = @event_type.title .row .col-md-12 - = semantic_form_for(@event_type, :url => (@event_type.new_record? ? admin_conference_event_types_path : admin_conference_event_type_path(@conference.short_title, @event_type))) do |f| + = semantic_form_for(@event_type, :url => (@event_type.new_record? ? admin_conference_program_event_types_path : admin_conference_program_event_type_path(@conference.short_title, @event_type))) do |f| = f.input :title = f.input :length, :input_html => {:size => 3} = f.input :description diff --git a/app/views/admin/event_types/index.html.haml b/app/views/admin/event_types/index.html.haml index e5513eff..3187282f 100644 --- a/app/views/admin/event_types/index.html.haml +++ b/app/views/admin/event_types/index.html.haml @@ -15,7 +15,7 @@ %th Color %th Actions %tbody - - @conference.event_types.each do |event_type| + - @conference.program.event_types.each do |event_type| %tr %td = event_type.title @@ -32,11 +32,11 @@ = event_type.color %td .btn-group{role: "group"} - = link_to 'Edit', edit_admin_conference_event_type_path(@conference.short_title, event_type.id), + = link_to 'Edit', edit_admin_conference_program_event_type_path(@conference.short_title, event_type.id), method: :get, class: 'btn btn-primary' - = link_to 'Delete', admin_conference_event_type_path(@conference.short_title, event_type.id), + = link_to 'Delete', admin_conference_program_event_type_path(@conference.short_title, event_type.id), method: :delete, class: 'btn btn-danger', data: { confirm: "Do you really want to delete #{event_type.name}?" } .row .col-md-12.text-right - = link_to 'Add Event Type', new_admin_conference_event_type_path(@conference.short_title), class: 'btn btn-primary' + = link_to 'Add Event Type', new_admin_conference_program_event_type_path(@conference.short_title), class: 'btn btn-primary' diff --git a/app/views/admin/events/_change_state_dropdown.html.haml b/app/views/admin/events/_change_state_dropdown.html.haml index dd0a96f8..f8dde305 100644 --- a/app/views/admin/events/_change_state_dropdown.html.haml +++ b/app/views/admin/events/_change_state_dropdown.html.haml @@ -1,37 +1,37 @@ - if event.transition_possible? :accept %li= link_to 'Accept event', - accept_admin_conference_event_path(@conference.short_title, event), + accept_admin_conference_program_event_path(@conference.short_title, event), method: :patch, id: "accept_event_#{event.id}" - if @conference.email_settings.send_on_accepted? %li= link_to 'Accept event (without email)', - accept_admin_conference_event_path(@conference.short_title, event, send_mail: false), + accept_admin_conference_program_event_path(@conference.short_title, event, send_mail: false), method: :patch, hint: 'Accept this event without sending an automated email.', id: "accept_event_without_mail_#{event.id}" - if event.transition_possible? :reject %li= link_to 'Reject event', - reject_admin_conference_event_path(@conference.short_title, event), + reject_admin_conference_program_event_path(@conference.short_title, event), method: :patch, confirm: 'Are you sure?', id: "reject_event_#{event.id}" - if @conference.email_settings.send_on_rejected? %li= link_to 'Reject event (without email)', - reject_admin_conference_event_path(@conference.short_title, event, send_mail: false), + reject_admin_conference_program_event_path(@conference.short_title, event, send_mail: false), method: :patch, confirm: 'Are you sure?', id: "reject_event_without_mail_#{event.id}" - if event.transition_possible? :restart %li= link_to 'Start review', - restart_admin_conference_event_path(@conference.short_title, event), + restart_admin_conference_program_event_path(@conference.short_title, event), method: :patch, id: "restart_event_#{event.id}" - if event.transition_possible? :confirm %li= link_to 'Confirm event', - confirm_admin_conference_event_path(@conference.short_title, event), + confirm_admin_conference_program_event_path(@conference.short_title, event), method: :patch, id: "confirm_event_#{event.id}", hint: 'Confirm that the speaker(s) will be present and that the event will actually take place.' - if event.transition_possible? :cancel %li= link_to 'Cancel event', - cancel_admin_conference_event_path(@conference.short_title, event), + cancel_admin_conference_program_event_path(@conference.short_title, event), method: :patch, id: "cancel_event_#{event.id}", - hint: 'Mark this event as cancelled. Usually this means that the speakers had to cancel their appearance.' \ No newline at end of file + hint: 'Mark this event as cancelled. Usually this means that the speakers had to cancel their appearance.' diff --git a/app/views/admin/events/_nested_comments.html.haml b/app/views/admin/events/_nested_comments.html.haml index 24c641f8..de0044d7 100644 --- a/app/views/admin/events/_nested_comments.html.haml +++ b/app/views/admin/events/_nested_comments.html.haml @@ -6,7 +6,7 @@ %div %a.pull-right.comment-reply-link{href: "#"} Reply .comment-reply - = form_tag "#{comment_admin_conference_event_path(@conference.short_title, comment.commentable_id)}", method: :post do + = form_tag "#{comment_admin_conference_program_event_path(@conference.short_title, comment.commentable_id)}", method: :post do %input{name: "parent", type: "hidden", value: "#{comment.id}"} %input{name: "authenticity_token", type: "hidden", value: "#{form_authenticity_token}"} %textarea{name: "comment"} diff --git a/app/views/admin/events/_proposal.html.haml b/app/views/admin/events/_proposal.html.haml index a29282a4..4e51b312 100644 --- a/app/views/admin/events/_proposal.html.haml +++ b/app/views/admin/events/_proposal.html.haml @@ -5,7 +5,7 @@ %br %small = @event.subtitle - = link_to 'Edit', edit_admin_conference_event_path(@conference.short_title, @event), class: 'btn btn-mini btn-primary pull-right' + = link_to 'Edit', edit_admin_conference_program_event_path(@conference.short_title, @event), class: 'btn btn-mini btn-primary pull-right' .row .col-md-12 @@ -24,7 +24,7 @@ %ul.dropdown-menu - @event_types.each do |type| %li= link_to type.title, - admin_conference_event_path(@conference.short_title, + admin_conference_program_event_path(@conference.short_title, @event, event: { event_type_id: type.id }), method: :patch @@ -33,7 +33,7 @@ %b Highlight %td = check_box_tag @conference.short_title, @event.id, @event.is_highlight, - method: :patch, url: "/admin/conference/#{@conference.short_title}/events/#{@event.id}?event[is_highlight]=", + method: :patch, url: "/admin/conference/#{@conference.short_title}/program/events/#{@event.id}?event[is_highlight]=", class: 'switch-checkbox', data: { size: 'small', off_color: 'warning', on_text: 'Yes', @@ -63,7 +63,7 @@ %ul.dropdown-menu - @tracks.each do |track| %li= link_to track.name, - admin_conference_event_path(@conference.short_title, + admin_conference_program_event_path(@conference.short_title, @event, event: { track_id: track.id }), method: :patch @@ -80,7 +80,7 @@ %ul.dropdown-menu - @difficulty_levels.each do |difficulty| - %li= link_to difficulty.title, admin_conference_event_path(@conference.short_title, + %li= link_to difficulty.title, admin_conference_program_event_path(@conference.short_title, @event, event: { difficulty_level_id: difficulty.id }), method: :patch @@ -89,7 +89,7 @@ %b Requires Registration %td = check_box_tag @conference.short_title, @event.id, @event.require_registration, - method: :patch, url: "/admin/conference/#{@conference.short_title}/events/#{@event.id}?event[require_registration]=", + method: :patch, url: "/admin/conference/#{@conference.short_title}/program/events/#{@event.id}?event[require_registration]=", class: 'switch-checkbox', data: { size: 'small', off_color: 'warning', on_text: 'Yes', @@ -137,7 +137,7 @@ %b Description %td= simple_format(@event.description) - - if @conference.call_for_paper && @conference.call_for_paper.rating && @conference.call_for_paper.rating > 0 + - if @conference.program && @conference.program.rating && @conference.program.rating > 0 = render partial: 'voting' .row @@ -147,7 +147,7 @@ %ul.media %div .row-fluid - = form_tag(comment_admin_conference_event_path(@conference.short_title, @event.id), method: :post) do + = form_tag(comment_admin_conference_program_event_path(@conference.short_title, @event.id), method: :post) do = text_area_tag(:comment, '') = submit_tag 'Add Comment', class: 'btn btn-primary pull-right' %br diff --git a/app/views/admin/events/_voting.html.haml b/app/views/admin/events/_voting.html.haml index 43b44cea..bc281d87 100644 --- a/app/views/admin/events/_voting.html.haml +++ b/app/views/admin/events/_voting.html.haml @@ -4,11 +4,11 @@ %b Rating %td - if @event.average_rating.to_f > 0 - #{@event.average_rating}/#{@conference.call_for_paper.rating} + #{@event.average_rating}/#{@conference.program.rating} - else - Rating: 0/#{@conference.call_for_paper.rating} + Rating: 0/#{@conference.program.rating} - - @conference.call_for_paper.rating.times do |counter| + - @conference.program.rating.times do |counter| - if @event.average_rating.to_f.round == counter+1 = label_tag "label_rating", "", :class => "avgrating", :avgrate => true = javascript_tag "$('label[avgrate=true]').prevAll().andSelf().addClass('bright');" @@ -27,12 +27,12 @@ %td %b Your vote %td - - @conference.call_for_paper.rating.times do |counter| + - @conference.program.rating.times do |counter| - voted = @event.voted?(@event, current_user) - if voted && voted.rating == counter+1 - = link_to "", vote_admin_conference_event_path(@conference.short_title, @event, :rating => counter+1), :remote => true, :id =>"label#{counter+1}", :class => "myrating", :voted => true + = link_to "", vote_admin_conference_program_event_path(@conference.short_title, @event, :rating => counter+1), :remote => true, :id =>"label#{counter+1}", :class => "myrating", :voted => true - else - = link_to "", vote_admin_conference_event_path(@conference.short_title, @event, :rating => counter+1), :remote => true, :id =>"label#{counter+1}", :class => "myrating" + = link_to "", vote_admin_conference_program_event_path(@conference.short_title, @event, :rating => counter+1), :remote => true, :id =>"label#{counter+1}", :class => "myrating" %br - if @ratings.length > 0 @@ -42,7 +42,7 @@ %td = rate.name %td - - @conference.call_for_paper.rating.times do |counter| + - @conference.program.rating.times do |counter| - voted = @event.voted?(@event, rate.user) - if voted && voted.rating == counter+1 = label_tag "label#{counter+1}", "", :class => "othersrating", :voted => true diff --git a/app/views/admin/events/index.html.haml b/app/views/admin/events/index.html.haml index 10a99f6d..6eea977f 100644 --- a/app/views/admin/events/index.html.haml +++ b/app/views/admin/events/index.html.haml @@ -15,7 +15,7 @@ %b ID %th %b Title - - if @conference.call_for_paper && @conference.call_for_paper.rating && @conference.call_for_paper.rating > 0 + - if @program.rating_enabled? %th %b Rating %th @@ -39,16 +39,16 @@ %td = event.id %td - =link_to event.title, admin_conference_event_path(@conference.short_title, event) + =link_to event.title, admin_conference_program_event_path(@conference.short_title, event) - - if @conference.call_for_paper && @conference.call_for_paper.rating && @conference.call_for_paper.rating > 0 + - if @program.rating_enabled? %td.col-md-1{'data-order' => "#{event.average_rating}"} - if event.average_rating.to_f > 0 - #{event.average_rating}/#{@conference.call_for_paper.rating} + #{event.average_rating}/#{@program.rating} %br #{pluralize(event.voters.length, 'voter')} %br - - @conference.call_for_paper.rating.times do |counter| + - @program.rating.times do |counter| - if event.average_rating.to_f.round == counter+1 = label_tag "label_rating", "", :class => "avgrating", :avgrate => true = javascript_tag "$('label[avgrate=true]').prevAll().andSelf().addClass('bright');" @@ -63,7 +63,7 @@ %span.label.label-danger Not rated - else - 0/#{@conference.call_for_paper.rating} + 0/#{@program.rating} %br - if event.submitter && event.submitter.registrations && event.submitter.registrations.count < 1 @@ -85,7 +85,7 @@ %td{'data-order' => "#{event.require_registration}"} = check_box_tag @conference.short_title, event.id, event.require_registration, - method: :patch, url: "/admin/conference/#{@conference.short_title}/events/#{event.id}?event[require_registration]=", + method: :patch, url: "/admin/conference/#{@conference.short_title}/program/events/#{event.id}?event[require_registration]=", class: 'switch-checkbox', data: { size: 'small', off_color: 'warning', on_text: 'Yes', @@ -93,7 +93,7 @@ %td{'data-order' => "#{event.is_highlight}"} = check_box_tag @conference.short_title, event.id, event.is_highlight, - method: :patch, url: "/admin/conference/#{@conference.short_title}/events/#{event.id}?event[is_highlight]=", + method: :patch, url: "/admin/conference/#{@conference.short_title}/program/events/#{event.id}?event[is_highlight]=", class: 'switch-checkbox', data: { size: 'small', off_color: 'warning', on_text: 'Yes', @@ -110,7 +110,7 @@ %ul.dropdown-menu - @event_types.each do |type| %li= link_to type.title, - admin_conference_event_path(@conference.short_title, + admin_conference_program_event_path(@conference.short_title, event, event: { event_type_id: type.id }), method: :patch @@ -125,7 +125,7 @@ %ul.dropdown-menu - @tracks.each do |track| %li= link_to track.name, - admin_conference_event_path(@conference.short_title, + admin_conference_program_event_path(@conference.short_title, event, event: { track_id: track.id }), method: :patch @@ -140,7 +140,7 @@ %ul.dropdown-menu - @difficulty_levels.each do |difficulty_level| %li= link_to difficulty_level.title, - admin_conference_event_path(@conference.short_title, + admin_conference_program_event_path(@conference.short_title, event, event: { difficulty_level_id: difficulty_level.id }), method: :patch diff --git a/app/views/admin/programs/_form.html.haml b/app/views/admin/programs/_form.html.haml new file mode 100644 index 00000000..13b1ce72 --- /dev/null +++ b/app/views/admin/programs/_form.html.haml @@ -0,0 +1,12 @@ +.row + .col-md-12 + .page-header + %h1 Program +.row + .col-md-8 + = semantic_form_for(@program, :url => admin_conference_program_path(@conference.short_title),:html => {:multipart => true}) do |f| + = f.input :schedule_public, label: "Show Schedule on the home and splash page" + = f.input :schedule_fluid, label: "Allow submitters to change their event after it is scheduled" + = f.input :rating, :hint => "Enter the number of different rating levels you want to have for voting on proposals. Enter 0 if you do not want to vote on proposals." + %p.text-right + = f.action :submit, :as => :button, :button_html => {:class => "btn btn-primary"} diff --git a/app/views/admin/programs/show.html.haml b/app/views/admin/programs/show.html.haml new file mode 100644 index 00000000..feff0205 --- /dev/null +++ b/app/views/admin/programs/show.html.haml @@ -0,0 +1,61 @@ +.row + .col-md-12 + .page-header + %h1 Program +- if @program + .row + .col-md-8 + %dl.dl-horizontal + - if @cfp + %dt + Start Date: + %dd#start_date + = @cfp.start_date.strftime('%A, %B %-d. %Y') + %dt + End Date: + %dd#end_date + = @cfp.end_date.strftime('%A, %B %-d. %Y') + %dt + Days Left: + %dd + = pluralize(@cfp.remaining_days, 'day') + %dt + Event types: + %dd + = event_types(@conference) + %dt + Tracks: + %dd + = tracks(@conference) + %dt + Difficulty Levels: + %dd + = difficulty_levels(@conference) + %dt + Public Schedule + %dd#schedule_public + - if @program.schedule_public + Yes + - else + No + %dt + Schedule changeable? + %dd#schedule_changes + - if @program.schedule_fluid + Yes + - else + No + %dt + Rating Levels + %dd#rating + = @program.rating + + + .row + .col-md-12.text-right + - if can? :edit, @progam + = link_to edit_admin_conference_program_path(@conference.short_title), class: 'btn btn-primary' do + Edit + - if can? :destroy, @program + = link_to admin_conference_program_path(@conference.short_title), method: 'delete', class: 'btn btn-danger', data: { confirm: 'Are you sure you want to delete this program?' } do + Delete diff --git a/app/views/admin/rooms/_form.html.haml b/app/views/admin/rooms/_form.html.haml index 05cf1b0d..47cd9a77 100644 --- a/app/views/admin/rooms/_form.html.haml +++ b/app/views/admin/rooms/_form.html.haml @@ -8,8 +8,8 @@ = @room.name .row .col-md-8 - = semantic_form_for(@room, :url => (@room.new_record? ? admin_conference_rooms_path : admin_conference_room_path(@conference.short_title, @room))) do |f| - = f.input :name + = semantic_form_for(@room, :url => (@room.new_record? ? admin_conference_venue_rooms_path : admin_conference_venue_room_path(@conference.short_title, @room))) do |f| + = f.input :name, input_html: { autofocus: true} = f.input :size, :input_html => {:size => 5} %p.text-right - = f.action :submit, as: :button, button_html: { class: 'btn btn-primary' } \ No newline at end of file + = f.action :submit, as: :button, button_html: { class: 'btn btn-primary' } diff --git a/app/views/admin/rooms/index.html.haml b/app/views/admin/rooms/index.html.haml index 52f00f18..8bf682c8 100644 --- a/app/views/admin/rooms/index.html.haml +++ b/app/views/admin/rooms/index.html.haml @@ -5,7 +5,7 @@ %p.text-muted The rooms of your conference venue -- if @conference.rooms.any? +- if @rooms.any? .row .col-md-12 %table.table.table-hover#rooms @@ -14,18 +14,18 @@ %th Size %th Actions %tbody - - @conference.rooms.each_with_index do |room, index| + - @rooms.each_with_index do |room, index| %tr %td = room.name %td = room.size %td - = link_to 'Edit', edit_admin_conference_room_path(@conference.short_title, room.id), + = link_to 'Edit', edit_admin_conference_venue_room_path(@conference.short_title, room.id), method: :get, class: 'btn btn-primary' - = link_to 'Delete', admin_conference_room_path(@conference.short_title, room.id), + = link_to 'Delete', admin_conference_venue_room_path(@conference.short_title, room.id), method: :delete, class: 'btn btn-danger', data: { confirm: "Do you really want to delete #{room.name}? Attention: This room will be removed from all Events that have it set"} .row .col-md-12.text-right - = link_to 'Add Room', new_admin_conference_room_path(@conference.short_title), class: 'btn btn-primary' + = link_to 'Add Room', new_admin_conference_venue_room_path(@conference.short_title), class: 'btn btn-primary' diff --git a/app/views/admin/tracks/_form.html.haml b/app/views/admin/tracks/_form.html.haml index db18e963..d637af26 100644 --- a/app/views/admin/tracks/_form.html.haml +++ b/app/views/admin/tracks/_form.html.haml @@ -8,7 +8,7 @@ Track .row .col-md-12 - = semantic_form_for(@track, :url => (@track.new_record? ? admin_conference_tracks_path : admin_conference_track_path(@conference.short_title, @track))) do |f| + = semantic_form_for(@track, :url => (@track.new_record? ? admin_conference_program_tracks_path : admin_conference_program_track_path(@conference.short_title, @track))) do |f| = f.input :name = f.input :color, :input_html => {:size => 6, :type => "color"}, :required=> true = f.input :description, :input_html => {:rows => 2, data: { provide: "markdown-editable" } }, hint: markdown_hint diff --git a/app/views/admin/tracks/index.html.haml b/app/views/admin/tracks/index.html.haml index 8ba3a41b..73b7979d 100644 --- a/app/views/admin/tracks/index.html.haml +++ b/app/views/admin/tracks/index.html.haml @@ -13,10 +13,10 @@ %th Color %th Actions %tbody - - @conference.tracks.each do |track| + - @tracks.each do |track| %tr %td - = link_to(admin_conference_track_path(@conference.short_title, track)) do + = link_to(admin_conference_program_track_path(@conference.short_title, track)) do = track.name %td %p @@ -26,12 +26,12 @@ = track.color %td .btn-group{role: "group"} - = link_to 'Edit', edit_admin_conference_track_path(@conference.short_title, track.id), + = link_to 'Edit', edit_admin_conference_program_track_path(@conference.short_title, track.id), method: :get, class: 'btn btn-primary' - = link_to 'Delete', admin_conference_track_path(@conference.short_title, track.id), + = link_to 'Delete', admin_conference_program_track_path(@conference.short_title, track.id), method: :delete, class: 'btn btn-danger', data: { confirm: "Do you really want to delete #{track.name}? Attention: This track will be removed from all Events that have it set" } .row .col-md-12.text-right - = link_to 'New Track', new_admin_conference_track_path(@conference.short_title), class: 'btn btn-success' + = link_to 'New Track', new_admin_conference_program_track_path(@conference.short_title), class: 'btn btn-success' diff --git a/app/views/admin/tracks/show.html.haml b/app/views/admin/tracks/show.html.haml index 5f6ffc04..240b9725 100644 --- a/app/views/admin/tracks/show.html.haml +++ b/app/views/admin/tracks/show.html.haml @@ -19,7 +19,7 @@ - @track.events.each_with_index do |event| %tr %td - =link_to event.title, admin_conference_event_path(@conference.short_title, event) + =link_to event.title, admin_conference_program_event_path(@conference.short_title, event) %td = event.event_type.title %td diff --git a/app/views/admin/users/_submissions.html.haml b/app/views/admin/users/_submissions.html.haml index 0daa1368..c3b05119 100644 --- a/app/views/admin/users/_submissions.html.haml +++ b/app/views/admin/users/_submissions.html.haml @@ -17,13 +17,13 @@ - @user.events.each do |event| %tr %td= event.id - %td= link_to event.conference.short_title, admin_conference_path(event.conference.short_title) - %td= link_to event.title, admin_conference_event_path(event.conference.short_title, event) + %td= link_to event.program.conference.short_title, admin_conference_path(event.program.conference.short_title) + %td= link_to event.title, admin_conference_program_event_path(event.program.conference.short_title, event) %td= event.state %td= "#{event.event_type.title} (#{show_time(event.event_type.length)})" %td - - if event.conference.call_for_paper && event.conference.call_for_paper.rating && event.conference.call_for_paper.rating > 0 - - event.conference.call_for_paper.rating.times do |counter| + - if event.program && event.program.rating && event.program.rating > 0 + - event.program.rating.times do |counter| - if event.average_rating.to_f.round == counter+1 = label_tag 'label_rating', '', class: 'avgrating', avgrate: true = javascript_tag "$('label[avgrate=true]').prevAll().andSelf().addClass('bright');" diff --git a/app/views/admin/venues/show.html.haml b/app/views/admin/venues/show.html.haml index 900e2b9e..00885085 100644 --- a/app/views/admin/venues/show.html.haml +++ b/app/views/admin/venues/show.html.haml @@ -20,12 +20,12 @@ = @venue.country_name .row .col-md-12 - = link_to(edit_admin_conference_venue_path(@conference.short_title), class: 'btn btn-primary') do + = link_to(edit_admin_conference_venue_path(@conference.short_title), class: 'btn btn-primary', disabled: !(can? :update, @venue) ) do Edit Venue - = link_to(admin_conference_venue_path(@conference.short_title), method: 'delete', class: 'btn btn-danger') do + = link_to(admin_conference_venue_path(@conference.short_title), method: 'delete', class: 'btn btn-danger', disabled: !(can? :destroy, @venue)) do Delete Venue -else .row .col-md-12.text-right = link_to(new_admin_conference_venue_path(@conference.short_title), class: 'btn btn-primary') do - Create Venue \ No newline at end of file + Create Venue diff --git a/app/views/commercials/edit.html.haml b/app/views/commercials/edit.html.haml new file mode 100644 index 00000000..174a1a60 --- /dev/null +++ b/app/views/commercials/edit.html.haml @@ -0,0 +1,9 @@ +.container + .row + .col-md-12 + .page-header + %h1 Editing Commercial + .row + .col-md-12 + = semantic_form_for @commercial, url: conference_program_proposal_commercial_path(conference_id: @conference.short_title, proposal_id: @event.id, id: @commercial.id) do |f| + = render 'form', f: f diff --git a/app/views/commercials/new.html.haml b/app/views/commercials/new.html.haml new file mode 100644 index 00000000..da726e89 --- /dev/null +++ b/app/views/commercials/new.html.haml @@ -0,0 +1,9 @@ +.container + .row + .col-md-12 + .page-header + %h1 New Commercial + .row + .col-md-12 + = semantic_form_for @commercial, url: conference_program_proposal_commercials_path(conference_id: @conference.short_title, proposal_id: @event.id) do |f| + = render 'form', f: f diff --git a/app/views/conference/_all_events.html.erb b/app/views/conference/_all_events.html.erb index 130dceca..f7fd7fc0 100644 --- a/app/views/conference/_all_events.html.erb +++ b/app/views/conference/_all_events.html.erb @@ -1,8 +1,8 @@

Program for <%= @conference.title %>

-<% @conference.events.confirmed.each do |event| %> +<% @conference.program.events.confirmed.each do |event| %>

- <%= link_to event.title, conference_proposal_path(@conference.short_title, event.id) %> + <%= link_to event.title, conference_program_proposal_path(@conference.short_title, event.id) %>
<%= event.subtitle %> @@ -13,7 +13,7 @@

<%= truncate(event.abstract, :length => 400) -%> - <%= link_to 'more', conference_proposal_path(@conference.short_title, event.id) if event.abstract.length > 400 %> + <%= link_to 'more', conference_program_proposal_path(@conference.short_title, @conference.program.id, event.id) if event.abstract.length > 400 %>

<% end %> diff --git a/app/views/conference/_call_for_paper.html.haml b/app/views/conference/_call_for_paper.html.haml index 32e2efe2..dd45ad60 100644 --- a/app/views/conference/_call_for_paper.html.haml +++ b/app/views/conference/_call_for_paper.html.haml @@ -12,22 +12,22 @@ .row .col-md-6.col-md-offset-3.col-sm-10.col-sm-offset-1 %p - - if @conference.event_types.any? + - if @program.event_types.any? You can submit proposals for = "#{event_types(@conference)}." - - if @conference.tracks.any? + - if @program.tracks.any? Proposals should fit in one of the - = "#{pluralize(@conference.tracks.count, 'track')}:" + = "#{pluralize(@program.tracks.count, 'track')}:" = "#{tracks(@conference)}." The submission period has begun %em - = @conference.call_for_paper.start_date.strftime('%A, %B %-d. %Y') + = @program.cfp.start_date.strftime('%A, %B %-d. %Y') and closes %em - = @conference.call_for_paper.end_date.strftime('%A, %B %-d. %Y.') - - if @conference.cfp_open? + = @program.cfp.end_date.strftime('%A, %B %-d. %Y.') + - if @program.cfp_open? That means you have only - %b= pluralize(@conference.call_for_paper.remaining_days, 'day') + %b= pluralize(@program.cfp.remaining_days, 'day') left! Remember = @conference.short_title @@ -37,4 +37,4 @@ .row .col-md-12.text-center %p.cta-button - = link_to "Submit your paper now", conference_proposal_index_path(@conference.short_title), class: 'btn btn-success btn-lg text-center' + = link_to "Submit your paper now", conference_program_proposal_index_path(@conference.short_title), class: 'btn btn-success btn-lg text-center' diff --git a/app/views/conference/_conference_details.html.haml b/app/views/conference/_conference_details.html.haml index 07704360..d3c07658 100644 --- a/app/views/conference/_conference_details.html.haml +++ b/app/views/conference/_conference_details.html.haml @@ -21,17 +21,19 @@ - if !@conference || @conference != conference - if conference.splashpage && conference.splashpage.public = link_to "View Conference", conference_path(conference.short_title), :class =>"btn btn-default" - - if conference.call_for_paper and conference.call_for_paper.schedule_public + - if conference.program and conference.program.schedule_public = link_to "Schedule", schedule_conference_path(conference.short_title), :class =>"btn btn-default" - if conference.registration_open? - if conference.user_registered?(current_user) = link_to "My Registration", conference_conference_registrations_path(conference.short_title), :class =>"btn btn-default" - else - = link_to "Register", new_conference_conference_registrations_path(conference.short_title), :class =>"btn btn-default" + = link_to "Register", new_conference_conference_registrations_path(conference.short_title), class: "btn btn-default", disabled: conference.registration_limit_exceeded? + - if conference.registration_limit_exceeded? + Sorry, no places left - if !current_user.nil? && current_user.proposal_count(conference) > 0 - = link_to "My Proposals", conference_proposal_index_path(conference.short_title), :class =>"btn btn-default" - - elsif conference.cfp_open? - = link_to "Submit Proposal", new_conference_proposal_path(conference.short_title), :class =>"btn btn-default" + = link_to "My Proposals", conference_program_proposal_index_path(conference.short_title), :class =>"btn btn-default" + - elsif conference.program.cfp_open? + = link_to "Submit Proposal", new_conference_program_proposal_path(conference.short_title), :class =>"btn btn-default" - if current_user.nil? || !current_user.subscribed?(conference) = link_to 'Subscribe', conference_subscriptions_path(conference.short_title), method: :post, class: 'btn btn-default' - else diff --git a/app/views/conference/_program.html.haml b/app/views/conference/_program.html.haml new file mode 100644 index 00000000..aaa699a9 --- /dev/null +++ b/app/views/conference/_program.html.haml @@ -0,0 +1,40 @@ += content_for :splash_nav do + %li + %a.smoothscroll{ href: '#callforpapers' } Call For Papers + +.container + .row + .col-md-12.text-center + %h2 + Call for Papers + %p.lead + We are ready to accept your proposals for sessions! + .row + .col-md-6.col-md-offset-3.col-sm-10.col-sm-offset-1 + %p + - if @conference.program.event_types.any? + You can submit proposals for + = "#{event_types(@conference)}." + - if @conference.tracks.any? + Proposals should fit in one of the + = "#{pluralize(@conference.tracks.count, 'track')}:" + = "#{tracks(@conference)}." + The submission period has begun + %em + = @program.cfp.start_date.strftime('%A, %B %-d. %Y') + and closes + %em + = @program.cfp.end_date.strftime('%A, %B %-d. %Y.') + - if @conference.cfp_open? + That means you have only + %b= pluralize(@program.cfp.remaining_days, 'day') + left! + Remember + = @conference.short_title + will only be as good as the sessions you present. Submit early, submit often! + - else + The submission period is closed. + .row + .col-md-12.text-center + %p.cta-button + = link_to "Submit your paper now", conference_proposal_index_path(@conference.short_title), class: 'btn btn-success btn-lg text-center' diff --git a/app/views/conference/_registration.html.haml b/app/views/conference/_registration.html.haml index a19ba66b..b7540b81 100644 --- a/app/views/conference/_registration.html.haml +++ b/app/views/conference/_registration.html.haml @@ -6,14 +6,25 @@ .row .col-md-12.text-center %h1 Registration - %p.lead - Going to - = @conference.short_title - is free of charge. - %p - We only ask you to register yourself until - = @conference.registration_period.end_date.strftime('%A, %B %-d. %Y') - so we can plan for the right amount of people. - %p.cta-button + + - if @conference.registration_limit_exceeded? + %p + Sorry, the conference registration limit has exceeded + - else + - if @conference.tickets.empty? + %p.lead + Going to + = @conference.short_title + is free of charge. + %p + We only ask you to register yourself until + = @conference.registration_period.end_date.strftime('%A, %B %-d. %Y') + so we can plan for the right amount of people. + %p.cta-button + - else + %p + The registration period ends on + = @conference.registration_period.end_date.strftime('%A, %B %-d. %Y') + %p.cta-button = link_to(new_conference_conference_registrations_path(@conference.short_title), class: 'btn btn-lg btn-success') do Register Now diff --git a/app/views/conference/_schedule_item.html.haml b/app/views/conference/_schedule_item.html.haml index 01db4cac..743095ca 100644 --- a/app/views/conference/_schedule_item.html.haml +++ b/app/views/conference/_schedule_item.html.haml @@ -1,7 +1,7 @@ %td.event{ style: "width: #{95 / @rooms.length}%; cursor:pointer", | rowspan: span[room.id], | role: "button" } | - %a.unstyled-link{href: url_for(conference_proposal_path(@conference.short_title, event[0].id))} + %a.unstyled-link{href: url_for(conference_program_proposal_path(@conference.short_title, event[0].id))} - if speaker = event[0].speakers.first = image_tag speaker.gravatar_url, :class => "img-circle pull-right", | :alt => speaker.name, | diff --git a/app/views/conference/_schedule_splashpage.html.haml b/app/views/conference/_schedule_splashpage.html.haml index b4c6eab1..1517f5db 100644 --- a/app/views/conference/_schedule_splashpage.html.haml +++ b/app/views/conference/_schedule_splashpage.html.haml @@ -6,10 +6,10 @@ %p.lead.text-center = @conference.short_title has the most awesome program ever! - - if @conference.splashpage and @conference.tracks.any? and @conference.splashpage.include_tracks + - if @conference.splashpage and @conference.program.tracks.any? and @conference.splashpage.include_tracks See rock-star speakers cover the topics of - if @conference.splashpage and @conference.splashpage.include_tracks - - @conference.tracks.each_slice(3) do |slice| + - @conference.program.tracks.each_slice(3) do |slice| .row.row-centered - slice.each do |track| .col-md-4.col-sm-4.col-centered.col-top.track @@ -17,7 +17,7 @@ = track.name = markdown(track.description) - - if @conference.call_for_paper and @conference.call_for_paper.schedule_public + - if @conference.program and @conference.program.schedule_public .row .col-md-12 %p.cta-button.text-center @@ -28,10 +28,10 @@ %h3.text-center Don't miss out! %br - - if @conference.events.highlights.any? + - if @conference.program.events.highlights.any? .row .col-md-12 - - @conference.events.highlights.each_slice(2) do |slice| + - @conference.program.events.highlights.each_slice(2) do |slice| .row.row-centered - slice.each do |event| .col-md-6.col-centered.col-top.highlights @@ -39,7 +39,7 @@ %b= event.title %h5.text-center = simple_format truncate(event.abstract, length: 500, separator: ' ') - = link_to "Read More", conference_proposal_path(@conference.short_title, event) + = link_to "Read More", conference_program_proposal_path(@conference.short_title, event) = content_for :splash_nav do %li diff --git a/app/views/conference/_venue.html.haml b/app/views/conference/_venue.html.haml index b99313a2..c07c5f8f 100644 --- a/app/views/conference/_venue.html.haml +++ b/app/views/conference/_venue.html.haml @@ -6,8 +6,9 @@ - popup = "

#{@conference.venue.name}


#{@conference.venue.street}
#{@conference.venue.city}
#{@conference.venue.country_name}" - content_for(:script_body) do :javascript + L.Icon.Default.imagePath = '/assets/leaflet/'; // create a map in the "map" div, set the view to a given place and zoom - var map = L.map('map', {scrollWheelZoom: false}).setView([#{@conference.venue.latitude}, #{@conference.venue.longitude}], 11); + var map = L.map('map', { scrollWheelZoom: false }).setView([#{@conference.venue.latitude}, #{@conference.venue.longitude}], 11); // add an OpenStreetMap tile layer L.tileLayer('http://{s}.tile.osm.org/{z}/{x}/{y}.png', { attribution: 'Map data © OpenStreetMap contributors, CC-BY-SA, Imagery © Mapbox', diff --git a/app/views/conference/schedule.html.erb b/app/views/conference/schedule.html.erb index d7c30da7..9390cf5d 100644 --- a/app/views/conference/schedule.html.erb +++ b/app/views/conference/schedule.html.erb @@ -1,5 +1,5 @@
- <% if @conference.events.scheduled.any? %> + <% if @conference.program.events.scheduled.any? %>
\ No newline at end of file +
diff --git a/app/views/conference/show.html.haml b/app/views/conference/show.html.haml index d3dcc8fa..63920eb6 100644 --- a/app/views/conference/show.html.haml +++ b/app/views/conference/show.html.haml @@ -36,7 +36,7 @@ %section#program = render 'schedule_splashpage' - - if @conference.cfp_open? and @conference.splashpage.include_cfp + - if @program.cfp_open? and @conference.splashpage.include_cfp %section#callforpapers = render 'call_for_paper' @@ -69,8 +69,13 @@ var triangle_colors = triangle_tcs.map(function(t) { return t.toHexString(); }); $(function () { $(document).ready(function() { - var t = new Trianglify({cellsize: 100, x_gradient: triangle_colors }); - var pattern = t.generate(document.body.clientWidth, ($( "#banner" ).height() + 200 )); - $('#banner').css('background-image', pattern.dataUrl); + var triangle_width = document.body.clientWidth; + var triangle_height = ($( "#banner" ).height() + 200 ); + var pattern = Trianglify({ width: triangle_width, + height: triangle_height, + cell_size: 100, + x_colors: triangle_colors + }); + $('#banner').css('background-image', 'url("' + pattern.png() + '")'); }); }); diff --git a/app/views/conference_registrations/_registration_info.html.haml b/app/views/conference_registrations/_registration_info.html.haml index 9653862d..2a852992 100644 --- a/app/views/conference_registrations/_registration_info.html.haml +++ b/app/views/conference_registrations/_registration_info.html.haml @@ -1,8 +1,8 @@ - if @conference.questions.any? = render partial: 'conference_registrations/questions', locals: { f: f } -- if @conference.events.workshops.any? +- if @conference.program.events.workshops.any? =f.inputs 'Pre-registration required for the following:' do - = f.input :events, as: :check_boxes, label: false, collection: @conference.events.workshops + = f.input :events, as: :check_boxes, label: false, collection: @conference.program.events.workshops = f.inputs 'Your Travel Info' do = f.input :arrival, as: :string, label: 'Your arrival time', input_html: { value: (f.object.arrival.to_formatted_s(:db_without_seconds) unless f.object.arrival.nil?), id: 'registration-arrival-datepicker', readonly: 'readonly' } = f.input :departure, as: :string, label: 'Your departure time', input_html: { value: (f.object.departure.to_formatted_s(:db_without_seconds) unless f.object.departure.nil?), id: 'registration-departure-datepicker', readonly: 'readonly' } diff --git a/app/views/conference_registrations/show.html.haml b/app/views/conference_registrations/show.html.haml index 298a1da3..7378190c 100644 --- a/app/views/conference_registrations/show.html.haml +++ b/app/views/conference_registrations/show.html.haml @@ -126,13 +126,13 @@ - @conference.participants.each do |participant| = image_tag(participant.gravatar_url(size: '25'), title: "#{participant.name}!", class: 'img-circle') .col-md-4.col-md-offset-2 - - if @conference.speakers.confirmed.any? + - if @conference.program.speakers.confirmed.any? %h4 %span.fa-stack %i.fa.fa-square-o.fa-stack-2x %i.fa.fa-microphone.fa-stack-1x - = @conference.speakers.confirmed.count + = @conference.program.speakers.confirmed.count Confirmed - = word_pluralize(@conference.speakers.confirmed.count, 'Speaker') - - @conference.speakers.confirmed.each do |speaker| + = word_pluralize(@conference.program.speakers.confirmed.count, 'Speaker') + - @conference.program.speakers.confirmed.each do |speaker| = image_tag(speaker.gravatar_url(size: '25'), title: "#{speaker.name}!", class: 'img-circle') diff --git a/app/views/layouts/_admin_sidebar.html.haml b/app/views/layouts/_admin_sidebar.html.haml index 016c77a2..928a0fef 100644 --- a/app/views/layouts/_admin_sidebar.html.haml +++ b/app/views/layouts/_admin_sidebar.html.haml @@ -47,39 +47,39 @@ - if can? :update, @conference %li{:class=> active_nav_li(edit_admin_conference_splashpage_path(@conference.short_title))} = link_to 'Splashpage', admin_conference_splashpage_path(@conference.short_title) - - if can? :index, Venue.new(conference_id: @conference.id) + - if can? :show, Venue.new(conference_id: @conference.id) %li{:class=> "#{active_nav_li(admin_conference_venue_path(@conference.short_title))}"} = link_to(admin_conference_venue_path(@conference.short_title)) do %span.fa.fa-road Venue %ul - - if can? :update, @conference.rooms.build - %li{:class=> active_nav_li(admin_conference_rooms_path(@conference.short_title))} - = link_to 'Rooms', admin_conference_rooms_path(@conference.short_title) + - if @conference.venue && @conference.venue.persisted? && (can? :update, @conference.venue.rooms.build) + %li{:class=> active_nav_li(admin_conference_venue_rooms_path(@conference.short_title))} + = link_to 'Rooms', admin_conference_venue_rooms_path(@conference.short_title) - if can? :update, @conference.lodgings.build %li{ class: active_nav_li(admin_conference_lodgings_path(@conference.short_title)) } = link_to 'Lodgings', admin_conference_lodgings_path(@conference.short_title) - %li - %a + %li{:class=> "#{active_nav_li(admin_conference_program_path(@conference.short_title))}"} + = link_to admin_conference_program_path(@conference.short_title) do %span.fa.fa-calendar Program %ul - - if can? :update, @conference.events.build - %li{:class=> active_nav_li(admin_conference_events_path(@conference.short_title))} - = link_to 'Events', admin_conference_events_path(@conference.short_title) - - if can? :update, CallForPaper.new(conference_id: @conference.id) - %li{:class=> "#{active_nav_li(admin_conference_call_for_paper_path(@conference.short_title))}"} - = link_to 'Call for Papers', admin_conference_call_for_paper_path(@conference.short_title) - - if can? :update, @conference.tracks.build - %li{:class=> active_nav_li(admin_conference_tracks_path(@conference.short_title))} - = link_to 'Tracks', admin_conference_tracks_path(@conference.short_title) - - if can? :update, @conference.event_types.build - %li{:class=> active_nav_li(admin_conference_event_types_path(@conference.short_title))} - = link_to 'Event Types', admin_conference_event_types_path(@conference.short_title) - - if can? :update, @conference.difficulty_levels.build, conference_id: @conference.id - %li{:class=> active_nav_li(admin_conference_difficulty_levels_path(@conference.short_title))} - = link_to 'Difficulty Levels', admin_conference_difficulty_levels_path(@conference.short_title) - - if can? :update, @conference.events.build + - if can? :update, Cfp.new(program_id: @conference.program.id) + %li{:class=> active_nav_li(admin_conference_program_cfp_path(@conference.short_title))} + = link_to 'Call for Papers', admin_conference_program_cfp_path(@conference.short_title) + - if can? :update, @conference.program.events.build + %li{:class=> active_nav_li(admin_conference_program_events_path(@conference.short_title))} + = link_to 'Events', admin_conference_program_events_path(@conference.short_title) + - if can? :update, @conference.program.tracks.build + %li{:class=> active_nav_li(admin_conference_program_tracks_path(@conference.short_title))} + = link_to 'Tracks', admin_conference_program_tracks_path(@conference.short_title) + - if can? :update, @conference.program.event_types.build + %li{:class=> active_nav_li(admin_conference_program_event_types_path(@conference.short_title))} + = link_to 'Event Types', admin_conference_program_event_types_path(@conference.short_title) + - if can? :update, @conference.program.difficulty_levels.build, conference_id: @conference.id + %li{:class=> active_nav_li(admin_conference_program_difficulty_levels_path(@conference.short_title))} + = link_to 'Difficulty Levels', admin_conference_program_difficulty_levels_path(@conference.short_title) + - if can? :update, @conference.program.events.build %li{class: active_nav_li(admin_conference_schedule_path(@conference.short_title))} = link_to 'Schedule', admin_conference_schedule_path(@conference.short_title), target: '_blank' diff --git a/app/views/layouts/_navigation.html.haml b/app/views/layouts/_navigation.html.haml index cf2b3b44..e94a0c92 100644 --- a/app/views/layouts/_navigation.html.haml +++ b/app/views/layouts/_navigation.html.haml @@ -37,7 +37,7 @@ - if unread_notifications(current_user).length > 0 %li.dropdown-header Last 5 Comments for: - unread_notifications(current_user).limit(5).group_by{ |comment| comment.commentable}.each do |event, comments| - %li= link_to("#{event.title}(#{comments.count})", admin_conference_event_path(event.conference.short_title, event.id)) + %li= link_to("#{event.title}(#{comments.count})", admin_conference_program_event_path(event.program.conference.short_title, event.id)) %li.divider %li= link_to "See all unread Comments (#{unread_notifications(current_user).length})", admin_comments_path %li= link_to 'See all Comments', admin_comments_path(anchor: 'all_comments') diff --git a/app/views/layouts/_user_menu.html.haml b/app/views/layouts/_user_menu.html.haml index 1764d9d0..ca4c7ef3 100644 --- a/app/views/layouts/_user_menu.html.haml +++ b/app/views/layouts/_user_menu.html.haml @@ -7,9 +7,9 @@ = link_to(edit_user_path(current_user.id)) do %span.fa.fa-user Edit Profile --if @conference and @conference.call_for_paper +-if @conference and @conference.program %li - = link_to(conference_proposal_index_path(@conference.short_title)) do + = link_to(conference_program_proposal_index_path(@conference.short_title)) do %span.fa.fa-comment My Submissions %li diff --git a/app/views/layouts/application.html.haml b/app/views/layouts/application.html.haml index e7a97b8a..8220dab3 100644 --- a/app/views/layouts/application.html.haml +++ b/app/views/layouts/application.html.haml @@ -2,7 +2,7 @@ %head %meta{:charset => "utf-8"} %meta{:name => "viewport", :content => "width=device-width, initial-scale=1, maximum-scale=1"} - %title= content_for?(:title) ? yield(:title) : "OSEM" + %title= content_for?(:title) ? yield(:title) : CONFIG['name'] %meta{:content => "", :name => "description"} %meta{:content => "", :name => "author"} = stylesheet_link_tag "application", :media => "all" diff --git a/app/views/layouts/schedule.html.haml b/app/views/layouts/schedule.html.haml index 56af1be7..f1f726ed 100644 --- a/app/views/layouts/schedule.html.haml +++ b/app/views/layouts/schedule.html.haml @@ -3,7 +3,7 @@ %head %meta{:charset => "utf-8"} %meta{:name => "viewport", :content => "width=device-width, initial-scale=1, maximum-scale=1"} - %title= content_for?(:title) ? yield(:title) : "OSEM" + %title= content_for?(:title) ? yield(:title) : CONFIG['name'] %meta{:content => "", :name => "description"} %meta{:content => "", :name => "author"} = stylesheet_link_tag "/stylesheets/schedule/jquery-ui-1.9.2.custom.min" diff --git a/app/views/proposal/_encouragement_text.html.haml b/app/views/proposal/_encouragement_text.html.haml index 52fed803..cf108019 100644 --- a/app/views/proposal/_encouragement_text.html.haml +++ b/app/views/proposal/_encouragement_text.html.haml @@ -1,20 +1,20 @@ %p.lead - - if @conference.event_types.any? + - if @program.event_types.any? You can submit proposals for = "#{event_types(@conference)}." - - if @conference.tracks.any? + - if @program.tracks.any? Proposals should fit in one of the - = "#{pluralize(@conference.tracks.count, 'track')}:" + = "#{pluralize(@program.tracks.count, 'track')}:" = "#{tracks(@conference)}." - - if @conference.cfp_open? + - if @program.cfp_open? The submission period has begun %em - = @conference.call_for_paper.start_date.strftime('%A, %B %-d. %Y') + = @program.cfp.start_date.strftime('%A, %B %-d. %Y') and closes %em - = @conference.call_for_paper.end_date.strftime('%A, %B %-d. %Y.') + = @program.cfp.end_date.strftime('%A, %B %-d. %Y.') That means you have - %b= pluralize(@conference.call_for_paper.remaining_days, 'day') + %b= pluralize(@program.cfp.remaining_days, 'day') left! Remember = @conference.title diff --git a/app/views/proposal/_form.html.haml b/app/views/proposal/_form.html.haml index 7405c4b6..7f8ec638 100644 --- a/app/views/proposal/_form.html.haml +++ b/app/views/proposal/_form.html.haml @@ -13,7 +13,7 @@ #commercials-content.tab-pane %p.text-muted You can add commercials for your proposal. These commercials will be displayed on the - = link_to 'public proposal page.', conference_proposal_path(@conference.short_title, @event) + = link_to 'public proposal page.', conference_program_proposal_path(@conference.short_title, @event) If you don't add a commercial, the conference commercial will be displayed! - if can? :create, @event.commercials.new .row @@ -22,7 +22,7 @@ #resource-placeholder{ style: 'background-color:#d3d3d3; float: left; width: 400px; height: 250px; margin: 5px; border-width: 1px; border-style: solid; border-color: rgba(0,0,0,.2);' } .row .col-md-6 - = semantic_form_for(@event.commercials.build, url: conference_proposal_commercials_path(conference_id: @conference.short_title, proposal_id: @event)) do |f| + = semantic_form_for(@event.commercials.build, url: conference_program_proposal_commercials_path(conference_id: @conference.short_title, proposal_id: @event)) do |f| = f.input :url, label: 'URL', as: :string, input_html: { required: 'required', type: 'url' }, hint: 'Just paste the url of your video/photo provider. Currently supported: YouTube, Vimeo, SpeakerDeck, SlideShare, Instagram, Flickr.' = f.action :submit, as: :button, button_html: { class: 'btn btn-primary pull-right', disabled: true } @@ -37,9 +37,9 @@ = render partial: 'shared/media_item', locals: { commercial: commercial } .caption - if can? :update, commercial - = semantic_form_for commercial, url: conference_proposal_commercial_path(conference_id: @conference.short_title, proposal_id: @event, id: commercial) do |f| + = semantic_form_for commercial, url: conference_program_proposal_commercial_path(conference_id: @conference.short_title, proposal_id: @event, id: commercial) do |f| = f.input :url, label: 'URL', as: :string, input_html: { id: "commercial_url_#{commercial.id}", required: 'required', type: 'url' } = f.action :submit, as: :button, button_html: { class: 'btn btn-success' }, label: 'Update' - if can? :destroy, commercial - = link_to 'Delete', conference_proposal_commercial_path(@conference.short_title, @event.id, commercial.id), + = link_to 'Delete', conference_program_proposal_commercial_path(@conference.short_title, @event.id, commercial.id), :method => :delete, :data => { :confirm => 'Are you sure?' }, class: 'btn btn-danger' diff --git a/app/views/proposal/_proposal_form.html.haml b/app/views/proposal/_proposal_form.html.haml index 83b34a5f..d30ad689 100644 --- a/app/views/proposal/_proposal_form.html.haml +++ b/app/views/proposal/_proposal_form.html.haml @@ -5,21 +5,21 @@ = f.input :subtitle, as: :string = f.input :event_type_id, as: :select, - collection: @conference.event_types.map {|type| ["#{type.title} - #{show_time(type.length)}", type.id, + collection: @conference.program.event_types.map {|type| ["#{type.title} - #{show_time(type.length)}", type.id, data: { min_words: type.minimum_abstract_length, max_words: type.maximum_abstract_length }]}, include_blank: false, label: 'Type', input_html: { class: 'select-help-toggle' } - - @conference.event_types.each do |event_type| + - @conference.program.event_types.each do |event_type| %span{ class: 'help-block select-help-text event_event_type_id collapse', id: "#{event_type.id}-help" } = event_type.description :javascript - $("##{@conference.event_types.first.id}-help").collapse('show'); + $("##{@conference.program.event_types.first.id}-help").collapse('show'); - = f.input :difficulty_level, as: :select, collection: @conference.difficulty_levels, input_html: { class: 'select-help-toggle' }, - include_blank: '(Please select)' if @conference.difficulty_levels.any? + = f.input :difficulty_level, as: :select, collection: @conference.program.difficulty_levels, input_html: { class: 'select-help-toggle' }, + include_blank: '(Please select)' if @conference.program.difficulty_levels.any? - - @conference.difficulty_levels.each do |difficulty_level| + - @conference.program.difficulty_levels.each do |difficulty_level| %span{ class: 'help-block select-help-text collapse event_difficulty_level_id', id: "#{difficulty_level.id}-help" } = difficulty_level.description diff --git a/app/views/proposal/_tooltip.html.haml b/app/views/proposal/_tooltip.html.haml index 4e9fd243..aced298b 100644 --- a/app/views/proposal/_tooltip.html.haml +++ b/app/views/proposal/_tooltip.html.haml @@ -3,9 +3,9 @@ %li{'class'=>class_for_todo(progress_status['registered'])} %span{'class'=>icon_for_todo(progress_status['registered'])} - if progress_status['registered'] - = link_to 'Edit your registration', edit_conference_conference_registrations_path(event.conference.short_title) + = link_to 'Edit your registration', edit_conference_conference_registrations_path(event.program.conference.short_title) - else - = link_to 'Register to the conference', new_conference_conference_registrations_path(event.conference.short_title) + = link_to 'Register to the conference', new_conference_conference_registrations_path(event.program.conference.short_title) %li{'class'=>class_for_todo(progress_status['biography'])} %span{'class'=>icon_for_todo(progress_status['biography'])} @@ -17,20 +17,19 @@ %li{'class'=>class_for_todo(progress_status['subtitle'])} %span{'class'=>icon_for_todo(progress_status['subtitle'])} - if progress_status['subtitle'] - = link_to 'Edit the subtitle', edit_conference_proposal_path(event.conference.short_title, event) + = link_to 'Edit the subtitle', edit_conference_program_proposal_path(event.program.conference.short_title, event) - else - = link_to 'Add a subtitle', edit_conference_proposal_path(event.conference.short_title, event) + = link_to 'Add a subtitle', edit_conference_program_proposal_path(event.program.conference.short_title, event) %li{'class'=>class_for_todo(progress_status['commercials'])} %span{'class'=>icon_for_todo(progress_status['commercials'])} - if progress_status['commercials'] - = link_to 'Edit the commercials', edit_conference_proposal_path(event.conference.short_title, event, anchor: 'commercials-content') + = link_to 'Edit the commercials', edit_conference_program_proposal_path(event.program.conference.short_title, event, anchor: 'commercials-content') - else - = link_to 'Add a commercial', edit_conference_proposal_path(event.conference.short_title, event, anchor: 'commercials-content') - + = link_to 'Add a commercial', edit_conference_program_proposal_path(event.program.conference.short_title, event, anchor: 'commercials-content') %li{'class'=>class_for_todo(progress_status['difficulty_level'])} %span{'class'=>icon_for_todo(progress_status['difficulty_level'])} - if progress_status['difficulty_level'] - = link_to 'Change the difficulty level', edit_conference_proposal_path(event.conference.short_title, event) + = link_to 'Change the difficulty level', edit_conference_program_proposal_path(event.program.conference.short_title, event) - else - = link_to 'Add a difficulty level', edit_conference_proposal_path(event.conference.short_title, event) + = link_to 'Add a difficulty level', edit_conference_program_proposal_path(event.program.conference.short_title, event) diff --git a/app/views/proposal/index.html.haml b/app/views/proposal/index.html.haml index 0c901f0c..0a514daa 100644 --- a/app/views/proposal/index.html.haml +++ b/app/views/proposal/index.html.haml @@ -18,7 +18,7 @@ Some of your proposals have been selected as a highlight of #{@conference.title}! %ul - @events.highlighted.each do |event| - %li= link_to event.title, conference_proposal_path(@conference.short_title, event) + %li= link_to event.title, conference_program_proposal_path(@conference.short_title, event) .row @@ -60,7 +60,7 @@ %span{ title: event.state.humanize, class: "fa #{event_status_icon(event)}" } %td.col-md-7{style: "padding:20px 8px 20px 8px;"} - = link_to event.title, conference_proposal_path(@conference.short_title, event.id) + = link_to event.title, conference_program_proposal_path(@conference.short_title, event.id) %br %small.text-muted = event.event_type.title @@ -82,20 +82,20 @@ .pull-right - if event.transition_possible? :confirm = link_to 'Confirm', - confirm_conference_proposal_path(@conference.short_title, event), + confirm_conference_program_proposal_path(@conference.short_title, event), method: :patch, class: 'btn btn-mini btn-success', id: "confirm_proposal_#{event.id}" - if event.transition_possible? :withdraw - = link_to 'Withdraw', conference_proposal_path(@conference.short_title, event.id), method: :delete, + = link_to 'Withdraw', conference_program_proposal_path(@conference.short_title, event.id), method: :delete, data: { confirm: 'Are you sure you want to withdraw this proposal?' }, class: 'btn btn-mini btn-warning', id: "delete_proposal_#{event.id}" - if event.state == 'withdrawn' || event.state == 'rejected' = link_to 'Re-Submit', - restart_conference_proposal_path(@conference.short_title, event.id), + restart_conference_program_proposal_path(@conference.short_title, event.id), method: :patch, class: 'btn btn-mini btn-success', id: "review_event_#{event.id}" - = link_to 'Edit', edit_conference_proposal_path(@conference.short_title, event.id), + = link_to 'Edit', edit_conference_program_proposal_path(@conference.short_title, event.id), class: 'btn btn-default', id: "edit_proposal_#{event.id}" .row .col-md-12 - - if @conference.cfp_open? || (current_user.has_role? :organizer, @conference) - = link_to "New Proposal", new_conference_proposal_path(@conference.short_title), :class => "btn btn-success pull-right" + - if can? :create, @program.events.new + = link_to "New Proposal", new_conference_program_proposal_path(@conference.short_title), :class => "btn btn-success pull-right" diff --git a/app/views/proposal/new.html.haml b/app/views/proposal/new.html.haml index e4b4fd99..37e89b94 100644 --- a/app/views/proposal/new.html.haml +++ b/app/views/proposal/new.html.haml @@ -27,16 +27,16 @@ = f.inputs name: 'Proposal Information' do = f.input :title, as: :string, required: true, input_html: { required: true } = f.input :event_type_id, as: :select, - collection: @conference.event_types.map {|type| ["#{type.title} - #{show_time(type.length)}", type.id, + collection: @program.event_types.map {|type| ["#{type.title} - #{show_time(type.length)}", type.id, data: { min_words: type.minimum_abstract_length, max_words: type.maximum_abstract_length }]}, include_blank: false, label: 'Type', input_html: { class: 'select-help-toggle' } - - @conference.event_types.each do |event_type| + - @program.event_types.each do |event_type| %span{ class: 'help-block event_event_type_id collapse', id: "#{event_type.id}-help" } = event_type.description :javascript - $("##{@conference.event_types.first.id}-help").collapse('show'); + $("##{@program.event_types.first.id}-help").collapse('show'); = f.input :abstract, input_html: { rows: 5, required: true }, required: true, hint: link_to('Tips to improve your presentations', 'http://blog.hubspot.com/blog/tabid/6307/bid/5975/10-Rules-to-Instantly-Improve-Your-Presentations.aspx') diff --git a/app/views/proposal/show.html.haml b/app/views/proposal/show.html.haml index 5cb91ff8..d14d5acb 100644 --- a/app/views/proposal/show.html.haml +++ b/app/views/proposal/show.html.haml @@ -9,7 +9,7 @@ = @event.subtitle = link_to "Schedule", schedule_conference_path(@conference.short_title), :class =>"btn btn-success pull-right" - if can? :edit, @event - = link_to "Edit", edit_admin_conference_event_path(@conference.short_title, @event), :class => "btn btn-mini btn-primary pull-right" + = link_to "Edit", edit_admin_conference_program_event_path(@conference.short_title, @event), :class => "btn btn-mini btn-primary pull-right" .row .col-md-3 %p @@ -24,7 +24,7 @@ - if @event.room_id = @event.room.name %dt Conference: - %dd= @event.conference.title + %dd= @event.program.conference.title %dt Language: %dd= @event.language if @event.language %dt Track: diff --git a/app/views/users/show.html.haml b/app/views/users/show.html.haml index 98352e00..0b172898 100644 --- a/app/views/users/show.html.haml +++ b/app/views/users/show.html.haml @@ -18,7 +18,7 @@ - @user.events.confirmed.each do |event| %li %h4 - = link_to event.title, conference_proposal_path(event.conference.short_title, event.id) + = link_to event.title, conference_program_proposal_path(event.program.conference.short_title, event.id) %strong at - = event.conference.title \ No newline at end of file + = event.program.conference.title diff --git a/bin/rspec b/bin/rspec new file mode 100644 index 00000000..20060ebd --- /dev/null +++ b/bin/rspec @@ -0,0 +1,7 @@ +#!/usr/bin/env ruby +begin + load File.expand_path("../spring", __FILE__) +rescue LoadError +end +require 'bundler/setup' +load Gem.bin_path('rspec-core', 'rspec') diff --git a/bin/spring b/bin/spring new file mode 100644 index 00000000..253ec37c --- /dev/null +++ b/bin/spring @@ -0,0 +1,18 @@ +#!/usr/bin/env ruby + +# This file loads spring without using Bundler, in order to be fast +# It gets overwritten when you run the `spring binstub` command + +unless defined?(Spring) + require "rubygems" + require "bundler" + + if match = Bundler.default_lockfile.read.match(/^GEM$.*?^ spring \((.*?)\)$.*?^$/m) + ENV["GEM_PATH"] = ([Bundler.bundle_path.to_s] + Gem.path).join(File::PATH_SEPARATOR) + ENV["GEM_HOME"] = "" + Gem.paths = ENV + + gem "spring", match[1] + require "spring/binstub" + end +end diff --git a/config/environments/test.rb b/config/environments/test.rb index bac307fa..d33fbc31 100644 --- a/config/environments/test.rb +++ b/config/environments/test.rb @@ -46,6 +46,7 @@ Osem::Application.configure do # Set Time.now to May 1, 2014 00:01:00 AM (at this instant), but allow it to move forward t = Time.local(2014, 05, 01, 00, 01, 00) Timecop.travel(t) + ActiveSupport::Deprecation.silenced = true end end diff --git a/config/routes.rb b/config/routes.rb index 95bd6125..e7976f1f 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -44,15 +44,31 @@ Osem::Application.routes.draw do # Singletons resource :splashpage - resource :call_for_paper - resource :venue + resource :venue do + resources :rooms, except: [:show] + end resource :registration_period + resource :program do + resource :cfp + resources :tracks + resources :event_types + resources :difficulty_levels + resources :events do + member do + post :comment + patch :accept + patch :confirm + patch :cancel + patch :reject + patch :unconfirm + patch :restart + get :vote + end + resource :speaker, only: [:edit, :update] + end + end resources :tickets - resources :tracks - resources :event_types - resources :difficulty_levels - resources :rooms, except: [:show] resources :sponsors, except: [:show] resources :lodgings, except: [:show] resources :targets, except: [:show] @@ -71,31 +87,19 @@ Osem::Application.routes.draw do patch :update_conference end end - - resources :events do - member do - post :comment - patch :accept - patch :confirm - patch :cancel - patch :reject - patch :unconfirm - patch :restart - get :vote - end - resource :speaker, only: [:edit, :update] - end end end resources :conference, only: [:index, :show] do - resources :proposal do - get 'commercials/render_commercial' => 'commercials#render_commercial' - resources :commercials, only: [:create, :update, :destroy] - resources :event_attachment, controller: 'event_attachments' - member do - patch '/confirm' => 'proposal#confirm' - patch '/restart' => 'proposal#restart' + resource :program, except: :destroy do + resources :proposal do + get 'commercials/render_commercial' => 'commercials#render_commercial' + resources :commercials, only: [:create, :update, :destroy] + resources :event_attachment, controller: 'event_attachments' + member do + patch '/confirm' => 'proposal#confirm' + patch '/restart' => 'proposal#restart' + end end end @@ -111,8 +115,7 @@ Osem::Application.routes.draw do namespace :api, defaults: {format: 'json'} do namespace :v1 do - resources :conferences, only: :index do - resources :conferences, only: :index + resources :conferences, only: [ :index, :show ] do resources :rooms, only: :index resources :tracks, only: :index resources :speakers, only: :index diff --git a/db/migrate/20151018152439_create_programs_table.rb b/db/migrate/20151018152439_create_programs_table.rb new file mode 100644 index 00000000..aa52a33c --- /dev/null +++ b/db/migrate/20151018152439_create_programs_table.rb @@ -0,0 +1,76 @@ +class CreateProgramsTable< ActiveRecord::Migration + class TempConference < ActiveRecord::Base + self.table_name = 'conferences' + end + + class TempCfp < ActiveRecord::Base + self.table_name = 'cfps' + end + + class TempCallForPaper < ActiveRecord::Base + self.table_name = 'call_for_papers' + end + + class TempProgram < ActiveRecord::Base + self.table_name = 'programs' + end + + def up + create_table :programs do |t| + t.references :conference + t.integer :rating, default: 0 + t.boolean :schedule_public, default: false + t.boolean :schedule_fluid, default: false + t.timestamps + end + + add_column :call_for_papers, :program_id, :integer + + TempConference.all.each do |conference| + unless TempProgram.find_by(conference_id: conference.id) + program = TempProgram.new + program.conference_id = conference.id + program.save! + + if (cfp = TempCallForPaper.find_by(conference_id: conference.id)) + cfp.program_id = program.id + cfp.save! + + program.rating = cfp.rating + program.schedule_public = cfp.schedule_public + program.schedule_fluid = cfp.schedule_changes + program.save! + end + end + end + remove_column :call_for_papers, :conference_id + remove_column :call_for_papers, :rating + remove_column :call_for_papers, :schedule_public + remove_column :call_for_papers, :schedule_changes + rename_table :call_for_papers, :cfps + end + + def down + rename_table :cfps, :call_for_papers + add_column :call_for_papers, :conference_id, :integer + add_column :call_for_papers, :rating, :integer, default: 0 + add_column :call_for_papers, :schedule_public, :boolean, default: false + add_column :call_for_papers, :schedule_changes, :boolean, default: false + + TempConference.all.each do |conference| + if (program = TempProgram.find_by(conference_id: conference.id)) + if (cfp = TempCallForPaper.find_by(program_id: program.id)) + cfp.conference_id = program.conference_id + cfp.rating = program.rating + cfp.schedule_public = program.schedule_public + cfp.schedule_changes = program.schedule_fluid + + cfp.save! + end + end + end + + remove_column :call_for_papers, :program_id + drop_table :programs + end +end diff --git a/db/migrate/20151018154513_rename_conference_id_to_program_id_in_events_tracks_difficulty_levels.rb b/db/migrate/20151018154513_rename_conference_id_to_program_id_in_events_tracks_difficulty_levels.rb new file mode 100644 index 00000000..b540b9a3 --- /dev/null +++ b/db/migrate/20151018154513_rename_conference_id_to_program_id_in_events_tracks_difficulty_levels.rb @@ -0,0 +1,99 @@ +class RenameConferenceIdToProgramIdInEventsTracksDifficultyLevels < ActiveRecord::Migration + class TempConference < ActiveRecord::Base + self.table_name = 'conferences' + end + + class TempEvent < ActiveRecord::Base + self.table_name = 'events' + end + + class TempEventType < ActiveRecord::Base + self.table_name = 'event_types' + end + + class TempTrack < ActiveRecord::Base + self.table_name = 'tracks' + end + + class TempDifficultyLevel < ActiveRecord::Base + self.table_name = 'difficulty_levels' + end + + class TempProgram < ActiveRecord::Base + self.table_name = 'programs' + end + + def up + add_column :events, :program_id, :integer + add_column :event_types, :program_id, :integer + add_column :tracks, :program_id, :integer + add_column :difficulty_levels, :program_id, :integer + + TempConference.all.each do |conference| + program = Program.find_by(conference_id: conference.id) + + TempEvent.where(conference_id: conference.id).each do |event| + event.program_id = program.id + event.save! + end + + TempEventType.where(conference_id: conference.id).each do |event_type| + event_type.program_id = program.id + event_type.save! + end + + TempTrack.where(conference_id: conference.id).each do |track| + track.program_id = program.id + track.save! + end + + TempDifficultyLevel.where(conference_id: conference.id).each do |difficulty_level| + difficulty_level.program_id = program.id + difficulty_level.save! + end + end + + remove_column :events, :conference_id + remove_column :event_types, :conference_id + remove_column :tracks, :conference_id + remove_column :difficulty_levels, :conference_id + end + + def down + add_column :events, :conference_id, :integer + add_column :event_types, :conference_id, :integer + add_column :tracks, :conference_id, :integer + add_column :difficulty_levels, :conference_id, :integer + + TempConference.all.each do |conference| + program = TempProgram.find_by(conference_id: conference.id) + + if program + TempEvent.where(program_id: program.id).each do |event| + event.conference_id = conference.id + event.save! + end + + TempEventType.where(program_id: program.id).each do |event_type| + event_type.conference_id = conference.id + event_type.save! + end + + TempTrack.where(program_id: program.id).each do |track| + track.conference_id = conference.id + track.save! + end + + TempDifficultyLevel.where(program_id: program.id).each do |difficulty_level| + difficulty_level.conference_id = conference.id + difficulty_level.save! + end + end + end + + remove_column :events, :program_id + remove_column :event_types, :program_id + remove_column :tracks, :program_id + remove_column :difficulty_levels, :program_id + end +end diff --git a/db/migrate/20151021113015_rename_email_settings_with_cfp_and_program.rb b/db/migrate/20151021113015_rename_email_settings_with_cfp_and_program.rb new file mode 100644 index 00000000..ca2978ca --- /dev/null +++ b/db/migrate/20151021113015_rename_email_settings_with_cfp_and_program.rb @@ -0,0 +1,10 @@ +class RenameEmailSettingsWithCfpAndProgram < ActiveRecord::Migration + def change + rename_column :email_settings, :send_on_call_for_papers_schedule_public, :send_on_program_schedule_public + rename_column :email_settings, :call_for_papers_schedule_public_body, :program_schedule_public_body + rename_column :email_settings, :call_for_papers_schedule_public_subject, :program_schedule_public_subject + rename_column :email_settings, :send_on_call_for_papers_dates_updated, :send_on_cfp_dates_updated + rename_column :email_settings, :call_for_papers_dates_updated_subject, :cfp_dates_updated_subject + rename_column :email_settings, :call_for_papers_dates_updated_body, :cfp_dates_updated_body + end +end diff --git a/db/migrate/20151031092713_change_conference_id_to_venue_id_in_rooms.rb b/db/migrate/20151031092713_change_conference_id_to_venue_id_in_rooms.rb new file mode 100644 index 00000000..ca8ef153 --- /dev/null +++ b/db/migrate/20151031092713_change_conference_id_to_venue_id_in_rooms.rb @@ -0,0 +1,56 @@ +class ChangeConferenceIdToVenueIdInRooms < ActiveRecord::Migration + class TempConference < ActiveRecord::Base + self.table_name = 'conferences' + + has_one :temp_venue + end + + class TempVenue < ActiveRecord::Base + self.table_name = 'venues' + + belongs_to :temp_conference + has_many :temp_rooms + end + + class TempRoom < ActiveRecord::Base + self.table_name = 'rooms' + + belongs_to :temp_venue + end + + def up + add_column :rooms, :venue_id, :integer + + TempRoom.all.each do |room| + venue = TempVenue.find_by(conference_id: room.conference_id) + if venue + room.venue_id = venue.id + else + test_venue = Venue.find_or_create_by!(conference_id: room.conference_id, name: 'test venue', street: 'test street', city: 'test city', country: 'test') + room.venue_id = test_venue.id + end + room.save! + end + + change_column :rooms, :venue_id, :integer, null: false + remove_column :rooms, :conference_id + end + + def down + add_column :rooms, :conference_id, :integer + + TempRoom.all.each do |room| + venue = TempVenue.find(room.venue_id) + conference = TempConference.find(venue.conference_id) + + if conference + room.conference_id = conference.id + end + + room.save! + end + + change_column :rooms, :conference_id, :integer, null: false + remove_column :rooms, :venue_id + end +end diff --git a/db/migrate/20160201221411_add_registration_limit_to_conferences.rb b/db/migrate/20160201221411_add_registration_limit_to_conferences.rb new file mode 100644 index 00000000..bbc8724e --- /dev/null +++ b/db/migrate/20160201221411_add_registration_limit_to_conferences.rb @@ -0,0 +1,5 @@ +class AddRegistrationLimitToConferences < ActiveRecord::Migration + def change + add_column :conferences, :registration_limit, :integer, default: 0 + end +end diff --git a/db/schema.rb b/db/schema.rb index cd241c4e..85f41ae0 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,8 +11,7 @@ # # It's strongly recommended that you check this file into your version control system. - -ActiveRecord::Schema.define(version: 20151005161518) do +ActiveRecord::Schema.define(version: 20160201221411) do create_table "ahoy_events", force: true do |t| t.uuid "visit_id" @@ -32,17 +31,6 @@ ActiveRecord::Schema.define(version: 20151005161518) do t.datetime "updated_at" end - create_table "call_for_papers", force: true do |t| - t.date "start_date", null: false - t.date "end_date", null: false - t.integer "conference_id" - t.datetime "created_at" - t.datetime "updated_at" - t.boolean "schedule_changes", default: false - t.integer "rating", default: 3 - t.boolean "schedule_public" - end - create_table "campaigns", force: true do |t| t.integer "conference_id" t.string "name" @@ -55,6 +43,14 @@ ActiveRecord::Schema.define(version: 20151005161518) do t.datetime "updated_at" end + create_table "cfps", force: true do |t| + t.date "start_date", null: false + t.date "end_date", null: false + t.datetime "created_at" + t.datetime "updated_at" + t.integer "program_id" + end + create_table "comments", force: true do |t| t.string "title", limit: 50, default: "" t.text "body" @@ -106,6 +102,7 @@ ActiveRecord::Schema.define(version: 20151005161518) do t.string "color" t.text "events_per_week" t.text "description" + t.integer "registration_limit", default: 0 end create_table "conferences_questions", id: false, force: true do |t| @@ -150,12 +147,12 @@ ActiveRecord::Schema.define(version: 20151005161518) do end create_table "difficulty_levels", force: true do |t| - t.integer "conference_id" t.string "title" t.text "description" t.string "color" t.datetime "created_at" t.datetime "updated_at" + t.integer "program_id" end create_table "email_settings", force: true do |t| @@ -183,22 +180,22 @@ ActiveRecord::Schema.define(version: 20151005161518) do t.boolean "send_on_venue_updated", default: false t.string "venue_updated_subject" t.text "venue_updated_body" - t.boolean "send_on_call_for_papers_dates_updated", default: false - t.boolean "send_on_call_for_papers_schedule_public", default: false - t.string "call_for_papers_schedule_public_subject" - t.string "call_for_papers_dates_updated_subject" - t.text "call_for_papers_schedule_public_body" - t.text "call_for_papers_dates_updated_body" + t.boolean "send_on_cfp_dates_updated", default: false + t.boolean "send_on_program_schedule_public", default: false + t.string "program_schedule_public_subject" + t.string "cfp_dates_updated_subject" + t.text "program_schedule_public_body" + t.text "cfp_dates_updated_body" end create_table "event_types", force: true do |t| - t.integer "conference_id" t.string "title", null: false t.integer "length", default: 30 t.integer "minimum_abstract_length", default: 0 t.integer "maximum_abstract_length", default: 500 t.string "color" t.string "description" + t.integer "program_id" end create_table "event_users", force: true do |t| @@ -212,7 +209,6 @@ ActiveRecord::Schema.define(version: 20151005161518) do create_table "events", force: true do |t| t.string "guid", null: false - t.integer "conference_id" t.integer "event_type_id" t.string "title", null: false t.string "subtitle" @@ -237,6 +233,7 @@ ActiveRecord::Schema.define(version: 20151005161518) do t.integer "difficulty_level_id" t.integer "week" t.boolean "is_highlight", default: false + t.integer "program_id" end create_table "events_registrations", id: false, force: true do |t| @@ -277,6 +274,15 @@ ActiveRecord::Schema.define(version: 20151005161518) do t.datetime "updated_at" end + create_table "programs", force: true do |t| + t.integer "conference_id" + t.integer "rating", default: 0 + t.boolean "schedule_public", default: false + t.boolean "schedule_fluid", default: false + t.datetime "created_at" + t.datetime "updated_at" + end + create_table "qanswers", force: true do |t| t.integer "question_id" t.integer "answer_id" @@ -357,10 +363,10 @@ ActiveRecord::Schema.define(version: 20151005161518) do add_index "roles_users", ["user_id", "role_id"], name: "index_roles_users_on_user_id_and_role_id" create_table "rooms", force: true do |t| - t.string "guid", null: false - t.integer "conference_id" - t.string "name", null: false + t.string "guid", null: false + t.string "name", null: false t.integer "size" + t.integer "venue_id", null: false end create_table "social_events", force: true do |t| @@ -443,13 +449,13 @@ ActiveRecord::Schema.define(version: 20151005161518) do end create_table "tracks", force: true do |t| - t.string "guid", null: false - t.integer "conference_id" - t.string "name", null: false + t.string "guid", null: false + t.string "name", null: false t.text "description" t.string "color" t.datetime "created_at" t.datetime "updated_at" + t.integer "program_id" end create_table "users", force: true do |t| diff --git a/public/javascripts/schedule/schedule.js b/public/javascripts/schedule/schedule.js index 91340fae..758a8bf3 100644 --- a/public/javascripts/schedule/schedule.js +++ b/public/javascripts/schedule/schedule.js @@ -30,7 +30,7 @@ var scheduleDayEvents = {}; var Schedule = { loadEvents: function(conference_id, start_date) { var eventDates = {}; - var url = '/admin/conference/' + conference_id + '/events'; + var url = '/admin/conference/' + conference_id + '/program/events'; var params = { start: $('#start').text(), end: $('#end').text()}; var callback = function(data) { $.each(data, function(key, val) { diff --git a/spec/controllers/admin/comments_controller_spec.rb b/spec/controllers/admin/comments_controller_spec.rb index ac75b189..759f1538 100644 --- a/spec/controllers/admin/comments_controller_spec.rb +++ b/spec/controllers/admin/comments_controller_spec.rb @@ -8,7 +8,7 @@ describe Admin::CommentsController, type: :controller do let!(:organizer_role) { create(:role, name: 'organizer', resource: conference) } let(:organizer) { create(:user, role_ids: organizer_role.id, last_sign_in_at: Time.now - 1.day) } let(:participant) { create(:user) } - let(:event) { create(:event, conference: conference) } + let(:event) { create(:event, program: conference.program) } let(:comment) { create(:comment, commentable_type: 'Event', commentable_id: event.id) } context 'not logged in user' do @@ -32,7 +32,7 @@ describe Admin::CommentsController, type: :controller do expect(assigns(:comments)).to be_a(Hash) # assigns(:comments).first returns an array of first pair key-value from hash. # Calling again 'first' returns the key, meaning the Conference object. - expect(assigns(:comments).first.first.title).to eq(comment.commentable.conference.title) + expect(assigns(:comments).first.first.title).to eq(comment.commentable.program.conference.title) end it 'has status 200: OK' do get :index diff --git a/spec/controllers/admin/conferences_controller_spec.rb b/spec/controllers/admin/conferences_controller_spec.rb index 4e2f0d78..fd9f2282 100644 --- a/spec/controllers/admin/conferences_controller_spec.rb +++ b/spec/controllers/admin/conferences_controller_spec.rb @@ -165,9 +165,10 @@ describe Admin::ConferenceController do it 'assigns cfp_max an array with maximum weeks' do conference date = Date.new(2014, 05, 26) - conference.call_for_paper = create(:call_for_paper, - start_date: date, - end_date: date + 14) + conference.program.cfp = create(:cfp, + program: conference.program, + start_date: date, + end_date: date + 14) get :index expect(assigns(:cfp_weeks)).to match_array([1, 2, 3]) end diff --git a/spec/controllers/admin/programs_controller_spec.rb b/spec/controllers/admin/programs_controller_spec.rb new file mode 100644 index 00000000..4fe5952c --- /dev/null +++ b/spec/controllers/admin/programs_controller_spec.rb @@ -0,0 +1,33 @@ +require 'spec_helper' + +describe Admin::ProgramsController, type: :controller do + + # It is necessary to use bang version of let to build roles before user + let(:conference) { create(:conference) } + let!(:first_user) { create(:user) } + let!(:organizer_role) { create(:role, name: 'organizer', resource: conference) } + let(:organizer) { create(:user, role_ids: organizer_role.id, last_sign_in_at: Time.now - 1.day) } + + context 'not logged in user' do + describe 'GET #show' do + it 'does not render admin/programs#show' do + get :show, conference_id: conference.short_title + expect(response).to redirect_to(user_session_path) + end + end + end + + context 'logged in as admin, organizer or cfp' do + before :each do + sign_in(organizer) + end + + describe 'PATCH #update' do + it 'redirects to admin/programs#index' do + patch :update, conference_id: conference.short_title, program: attributes_for(:program) + conference.program.reload + expect(response).to redirect_to admin_conference_program_path(conference.short_title) + end + end + end +end diff --git a/spec/controllers/admin/registration_periods_controller_spec.rb b/spec/controllers/admin/registration_periods_controller_spec.rb index ae4586ea..01015ea1 100644 --- a/spec/controllers/admin/registration_periods_controller_spec.rb +++ b/spec/controllers/admin/registration_periods_controller_spec.rb @@ -27,7 +27,7 @@ describe Admin::RegistrationPeriodsController do end it 'changes registration period attributes' do - the_date = 10.days.from_now.to_date + the_date = conference.end_date - 10 patch :update, conference_id: conference.short_title, registration_period: attributes_for(:registration_period, start_date: the_date) diff --git a/spec/factories/cfps.rb b/spec/factories/cfps.rb new file mode 100644 index 00000000..14b3fbc5 --- /dev/null +++ b/spec/factories/cfps.rb @@ -0,0 +1,9 @@ +# Read about factories at https://github.com/thoughtbot/factory_girl + +FactoryGirl.define do + factory :cfp do + program + start_date { 1.day.ago } + end_date { 6.days.from_now } + end +end diff --git a/spec/factories/conferences.rb b/spec/factories/conferences.rb index c92c10c2..d39db79f 100644 --- a/spec/factories/conferences.rb +++ b/spec/factories/conferences.rb @@ -7,21 +7,22 @@ FactoryGirl.define do timezone 'Amsterdam' start_date { Date.today } end_date { 6.days.from_now } + registration_limit 0 + factory :full_conference do - venue splashpage registration_period - call_for_paper - after(:build) do |conference| - conference.commercials << build(:conference_commercial, commercialable: conference) - conference.campaigns << build(:campaign, conference: conference) - conference.targets << build(:target, conference: conference) - conference.questions << build(:question, conference_id: conference.id) - conference.lodgings << build(:lodging, conference: conference) - conference.sponsors << build(:sponsor, conference: conference) - conference.sponsorship_levels << build(:sponsorship_level, conference: conference) - conference.tickets << build(:ticket, conference: conference) + after :create do |conference| + create(:venue, conference_id: conference.id) + conference.commercials << create(:conference_commercial, commercialable: conference) + conference.campaigns << create(:campaign, conference: conference) + conference.targets << create(:target, conference: conference) + conference.questions << create(:question, conference_id: conference.id) + conference.lodgings << create(:lodging, conference: conference) + conference.sponsors << create(:sponsor, conference: conference) + conference.sponsorship_levels << create(:sponsorship_level, conference: conference) + conference.tickets << create(:ticket, conference: conference) end end end diff --git a/spec/factories/difficulty_levels.rb b/spec/factories/difficulty_levels.rb index af675c86..7a1e8da5 100644 --- a/spec/factories/difficulty_levels.rb +++ b/spec/factories/difficulty_levels.rb @@ -3,7 +3,6 @@ FactoryGirl.define do title 'Example Difficulty Level' description 'Lorem Ipsum dolsum' color '#ffffff' - conference + program end - end diff --git a/spec/factories/email_settings.rb b/spec/factories/email_settings.rb index 2ba04e4f..d10a6b51 100644 --- a/spec/factories/email_settings.rb +++ b/spec/factories/email_settings.rb @@ -8,8 +8,8 @@ FactoryGirl.define do send_on_confirmed_without_registration false send_on_conference_dates_updated true send_on_conference_registration_dates_updated true - send_on_call_for_papers_schedule_public true - send_on_call_for_papers_dates_updated true + send_on_program_schedule_public true + send_on_cfp_dates_updated true conference_dates_updated_body 'Sample Conference\n New Dates: January 17 - 21 2014' conference_dates_updated_subject 'Conference dates have been updated' conference_registration_dates_updated_subject 'Conference registration dates have been updated' @@ -19,9 +19,9 @@ FactoryGirl.define do venue_updated_body 'Venue has been Updated to Sample Location' registration_subject 'Lorem Ipsum Dolsum' registration_body 'Lorem ipsum dolor sit amet, consectetuer adipiscing elit' - call_for_papers_dates_updated_subject 'Call for Papers dates have been updated' - call_for_papers_dates_updated_body 'Please checkout the new updates to submit your proposal for Sample Conference' - call_for_papers_schedule_public_subject 'Sample Conference Cfp schedule is Public' - call_for_papers_schedule_public_body 'Call for Papers schedule is Public.Checkout the link' + cfp_dates_updated_subject 'Call for Papers dates have been updated' + cfp_dates_updated_body 'Please checkout the new updates to submit your proposal for Sample Conference' + program_schedule_public_subject 'Sample Conference Cfp schedule is Public' + program_schedule_public_body 'Call for Papers schedule is Public.Checkout the link' end end diff --git a/spec/factories/event_types.rb b/spec/factories/event_types.rb index 2601783c..3b616fa9 100644 --- a/spec/factories/event_types.rb +++ b/spec/factories/event_types.rb @@ -6,7 +6,7 @@ FactoryGirl.define do length 30 minimum_abstract_length 0 maximum_abstract_length 500 - conference + program end end diff --git a/spec/factories/events.rb b/spec/factories/events.rb index 6dc89b22..ce8e46db 100644 --- a/spec/factories/events.rb +++ b/spec/factories/events.rb @@ -3,7 +3,7 @@ FactoryGirl.define do factory :event do sequence(:title) { |n| "The ##{n} talk you'll ever attend." } - conference + program abstract <<-EOS Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer ante lacus, mollis non urna vitae, varius semper leo. Nulla ac nibh dui. Mauris @@ -35,7 +35,7 @@ FactoryGirl.define do # set an event_type if none is passed to the factory. # needs to be created here because otherwise it doesn't belong to the # same conference as the event - event.event_type ||= build(:event_type, conference: event.conference) + event.event_type ||= build(:event_type, program: event.program) end factory :event_full do @@ -44,9 +44,12 @@ FactoryGirl.define do room after(:build) do |event| event.commercials << build(:event_commercial, commercialable: event) - event.difficulty_level = build(:difficulty_level, conference: event.conference) - event.track = build(:track, conference: event.conference) - event.room = build(:room, conference: event.conference) + event.difficulty_level = build(:difficulty_level, program: event.program) + event.track = build(:track, program: event.program) + unless (venue = event.program.conference.venue) + venue = create(:venue, conference: event.program.conference) + end + event.room = build(:room, venue: venue) event.comment_threads << build(:comment, commentable: event) end end diff --git a/spec/factories/programs.rb b/spec/factories/programs.rb new file mode 100644 index 00000000..a1a6e1f7 --- /dev/null +++ b/spec/factories/programs.rb @@ -0,0 +1,9 @@ +# Read about factories at https://github.com/thoughtbot/factory_girl + +FactoryGirl.define do + factory :program do + schedule_public false + schedule_fluid false + conference + end +end diff --git a/spec/factories/rooms.rb b/spec/factories/rooms.rb index 5bd18ebc..7e610ad5 100644 --- a/spec/factories/rooms.rb +++ b/spec/factories/rooms.rb @@ -3,7 +3,7 @@ FactoryGirl.define do factory :room do name 'Example Room' size 4 - conference + venue factory :room_for_100 do name 'Room for 100' diff --git a/spec/factories/tracks.rb b/spec/factories/tracks.rb index 7f3e1ecf..03167789 100644 --- a/spec/factories/tracks.rb +++ b/spec/factories/tracks.rb @@ -3,7 +3,7 @@ FactoryGirl.define do name 'Example Track' description 'Lorem Ipsum dolsum' color '#ffffff' - conference + program end end diff --git a/spec/factories/venues.rb b/spec/factories/venues.rb index 190f4600..31aa64e9 100644 --- a/spec/factories/venues.rb +++ b/spec/factories/venues.rb @@ -8,5 +8,6 @@ FactoryGirl.define do country 'DE' website 'www.opensuse.org' description 'Lorem Ipsum Dolor' + conference end end diff --git a/spec/features/ability_spec.rb b/spec/features/ability_spec.rb index b2b38cdf..d21f82c1 100644 --- a/spec/features/ability_spec.rb +++ b/spec/features/ability_spec.rb @@ -2,11 +2,11 @@ require 'spec_helper' feature 'Has correct abilities' do # It is necessary to use bang version of let to build roles before user - let(:conference1) { create(:conference) } # user is organizer - let(:conference2) { create(:conference) } # user is cfp - let(:conference3) { create(:conference) } # user is info_desk - let(:conference4) { create(:conference) } # user is volunteer coordinator - let(:conference5) { create(:conference) } # user has no role + let(:conference1) { create(:full_conference) } # user is organizer + let(:conference2) { create(:full_conference) } # user is cfp + let(:conference3) { create(:full_conference) } # user is info_desk + let(:conference4) { create(:full_conference) } # user is volunteer coordinator + let(:conference5) { create(:full_conference) } # user has no role let(:role_organizer) { create(:role, name: 'organizer', resource: conference1) } let(:role_cfp) { create(:role, name: 'cfp', resource: conference2) } @@ -37,22 +37,23 @@ feature 'Has correct abilities' do expect(page).to have_link('Basics', href: "/admin/conference/#{conference1.short_title}/edit") expect(page).to have_link('Contact', href: "/admin/conference/#{conference1.short_title}/contact/edit") expect(page).to have_link('Commercials', href: "/admin/conference/#{conference1.short_title}/commercials") - expect(page).to have_link('Events', href: "/admin/conference/#{conference1.short_title}/events") + expect(page).to have_link('Events', href: "/admin/conference/#{conference1.short_title}/program/events") expect(page).to have_link('Registrations', href: "/admin/conference/#{conference1.short_title}/registrations") expect(page).to have_link('Schedule', href: "/admin/conference/#{conference1.short_title}/schedule") expect(page).to have_link('Campaigns', href: "/admin/conference/#{conference1.short_title}/campaigns") expect(page).to have_link('Goals', href: "/admin/conference/#{conference1.short_title}/targets") expect(page).to have_link('Venue', href: "/admin/conference/#{conference1.short_title}/venue") - expect(page).to have_link('Rooms', href: "/admin/conference/#{conference1.short_title}/rooms") + expect(page).to have_link('Rooms', href: "/admin/conference/#{conference1.short_title}/venue/rooms") expect(page).to have_link('Lodgings', href: "/admin/conference/#{conference1.short_title}/lodgings") expect(page).to have_link('Sponsorship', href: "/admin/conference/#{conference1.short_title}/sponsorship_levels") expect(page).to have_link('Sponsors', href: "/admin/conference/#{conference1.short_title}/sponsors") expect(page).to have_link('Tickets', href: "/admin/conference/#{conference1.short_title}/tickets") expect(page).to have_link('E-Mails', href: "/admin/conference/#{conference1.short_title}/emails") - expect(page).to have_link('Call for Papers', href: "/admin/conference/#{conference1.short_title}/call_for_paper") - expect(page).to have_link('Tracks', href: "/admin/conference/#{conference1.short_title}/tracks") - expect(page).to have_link('Event Types', href: "/admin/conference/#{conference1.short_title}/event_types") - expect(page).to have_link('Difficulty Levels', href: "/admin/conference/#{conference1.short_title}/difficulty_levels") + expect(page).to have_link('Program', href: "/admin/conference/#{conference1.short_title}/program") + expect(page).to have_link('Call for Papers', href: "/admin/conference/#{conference1.short_title}/program/cfp") + expect(page).to have_link('Tracks', href: "/admin/conference/#{conference1.short_title}/program/tracks") + expect(page).to have_link('Event Types', href: "/admin/conference/#{conference1.short_title}/program/event_types") + expect(page).to have_link('Difficulty Levels', href: "/admin/conference/#{conference1.short_title}/program/difficulty_levels") expect(page).to have_link('Questions', href: "/admin/conference/#{conference1.short_title}/questions") expect(page).to have_link('Roles', href: "/admin/conference/#{conference1.short_title}/roles") @@ -65,8 +66,8 @@ feature 'Has correct abilities' do visit admin_conference_registrations_path(conference1.short_title) expect(current_path).to eq(admin_conference_registrations_path(conference1.short_title)) - visit admin_conference_events_path(conference1.short_title) - expect(current_path).to eq(admin_conference_events_path(conference1.short_title)) + visit admin_conference_program_events_path(conference1.short_title) + expect(current_path).to eq(admin_conference_program_events_path(conference1.short_title)) visit admin_conference_schedule_path(conference1.short_title) expect(current_path).to eq(admin_conference_schedule_path(conference1.short_title)) @@ -93,8 +94,8 @@ feature 'Has correct abilities' do visit admin_conference_emails_path(conference1.short_title) expect(current_path).to eq(admin_conference_emails_path(conference1.short_title)) - visit new_admin_conference_call_for_paper_path(conference1.short_title) - expect(current_path).to eq(new_admin_conference_call_for_paper_path(conference1.short_title)) + visit new_admin_conference_program_cfp_path(conference1.short_title) + expect(current_path).to eq(new_admin_conference_program_cfp_path(conference1.short_title)) visit admin_conference_questions_path(conference1.short_title) expect(current_path).to eq(admin_conference_questions_path(conference1.short_title)) @@ -113,22 +114,23 @@ feature 'Has correct abilities' do expect(page).to have_text('Basics') expect(page).to_not have_link('Contact', href: "/admin/conference/#{conference2.short_title}/contact/edit") expect(page).to have_link('Commercials', href: "/admin/conference/#{conference2.short_title}/commercials") - expect(page).to have_link('Events', href: "/admin/conference/#{conference2.short_title}/events") + expect(page).to have_link('Events', href: "/admin/conference/#{conference2.short_title}/program/events") expect(page).to_not have_link('Registrations', href: "/admin/conference/#{conference2.short_title}/registrations") expect(page).to have_link('Schedule', href: "/admin/conference/#{conference2.short_title}/schedule") expect(page).to_not have_link('Campaigns', href: "/admin/conference/#{conference2.short_title}/campaigns") expect(page).to_not have_link('Goals', href: "/admin/conference/#{conference2.short_title}/targets") expect(page).to have_link('Venue', href: "/admin/conference/#{conference2.short_title}/venue") - expect(page).to have_link('Rooms', href: "/admin/conference/#{conference2.short_title}/rooms") + expect(page).to have_link('Rooms', href: "/admin/conference/#{conference2.short_title}/venue/rooms") expect(page).to_not have_link('Lodgings', href: "/admin/conference/#{conference2.short_title}/lodgings") expect(page).to_not have_link('Sponsorship', href: "/admin/conference/#{conference2.short_title}/sponsorship_levels") expect(page).to_not have_link('Sponsors', href: "/admin/conference/#{conference2.short_title}/sponsors") expect(page).to_not have_link('Supporter Levels', href: "/admin/conference/#{conference2.short_title}/supporter_levels") expect(page).to have_link('E-Mails', href: "/admin/conference/#{conference2.short_title}/emails") - expect(page).to have_link('Call for Papers', href: "/admin/conference/#{conference2.short_title}/call_for_paper") - expect(page).to have_link('Tracks', href: "/admin/conference/#{conference2.short_title}/tracks") - expect(page).to have_link('Event Types', href: "/admin/conference/#{conference2.short_title}/event_types") - expect(page).to have_link('Difficulty Levels', href: "/admin/conference/#{conference2.short_title}/difficulty_levels") + expect(page).to have_link('Program', href: "/admin/conference/#{conference2.short_title}/program") + expect(page).to have_link('Call for Papers', href: "/admin/conference/#{conference2.short_title}/program/cfp") + expect(page).to have_link('Tracks', href: "/admin/conference/#{conference2.short_title}/program/tracks") + expect(page).to have_link('Event Types', href: "/admin/conference/#{conference2.short_title}/program/event_types") + expect(page).to have_link('Difficulty Levels', href: "/admin/conference/#{conference2.short_title}/program/difficulty_levels") expect(page).to_not have_link('Questions', href: "/admin/conference/#{conference2.short_title}/questions") expect(page).to_not have_link('Roles', href: "/admin/conference/#{conference2.short_title}/roles") @@ -141,8 +143,8 @@ feature 'Has correct abilities' do visit admin_conference_registrations_path(conference2.short_title) expect(current_path).to eq(admin_conference_registrations_path(conference2.short_title)) - visit admin_conference_events_path(conference2.short_title) - expect(current_path).to eq(admin_conference_events_path(conference2.short_title)) + visit admin_conference_program_events_path(conference2.short_title) + expect(current_path).to eq(admin_conference_program_events_path(conference2.short_title)) visit admin_conference_schedule_path(conference2.short_title) expect(current_path).to eq(admin_conference_schedule_path(conference2.short_title)) @@ -165,8 +167,8 @@ feature 'Has correct abilities' do visit admin_conference_emails_path(conference2.short_title) expect(current_path).to eq(admin_conference_emails_path(conference2.short_title)) - visit new_admin_conference_call_for_paper_path(conference2.short_title) - expect(current_path).to eq(new_admin_conference_call_for_paper_path(conference2.short_title)) + visit new_admin_conference_program_cfp_path(conference2.short_title) + expect(current_path).to eq(new_admin_conference_program_cfp_path(conference2.short_title)) visit admin_conference_questions_path(conference2.short_title) expect(current_path).to eq(root_path) @@ -185,22 +187,23 @@ feature 'Has correct abilities' do expect(page).to have_text('Basics') expect(page).to_not have_link('Contact', href: "/admin/conference/#{conference3.short_title}/contact/edit") expect(page).to have_link('Commercials', href: "/admin/conference/#{conference3.short_title}/commercials") - expect(page).to_not have_link('Events', href: "/admin/conference/#{conference3.short_title}/events") + expect(page).to_not have_link('Events', href: "/admin/conference/#{conference3.short_title}/program/events") expect(page).to have_link('Registrations', href: "/admin/conference/#{conference3.short_title}/registrations") expect(page).to_not have_link('Schedule', href: "/admin/conference/#{conference3.short_title}/schedule") expect(page).to_not have_link('Campaigns', href: "/admin/conference/#{conference3.short_title}/campaigns") expect(page).to_not have_link('Targets', href: "/admin/conference/#{conference3.short_title}/targets") expect(page).to_not have_link('Venue', href: "/admin/conference/#{conference3.short_title}/venue") - expect(page).to_not have_link('Rooms', href: "/admin/conference/#{conference3.short_title}/rooms") + expect(page).to_not have_link('Rooms', href: "/admin/conference/#{conference3.short_title}/venue/rooms") expect(page).to_not have_link('Lodgings', href: "/admin/conference/#{conference3.short_title}/lodgings") expect(page).to_not have_link('Sponsorship', href: "/admin/conference/#{conference3.short_title}/sponsorship_levels") expect(page).to_not have_link('Sponsors', href: "/admin/conference/#{conference3.short_title}/sponsors") expect(page).to_not have_link('Supporter Levels', href: "/admin/conference/#{conference3.short_title}/supporter_levels") expect(page).to_not have_link('E-Mails', href: "/admin/conference/#{conference3.short_title}/emails") - expect(page).to_not have_link('Call for papers', href: "/admin/conference/#{conference3.short_title}/call_for_paper") - expect(page).to_not have_link('Tracks', href: "/admin/conference/#{conference3.short_title}/tracks") - expect(page).to_not have_link('Event types', href: "/admin/conference/#{conference3.short_title}/event_types") - expect(page).to_not have_link('Difficulty levels', href: "/admin/conference/#{conference3.short_title}/difficulty_levels") + expect(page).to_not have_link('Program', href: "/admin/conference/#{conference3.short_title}/program") + expect(page).to_not have_link('Call for papers', href: "/admin/conference/#{conference3.short_title}/program/cfp") + expect(page).to_not have_link('Tracks', href: "/admin/conference/#{conference3.short_title}/program/tracks") + expect(page).to_not have_link('Event types', href: "/admin/conference/#{conference3.short_title}/program/event_types") + expect(page).to_not have_link('Difficulty levels', href: "/admin/conference/#{conference3.short_title}/program/difficulty_levels") expect(page).to have_link('Questions', href: "/admin/conference/#{conference3.short_title}/questions") expect(page).to_not have_link('Roles', href: "/admin/conference/#{conference3.short_title}/roles") @@ -213,7 +216,7 @@ feature 'Has correct abilities' do visit admin_conference_registrations_path(conference3.short_title) expect(current_path).to eq(admin_conference_registrations_path(conference3.short_title)) - visit admin_conference_events_path(conference3.short_title) + visit admin_conference_program_events_path(conference3.short_title) expect(current_path).to eq(root_path) visit admin_conference_schedule_path(conference3.short_title) @@ -237,7 +240,7 @@ feature 'Has correct abilities' do visit admin_conference_emails_path(conference3.short_title) expect(current_path).to eq(root_path) - visit new_admin_conference_call_for_paper_path(conference3.short_title) + visit new_admin_conference_program_cfp_path(conference3.short_title) expect(current_path).to eq(root_path) visit admin_conference_questions_path(conference3.short_title) diff --git a/spec/features/cfp_spec.rb b/spec/features/cfp_spec.rb index d9610dcf..6f1539da 100644 --- a/spec/features/cfp_spec.rb +++ b/spec/features/cfp_spec.rb @@ -8,13 +8,13 @@ feature Conference do shared_examples 'add and update cfp' do scenario 'adds a new cfp', feature: true, js: true do - expected_count = CallForPaper.count + 1 + expected_count = Cfp.count + 1 sign_in organizer - visit new_admin_conference_call_for_paper_path(conference.short_title) + visit new_admin_conference_program_cfp_path(conference.short_title) - click_button 'Create Call for paper' + click_button 'Create Cfp' expect(flash). to eq('Creating the call for papers failed. ' + @@ -26,32 +26,29 @@ feature Conference do page.execute_script( "$('#conference-end-datepicker').val('#{(today + 6).strftime('%d/%m/%Y')}')") - fill_in 'call_for_paper_rating', with: '4' - - click_button 'Create Call for paper' + click_button 'Create Cfp' # Validations expect(flash). to eq('Call for papers successfully created.') expect(find('#start_date').text).to eq(today.strftime('%A, %B %-d. %Y')) expect(find('#end_date').text).to eq((today + 6).strftime('%A, %B %-d. %Y')) - expect(find('#rating').text).to eq('4') - expect(CallForPaper.count).to eq(expected_count) + expect(Cfp.count).to eq(expected_count) end scenario 'update cfp', feature: true, js: true do - conference.call_for_paper = create(:call_for_paper) - expected_count = CallForPaper.count + conference.program.cfp = create(:cfp) + expected_count = Cfp.count sign_in organizer - visit admin_conference_call_for_paper_path(conference.short_title) + visit admin_conference_program_cfp_path(conference.short_title) click_link 'Edit' # Validate update with empty start date will not saved page.execute_script( "$('#conference-start-datepicker').val('')") - click_button 'Update Call for paper' + click_button 'Update Cfp' expect(flash). to eq('Updating call for papers failed. ' + "Start date can't be blank.") @@ -63,16 +60,14 @@ feature Conference do page.execute_script( "$('#conference-end-datepicker').val('#{(today + 14).strftime('%d/%m/%Y')}')") - fill_in 'call_for_paper_rating', with: '0' - click_button 'Update Call for paper' + click_button 'Update Cfp' # Validations expect(flash). to eq('Call for papers successfully updated.') expect(find('#start_date').text).to eq(today.strftime('%A, %B %-d. %Y')) expect(find('#end_date').text).to eq((today + 14).strftime('%A, %B %-d. %Y')) - expect(find('#rating').text).to eq('0') - expect(CallForPaper.count).to eq(expected_count) + expect(Cfp.count).to eq(expected_count) end end diff --git a/spec/features/commercials_spec.rb b/spec/features/commercials_spec.rb index fde330c1..df50e260 100644 --- a/spec/features/commercials_spec.rb +++ b/spec/features/commercials_spec.rb @@ -42,7 +42,7 @@ feature Commercial do end context 'in public area' do - let!(:event) { create(:event, conference: conference, title: 'Example Proposal') } + let!(:event) { create(:event, program: conference.program, title: 'Example Proposal') } before(:each) do event.event_users = [create(:event_user, @@ -58,8 +58,8 @@ feature Commercial do sign_out end - scenario 'adds a commercial of an event', feature: true, js: true do - visit edit_conference_proposal_path(conference.short_title, event.id) + scenario 'adds a valid commercial of an event', feature: true, js: true do + visit edit_conference_program_proposal_path(conference.short_title, event.id) click_link 'Commercials' fill_in 'commercial_url', with: 'https://www.youtube.com/watch?v=M9bq_alk-sw' @@ -75,7 +75,7 @@ feature Commercial do commercial = create(:commercial, commercialable_id: event.id, commercialable_type: 'Event') - visit edit_conference_proposal_path(conference.short_title, event.id) + visit edit_conference_program_proposal_path(conference.short_title, event.id) click_link 'Commercials' fill_in "commercial_url_#{commercial.id}", with: 'https://www.youtube.com/watch?v=M9bq_alk-sw' click_button 'Update' @@ -89,7 +89,7 @@ feature Commercial do create(:commercial, commercialable_id: event.id, commercialable_type: 'Event') - visit edit_conference_proposal_path(conference.short_title, event.id) + visit edit_conference_program_proposal_path(conference.short_title, event.id) click_link 'Commercials' click_link 'Delete' page.driver.network_traffic diff --git a/spec/features/difficulty_levels_spec.rb b/spec/features/difficulty_levels_spec.rb index d670d29a..c155e672 100644 --- a/spec/features/difficulty_levels_spec.rb +++ b/spec/features/difficulty_levels_spec.rb @@ -9,7 +9,7 @@ feature DifficultyLevel do scenario 'adds difficulty level', feature: true, js: true do sign_in organizer - visit admin_conference_difficulty_levels_path( + visit admin_conference_program_difficulty_levels_path( conference_id: conference.short_title) # Add difficulty level @@ -32,9 +32,9 @@ feature DifficultyLevel do scenario 'updates difficulty level', feature: true, js: true do - conference.difficulty_levels << create(:difficulty_level) + conference.program.difficulty_levels << create(:difficulty_level) sign_in organizer - visit admin_conference_difficulty_levels_path( + visit admin_conference_program_difficulty_levels_path( conference_id: conference.short_title) # Remove difficulty level diff --git a/spec/features/event_types_spec.rb b/spec/features/event_types_spec.rb index b47cb73e..fee4f07b 100644 --- a/spec/features/event_types_spec.rb +++ b/spec/features/event_types_spec.rb @@ -9,7 +9,7 @@ feature EventType do scenario 'adds and updates event type', feature: true, js: true do sign_in organizer - visit admin_conference_event_types_path( + visit admin_conference_program_event_types_path( conference_id: conference.short_title) within('table#event_types') do diff --git a/spec/features/omniauth_spec.rb b/spec/features/omniauth_spec.rb index 93ccd4a4..94949d58 100644 --- a/spec/features/omniauth_spec.rb +++ b/spec/features/omniauth_spec.rb @@ -46,7 +46,7 @@ feature Openid do click_link 'omniauth-google' end - expect(flash).to eq("Could not authenticate you from Google because \"Invalid credentials\".") + expect(flash).to eq('Could not authenticate you from Google because "Invalid credentials".') end scenario 'adds openid to existing user' do diff --git a/spec/features/program_spec.rb b/spec/features/program_spec.rb new file mode 100644 index 00000000..b32a2854 --- /dev/null +++ b/spec/features/program_spec.rb @@ -0,0 +1,30 @@ +require 'spec_helper' + +feature Program do + + let!(:conference) { create(:conference) } + let!(:program) { conference.program } + let!(:organizer_role) { create(:organizer_role, resource: conference) } + let!(:organizer) { create(:user, role_ids: [organizer_role.id]) } + + describe 'edit program' do + before :each do + sign_in organizer + end + + scenario 'changes rating', feature: true, js: true do + visit admin_conference_program_path(conference.short_title) + + click_link 'Edit' + + fill_in 'program_rating', with: '4' + + click_button 'Update Program' + + # Validations + expect(flash). + to eq('The program was successfully updated.') + expect(find('#rating').text).to eq('4') + end + end +end diff --git a/spec/features/proposal_spec.rb b/spec/features/proposal_spec.rb index 43f4a5f2..3c5890ab 100644 --- a/spec/features/proposal_spec.rb +++ b/spec/features/proposal_spec.rb @@ -1,7 +1,8 @@ require 'spec_helper' feature Event do - let!(:conference) { create(:conference, call_for_paper: create(:call_for_paper)) } + let!(:conference) { create(:conference) } + let!(:cfp) { create(:cfp, program_id: conference.program.id) } let!(:organizer_role) { create(:organizer_role, resource: conference) } let!(:organizer) { create(:user, email: 'admin@example.com', role_ids: [organizer_role.id]) } let!(:participant) { create(:user) } @@ -10,7 +11,7 @@ feature Event do before(:each) do @options = {} @options[:send_mail] = 'false' - @event = create(:event, conference: conference, title: 'Example Proposal') + @event = create(:event, program: conference.program, title: 'Example Proposal') end after(:each) do @@ -23,7 +24,7 @@ feature Event do end scenario 'rejects a proposal', feature: true, js: true do - visit admin_conference_events_path(conference.short_title) + visit admin_conference_program_events_path(conference.short_title) expect(page.has_content?('Example Proposal')).to be true click_button 'New' @@ -34,7 +35,7 @@ feature Event do end scenario 'accepts a proposal', feature: true, js: true do - visit admin_conference_events_path(conference.short_title) + visit admin_conference_program_events_path(conference.short_title) expect(page.has_content?('Example Proposal')).to be true click_button 'New' @@ -47,7 +48,7 @@ feature Event do scenario 'restarts review of a proposal', feature: true, js: true do @event.reject!(@options) - visit admin_conference_events_path(conference.short_title) + visit admin_conference_program_events_path(conference.short_title) expect(page.has_content?('Example Proposal')).to be true click_button 'Rejected' @@ -71,7 +72,7 @@ feature Event do expected_count_event = Event.count + 1 expected_count_user = User.count + 1 - visit new_conference_proposal_path(conference.short_title) + visit new_conference_program_proposal_path(conference.short_title) fill_in 'user_username', with: 'Test User' fill_in 'user_email', with: 'testuser@osem.io' @@ -90,11 +91,12 @@ feature Event do end scenario 'update a proposal' do - proposal = create(:event) + conference = create(:conference) + proposal = create(:event, program: conference.program) sign_in proposal.submitter - visit edit_conference_proposal_path(proposal.conference.short_title, proposal) + visit edit_conference_program_proposal_path(proposal.program.conference.short_title, proposal) fill_in 'event_subtitle', with: 'My event subtitle' select('Easy', from: 'event[difficulty_level_id]') @@ -106,7 +108,7 @@ feature Event do scenario 'signed_in user submits a valid proposal', feature: true, js: true do sign_in participant_without_bio expected_count = Event.count + 1 - visit conference_proposal_index_path(conference.short_title) + visit conference_program_proposal_index_path(conference.short_title) click_link 'New Proposal' fill_in 'event_title', with: 'Example Proposal' @@ -120,13 +122,13 @@ feature Event do click_button 'Create Proposal' expect(flash).to eq('Proposal was successfully submitted.') - expect(current_path).to eq(conference_proposal_index_path(conference.short_title)) + expect(current_path).to eq(conference_program_proposal_index_path(conference.short_title)) expect(Event.count).to eq(expected_count) end scenario 'confirms a proposal', feature: true, js: true do sign_in participant - visit conference_proposal_index_path(conference.short_title) + visit conference_program_proposal_index_path(conference.short_title) expect(page.has_content?('Example Proposal')).to be true expect(@event.state).to eq('unconfirmed') click_link "confirm_proposal_#{@event.id}" @@ -139,7 +141,7 @@ feature Event do scenario 'withdraw a proposal', feature: true, js: true do sign_in participant @event.confirm! - visit conference_proposal_index_path(conference.short_title) + visit conference_program_proposal_index_path(conference.short_title) expect(page.has_content?('Example Proposal')).to be true click_link "delete_proposal_#{@event.id}" expect(flash).to eq('Proposal was successfully withdrawn.') diff --git a/spec/features/registration_periods_spec.rb b/spec/features/registration_periods_spec.rb index 341edbe9..c0515e97 100644 --- a/spec/features/registration_periods_spec.rb +++ b/spec/features/registration_periods_spec.rb @@ -25,7 +25,7 @@ feature RegistrationPeriod do "#{Date.today.strftime('%d/%m/%Y')}')") page. execute_script("$('#registration-period-end-datepicker').val('" + - "#{(Date.today + 7).strftime('%d/%m/%Y')}')") + "#{(Date.today + 5).strftime('%d/%m/%Y')}')") click_button 'Save Registration Period' @@ -35,7 +35,7 @@ feature RegistrationPeriod do registration_period = RegistrationPeriod.where(conference_id: conference.id).first registration_period.reload expect(registration_period.start_date).to eq(Date.today) - expect(registration_period.end_date).to eq(Date.today + 7) + expect(registration_period.end_date).to eq(Date.today + 5) end end diff --git a/spec/features/rooms_spec.rb b/spec/features/rooms_spec.rb index 96480351..0b510c46 100644 --- a/spec/features/rooms_spec.rb +++ b/spec/features/rooms_spec.rb @@ -2,13 +2,14 @@ require 'spec_helper' feature Room do let!(:conference) { create(:conference) } + let!(:venue) { create(:venue, conference: conference) } let!(:organizer_role) { create(:organizer_role, resource: conference) } let!(:organizer) { create(:user, role_ids: [organizer_role.id]) } shared_examples 'rooms' do scenario 'adds a room', feature: true, js: true do sign_in organizer - visit admin_conference_rooms_path( + visit admin_conference_venue_rooms_path( conference_id: conference.short_title) expect(page.has_no_table?('#rooms')).to be true @@ -30,9 +31,9 @@ feature Room do end scenario 'updates a room', feature: true, js: true do - room = create(:room, conference_id: conference.id) + room = create(:room, venue: venue) sign_in organizer - visit edit_admin_conference_room_path( + visit edit_admin_conference_venue_room_path( conference_id: conference.short_title, id: room.id) fill_in 'room_name', with: 'Auditorium' diff --git a/spec/features/tickets_spec.rb b/spec/features/tickets_spec.rb index b7bde589..de5b1220 100644 --- a/spec/features/tickets_spec.rb +++ b/spec/features/tickets_spec.rb @@ -52,7 +52,8 @@ feature Ticket do click_button 'Update Ticket' ticket.reload - expect(ticket.price).to eq(50) + # It's necessary to multiply by 100 because the price is in cents + expect(ticket.price).to eq(Money.new(50 * 100, 'USD')) expect(ticket.title).to eq('Free Ticket') expect(flash).to eq('Ticket successfully updated.') expect(Ticket.count).to eq(1) @@ -68,7 +69,8 @@ feature Ticket do click_button 'Update Ticket' ticket.reload - expect(ticket.price).to eq(100) + # It's necessary to multiply by 100 because the price is in cents + expect(ticket.price).to eq(Money.new(100 * 100, 'USD')) expect(ticket.title).to eq('Business Ticket') expect(flash).to eq("Ticket update failed: Title can't be blank. Price cents must be greater than 0.") expect(Ticket.count).to eq(1) diff --git a/spec/features/tracks_spec.rb b/spec/features/tracks_spec.rb index ecaf0789..f66bbb87 100644 --- a/spec/features/tracks_spec.rb +++ b/spec/features/tracks_spec.rb @@ -10,7 +10,7 @@ feature Track do sign_in organizer - visit admin_conference_tracks_path(conference_id: conference.short_title) + visit admin_conference_program_tracks_path(conference_id: conference.short_title) click_link 'New Track' fill_in 'track_name', with: 'Distribution' @@ -27,10 +27,10 @@ feature Track do end scenario 'deletes a track', feature: true, js: true do - track = create(:track, conference_id: conference.id) + track = create(:track, program_id: conference.program.id) sign_in organizer - visit admin_conference_tracks_path(conference_id: conference.short_title) + visit admin_conference_program_tracks_path(conference_id: conference.short_title) click_link 'Delete' @@ -43,10 +43,10 @@ feature Track do end scenario 'updates a track', feature: true, js: true do - create(:track, conference_id: conference.id) + create(:track, program_id: conference.program.id) sign_in organizer - visit admin_conference_tracks_path(conference_id: conference.short_title) + visit admin_conference_program_tracks_path(conference_id: conference.short_title) click_link 'Edit' fill_in 'track_name', with: 'Distribution' diff --git a/spec/models/ability_spec.rb b/spec/models/ability_spec.rb index 73812dc1..fd9cd9ff 100644 --- a/spec/models/ability_spec.rb +++ b/spec/models/ability_spec.rb @@ -10,8 +10,20 @@ describe 'User' do subject(:ability){ Ability.new(user) } let(:user){ nil } + let!(:my_conference) { create(:full_conference) } + let!(:my_cfp) { create(:cfp, program: my_conference.program) } + let(:my_venue) { my_conference.venue || create(:venue, conference: my_conference) } + let(:my_registration) { create(:registration, conference: my_conference, user: first_user) } + + let(:other_registration) { create(:registration, conference: conference_public) } + let(:my_event) { create(:event_full, program: my_conference.program) } + let(:my_room) { create(:room, venue: my_conference.venue) } + let!(:my_event_scheduled) { create(:event_full, program: my_conference.program, room_id: my_room.id) } + let(:other_event) { create(:event_full, program: conference_public.program) } + let(:conference_not_public) { create(:conference, splashpage: create(:splashpage, public: false)) } - let(:conference_public) { create(:full_conference, splashpage: create(:splashpage, public: true), call_for_paper: create(:call_for_paper, schedule_public: true)) } + let(:conference_public) { create(:full_conference, splashpage: create(:splashpage, public: true)) } + let!(:conference_public_cfp) { create(:cfp, program: conference_public.program) } let(:event_confirmed) { create(:event, state: 'confirmed') } let(:event_unconfirmed) { create(:event) } @@ -28,7 +40,11 @@ describe 'User' do it{ should be_able_to(:show, conference_public)} it{ should_not be_able_to(:show, conference_not_public)} - it{ should be_able_to(:schedule, conference_public)} + it do + conference_public.program.schedule_public = true + conference_public.program.save + should be_able_to(:schedule, conference_public) + end it{ should_not be_able_to(:schedule, conference_not_public)} it{ should be_able_to(:show, event_confirmed)} @@ -57,10 +73,8 @@ describe 'User' do let(:registration_public) { create(:registration, conference: conference_public, user: user) } let(:registration_not_public) { create(:registration, conference: conference_not_public, user: user) } - let(:my_event) { create(:event, users: [user]) } - - let(:commercial) { create(:commercial, commercialable: event_unconfirmed) } - let(:my_commercial) { create(:commercial, commercialable: my_event) } + let(:user_event) { create(:event, users: [user]) } + let(:user_commercial) { create(:commercial, commercialable: user_event) } it{ should be_able_to(:manage, user) } @@ -74,27 +88,39 @@ describe 'User' do it{ should be_able_to(:destroy, subscription) } it{ should be_able_to(:create, Event) } - it{ should be_able_to(:manage, my_event) } + it{ should be_able_to(:manage, user_event) } it{ should_not be_able_to(:manage, event_unconfirmed) } - it{ should be_able_to(:create, my_event.commercials.new) } - it{ should be_able_to(:manage, my_commercial) } - it{ should_not be_able_to(:manage, commercial) } + it{ should be_able_to(:create, user_event.commercials.new) } + it{ should be_able_to(:manage, user_commercial) } + it{ should_not be_able_to(:manage, commercial_event_unconfirmed) } end context 'user #is_admin?' do + let(:venue) { my_conference.venue } + let(:room) { create(:room, venue: venue) } + let!(:event) { create(:event_full, program: my_conference.program, room_id: room.id) } let(:user) { create(:admin) } it{ should be_able_to(:manage, :all) } + it{ should_not be_able_to(:destroy, my_conference.program) } + it{ should_not be_able_to(:destroy, my_venue) } end context 'when user has the role organizer' do - let!(:my_conference) { create(:full_conference) } let(:role) { create(:organizer_role, resource: my_conference) } let(:user) { create(:user, role_ids: [role.id], is_admin: false) } - let(:registration) { create(:registration, conference: my_conference) } - let(:other_registration) { create(:registration, conference: conference_public) } - let(:event) { create(:event_full, conference: my_conference) } - let(:other_event) { create(:event_full, conference: conference_public) } + + it{ should_not be_able_to(:destroy, my_conference.program) } + it 'when there is a room assigned to an event' do + should_not be_able_to(:destroy, my_venue) + end + + it 'when there are no rooms used' do + my_event_scheduled.room_id = nil + my_event_scheduled.save! + my_event_scheduled.reload + should be_able_to(:destroy, my_venue) + end it{ should be_able_to([:create, :new], Conference) } it{ should be_able_to(:manage, my_conference) } @@ -115,8 +141,8 @@ describe 'User' do it{ should_not be_able_to(:manage, conference_public.registration_period) } it{ should be_able_to(:manage, my_conference.questions.first) } it{ should_not be_able_to(:manage, conference_public.questions.first) } - it{ should be_able_to(:manage, my_conference.call_for_paper) } - it{ should_not be_able_to(:manage, conference_public.call_for_paper) } + it{ should be_able_to(:manage, my_conference.program.cfp) } + it{ should_not be_able_to(:manage, conference_public.program.cfp) } it{ should be_able_to(:manage, my_conference.venue) } it{ should_not be_able_to(:manage, conference_public.venue) } it{ should be_able_to(:manage, my_conference.lodgings.first) } @@ -128,31 +154,26 @@ describe 'User' do it{ should be_able_to(:manage, my_conference.tickets.first) } it{ should_not be_able_to(:manage, conference_public.tickets.first) } - it{ should be_able_to(:manage, registration) } + it{ should be_able_to(:manage, my_registration) } it{ should_not be_able_to(:manage, other_registration) } - it{ should be_able_to(:manage, event) } + it{ should be_able_to(:manage, my_event) } it{ should_not be_able_to(:manage, other_event) } - it{ should be_able_to(:manage, event.event_type) } + it{ should be_able_to(:manage, my_event.event_type) } it{ should_not be_able_to(:manage, other_event.event_type) } - it{ should be_able_to(:manage, event.track) } + it{ should be_able_to(:manage, my_event.track) } it{ should_not be_able_to(:manage, other_event.track) } - it{ should be_able_to(:manage, event.difficulty_level) } + it{ should be_able_to(:manage, my_event.difficulty_level) } it{ should_not be_able_to(:manage, other_event.difficulty_level) } - it{ should be_able_to(:manage, event.commercials.first) } + it{ should be_able_to(:manage, my_event.commercials.first) } it{ should_not be_able_to(:manage, other_event.commercials.first) } - it{ should be_able_to(:index, event.comment_threads.first) } + it{ should be_able_to(:index, my_event.comment_threads.first) } it{ should_not be_able_to(:index, other_event.comment_threads.first) } end context 'when user has the role cfp' do - let!(:my_conference) { create(:full_conference) } let(:role) { create(:cfp_role, resource: my_conference) } let(:user) { create(:user, role_ids: [role.id], is_admin: false) } - let(:registration) { create(:registration, conference: my_conference) } - let(:other_registration) { create(:registration, conference: conference_public) } - let(:event) { create(:event_full, conference: my_conference) } - let(:other_event) { create(:event_full, conference: conference_public) } it{ should_not be_able_to([:create, :new], Conference.new) } it{ should_not be_able_to(:manage, my_conference) } @@ -173,10 +194,10 @@ describe 'User' do it{ should_not be_able_to(:manage, conference_public.registration_period) } it{ should_not be_able_to(:manage, my_conference.questions.first) } it{ should_not be_able_to(:manage, conference_public.questions.first) } - it{ should be_able_to(:manage, my_conference.call_for_paper) } - it{ should_not be_able_to(:manage, conference_public.call_for_paper) } + it{ should be_able_to(:manage, my_conference.program.cfp) } + it{ should_not be_able_to(:manage, conference_public.program.cfp) } it{ should_not be_able_to(:manage, my_conference.venue) } - it{ should be_able_to(:index, my_conference.venue) } + it{ should be_able_to(:show, my_conference.venue) } it{ should_not be_able_to(:manage, conference_public.venue) } it{ should_not be_able_to(:manage, my_conference.lodgings.first) } it{ should_not be_able_to(:manage, conference_public.lodgings.first) } @@ -187,31 +208,26 @@ describe 'User' do it{ should_not be_able_to(:manage, my_conference.tickets.first) } it{ should_not be_able_to(:manage, conference_public.tickets.first) } - it{ should_not be_able_to(:manage, registration) } + it{ should_not be_able_to(:manage, my_registration) } it{ should_not be_able_to(:manage, other_registration) } - it{ should be_able_to(:manage, event) } + it{ should be_able_to(:manage, my_event) } it{ should_not be_able_to(:manage, other_event) } - it{ should be_able_to(:manage, event.event_type) } + it{ should be_able_to(:manage, my_event.event_type) } it{ should_not be_able_to(:manage, other_event.event_type) } - it{ should be_able_to(:manage, event.track) } + it{ should be_able_to(:manage, my_event.track) } it{ should_not be_able_to(:manage, other_event.track) } - it{ should be_able_to(:manage, event.difficulty_level) } + it{ should be_able_to(:manage, my_event.difficulty_level) } it{ should_not be_able_to(:manage, other_event.difficulty_level) } - it{ should be_able_to(:manage, event.commercials.first) } + it{ should be_able_to(:manage, my_event.commercials.first) } it{ should_not be_able_to(:manage, other_event.commercials.first) } - it{ should be_able_to(:index, event.comment_threads.first) } + it{ should be_able_to(:index, my_event.comment_threads.first) } it{ should_not be_able_to(:index, other_event.comment_threads.first) } end context 'when user has the role info_desk' do - let!(:my_conference) { create(:full_conference) } let(:role) { create(:info_desk_role, resource: my_conference) } let(:user) { create(:user, role_ids: [role.id], is_admin: false) } - let(:registration) { create(:registration, conference: my_conference) } - let(:other_registration) { create(:registration, conference: conference_public) } - let(:event) { create(:event_full, conference: my_conference) } - let(:other_event) { create(:event_full, conference: conference_public) } it{ should_not be_able_to([:create, :new], Conference.new) } it{ should_not be_able_to(:manage, my_conference) } @@ -232,10 +248,10 @@ describe 'User' do it{ should_not be_able_to(:manage, conference_public.registration_period) } it{ should be_able_to(:manage, my_conference.questions.first) } it{ should_not be_able_to(:manage, conference_public.questions.first) } - it{ should_not be_able_to(:manage, my_conference.call_for_paper) } - it{ should_not be_able_to(:manage, conference_public.call_for_paper) } + it{ should_not be_able_to(:manage, my_conference.program.cfp) } + it{ should_not be_able_to(:manage, conference_public.program.cfp) } it{ should_not be_able_to(:manage, my_conference.venue) } - it{ should_not be_able_to(:index, my_conference.venue) } + it{ should_not be_able_to(:show, my_conference.venue) } it{ should_not be_able_to(:manage, conference_public.venue) } it{ should_not be_able_to(:manage, my_conference.lodgings.first) } it{ should_not be_able_to(:manage, conference_public.lodgings.first) } @@ -246,31 +262,26 @@ describe 'User' do it{ should_not be_able_to(:manage, my_conference.tickets.first) } it{ should_not be_able_to(:manage, conference_public.tickets.first) } - it{ should be_able_to(:manage, registration) } + it{ should be_able_to(:manage, my_registration) } it{ should_not be_able_to(:manage, other_registration) } - it{ should_not be_able_to(:manage, event) } + it{ should_not be_able_to(:manage, my_event) } it{ should_not be_able_to(:manage, other_event) } - it{ should_not be_able_to(:manage, event.event_type) } + it{ should_not be_able_to(:manage, my_event.event_type) } it{ should_not be_able_to(:manage, other_event.event_type) } - it{ should_not be_able_to(:manage, event.track) } + it{ should_not be_able_to(:manage, my_event.track) } it{ should_not be_able_to(:manage, other_event.track) } - it{ should_not be_able_to(:manage, event.difficulty_level) } + it{ should_not be_able_to(:manage, my_event.difficulty_level) } it{ should_not be_able_to(:manage, other_event.difficulty_level) } - it{ should_not be_able_to(:manage, event.commercials.first) } + it{ should_not be_able_to(:manage, my_event.commercials.first) } it{ should_not be_able_to(:manage, other_event.commercials.first) } - it{ should_not be_able_to(:index, event.comment_threads.first) } + it{ should_not be_able_to(:index, my_event.comment_threads.first) } it{ should_not be_able_to(:index, other_event.comment_threads.first) } end context 'when user has the role volunteers_coordinator' do - let!(:my_conference) { create(:full_conference) } let(:role) { create(:volunteers_coordinator_role, resource: my_conference) } let(:user) { create(:user, role_ids: [role.id], is_admin: false) } - let(:registration) { create(:registration, conference: my_conference) } - let(:other_registration) { create(:registration, conference: conference_public) } - let(:event) { create(:event_full, conference: my_conference) } - let(:other_event) { create(:event_full, conference: conference_public) } it{ should_not be_able_to([:create, :new], Conference.new) } it{ should_not be_able_to(:manage, my_conference) } @@ -291,10 +302,10 @@ describe 'User' do it{ should_not be_able_to(:manage, conference_public.registration_period) } it{ should_not be_able_to(:manage, my_conference.questions.first) } it{ should_not be_able_to(:manage, conference_public.questions.first) } - it{ should_not be_able_to(:manage, my_conference.call_for_paper) } - it{ should_not be_able_to(:manage, conference_public.call_for_paper) } + it{ should_not be_able_to(:manage, my_conference.program.cfp) } + it{ should_not be_able_to(:manage, conference_public.program.cfp) } it{ should_not be_able_to(:manage, my_conference.venue) } - it{ should_not be_able_to(:index, my_conference.venue) } + it{ should_not be_able_to(:show, my_conference.venue) } it{ should_not be_able_to(:manage, conference_public.venue) } it{ should_not be_able_to(:manage, my_conference.lodgings.first) } it{ should_not be_able_to(:manage, conference_public.lodgings.first) } @@ -308,17 +319,17 @@ describe 'User' do it{ should_not be_able_to(:manage, registration) } it{ should_not be_able_to(:manage, other_registration) } - it{ should_not be_able_to(:manage, event) } + it{ should_not be_able_to(:manage, my_event) } it{ should_not be_able_to(:manage, other_event) } - it{ should_not be_able_to(:manage, event.event_type) } + it{ should_not be_able_to(:manage, my_event.event_type) } it{ should_not be_able_to(:manage, other_event.event_type) } - it{ should_not be_able_to(:manage, event.track) } + it{ should_not be_able_to(:manage, my_event.track) } it{ should_not be_able_to(:manage, other_event.track) } - it{ should_not be_able_to(:manage, event.difficulty_level) } + it{ should_not be_able_to(:manage, my_event.difficulty_level) } it{ should_not be_able_to(:manage, other_event.difficulty_level) } - it{ should_not be_able_to(:manage, event.commercials.first) } + it{ should_not be_able_to(:manage, my_event.commercials.first) } it{ should_not be_able_to(:manage, other_event.commercials.first) } - it{ should_not be_able_to(:index, event.comment_threads.first) } + it{ should_not be_able_to(:index, my_event.comment_threads.first) } it{ should_not be_able_to(:index, other_event.comment_threads.first) } it 'should be_able to :manage Vposition' it 'should be_able to :manage Vday' diff --git a/spec/models/cfp_spec.rb b/spec/models/cfp_spec.rb index 122dca07..3f8e7a0f 100644 --- a/spec/models/cfp_spec.rb +++ b/spec/models/cfp_spec.rb @@ -1,38 +1,100 @@ require 'spec_helper' -describe CallForPaper do +describe Cfp do let!(:conference) { create(:conference, end_date: Date.today) } + let!(:cfp) { build(:cfp, start_date: Date.today - 2, end_date: Date.today - 1, program_id: conference.program.id) } describe '#before_end_of_conference' do describe 'fails to save cfp' do it 'when cfp end_date is after conference end_date' do - cfp = build(:call_for_paper, end_date: Date.today + 1, conference_id: conference.id) - expect(cfp.valid?).to be false + cfp.end_date = Date.today + 1 + expect(cfp.valid?).to be false end it 'when cfp start_date is after conference end_date' do - cfp = build(:call_for_paper, end_date: Date.today + 1, conference_id: conference.id) - expect(cfp.valid?).to be false + cfp.start_date = Date.today + 1 + expect(cfp.valid?).to be false end end describe 'successfully saves cfp' do - it 'when cfp end_date and start_date are not after conference end_date' do - cfp = build(:call_for_paper, start_date: Date.today - 2, end_date: Date.today - 1, conference_id: conference.id) - expect(cfp.valid?).to be true + it 'when cfp end_date and start_date are before the conference end_date' do + expect(cfp.valid?).to be true end end end describe '#start_after_end_date' do - it 'fails when cfp start_date is after cfp end_date' do - cfp = build(:call_for_paper, start_date: Date.today - 1, end_date: Date.today - 2, conference_id: conference.id) - expect(cfp.valid?).to be false + it 'succeeds when cfp start_date is after cfp end_date' do + expect(cfp.valid?).to be true end - it 'succeeds when cfp start_date is after cfp end_date' do - cfp = build(:call_for_paper, start_date: Date.today - 2, end_date: Date.today - 1, conference_id: conference.id) - expect(cfp.valid?).to be true + it 'fails when cfp start_date is after cfp end_date' do + cfp.start_date = Date.today + expect(cfp.valid?).to be false + end + end + + describe '#notify_on_cfp_date_update?' do + before :each do + email_settings = conference.email_settings + email_settings.send_on_cfp_dates_updated = true + email_settings.cfp_dates_updated_subject = 'subject' + email_settings.cfp_dates_updated_body = 'body text' + email_settings.save! + + cfp.save! + end + + describe 'returns true' do + it 'when end_date changed' do + cfp.end_date = Date.today + expect(cfp.start_date_changed?).to eq false + expect(cfp.end_date_changed?).to eq true + expect(cfp.notify_on_cfp_date_update?).to eq true + end + + it 'when start_date changed' do + cfp.start_date = Date.today + expect(cfp.end_date_changed?).to eq false + expect(cfp.start_date_changed?).to eq true + expect(cfp.notify_on_cfp_date_update?).to eq true + end + end + + describe 'returns false' do + it 'when there is no change in cfp dates' do + expect(cfp.start_date_changed?).to eq false + expect(cfp.end_date_changed?).to eq false + expect(cfp.notify_on_cfp_date_update?).to eq false + end + + it 'when send_on_cfp_dates_updates is not set' do + conference.email_settings.send_on_cfp_dates_updated = false + conference.email_settings.save! + cfp.end_date = Date.today + + expect(cfp.end_date_changed?).to eq true + expect(cfp.notify_on_cfp_date_update?).to eq false + end + + it 'when cfp_dates_updates_subject is not set' do + conference.email_settings.cfp_dates_updated_subject = '' + conference.email_settings.save! + cfp.end_date = Date.today + + expect(cfp.end_date_changed?).to eq true + expect(cfp.notify_on_cfp_date_update?).to eq false + end + + it 'when cfp_dates_updates_template is not set' do + conference.email_settings.cfp_dates_updated_body = '' + conference.email_settings.save! + cfp.end_date = Date.today + + expect(cfp.end_date_changed?).to eq true + expect(cfp.notify_on_cfp_date_update?).to eq false + end end end end diff --git a/spec/models/conference_spec.rb b/spec/models/conference_spec.rb index d5ffcbca..d040d00b 100755 --- a/spec/models/conference_spec.rb +++ b/spec/models/conference_spec.rb @@ -4,7 +4,7 @@ require 'spec_helper' describe Conference do - let(:subject) { create(:conference, end_date: '2014-06-30') } + let(:subject) { create(:conference, start_date: Date.new(2014, 06, 30), end_date: Date.new(2014, 06, 30)) } describe '#write_event_distribution_to_db' do @@ -48,26 +48,26 @@ describe Conference do subject.start_date = Date.today + 6.weeks subject.end_date = Date.today + 7.weeks subject.save - subject.call_for_paper = create(:call_for_paper, start_date: Date.today - 3.weeks) + subject.program.cfp = create(:cfp, start_date: Date.today - 3.weeks) - create(:event, conference: subject, created_at: Date.today) + create(:event, program: subject.program, created_at: Date.today) options = {} options[:send_mail] = 'false' - withdrawn = create(:event, conference: subject) + withdrawn = create(:event, program: subject.program) withdrawn.withdraw! - unconfirmed = create(:event, conference: subject) + unconfirmed = create(:event, program: subject.program) unconfirmed.accept!(options) - rejected = create(:event, conference: subject) + rejected = create(:event, program: subject.program) rejected.reject!(options) - confirmed = create(:event, conference: subject) + confirmed = create(:event, program: subject.program) confirmed.accept!(options) confirmed.confirm! - canceled = create(:event, conference: subject) + canceled = create(:event, program: subject.program) canceled.accept!(options) canceled.cancel! @@ -115,11 +115,11 @@ describe Conference do } subject.events_per_week = db_data subject.save - subject.call_for_paper = create(:call_for_paper, start_date: Date.today - 3.weeks) + subject.program.cfp = create(:cfp, start_date: Date.today - 3.weeks) - create(:event, conference: subject, created_at: Date.today) - unconfirmed = create(:event, conference: subject) - confirmed = create(:event, conference: subject) + create(:event, program: subject.program, created_at: Date.today) + unconfirmed = create(:event, program: subject.program) + confirmed = create(:event, program: subject.program) options = {} options[:send_mail] = 'false' unconfirmed.accept!(options) @@ -186,9 +186,9 @@ describe Conference do subject.events_per_week = db_data subject.save - subject.call_for_paper = create(:call_for_paper, start_date: Date.today - 2.weeks) + subject.program.cfp = create(:cfp, start_date: Date.today - 2.weeks) - create(:event, conference: subject, created_at: Date.today - 2.weeks) + create(:event, program: subject.program, created_at: Date.today - 2.weeks) result = { 'Submitted' => [1, 1, 1], @@ -203,8 +203,8 @@ describe Conference do subject.start_date = Date.today + 6.weeks subject.end_date = Date.today + 7.weeks subject.save - subject.call_for_paper = create(:call_for_paper, start_date: Date.today) - create(:event, conference: subject) + subject.program.cfp = create(:cfp, start_date: Date.today) + create(:event, program: subject.program) result = { 'Submitted' => [1], @@ -220,11 +220,11 @@ describe Conference do subject.start_date = Date.today + 6.weeks subject.end_date = Date.today + 7.weeks subject.save - subject.call_for_paper = create(:call_for_paper, start_date: Date.today - 3.weeks) + subject.program.cfp = create(:cfp, start_date: Date.today - 3.weeks) - create(:event, conference: subject, created_at: Date.today) - unconfirmed = create(:event, conference: subject) - confirmed = create(:event, conference: subject) + create(:event, program: subject.program, created_at: Date.today) + unconfirmed = create(:event, program: subject.program) + confirmed = create(:event, program: subject.program) options = {} options[:send_mail] = 'false' unconfirmed.accept!(options) @@ -258,9 +258,9 @@ describe Conference do subject.events_per_week = db_data subject.save - subject.call_for_paper = create(:call_for_paper, start_date: Date.today - 3.weeks) + subject.program.cfp = create(:cfp, start_date: Date.today - 3.weeks) - create(:event, conference: subject, created_at: Date.today - 3.weeks) + create(:event, program: subject.program, created_at: Date.today - 3.weeks) result = { 'Submitted' => [1, 1, 1, 1], @@ -278,7 +278,7 @@ describe Conference do let!(:organizer) { create(:user, role_ids: [organizer_role.id]) } it 'calculates correct hash with top submitters' do - event = create(:event, conference: subject) + event = create(:event, program: subject.program) result = { event.submitter => 1 } @@ -286,11 +286,11 @@ describe Conference do end it 'returns the submitter ordered by submissions' do - e1 = create(:event, conference: subject) + e1 = create(:event, program: subject.program) - e2 = create(:event, conference: subject) - e3 = create(:event, conference: subject) - e4 = create(:event, conference: subject) + e2 = create(:event, program: subject.program) + e3 = create(:event, program: subject.program) + e4 = create(:event, program: subject.program) e3.event_users = [create(:event_user, user: e2.submitter, event_role: 'submitter')] e4.event_users = [create(:event_user, user: e2.submitter, event_role: 'submitter')] @@ -337,7 +337,7 @@ describe Conference do it 'returns 10 if there is 1 submissions of 10' do target = build(:target, target_count: 10, unit: Target.units[:submissions]) subject.targets = [target] - subject.events = [create(:event)] + subject.program.events = [create(:event)] result = { "10 Submissions by #{target.due_date}" => '10' } @@ -356,7 +356,7 @@ describe Conference do it 'returns 10 if there is 30 program minutes of 300' do target = build(:target, target_count: 300, unit: Target.units[:program_minutes]) subject.targets = [target] - subject.events = [create(:event)] + subject.program.events = [create(:event)] result = { "300 Program minutes by #{target.due_date}" => '10' } @@ -372,10 +372,10 @@ describe Conference do describe '#actual_program_minutes' do it 'calculates correct values with events' do - create(:event, conference: subject, event_type: @long) - create(:event, conference: subject, event_type: @long) - create(:event, conference: subject, event_type: @short) - create(:event, conference: subject, event_type: @short) + create(:event, program: subject.program, event_type: @long) + create(:event, program: subject.program, event_type: @long) + create(:event, program: subject.program, event_type: @short) + create(:event, program: subject.program, event_type: @short) result_in_hours = 4 result_in_minutes = 220 expect(subject.current_program_hours).to eq(result_in_hours) @@ -392,10 +392,10 @@ describe Conference do describe '#new_program_minutes' do it 'calculates correct values with events' do - create(:event, conference: subject, event_type: @long, created_at: Time.now - 3.days) - create(:event, conference: subject, event_type: @long) - create(:event, conference: subject, event_type: @short, created_at: Time.now - 3.days) - create(:event, conference: subject, event_type: @short) + create(:event, program: subject.program, event_type: @long, created_at: Time.now - 3.days) + create(:event, program: subject.program, event_type: @long) + create(:event, program: subject.program, event_type: @short, created_at: Time.now - 3.days) + create(:event, program: subject.program, event_type: @short) result_in_hours = 2 result_in_minutes = 110 expect(subject.new_program_hours(Time.now - 5.minutes)).to eq(result_in_hours) @@ -420,9 +420,9 @@ describe Conference do describe '#difficulty_levels_distribution' do it 'calculates correct for different difficulty levels' do - create(:event, conference: subject, difficulty_level: @easy) - create(:event, conference: subject, difficulty_level: @easy) - create(:event, conference: subject, difficulty_level: @hard) + create(:event, program: subject.program, difficulty_level: @easy) + create(:event, program: subject.program, difficulty_level: @easy) + create(:event, program: subject.program, difficulty_level: @hard) result = {} result['Hard'] = { 'value' => 1, @@ -436,7 +436,7 @@ describe Conference do end it 'calculates correct for one difficulty levels' do - create(:event, conference: subject, difficulty_level: @easy) + create(:event, program: subject.program, difficulty_level: @easy) result = {} result['Easy'] = { 'value' => 1, @@ -453,18 +453,18 @@ describe Conference do describe '#difficulty_levels_distribution_confirmed' do it 'calculates correct for different difficulty levels without confirmed' do - create(:event, conference: subject, difficulty_level: @easy) - create(:event, conference: subject, difficulty_level: @easy) - create(:event, conference: subject, difficulty_level: @hard) + create(:event, program: subject.program, difficulty_level: @easy) + create(:event, program: subject.program, difficulty_level: @easy) + create(:event, program: subject.program, difficulty_level: @hard) result = {} expect(subject.difficulty_levels_distribution(:confirmed)).to eq(result) end it 'calculates correct for different difficulty levels with confirmed' do - confirmed_easy = create(:event, conference: subject, difficulty_level: @easy) - create(:event, conference: subject, difficulty_level: @easy) - confirmed_hard = create(:event, conference: subject, difficulty_level: @hard) + confirmed_easy = create(:event, program: subject.program, difficulty_level: @easy) + create(:event, program: subject.program, difficulty_level: @easy) + confirmed_hard = create(:event, program: subject.program, difficulty_level: @hard) options = {} options[:send_mail] = 'false' @@ -486,7 +486,7 @@ describe Conference do end it 'calculates correct for one difficulty levels' do - confirmed = create(:event, conference: subject, difficulty_level: @easy) + confirmed = create(:event, program: subject.program, difficulty_level: @easy) options = {} options[:send_mail] = 'false' confirmed.accept!(options) @@ -510,15 +510,15 @@ describe Conference do describe 'event type distribution' do before do subject.email_settings = create(:email_settings) - @workshop = create(:event_type, title: 'Workshop', color: '#000000', conference: subject) - @lecture = create(:event_type, title: 'Lecture', color: '#ffffff', conference: subject) + @workshop = create(:event_type, title: 'Workshop', color: '#000000', program: subject.program) + @lecture = create(:event_type, title: 'Lecture', color: '#ffffff', program: subject.program) end describe '#event_type_distribution' do it 'calculates correct for different event types' do - create(:event, conference: subject, event_type: @workshop) - create(:event, conference: subject, event_type: @workshop) - create(:event, conference: subject, event_type: @lecture) + create(:event, program: subject.program, event_type: @workshop) + create(:event, program: subject.program, event_type: @workshop) + create(:event, program: subject.program, event_type: @lecture) result = {} result['Workshop'] = { 'value' => 2, @@ -532,7 +532,7 @@ describe Conference do end it 'calculates correct for one event types' do - create(:event, conference: subject, event_type: @workshop) + create(:event, program: subject.program, event_type: @workshop) result = {} result['Workshop'] = { 'value' => 1, @@ -549,18 +549,18 @@ describe Conference do describe '#event_type_distribution_confirmed' do it 'calculates correct for different event types without confirmed' do - create(:event, conference: subject, event_type: @workshop) - create(:event, conference: subject, event_type: @workshop) - create(:event, conference: subject, event_type: @lecture) + create(:event, program: subject.program, event_type: @workshop) + create(:event, program: subject.program, event_type: @workshop) + create(:event, program: subject.program, event_type: @lecture) result = {} expect(subject.event_type_distribution(:confirmed)).to eq(result) end it 'calculates correct for different event types with confirmed' do - confirmed_ws = create(:event, conference: subject, event_type: @workshop) - create(:event, conference: subject, event_type: @workshop) - confirmed_lt = create(:event, conference: subject, event_type: @lecture) + confirmed_ws = create(:event, program: subject.program, event_type: @workshop) + create(:event, program: subject.program, event_type: @workshop) + confirmed_lt = create(:event, program: subject.program, event_type: @lecture) options = {} options[:send_mail] = 'false' @@ -582,7 +582,7 @@ describe Conference do end it 'calculates correct for one event types' do - confirmed = create(:event, conference: subject, event_type: @workshop) + confirmed = create(:event, program: subject.program, event_type: @workshop) options = {} options[:send_mail] = 'false' confirmed.accept!(options) @@ -612,9 +612,9 @@ describe Conference do describe '#tracks_distribution' do it 'calculates correct for different tracks' do - create(:event, conference: subject, track: @track_one) - create(:event, conference: subject, track: @track_one) - create(:event, conference: subject, track: @track_two) + create(:event, program: subject.program, track: @track_one) + create(:event, program: subject.program, track: @track_one) + create(:event, program: subject.program, track: @track_two) result = {} result['Track One'] = { 'value' => 2, @@ -628,7 +628,7 @@ describe Conference do end it 'calculates correct for one track' do - create(:event, conference: subject, track: @track_one) + create(:event, program: subject.program, track: @track_one) result = {} result['Track One'] = { 'value' => 1, @@ -645,18 +645,18 @@ describe Conference do describe '#tracks_distribution_confirmed' do it 'calculates correct for different tracks without confirmed' do - create(:event, conference: subject, track: @track_one) - create(:event, conference: subject, track: @track_one) - create(:event, conference: subject, track: @track_two) + create(:event, program: subject.program, track: @track_one) + create(:event, program: subject.program, track: @track_one) + create(:event, program: subject.program, track: @track_two) result = {} expect(subject.tracks_distribution(:confirmed)).to eq(result) end it 'calculates correct for different tracks with confirmed' do - confirmed_one = create(:event, conference: subject, track: @track_one) - create(:event, conference: subject, track: @track_one) - confirmed_two = create(:event, conference: subject, track: @track_two) + confirmed_one = create(:event, program: subject.program, track: @track_one) + create(:event, program: subject.program, track: @track_one) + confirmed_two = create(:event, program: subject.program, track: @track_two) options = {} options[:send_mail] = 'false' @@ -678,7 +678,7 @@ describe Conference do end it 'calculates correct for one track' do - confirmed = create(:event, conference: subject, track: @track_one) + confirmed = create(:event, program: subject.program, track: @track_one) options = {} options[:send_mail] = 'false' confirmed.accept!(options) @@ -789,22 +789,22 @@ describe Conference do @options = {} @options[:send_mail] = 'false' - create(:event, conference: @conference) + create(:event, program: @conference.program) - withdrawn = create(:event, conference: @conference) + withdrawn = create(:event, program: @conference.program) withdrawn.withdraw! - unconfirmed = create(:event, conference: @conference) + unconfirmed = create(:event, program: @conference.program) unconfirmed.accept!(@options) - rejected = create(:event, conference: @conference) + rejected = create(:event, program: @conference.program) rejected.reject!(@options) - confirmed = create(:event, conference: @conference) + confirmed = create(:event, program: @conference.program) confirmed.accept!(@options) confirmed.confirm! - canceled = create(:event, conference: @conference) + canceled = create(:event, program: @conference.program) canceled.accept!(@options) canceled.cancel! @@ -822,20 +822,20 @@ describe Conference do end it '#event_distribution does calculate correct values with no events' do - @conference.events.clear + @conference.program.events.clear expect(@conference.event_distribution).to eq({}) end it 'event_distribution does calculate correct values with just a new event' do conference = create(:conference) - create(:event, conference: conference) + create(:event, program: conference.program) result = { 'New' => { 'value' => 1, 'color' => '#0000FF' } } expect(conference.event_distribution).to eq(result) end it 'event_distribution does calculate correct values with just an withdrawn event' do conference = create(:conference) - event = create(:event, conference: conference) + event = create(:event, program: conference.program) event.withdraw! result = { 'Withdrawn' => { 'value' => 1, 'color' => '#FF8000' } } expect(conference.event_distribution).to eq(result) @@ -843,7 +843,7 @@ describe Conference do it 'event_distribution does calculate correct values with just an unconfirmed event' do conference = create(:conference) - event = create(:event, conference: conference) + event = create(:event, program: conference.program) event.accept!(@options) result = { 'Unconfirmed' => { 'value' => 1, 'color' => '#FFFF00' } } expect(conference.event_distribution).to eq(result) @@ -851,7 +851,7 @@ describe Conference do it 'event_distribution does calculate correct values with just an rejected event' do conference = create(:conference) - event = create(:event, conference: conference) + event = create(:event, program: conference.program) event.reject!(@options) result = { 'Rejected' => { 'value' => 1, 'color' => '#FF0000' } } expect(conference.event_distribution).to eq(result) @@ -860,7 +860,7 @@ describe Conference do it 'event_distribution does calculate correct values with just an confirmed event' do conference = create(:conference) conference.email_settings = create(:email_settings) - event = create(:event, conference: conference) + event = create(:event, program: conference.program) event.accept!(@options) event.confirm! result = { 'Confirmed' => { 'value' => 1, 'color' => '#00FF00' } } @@ -869,7 +869,7 @@ describe Conference do it 'event_distribution does calculate correct values with just an canceled event' do conference = create(:conference) - event = create(:event, conference: conference) + event = create(:event, program: conference.program) event.accept!(@options) event.cancel! result = { 'Canceled' => { 'value' => 1, 'color' => '#848484' } } @@ -881,20 +881,20 @@ describe Conference do end it 'self#event_distribution does calculate correct values with no events' do - @conference.events.clear + @conference.program.events.clear expect(Conference.event_distribution).to eq({}) end it 'self#event_distribution does calculate correct values with just a new event' do - @conference.events.clear - create(:event, conference: @conference) + @conference.program.events.clear + create(:event, program: @conference.program) result = { 'New' => { 'value' => 1, 'color' => '#0000FF' } } expect(Conference.event_distribution).to eq(result) end it 'self#event_distribution does calculate correct values with just a new events from different conferences' do - create(:event, conference: @conference) + create(:event, program: @conference.program) @result['New'] = { 'value' => 2, 'color' => '#0000FF' } expect(Conference.event_distribution).to eq(@result) end @@ -970,12 +970,11 @@ describe Conference do end it 'calculates correct for new conference' do - subject.call_for_paper = nil + subject.program.cfp = nil subject.venue = nil - subject.rooms = [] - subject.tracks = [] - subject.event_types = [] - subject.difficulty_levels = [] + subject.program.tracks = [] + subject.program.event_types = [] + subject.program.difficulty_levels = [] subject.splashpage = create(:splashpage, public: false) expect(subject.get_status).to eq(@result_false) @@ -983,14 +982,14 @@ describe Conference do it 'calculates correct for conference with registration' do subject.registration_period = create(:registration_period, - start_date: Date.today, - end_date: Date.today + 14) - subject.call_for_paper = nil + start_date: subject.end_date - 14, + end_date: subject.end_date, conference: subject) + subject.program.cfp = nil subject.venue = nil - subject.rooms = [] - subject.tracks = [] - subject.event_types = [] - subject.difficulty_levels = [] + subject.program.event_types = [] + subject.program.tracks = [] + subject.program.event_types = [] + subject.program.difficulty_levels = [] subject.splashpage = create(:splashpage, public: false) @result_false['registration'] = true @@ -1001,14 +1000,13 @@ describe Conference do it 'calculates correct for conference with registration, cfp' do subject.registration_period = create(:registration_period, - start_date: Date.today, - end_date: Date.today + 14) - subject.call_for_paper = create(:call_for_paper) + start_date: subject.end_date - 14, + end_date: subject.end_date, conference: subject) + subject.program.cfp = create(:cfp) subject.venue = nil - subject.rooms = [] - subject.tracks = [] - subject.event_types = [] - subject.difficulty_levels = [] + subject.program.tracks = [] + subject.program.event_types = [] + subject.program.difficulty_levels = [] subject.splashpage = create(:splashpage, public: false) @result_false['cfp'] = true @@ -1019,15 +1017,16 @@ describe Conference do end it 'calculates correct for conference with registration, cfp, venue' do + expect(subject.end_date).to eq Date.new(2014, 06, 30) subject.registration_period = create(:registration_period, - start_date: Date.today, - end_date: Date.today + 14) - subject.call_for_paper = create(:call_for_paper) - subject.venue = create(:venue) - subject.rooms = [] - subject.tracks = [] - subject.event_types = [] - subject.difficulty_levels = [] + start_date: subject.end_date - 14, + end_date: subject.end_date, conference: subject) + subject.program.cfp = create(:cfp) + subject.venue = create(:venue, conference: subject) + subject.venue.rooms = [] + subject.program.tracks = [] + subject.program.event_types = [] + subject.program.difficulty_levels = [] subject.splashpage = create(:splashpage, public: false) @result_false['cfp'] = true @@ -1039,15 +1038,15 @@ describe Conference do end it 'calculates correct for conference with registration, cfp, venue, rooms' do - subject.rooms = [create(:room)] subject.registration_period = create(:registration_period, start_date: Date.today, - end_date: Date.today + 14) - subject.call_for_paper = create(:call_for_paper) - subject.venue = create(:venue) - subject.tracks = [] - subject.event_types = [] - subject.difficulty_levels = [] + end_date: Date.today + 14, conference: subject) + subject.program.cfp = create(:cfp) + subject.venue = create(:venue, conference: subject) + subject.venue.rooms = [create(:room, venue: subject.venue)] + subject.program.tracks = [] + subject.program.event_types = [] + subject.program.difficulty_levels = [] subject.splashpage = create(:splashpage, public: false) @result_false['cfp'] = true @@ -1060,15 +1059,15 @@ describe Conference do end it 'calculates correct for conference with registration, cfp, venue, rooms, tracks' do - subject.rooms = [create(:room)] - subject.tracks = [create(:track)] + subject.venue = create(:venue, conference: subject) + subject.venue.rooms = [create(:room, venue: subject.venue)] + subject.program.tracks = [create(:track)] subject.registration_period = create(:registration_period, start_date: Date.today, - end_date: Date.today + 14) - subject.call_for_paper = create(:call_for_paper) - subject.venue = create(:venue) - subject.event_types = [] - subject.difficulty_levels = [] + end_date: Date.today + 14, conference: subject) + subject.program.cfp = create(:cfp) + subject.program.event_types = [] + subject.program.difficulty_levels = [] subject.splashpage = create(:splashpage, public: false) @result_false['cfp'] = true @@ -1083,15 +1082,15 @@ describe Conference do it 'calculates correct for conference with registration, cfp, venue, rooms, tracks, event_types' do - subject.rooms = [create(:room)] - subject.tracks = [create(:track)] - subject.event_types = [create(:event_type)] + subject.program.tracks = [create(:track)] + subject.program.event_types = [create(:event_type)] subject.registration_period = create(:registration_period, start_date: Date.today, - end_date: Date.today + 14) - subject.call_for_paper = create(:call_for_paper) - subject.venue = create(:venue) - subject.difficulty_levels = [] + end_date: Date.today + 14, conference: subject) + subject.program.cfp = create(:cfp) + subject.venue = create(:venue, conference: subject) + subject.venue.rooms = [create(:room, venue: subject.venue)] + subject.program.difficulty_levels = [] subject.splashpage = create(:splashpage, public: false) @result_false['cfp'] = true @@ -1106,16 +1105,15 @@ describe Conference do end it 'calculates correct for conference with all mandatory options' do - subject.rooms = [create(:room)] - subject.tracks = [create(:track)] - subject.event_types = [create(:event_type)] - subject.difficulty_levels = [create(:difficulty_level)] + subject.program.tracks = [create(:track)] + subject.program.event_types = [create(:event_type)] + subject.program.difficulty_levels = [create(:difficulty_level)] subject.registration_period = create(:registration_period, start_date: Date.today, - end_date: Date.today + 14) - subject.venue = create(:venue) - subject.call_for_paper = create(:call_for_paper) - subject.venue = create(:venue) + end_date: Date.today + 14, conference: subject) + subject.program.cfp = create(:cfp) + subject.venue = create(:venue, conference: subject) + subject.venue.rooms = [create(:room, venue: subject.venue)] subject.splashpage = create(:splashpage, public: true) expect(subject.get_status).to eq(@result) @@ -1134,21 +1132,21 @@ describe Conference do it 'is one if start and end are 6 days apart' do subject.registration_period = create(:registration_period, start_date: Date.new(2014, 05, 26), - end_date: Date.new(2014, 05, 26) + 6) + end_date: Date.new(2014, 05, 26) + 6, conference: subject) expect(subject.registration_weeks).to eq(1) end it 'is one if start and end date are the same' do subject.registration_period = create(:registration_period, start_date: Date.new(2014, 05, 26), - end_date: Date.new(2014, 05, 26)) + end_date: Date.new(2014, 05, 26), conference: subject) expect(subject.registration_weeks).to eq(1) end it 'is two if start and end are 10 days apart' do subject.registration_period = create(:registration_period, - start_date: Date.new(2014, 05, 26), - end_date: Date.new(2014, 05, 26) + 10) + start_date: Date.new(2014, 05, 17), + end_date: Date.new(2014, 05, 15) + 10, conference: subject) expect(subject.registration_weeks).to eq(2) end end @@ -1156,34 +1154,34 @@ describe Conference do describe '#cfp_weeks' do it 'calculates new year' do - cfp = create(:call_for_paper) + cfp = create(:cfp) cfp.start_date = Date.new(2013, 12, 30) cfp.end_date = Date.new(2013, 12, 30) + 6 - subject.call_for_paper = cfp + subject.program.cfp = cfp expect(subject.cfp_weeks).to eq(1) end it 'is one if start and end are 6 days apart' do - cfp = create(:call_for_paper) + cfp = create(:cfp) cfp.start_date = Date.new(2014, 05, 26) cfp.end_date = Date.new(2014, 05, 26) + 6 - subject.call_for_paper = cfp + subject.program.cfp = cfp expect(subject.cfp_weeks).to eq(1) end it 'is one if start and end are the same date' do - cfp = create(:call_for_paper) + cfp = create(:cfp) cfp.start_date = Date.new(2014, 05, 26) cfp.end_date = Date.new(2014, 05, 26) - subject.call_for_paper = cfp + subject.program.cfp = cfp expect(subject.cfp_weeks).to eq(1) end it 'is two if start and end are 10 days apart' do - cfp = create(:call_for_paper) + cfp = create(:cfp) cfp.start_date = Date.new(2014, 05, 26) cfp.end_date = Date.new(2014, 05, 26) + 10 - subject.call_for_paper = cfp + subject.program.cfp = cfp expect(subject.cfp_weeks).to eq(2) end end @@ -1191,88 +1189,88 @@ describe Conference do describe '#get_submissions_per_week' do it 'does calculate correct if cfp start date is altered' do - cfp = create(:call_for_paper) + cfp = create(:cfp) cfp.start_date = Date.new(2014, 05, 26) cfp.end_date = Date.new(2014, 05, 26) + 21 - subject.call_for_paper = cfp - subject.events += [create(:event, created_at: Date.new(2014, 05, 26) - 7)] + subject.program.cfp = cfp + subject.program.events += [create(:event, created_at: Date.new(2014, 05, 26) - 7)] expect(subject.get_submissions_per_week).to eq([1, 1, 1, 1, 1]) end it 'does calculate correct if cfp end date is altered' do - cfp = create(:call_for_paper) + cfp = create(:cfp) cfp.start_date = Date.new(2014, 05, 26) cfp.end_date = Date.new(2014, 05, 26) + 21 - subject.call_for_paper = cfp - subject.events += [create(:event, created_at: Date.new(2014, 05, 26) + 28)] + subject.program.cfp = cfp + subject.program.events += [create(:event, created_at: Date.new(2014, 05, 26) + 28)] expect(subject.get_submissions_per_week).to eq([0, 0, 0, 0, 1]) end it 'pads with zeros if there are no submissions' do - cfp = create(:call_for_paper) + cfp = create(:cfp) cfp.start_date = Date.new(2014, 05, 26) cfp.end_date = Date.new(2014, 05, 26) + 21 - subject.call_for_paper = cfp + subject.program.cfp = cfp expect(subject.get_submissions_per_week).to eq([0, 0, 0, 0]) end it 'summarized correct if there are no submissions in one week' do - cfp = create(:call_for_paper) + cfp = create(:cfp) cfp.start_date = Date.new(2014, 05, 26) cfp.end_date = Date.new(2014, 05, 26) + 28 - subject.call_for_paper = cfp - subject.events += [create(:event, created_at: Date.new(2014, 05, 26) + 7)] - subject.events += [create(:event, created_at: Date.new(2014, 05, 26) + 14)] - subject.events += [create(:event, created_at: Date.new(2014, 05, 26) + 28)] + subject.program.cfp = cfp + subject.program.events += [create(:event, created_at: Date.new(2014, 05, 26) + 7)] + subject.program.events += [create(:event, created_at: Date.new(2014, 05, 26) + 14)] + subject.program.events += [create(:event, created_at: Date.new(2014, 05, 26) + 28)] expect(subject.get_submissions_per_week).to eq([0, 1, 2, 2, 3]) end it 'summarized correct if there are submissions every week except the first' do - cfp = create(:call_for_paper) + cfp = create(:cfp) cfp.start_date = Date.new(2014, 05, 26) cfp.end_date = Date.new(2014, 05, 26) + 21 - subject.call_for_paper = cfp - subject.events += [create(:event, created_at: Date.new(2014, 05, 26) + 7)] - subject.events += [create(:event, created_at: Date.new(2014, 05, 26) + 14)] + subject.program.cfp = cfp + subject.program.events += [create(:event, created_at: Date.new(2014, 05, 26) + 7)] + subject.program.events += [create(:event, created_at: Date.new(2014, 05, 26) + 14)] expect(subject.get_submissions_per_week).to eq([0, 1, 2, 2]) end it 'summarized correct if there are submissions every week' do - cfp = create(:call_for_paper) + cfp = create(:cfp) cfp.start_date = Date.new(2014, 05, 26) cfp.end_date = Date.new(2014, 05, 26) + 21 - subject.call_for_paper = cfp - subject.events += [create(:event, created_at: Date.new(2014, 05, 26))] - subject.events += [create(:event, created_at: Date.new(2014, 05, 26) + 7)] - subject.events += [create(:event, created_at: Date.new(2014, 05, 26) + 14)] + subject.program.cfp = cfp + subject.program.events += [create(:event, created_at: Date.new(2014, 05, 26))] + subject.program.events += [create(:event, created_at: Date.new(2014, 05, 26) + 7)] + subject.program.events += [create(:event, created_at: Date.new(2014, 05, 26) + 14)] expect(subject.get_submissions_per_week).to eq([1, 2, 3, 3]) end it 'pads left' do - cfp = create(:call_for_paper) + cfp = create(:cfp) cfp.start_date = Date.new(2014, 05, 26) cfp.end_date = Date.new(2014, 05, 26) + 21 - subject.call_for_paper = cfp - subject.events += [create(:event, created_at: Date.new(2014, 05, 26) + 21)] + subject.program.cfp = cfp + subject.program.events += [create(:event, created_at: Date.new(2014, 05, 26) + 21)] expect(subject.get_submissions_per_week).to eq([0, 0, 0, 1]) end it 'pads middle' do - cfp = create(:call_for_paper) + cfp = create(:cfp) cfp.start_date = Date.new(2014, 05, 26) cfp.end_date = Date.new(2014, 05, 26) + 21 - subject.call_for_paper = cfp - subject.events += [create(:event, created_at: Date.new(2014, 05, 26))] - subject.events += [create(:event, created_at: Date.new(2014, 05, 26) + 21)] + subject.program.cfp = cfp + subject.program.events += [create(:event, created_at: Date.new(2014, 05, 26))] + subject.program.events += [create(:event, created_at: Date.new(2014, 05, 26) + 21)] expect(subject.get_submissions_per_week).to eq([1, 1, 1, 2]) end it 'pads right' do - cfp = create(:call_for_paper) + cfp = create(:cfp) cfp.start_date = Date.new(2014, 05, 26) cfp.end_date = Date.new(2014, 05, 26) + 21 - subject.call_for_paper = cfp - subject.events += [create(:event, created_at: Date.new(2014, 05, 26))] + subject.program.cfp = cfp + subject.program.events += [create(:event, created_at: Date.new(2014, 05, 26))] expect(subject.get_submissions_per_week).to eq([1, 1, 1, 1]) end end @@ -1282,7 +1280,7 @@ describe Conference do it 'pads with zeros if there are no registrations' do subject.registration_period = create(:registration_period, start_date: Date.new(2014, 05, 26), - end_date: Date.new(2014, 05, 26) + 21) + end_date: Date.new(2014, 05, 26) + 21, conference: subject) expect(subject.get_registrations_per_week).to eq([0, 0, 0, 0]) end @@ -1290,7 +1288,7 @@ describe Conference do it 'summarized correct if there are no registrations in one week' do subject.registration_period = create(:registration_period, start_date: Date.new(2014, 05, 26), - end_date: Date.new(2014, 05, 26) + 28) + end_date: Date.new(2014, 05, 26) + 28, conference: subject) create(:registration, conference: subject, created_at: Date.new(2014, 05, 26) + 7) @@ -1305,7 +1303,7 @@ describe Conference do it 'returns [1] if there is one registration on the first day' do subject.registration_period = create(:registration_period, start_date: Date.new(2014, 05, 26), - end_date: Date.new(2014, 05, 26) + 7) + end_date: Date.new(2014, 05, 26) + 7, conference: subject) create(:registration, conference: subject, created_at: Date.new(2014, 05, 26)) @@ -1315,7 +1313,7 @@ describe Conference do it 'summarized correct if there are registrations every week' do subject.registration_period = create(:registration_period, start_date: Date.new(2014, 05, 26), - end_date: Date.new(2014, 05, 26) + 21) + end_date: Date.new(2014, 05, 26) + 21, conference: subject) create(:registration, conference: subject, created_at: Date.new(2014, 05, 26)) create(:registration, conference: subject, @@ -1329,7 +1327,7 @@ describe Conference do it 'summarized correct if there are registrations every week except the first' do subject.registration_period = create(:registration_period, start_date: Date.new(2014, 05, 26), - end_date: Date.new(2014, 05, 26) + 28) + end_date: Date.new(2014, 05, 26) + 28, conference: subject) create(:registration, conference: subject, created_at: Date.new(2014, 05, 26) + 7) @@ -1344,7 +1342,7 @@ describe Conference do it 'pads left' do subject.registration_period = create(:registration_period, start_date: Date.new(2014, 05, 26), - end_date: Date.new(2014, 05, 26) + 35) + end_date: Date.new(2014, 05, 26) + 35, conference: subject) create(:registration, conference: subject, created_at: Date.new(2014, 05, 26) + 21) @@ -1359,7 +1357,7 @@ describe Conference do it 'pads middle' do subject.registration_period = create(:registration_period, start_date: Date.new(2014, 05, 26), - end_date: Date.new(2014, 05, 26) + 35) + end_date: Date.new(2014, 05, 26) + 35, conference: subject) create(:registration, conference: subject, created_at: Date.new(2014, 05, 26)) @@ -1372,7 +1370,7 @@ describe Conference do it 'pads right' do subject.registration_period = create(:registration_period, start_date: Date.new(2014, 05, 26), - end_date: Date.new(2014, 05, 26) + 35) + end_date: Date.new(2014, 05, 26) + 35, conference: subject) create(:registration, conference: subject, created_at: Date.new(2014, 05, 26)) @@ -1414,9 +1412,10 @@ describe Conference do context 'open registration' do before do + subject.end_date = Date.today + 7 enrollment = create(:registration_period, start_date: Date.today - 1, - end_date: Date.today + 7) + end_date: Date.today + 7, conference: subject) subject.registration_period = enrollment end @@ -1431,7 +1430,7 @@ describe Conference do context 'closed cfp' do it '#cfp_open? is false' do - expect(subject.cfp_open?).to be false + expect(subject.program.cfp_open?).to be false end end @@ -1439,11 +1438,11 @@ describe Conference do context 'open cfp' do before do - subject.call_for_paper = create(:call_for_paper) + subject.program.cfp = create(:cfp) end it '#registration_open? is true' do - expect(subject.cfp_open?).to be true + expect(subject.program.cfp_open?).to be true end end end @@ -1482,6 +1481,48 @@ describe Conference do end end + describe 'registration_limit_exceeded?' do + context 'limit less than 0' do + before do + subject.registration_limit = -1 + end + it '#registration_limit_exceeded? is false' do + expect(subject.registration_limit_exceeded?).to be false + end + end + + context 'limit is 0' do + before do + subject.registration_limit = 0 + end + it '#registration_limit_exceeded? is false' do + expect(subject.registration_limit_exceeded?).to be false + end + end + + context 'limit is 1' do + before do + subject.registration_limit = 1 + end + context 'there are no registration' do + it '#registration_limit_exceeded? is false' do + expect(subject.registration_limit_exceeded?).to be false + end + end + + context 'there are 1 registration' do + before do + registration1 = create(:registration) + subject.registrations << registration1 + end + + it '#registration_limit_exceeded? is true' do + expect(subject.registration_limit_exceeded?).to be true + end + end + end + end + describe 'validations' do it 'has a valid factory' do @@ -1516,6 +1557,14 @@ describe Conference do should_not allow_value('&%§!?äÄüÜ/()').for(:short_title) end + it 'is not valid with a registration limit as float' do + should_not allow_value(0.5).for(:registration_limit) + end + + it 'is not valid with a negative registration limit' do + should_not allow_value(-1).for(:registration_limit) + end + describe 'valid_date_range?' do it 'is not valid if start date is greater than end date' do diff --git a/spec/models/program_spec.rb b/spec/models/program_spec.rb new file mode 100644 index 00000000..3adad84e --- /dev/null +++ b/spec/models/program_spec.rb @@ -0,0 +1,61 @@ +require 'spec_helper' + +describe Program do + let!(:conference) { create(:conference, end_date: Date.today + 3) } + let!(:program) { conference.program } + + describe '#rating_enabled?' do + it 'returns true if proposals can be rated (program.rating > 0)' do + program.rating = 3 + expect(program.rating_enabled?).to be true + end + + it 'returns false if proposals cannot be rated (program.ratinig == 0) ' do + program = conference.program + program.rating = 3 + expect(program.rating_enabled?).to be true + end + end + + describe '#cfp_open?' do + describe 'returns true' do + it 'when there is an open Call for Papers for the conference' do + create(:cfp, start_date: Date.today - 2, end_date: Date.today, program_id: program.id) + expect(program.cfp_open?).to be true + end + end + + describe 'returns false' do + it 'when there is no Call for Papers for the conference' do + expect(program.cfp_open?).to be false + end + + it 'when the Call for Papers period is over' do + build(:cfp, start_date: Date.today - 2, end_date: Date.today - 1, program_id: program.id) + expect(program.cfp_open?).to be false + end + end + end + + describe 'excecutes before_create functions' do + it 'and creates events_types' do + program.destroy! + conference.reload + expect(conference.program).to eq nil + + create(:program, conference_id: conference.id) + conference.reload + expect(conference.program.event_types.count).to eq 2 + end + + it 'and creates difficulty_levels' do + program.destroy! + conference.reload + expect(conference.program).to eq nil + + create(:program, conference_id: conference.id) + conference.reload + expect(conference.program.difficulty_levels.count).to eq 3 + end + end +end diff --git a/spec/models/registration_period_spec.rb b/spec/models/registration_period_spec.rb new file mode 100644 index 00000000..ef28bab1 --- /dev/null +++ b/spec/models/registration_period_spec.rb @@ -0,0 +1,74 @@ +require 'spec_helper' + +describe RegistrationPeriod do + let!(:conference) { create(:conference, start_date: Date.today, end_date: Date.today + 6) } + let!(:registration_period) { create(:registration_period, start_date: Date.today - 2, end_date: Date.today - 1, conference: conference) } + + describe 'validations' do + it 'has a valid factory' do + expect(build(:registration_period)).to be_valid + end + + it 'is not valid without a start_date' do + should validate_presence_of(:start_date) + end + + it 'is not valid without an end_date' do + should validate_presence_of(:end_date) + end + end + + describe '#before_end_of_conference' do + context 'is valid' do + it 'when start_date and end_date are before conference end_date' do + registration_period.start_date = conference.end_date - 2 + registration_period.end_date = conference.end_date - 1 + expect(registration_period.valid?).to eq true + end + + it 'when start_date and end_date are the same day as conference end_date' do + registration_period.start_date = conference.end_date + registration_period.end_date = conference.end_date + expect(registration_period.valid?).to eq true + end + end + + context 'is invalid' do + it 'when start_date and end_date are after conference end_date' do + registration_period.start_date = conference.end_date + 1 + registration_period.end_date = conference.end_date + 2 + expect(registration_period.valid?).to eq false + end + + it 'when end_date is after conference end_date' do + registration_period.start_date = conference.end_date - 1 + registration_period.end_date = conference.end_date + 1 + expect(registration_period.valid?).to eq false + end + end + end + + describe '#start_date_before_end_date' do + context 'is valid' do + it 'when start_date is before end_date' do + registration_period.start_date = conference.end_date - 2 + registration_period.end_date = conference.end_date - 1 + expect(registration_period.valid?).to eq true + end + + it 'when start_date and end_date are on the same day' do + registration_period.start_date = conference.end_date - 2 + registration_period.end_date = conference.end_date - 2 + expect(registration_period.valid?).to eq true + end + end + + context 'is invalid' do + it 'when start_date is after end_date' do + registration_period.start_date = conference.start_date + 2 + registration_period.end_date = conference.start_date + 1 + expect(registration_period.valid?).to eq false + end + end + end +end diff --git a/spec/models/registration_spec.rb b/spec/models/registration_spec.rb new file mode 100644 index 00000000..1bf9e88f --- /dev/null +++ b/spec/models/registration_spec.rb @@ -0,0 +1,25 @@ +#!/bin/env ruby +# encoding: utf-8 +require 'spec_helper' + +describe 'Registration' do + describe 'validations' do + it 'has a valid factory' do + expect(build(:registration)).to be_valid + end + + describe 'registration_limit_not_exceed' do + it 'is not valid when limit exceeded' do + conference = build(:conference) + conference.registration_limit = 1 + registration1 = build(:registration, conference: conference) + registration1.save + registration2 = build(:registration, conference: conference) + registration2.save + expect(conference.registrations.size).to be 1 + expect(registration2.valid?).to be false + expect(registration2.errors.full_messages).to eq(['Registration limit exceeded']) + end + end + end +end diff --git a/spec/models/target_spec.rb b/spec/models/target_spec.rb index 53c46ae3..50a4103f 100644 --- a/spec/models/target_spec.rb +++ b/spec/models/target_spec.rb @@ -53,7 +53,7 @@ describe Target do end it 'returns zero if there are no submissions' do - conference = build(:conference) + conference = create(:conference) target = build(:target, target_count: 10, unit: Target.units[:submissions]) conference.targets = [target] @@ -66,13 +66,13 @@ describe Target do event = create(:event) conference.targets = [target] - conference.events = [event] + conference.program.events = [event] expect(target.get_progress).to eq('10') end it 'returns zero if there are no program minutes' do - conference = build(:conference) + conference = create(:conference) target = build(:target, target_count: 10, unit: Target.units[:program_minutes]) conference.targets = [target] @@ -85,7 +85,7 @@ describe Target do event = create(:event) conference.targets = [target] - conference.events = [event] + conference.program.events = [event] expect(target.get_progress).to eq('10') end diff --git a/spec/models/ticket_spec.rb b/spec/models/ticket_spec.rb index c093b072..2b673fbb 100644 --- a/spec/models/ticket_spec.rb +++ b/spec/models/ticket_spec.rb @@ -68,11 +68,11 @@ describe Ticket do user: user, ticket: ticket, quantity: 20) - expect(ticket.total_price(user)).to eq(20 * 50) + expect(ticket.total_price(user)).to eq(Money.new(20 * ticket.price_cents, 'USD')) end it 'returns zero if the user has not bought this ticket' do - expect(ticket.total_price(user)).to eq(0) + expect(ticket.total_price(user)).to eq(Money.new(0, 'USD')) end end @@ -82,11 +82,11 @@ describe Ticket do user: user, ticket: ticket, quantity: 20) - expect(Ticket.total_price(conference, user)).to eq(20 * 50) + expect(Ticket.total_price(conference, user)).to eq(Money.new(20 * ticket.price_cents, 'USD')) end it 'returns zero if the user has not bought this ticket' do - expect(Ticket.total_price(conference, user)).to eq(0) + expect(Ticket.total_price(conference, user)).to eq(Money.new(0, 'USD')) end end end diff --git a/spec/views/admin/cfps/show.html.haml_spec.rb b/spec/views/admin/cfps/show.html.haml_spec.rb new file mode 100644 index 00000000..f7821938 --- /dev/null +++ b/spec/views/admin/cfps/show.html.haml_spec.rb @@ -0,0 +1,17 @@ +require 'spec_helper' + +describe 'admin/cfps/show' do + + it 'renders call for papers details' do + conference = create(:conference) + assign :conference, conference + assign :program, conference.program + assign :cfp, create(:cfp, program: conference.program) + render + expect(rendered).to include('Start Date') + expect(rendered).to include('End Date') + expect(rendered).to include(1.day.ago.strftime('%A, %B %-d. %Y')) + expect(rendered).to include(6.days.from_now.strftime('%A, %B %-d. %Y')) + end + +end diff --git a/spec/views/admin/conference/show.html.haml_spec.rb b/spec/views/admin/conference/show.html.haml_spec.rb index 383af195..18a2efd3 100644 --- a/spec/views/admin/conference/show.html.haml_spec.rb +++ b/spec/views/admin/conference/show.html.haml_spec.rb @@ -5,6 +5,7 @@ describe 'admin/conference/show' do it 'renders conference dashboard' do conference = create(:conference, title: 'openSUSE') assign :conference, conference + assign :program, conference.program assign :conference_progress, conference.get_status render expect(rendered).to include("Dashboard for #{conference.title}") diff --git a/spec/views/admin/difficulty_levels/index.html.haml_spec.rb b/spec/views/admin/difficulty_levels/index.html.haml_spec.rb index 07dc6e04..6e7d469a 100644 --- a/spec/views/admin/difficulty_levels/index.html.haml_spec.rb +++ b/spec/views/admin/difficulty_levels/index.html.haml_spec.rb @@ -3,8 +3,9 @@ require 'spec_helper' describe 'admin/difficulty_levels/index' do it 'renders difficulty levels' do - @difficulty_level = create(:difficulty_level) - assign :conference, @difficulty_level.conference + conference = create(:conference) + @difficulty_level = create(:difficulty_level, program: conference.program) + assign :conference, conference render expect(rendered).to include('Example Difficulty Level') expect(rendered).to include('Lorem Ipsum dolsum') diff --git a/spec/views/admin/event_types/index.html.haml_spec.rb b/spec/views/admin/event_types/index.html.haml_spec.rb index 661f7156..dbfbc3b2 100644 --- a/spec/views/admin/event_types/index.html.haml_spec.rb +++ b/spec/views/admin/event_types/index.html.haml_spec.rb @@ -3,8 +3,9 @@ require 'spec_helper' describe 'admin/event_types/index' do it 'renders event types' do - @event_type = create(:event_type) - assign :conference, @event_type.conference + conference = create(:conference) + @event_type = create(:event_type, program: conference.program) + assign :conference, @event_type.program.conference render expect(rendered).to include('Example Event Type') expect(rendered).to include('30') diff --git a/spec/views/admin/events/index.html.haml_spec.rb b/spec/views/admin/events/index.html.haml_spec.rb index f9e06dad..07b9fd11 100644 --- a/spec/views/admin/events/index.html.haml_spec.rb +++ b/spec/views/admin/events/index.html.haml_spec.rb @@ -2,15 +2,17 @@ require 'spec_helper' describe 'admin/events/index' do let!(:conference) { create(:conference) } - let!(:event1) { create(:event, conference: conference, title: 'event1') } - let!(:event2) { create(:event, conference: conference, title: 'event2') } + let!(:program) { conference.program } + let!(:event1) { create(:event, program: conference.program, title: 'event1') } + let!(:event2) { create(:event, program: conference.program, title: 'event2') } it 'renders all conference events' do assign(:conference, conference) + assign(:program, conference.program) assign(:events, [ event1, event2 ]) - assign(:event_types, [ create(:event_type, conference: conference), create(:event_type, conference: conference) ]) - assign(:tracks, [ create(:track, conference: conference), create(:track, conference: conference) ]) - assign(:difficulty_levels, [ create(:difficulty_level, conference: conference), create(:difficulty_level, conference: conference) ]) + assign(:event_types, [ create(:event_type, program: conference.program), create(:event_type, program: conference.program) ]) + assign(:tracks, [ create(:track, program: conference.program), create(:track, program: conference.program) ]) + assign(:difficulty_levels, [ create(:difficulty_level, program: conference.program), create(:difficulty_level, program: conference.program) ]) render @@ -25,7 +27,7 @@ describe 'admin/events/index' do expect(rendered).to have_selector('table thead th:nth-of-type(9)', text: 'Difficulty') expect(rendered).to have_selector('table thead th:nth-of-type(10)', text: 'State') - expect(conference.events.count).to eq 2 + expect(conference.program.events.count).to eq 2 expect(rendered).to have_selector('table tr:nth-of-type(1) td:nth-of-type(1)', text: event1.id) expect(rendered).to have_selector('table tr:nth-of-type(1) td:nth-of-type(2)', text: 'event1') diff --git a/spec/views/admin/programs/show.html.haml_spec.rb b/spec/views/admin/programs/show.html.haml_spec.rb new file mode 100644 index 00000000..807d8c34 --- /dev/null +++ b/spec/views/admin/programs/show.html.haml_spec.rb @@ -0,0 +1,16 @@ +require 'spec_helper' + +describe 'admin/programs/show' do + + it 'renders call for papers details' do + conference = create(:conference) + assign :conference, conference + assign :program, conference.program + render + expect(rendered).to have_css('dt', text: 'Event types:') + expect(rendered).to have_css('dd', text: 'Talks and Workshops') + expect(rendered).to have_css('dt', text: 'Tracks:') + expect(rendered).to have_css('dt', text: 'Difficulty Levels:') + expect(rendered).to have_css('dd', text: 'Easy, Medium and Hard') + end +end diff --git a/spec/views/admin/rooms/index.html.haml_spec.rb b/spec/views/admin/rooms/index.html.haml_spec.rb index 71caf7f4..961c016b 100644 --- a/spec/views/admin/rooms/index.html.haml_spec.rb +++ b/spec/views/admin/rooms/index.html.haml_spec.rb @@ -1,9 +1,13 @@ require 'spec_helper' + describe 'admin/rooms/index' do it 'renders rooms list' do - @room = create(:room) - assign :conference, @room.conference + conference = create(:conference) + venue = create(:venue, conference: conference) + room = create(:room, name: 'Example Room', size: 4, venue: venue) + assign :conference, conference + assign :rooms, [room] render expect(rendered).to include('Example Room') expect(rendered).to include('4') diff --git a/spec/views/admin/tracks/index.html.haml_spec.rb b/spec/views/admin/tracks/index.html.haml_spec.rb index ae75a3a1..e90275ba 100644 --- a/spec/views/admin/tracks/index.html.haml_spec.rb +++ b/spec/views/admin/tracks/index.html.haml_spec.rb @@ -3,8 +3,10 @@ require 'spec_helper' describe 'admin/tracks/index' do it 'renders tracks' do - @track = create(:track) - assign :conference, @track.conference + conference = create(:conference) + create(:track, name: 'Example Track', description: 'Lorem Ipsum dolsum', color: '#ffffff', program: conference.program) + assign :tracks, conference.program.tracks + assign :conference, conference render expect(rendered).to include('Example Track') expect(rendered).to include('Lorem Ipsum dolsum') diff --git a/spec/views/conference/show.html.haml_spec.rb b/spec/views/conference/show.html.haml_spec.rb index 87219c90..31b1cdea 100644 --- a/spec/views/conference/show.html.haml_spec.rb +++ b/spec/views/conference/show.html.haml_spec.rb @@ -3,6 +3,7 @@ describe 'conference/show.html.haml' do before(:each) do allow(view).to receive(:date_string).and_return('January 17 - 21 2014') @conference = create(:conference, description: 'Lorem Ipsum') + @program = @conference.program @conference.splashpage = create(:splashpage, include_registrations: true, @@ -25,7 +26,7 @@ describe 'conference/show.html.haml' do start_date: Date.yesterday, end_date: Date.tomorrow) - @conference.call_for_paper = create(:call_for_paper, conference: @conference) + @conference.program.cfp = create(:cfp, program: @conference.program) @conference.sponsorship_levels << create(:sponsorship_level, conference: @conference) @sponsorship_level = @conference.sponsorship_levels.first From 598606547ee15444e55a64e3665660da263d481c Mon Sep 17 00:00:00 2001 From: Aditya Chatterjee Date: Tue, 1 Mar 2016 18:58:41 +0530 Subject: [PATCH 2/2] Flash uniformity done in a bunch of files --- app/controllers/application_controller.rb | 8 ++++---- app/controllers/commercials_controller.rb | 8 ++++---- .../conference_registrations_controller.rb | 16 +++++++-------- app/controllers/proposal_controller.rb | 20 ++++++++----------- app/controllers/registrations_controller.rb | 1 + app/controllers/subscriptions_controller.rb | 14 ++++++------- .../ticket_purchases_controller.rb | 2 ++ app/controllers/tickets_controller.rb | 2 ++ app/controllers/users_controller.rb | 5 +++-- 9 files changed, 37 insertions(+), 39 deletions(-) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index a0d87498..64f8299f 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -4,6 +4,8 @@ class ApplicationController < ActionController::Base before_filter :get_conferences before_filter :store_location helper_method :date_string + add_flash_types :error + add_flash_types :alert # Ensure every controller authorizes resource or skips authorization (skip_authorization_check) check_authorization unless: :devise_controller? @@ -52,16 +54,14 @@ class ApplicationController < ActionController::Base rescue_from IChainRecordNotFound do Rails.logger.debug('IChain Record was not Unique!') sign_out(current_user) - flash[:error] = 'Your E-Mail adress is already registered at OSEM. Please contact the admin if you want to attach your openSUSE Account to OSEM!' - redirect_to root_path + redirect_to root_path(@ user), error: "Your E-Mail adress is already registered at OSEM. Please contact the admin if you want to attach your openSUSE Account to OSEM!" end rescue_from UserDisabled do Rails.logger.debug('User is disabled!') sign_out(current_user) mail = User.admin.first ? User.admin.first.email : 'the admin!' - flash[:error] = "This User is disabled. Please contact #{mail}!" - redirect_to User.ichain_logout_url + redirect_to User.ichain_logout_url(@ user), error: "This User is disabled. Please contact #{mail}!" end def not_found diff --git a/app/controllers/commercials_controller.rb b/app/controllers/commercials_controller.rb index c36feedc..c0256de7 100644 --- a/app/controllers/commercials_controller.rb +++ b/app/controllers/commercials_controller.rb @@ -2,6 +2,8 @@ class CommercialsController < ApplicationController load_resource :conference, find_by: :short_title before_action :set_event load_and_authorize_resource through: :event + add_flash_types :error + add_flash_types :alert def create @commercial = @event.commercials.build(commercial_params) @@ -11,8 +13,7 @@ class CommercialsController < ApplicationController redirect_to edit_conference_program_proposal_path(conference_id: @conference.short_title, id: @event.id, anchor: 'commercials-content'), notice: 'Commercial was successfully created.' else - flash[:error] = "An error prohibited this Commercial from being saved: #{@commercial.errors.full_messages.join('. ')}." - redirect_to edit_conference_proposal_path(conference_id: @conference.short_title, id: @event.id, anchor: 'commercials-content') + redirect_to edit_conference_proposal_path(conference_id: @conference.short_title, id: @event.id, anchor: 'commercials-content'), error: "An error prohibited this Commercial from being saved: #{@commercial.errors.full_messages.join('. ')}." end end @@ -21,8 +22,7 @@ class CommercialsController < ApplicationController redirect_to edit_conference_program_proposal_path(conference_id: @conference.short_title, id: @event.id, anchor: 'commercials-content'), notice: 'Commercial was successfully updated.' else - flash[:error] = "An error prohibited this Commercial from being saved: #{@commercial.errors.full_messages.join('. ')}." - redirect_to edit_conference_proposal_path(conference_id: @conference.short_title, id: @event.id, anchor: 'commercials-content') + redirect_to edit_conference_proposal_path(conference_id: @conference.short_title, id: @event.id, anchor: 'commercials-content'), error: "An error prohibited this Commercial from being saved: #{@commercial.errors.full_messages.join('. ')}." end end diff --git a/app/controllers/conference_registrations_controller.rb b/app/controllers/conference_registrations_controller.rb index c9d7d216..926cac2a 100644 --- a/app/controllers/conference_registrations_controller.rb +++ b/app/controllers/conference_registrations_controller.rb @@ -3,6 +3,8 @@ class ConferenceRegistrationsController < ApplicationController load_resource :conference, find_by: :short_title authorize_resource :conference_registrations, class: Registration before_action :set_registration, only: [:edit, :update, :destroy, :show] + add_flash_types :error + add_flash_types :alert def new # Redirect to registration edit when user is already registered @@ -60,16 +62,14 @@ class ConferenceRegistrationsController < ApplicationController sign_in(@registration.user) end - flash[:notice] = 'You are now registered and will be receiving E-Mail notifications.' if @conference.tickets.any? && !current_user.supports?(@conference) - redirect_to conference_tickets_path(@conference.short_title) + redirect_to conference_tickets_path(@conference.short_title), notice: 'You are now registered and will be receiving E-Mail notifications.' else - redirect_to conference_conference_registrations_path(@conference.short_title) + redirect_to conference_conference_registrations_path(@conference.short_title), notice: 'You are now registered and will be receiving E-Mail notifications.' end else - flash[:error] = "Could not create your registration for #{@conference.title}: "\ + render :new, error: "Could not create your registration for #{@conference.title}: "\ "#{@registration.errors.full_messages.join('. ')}." - render :new end end @@ -78,9 +78,8 @@ class ConferenceRegistrationsController < ApplicationController redirect_to conference_conference_registrations_path(@conference.short_title), notice: 'Registration was successfully updated.' else - flash[:error] = "Could not update your registration for #{@conference.title}: "\ + render :edit, error: "Could not update your registration for #{@conference.title}: "\ "#{@registration.errors.full_messages.join('. ')}." - render :edit end end @@ -100,8 +99,7 @@ class ConferenceRegistrationsController < ApplicationController def set_registration @registration = Registration.find_by(conference: @conference, user: current_user) if !@registration - flash[:alert] = "Can't find a registration for #{@conference.title} for you. Please register." - redirect_to new_conference_conference_registrations_path(@conference.short_title) + redirect_to new_conference_conference_registrations_path(@conference.short_title), alert: "Can't find a registration for #{@conference.title} for you. Please register." end end diff --git a/app/controllers/proposal_controller.rb b/app/controllers/proposal_controller.rb index 95042af5..e56f5ce8 100644 --- a/app/controllers/proposal_controller.rb +++ b/app/controllers/proposal_controller.rb @@ -3,6 +3,8 @@ class ProposalController < ApplicationController load_resource :conference, find_by: :short_title load_resource :program, through: :conference, singleton: true load_and_authorize_resource :event, parent: false, through: :program + add_flash_types :error + add_flash_types :alert def index @events = current_user.proposals(@conference) @@ -31,8 +33,7 @@ class ProposalController < ApplicationController if @user.save sign_in(@user) else - flash[:error] = "Could not save user: #{@user.errors.full_messages.join(', ')}" - render action: 'new' + render action: 'new', error: "Could not save user: #{@user.errors.full_messages.join(', ')}" return end end @@ -48,15 +49,13 @@ class ProposalController < ApplicationController event_role: 'speaker') unless @event.save - flash[:error] = "Could not submit proposal: #{@event.errors.full_messages.join(', ')}" - render action: 'new' + render action: 'new', error: "Could not submit proposal: #{@event.errors.full_messages.join(', ')}" return end ahoy.track 'Event submission', title: 'New submission' - flash[:notice] = 'Proposal was successfully submitted.' - redirect_to conference_program_proposal_index_path(@conference.short_title) + redirect_to conference_program_proposal_index_path(@conference.short_title), notice: 'Proposal was successfully submitted.' end def update @@ -64,8 +63,7 @@ class ProposalController < ApplicationController @url = conference_program_proposal_path(@conference.short_title, params[:id]) if !@event.update(event_params) - flash[:error] = "Could not update proposal: #{@event.errors.full_messages.join(', ')}" - render action: 'new' + render action: 'new', error: "Could not update proposal: #{@event.errors.full_messages.join(', ')}" return end @@ -101,8 +99,7 @@ class ProposalController < ApplicationController end if !@event.save - flash[:error] = "Could not confirm proposal: #{@event.errors.full_messages.join(', ')}" - render action: 'new' + render action: 'new', error: "Could not confirm proposal: #{@event.errors.full_messages.join(', ')}" return end @@ -128,8 +125,7 @@ class ProposalController < ApplicationController end if !@event.save - flash[:error] = "Could not re-submit proposal: #{@event.errors.full_messages.join(', ')}" - render action: 'new' + render action: 'new', error: "Could not re-submit proposal: #{@event.errors.full_messages.join(', ')}" return end diff --git a/app/controllers/registrations_controller.rb b/app/controllers/registrations_controller.rb index 62292bf0..474fa2ec 100644 --- a/app/controllers/registrations_controller.rb +++ b/app/controllers/registrations_controller.rb @@ -1,5 +1,6 @@ class RegistrationsController < Devise::RegistrationsController before_action :configure_permitted_parameters, if: :devise_controller? + def edit @openids = Openid.where(user_id: current_user.id).order(:provider) diff --git a/app/controllers/subscriptions_controller.rb b/app/controllers/subscriptions_controller.rb index 6d5b7cdf..71821ba5 100644 --- a/app/controllers/subscriptions_controller.rb +++ b/app/controllers/subscriptions_controller.rb @@ -2,26 +2,24 @@ class SubscriptionsController < ApplicationController before_filter :authenticate_user! load_resource :conference, find_by: :short_title load_and_authorize_resource only: [:create, :destroy], through: :conference + add_flash_types :error + add_flash_types :alert def create @subscription = current_user.subscriptions.build(conference_id: @conference.id) if @subscription.save! - flash[:notice] = "You have been subscribed to receive email notifications for #{@conference.short_title}." - redirect_to root_path + redirect_to root_path, notice: "You have been subscribed to receive email notifications for #{@conference.short_title}." else - flash[:error] = subscription.errors.full_messages.to_sentence - redirect_to root_path + redirect_to root_path, error: subscription.errors.full_messages.to_sentence end end def destroy @subscription = current_user.subscriptions.find_by(conference_id: @conference.id) if @subscription.destroy - flash[:notice] = "You have been unsubscribed and now you will not be receiving email notifications for #{@conference.short_title}." - redirect_to root_path + redirect_to root_path, notice: "You have been unsubscribed and now you will not be receiving email notifications for #{@conference.short_title}." else - flash[:error] = @subscription.errors.full_messages.to_sentence - redirect_to root_path + redirect_to root_path, error: @subscription.errors.full_messages.to_sentence end end end diff --git a/app/controllers/ticket_purchases_controller.rb b/app/controllers/ticket_purchases_controller.rb index 395f09ce..947a9fe0 100644 --- a/app/controllers/ticket_purchases_controller.rb +++ b/app/controllers/ticket_purchases_controller.rb @@ -2,6 +2,8 @@ class TicketPurchasesController < ApplicationController before_filter :authenticate_user! load_resource :conference, find_by: :short_title authorize_resource :conference_registrations, class: Registration + add_flash_types :error + add_flash_types :alert def create message = TicketPurchase.purchase(@conference, current_user, params[:tickets][0]) diff --git a/app/controllers/tickets_controller.rb b/app/controllers/tickets_controller.rb index 55c73fc0..6cf917c1 100644 --- a/app/controllers/tickets_controller.rb +++ b/app/controllers/tickets_controller.rb @@ -4,6 +4,8 @@ class TicketsController < ApplicationController load_resource :ticket, through: :conference authorize_resource :conference_registrations, class: Registration before_filter :check_load_resource, only: :index + add_flash_types :error + add_flash_types :alert def index; end diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index a453c83f..291a6cfa 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -1,5 +1,7 @@ class UsersController < ApplicationController load_and_authorize_resource + add_flash_types :error + add_flash_types :alert # GET /users/1 def show @@ -15,8 +17,7 @@ class UsersController < ApplicationController if @user.update(user_params) redirect_to @user, notice: 'User was successfully updated.' else - flash[:error] = "An error prohibited your Profile from being saved: #{@user.errors.full_messages.join('. ')}." - render :edit + render :edit, error: "An error prohibited your Profile from being saved: #{@user.errors.full_messages.join('. ')}." end end