From 3b1cc84e387fdea7799fa11ff03695bdfef77d70 Mon Sep 17 00:00:00 2001 From: Katrin Marschner Date: Tue, 1 Oct 2019 00:36:22 +0200 Subject: [PATCH] Refactor admin panel - separate reports/statistics to own view - separate past events to own view - move tags under admin - sepate out events/applicatons logic for admin from regular controllers to admin controllers --- app/assets/javascripts/application.js | 1 - app/assets/javascripts/map-expander.js | 20 -- app/assets/stylesheets/admin.scss | 150 ++++++++++ app/assets/stylesheets/application.css.scss | 1 + app/assets/stylesheets/events.scss | 101 ------- app/assets/stylesheets/map.scss | 10 - .../admin/applications_controller.rb | 76 +++++ app/controllers/admin/events_controller.rb | 140 +++++++++ app/controllers/admin/tags_controller.rb | 34 +++ .../admin_applications_controller.rb | 64 ----- app/controllers/admin_events_controller.rb | 102 ------- app/controllers/application_controller.rb | 4 + app/controllers/applications_controller.rb | 2 +- app/controllers/events_controller.rb | 16 +- app/controllers/tags_controller.rb | 31 -- app/helpers/admin_events_helper.rb | 2 +- app/helpers/events_helper.rb | 5 - app/models/application.rb | 4 + app/models/event.rb | 8 +- app/services/create_categories_service.rb | 8 +- app/views/admin/_admin_navigation.html.erb | 9 + app/views/admin/applications/show.html.erb | 45 +++ app/views/admin/events/_event_row.html.erb | 54 ++++ app/views/admin/events/edit.html.erb | 19 ++ app/views/admin/events/index.html.erb | 62 ++++ app/views/admin/events/past.html.erb | 33 +++ app/views/admin/events/reports.html.erb | 46 +++ .../events}/show.html.erb | 56 ++-- app/views/{ => admin}/tags/index.html.erb | 16 +- app/views/admin_applications/show.html.erb | 61 ---- app/views/admin_events/_statistics.html.erb | 36 --- app/views/admin_events/index.html.erb | 134 --------- .../passed_event_deadline.text.erb | 2 +- .../admin_mailer/submitted_event.text.erb | 2 +- .../upcoming_event_deadline.text.erb | 2 +- .../_application_details.html.erb | 29 ++ app/views/applications/show.html.erb | 70 +---- app/views/events/edit.html.erb | 2 - app/views/events/show.html.erb | 3 +- app/views/layouts/_header.html.erb | 1 - app/views/shared/_breadcrumbs.html.erb | 81 +++--- config/locales/en.yml | 76 ----- config/locales/es.yml | 75 ----- config/locales/fr.yml | 75 ----- config/routes.rb | 66 +++-- .../admin/applications_controller_test.rb | 93 ++++++ .../admin/events_controller_test.rb | 272 ++++++++++++++++++ .../controllers/admin/tags_controller_test.rb | 85 ++++++ .../admin_applications_controller_test.rb | 21 -- .../admin_events_controller_test.rb | 177 ------------ .../applications_controller_test.rb | 147 +++++----- test/controllers/events_controller_test.rb | 65 +---- test/controllers/tags_controller_test.rb | 83 ------ test/integration/admin_event_details_test.rb | 10 +- test/integration/admin_events_test.rb | 4 +- test/integration/application_page_test.rb | 41 +-- 56 files changed, 1390 insertions(+), 1442 deletions(-) delete mode 100644 app/assets/javascripts/map-expander.js create mode 100644 app/assets/stylesheets/admin.scss create mode 100644 app/controllers/admin/applications_controller.rb create mode 100644 app/controllers/admin/events_controller.rb create mode 100644 app/controllers/admin/tags_controller.rb delete mode 100644 app/controllers/admin_applications_controller.rb delete mode 100644 app/controllers/admin_events_controller.rb delete mode 100644 app/controllers/tags_controller.rb create mode 100644 app/views/admin/_admin_navigation.html.erb create mode 100644 app/views/admin/applications/show.html.erb create mode 100644 app/views/admin/events/_event_row.html.erb create mode 100644 app/views/admin/events/edit.html.erb create mode 100644 app/views/admin/events/index.html.erb create mode 100644 app/views/admin/events/past.html.erb create mode 100644 app/views/admin/events/reports.html.erb rename app/views/{admin_events => admin/events}/show.html.erb (56%) rename app/views/{ => admin}/tags/index.html.erb (58%) delete mode 100644 app/views/admin_applications/show.html.erb delete mode 100644 app/views/admin_events/_statistics.html.erb delete mode 100644 app/views/admin_events/index.html.erb create mode 100644 app/views/applications/_application_details.html.erb create mode 100644 test/controllers/admin/applications_controller_test.rb create mode 100644 test/controllers/admin/events_controller_test.rb create mode 100644 test/controllers/admin/tags_controller_test.rb delete mode 100644 test/controllers/admin_applications_controller_test.rb delete mode 100644 test/controllers/admin_events_controller_test.rb delete mode 100644 test/controllers/tags_controller_test.rb diff --git a/app/assets/javascripts/application.js b/app/assets/javascripts/application.js index 44603f00..10a9057f 100644 --- a/app/assets/javascripts/application.js +++ b/app/assets/javascripts/application.js @@ -26,7 +26,6 @@ //= require events.js //= require markdown.js //= require marked.min.js -//= require map-expander.js //= require datepicker.js //= require filter-dropdown.js //= require top_menu.js diff --git a/app/assets/javascripts/map-expander.js b/app/assets/javascripts/map-expander.js deleted file mode 100644 index 8c8517d1..00000000 --- a/app/assets/javascripts/map-expander.js +++ /dev/null @@ -1,20 +0,0 @@ -$(document).ready(function(){ - $(".map-statistics-content").hide(); - $( "#map-expander-btn" ).click(function() { - $(".icon-sort-down-black").toggleClass("rotated"); - $(".map-statistics-content").toggle(); - }); - - //makes menu disappear when you click somewhere else on the page: - $(document).click(function() { - if ($(".map-statistics-content").is( ":visible" )) { - if ($(event.target).is('#map-statistics *')) { - return; - } - else { - $(".icon-sort-down-black").toggleClass("rotated"); - $(".map-statistics-content").toggle(); - } - } - }); -}); diff --git a/app/assets/stylesheets/admin.scss b/app/assets/stylesheets/admin.scss new file mode 100644 index 00000000..0ebfc7f7 --- /dev/null +++ b/app/assets/stylesheets/admin.scss @@ -0,0 +1,150 @@ +.secondary-navigation { + display: flex; + background-color: lighten($grey-mid, 20%); + padding: 0 10px; + height: 55px; + margin-bottom: 25px; + border-radius: 2px; + + ul { + list-style: none; + margin: 0; + padding: 0px 0px 0px 30px; + font-size: 15px; + display: flex; + flex-grow: 1; + justify-content: end; + } + + li { + margin-right: 1.3em; + line-height: $topbar-height; + } + + a { + display: inline-block; + text-decoration: none; + border-bottom: 1px solid transparent; + color: $black; + } + + a:hover, + .active { + background-color: inherit; + color: $green; + padding-bottom: 1px; + border: none; + &:after { + content: ""; + display: block; + height: 1px; + margin-top: -1px; + background-color: $green; + } + } + + p { + font-weight: 600; + } +} + +.approve-button { + input[type="checkbox"] { + margin-left: 10px; + } +} + +.admin-list, +.tags-list { + list-style: none; + padding: 0; + + li { + margin-bottom: 1em; + border-bottom: 3px solid #f1f1f1; + @media (min-width: $medium) { + display: flex; + flex-flow: row wrap; + justify-content: space-between; + border-bottom: none; + margin-bottom: 0; + } + } + .application-name { + flex: 0 0 40%; + white-space: nowrap; + overflow: hidden; + margin-right: 1em; + } + .application-mail { + flex-basis: 40%; + overflow: hidden; + margin-right: 1em; + flex-grow: 1; + } + p { + margin: 0 0 1em; + } + .admin-buttons>form { + display:inline; + } + .event-name { + flex-basis: 15em; + white-space: nowrap; + overflow: hidden; + } + .application-process { + flex-basis: 12em; + } + .application-deadline { + flex-basis: 11em; + } +} + +.organizer-list, +.applicant-list { + list-style: none; + padding: 0; + + li { + margin-bottom: 1em; + border-bottom: 3px solid #f1f1f1; + display: flex; + flex-flow: row wrap; + justify-content: space-between; + border-bottom: none; + margin-bottom: 0; + p:not(:last-child) { + margin-right: 1em; + } + } + p { + margin: 0 0 1em; + } + .event-name { + flex-grow: 1; + white-space: nowrap; + overflow: hidden; + } +} + +ul.tags { + padding-left: 0; + + li.tag { + list-style: none; + padding: 0.2em 0.5em; + border-radius: 3px; + display: inline-block; + margin: 0 0 0.5em; + &.programming-languages { + background-color: lighten($blue-bg, 30%); + } + &.languages { + background-color: lighten($green-bg, 20%); + } + &.fields-of-expertise { + background-color: lighten($yellow, 20%); + } + } +} diff --git a/app/assets/stylesheets/application.css.scss b/app/assets/stylesheets/application.css.scss index 4eb12b06..c810e475 100644 --- a/app/assets/stylesheets/application.css.scss +++ b/app/assets/stylesheets/application.css.scss @@ -52,6 +52,7 @@ $topbar-height: 55px; @import "login.scss"; @import "map.scss"; @import "searchbar.scss"; +@import "admin.scss"; *, *:before, *:after { box-sizing: border-box; diff --git a/app/assets/stylesheets/events.scss b/app/assets/stylesheets/events.scss index b20ab4f2..1d53331f 100644 --- a/app/assets/stylesheets/events.scss +++ b/app/assets/stylesheets/events.scss @@ -38,104 +38,3 @@ font-weight: 600; } } - -.approve-button { - input[type="checkbox"] { - margin-left: 10px; - } -} - -.admin-list, -.tags-list { - list-style: none; - padding: 0; - - li { - margin-bottom: 1em; - border-bottom: 3px solid #f1f1f1; - @media (min-width: $medium) { - display: flex; - flex-flow: row wrap; - justify-content: space-between; - border-bottom: none; - margin-bottom: 0; - } - } - .application-name { - flex: 0 0 40%; - white-space: nowrap; - overflow: hidden; - margin-right: 1em; - } - .application-mail { - flex-basis: 40%; - overflow: hidden; - margin-right: 1em; - flex-grow: 1; - } - p { - margin: 0 0 1em; - } - .admin-buttons { - display: inline-block; - } - .event-name { - flex-basis: 15em; - white-space: nowrap; - overflow: hidden; - } - .application-process { - flex-basis: 12em; - } - .application-deadline { - flex-basis: 11em; - } -} - -.organizer-list, -.applicant-list { - list-style: none; - padding: 0; - - li { - margin-bottom: 1em; - border-bottom: 3px solid #f1f1f1; - display: flex; - flex-flow: row wrap; - justify-content: space-between; - border-bottom: none; - margin-bottom: 0; - p:not(:last-child) { - margin-right: 1em; - } - } - p { - margin: 0 0 1em; - } - .event-name { - flex-grow: 1; - white-space: nowrap; - overflow: hidden; - } -} - -ul.tags { - padding-left: 0; - - li.tag { - list-style: none; - padding: 0.2em 0.5em; - border-radius: 3px; - display: inline-block; - margin: 0 0 0.5em; - &.programming-languages { - background-color: lighten($blue-bg, 30%); - } - &.languages { - background-color: lighten($green-bg, 20%); - } - &.fields-of-expertise { - background-color: lighten($yellow, 20%); - } - } -} diff --git a/app/assets/stylesheets/map.scss b/app/assets/stylesheets/map.scss index b95d67e0..997dd7d6 100644 --- a/app/assets/stylesheets/map.scss +++ b/app/assets/stylesheets/map.scss @@ -33,14 +33,4 @@ div.map-statistics { } } } - .map-expander-btn { - &:active, &:hover { - color: $green; - cursor: pointer; - } - .rotated { - transform: rotate(180deg); - background-position: 12px 2px; - } - } } diff --git a/app/controllers/admin/applications_controller.rb b/app/controllers/admin/applications_controller.rb new file mode 100644 index 00000000..ca9a1c2f --- /dev/null +++ b/app/controllers/admin/applications_controller.rb @@ -0,0 +1,76 @@ +#This controller manages the selection process of applications for a specific event (if selection +#process is being handled by this app), only accessable for admins. +module Admin + class ApplicationsController < ApplicationController + before_action :require_admin + before_action :set_locale_to_english + before_action :get_application + before_action :skip_validation, except: [:destroy] + + def show + if @application.event.deleted? + redirect_to( + admin_path, + notice: "You cannot view your application as the event you applied for has been removed "\ + "from Diversity Tickets" + ) + elsif @application.draft? + redirect_to admin_event_path(@application.event), notice: "You cannot view a draft." + end + end + + # to approve an application + def approve + get_event + @application.update_attributes(status: 'approved') + add_to_approved_tickets_count + redirect_to admin_event_path(@application.event_id), + notice: "#{ @application.name}'s application has been approved" + end + + # to reject an application + def reject + @application.update_attributes(status: 'rejected') + redirect_to admin_event_path(@application.event_id), + flash: { info: "#{ @application.name}'s application has been rejected" } + end + + # to set an application back to pending + def revert + remove_from_approved_tickets_count + @application.update_attributes(status: 'pending') + redirect_to admin_event_path(@application.event_id), + flash: { info: "#{ @application.name}'s application has been changed to pending" } + end + + def destroy + @application.destroy + redirect_to admin_event_path(@event.id) + end + + private + + def get_application + get_event + @application = @event.applications.find(params[:id]) + end + + def get_event + @event = Event.find(params[:event_id]) + end + + def skip_validation + @application.skip_validation = true + end + + def add_to_approved_tickets_count + @event.update_attributes(approved_tickets: @event.approved_tickets + 1) + end + + def remove_from_approved_tickets_count + if @application.status == 'approved' + @event.update_attributes(approved_tickets: @event.approved_tickets - 1) + end + end + end +end diff --git a/app/controllers/admin/events_controller.rb b/app/controllers/admin/events_controller.rb new file mode 100644 index 00000000..54049455 --- /dev/null +++ b/app/controllers/admin/events_controller.rb @@ -0,0 +1,140 @@ +require "report_exporter" + +module Admin + class EventsController < ApplicationController + before_action :require_admin + before_action :set_locale_to_english + before_action :get_event, only: [:show, :edit, :update, :approve, :destroy] + before_action :set_s3_direct_post, only: [:edit, :update] + before_action :set_approved_tickets_count, only: [:show] + + # Admin page view with all future events + def index + @application_process_options_handler = ApplicationProcessOptionsHandler.find(1) + @unapproved_events = Event.unapproved.upcoming.order(:deadline) + @approved_open_events = Event.approved.upcoming.open.order(:deadline) + @approved_closed_events = Event.approved.upcoming.closed.order(:deadline) + + respond_to do |format| + format.html + format.csv { send_data ReportExporter.events_report, filename: "events_report_#{DateTime.now.strftime("%F")}.csv" } + end + end + + # Admin page view with all past events + def past + @approved_events = Event.approved.past.order(deadline: :desc).active + @unapproved_events = Event.unapproved.past.order(:deadline).active + end + + def reports + @events = Event.all + @new_users = User.created_last_30_days + @total_organizers = Event.total_organizers + @countries = Event.pluck(:country).compact + @countries_statistics = CountriesStatistics.new(@events).to_json + @country_rank = CountriesStatistics.new(@events).country_rank + end + + # Events from current year + def annual + respond_to do |format| + format.csv { send_data ReportExporter.annual_events_report, filename: "anual_events_report_#{DateTime.now.strftime("%F")}.csv" } + end + end + + #Event show view for admins (events/:id/admin)- shows event details, an overview over the status of + #applications (if selection is handled by Travis) and allows selection process for applications as well as csv-download + def show + @categorized_applications = { + "Pending applications" => @event.applications.submitted.pending, + "Approved applications" => @event.applications.approved, + "Rejected applications" => @event.applications.rejected + } + + respond_to do |format| + format.html + format.csv { send_data @event.to_csv, filename: "#{@event.name} #{DateTime.now.strftime("%F")}.csv" } + end + end + + def edit + end + + def update + if @event.update(event_params) + redirect_to admin_event_path, notice: "You have successfully updated #{@event.name}" + else + render :edit + end + end + + #to approve/unapprove an event: + def approve + @event.toggle(:approved) + @event.save! + if @event.approved? + tweet_event_check + inform_applicants_country + inform_applicants_field_of_interest + redirect_to admin_path, notice: "#{@event.name} has been approved" + else + redirect_to admin_path, notice: "#{@event.name} has been unapproved" + end + end + + def destroy + @event.destroy + redirect_to admin_path + end + + private + + def get_event + @event = Event.find(params[:id]) + end + + def event_params + params.require(:event).permit permitted_params_for_admins + end + + def permitted_params_for_admins + [ + :organizer_name, :organizer_email, :organizer_email_confirmation, + :description, :name, :logo, :start_date, :end_date, :ticket_funded, + :accommodation_funded, :travel_funded, :deadline, :number_of_tickets, + :website, :code_of_conduct, :city, :country, :applicant_directions, + :data_protection_confirmation, :application_link, :application_process, + :twitter_handle, :state_province, :approved_tickets, :locale, :approved, + { :tag_ids => [] }, tags_attributes: [:id, :name, :category_id] + ] + end + + def set_s3_direct_post + @s3_direct_post = S3_BUCKET.presigned_post(key: "uploads/#{SecureRandom.uuid}/${filename}", success_action_status: '201', acl: 'public-read') + end + + def inform_applicants_country + User.where(country: @event.country).where(country_email_notifications: true).each do |user| + UserNotificationsMailer.new_local_event(@event, user).deliver_later + end + end + + def inform_applicants_field_of_interest + @event.interested_users.where(tag_email_notifications: true).each do |user| + UserNotificationsMailer.new_field_specific_event(@event, user).deliver_later + end + end + + def tweet_event_check + Tweet.create(event_id: @event.id, published: false) if params[:approve][:tweet] == "0" + end + + def set_approved_tickets_count + if @event.approved_tickets == 0 + approved_tickets = Application.where(event_id: @event.id, status: 'approved').count + @event.update_attributes(approved_tickets: approved_tickets) + end + end + end +end diff --git a/app/controllers/admin/tags_controller.rb b/app/controllers/admin/tags_controller.rb new file mode 100644 index 00000000..65f74392 --- /dev/null +++ b/app/controllers/admin/tags_controller.rb @@ -0,0 +1,34 @@ +#Handles Tag management - Event organizers can choose from a pool of existing tags +#and add them to their event. Only Admins can access the tags_index_view to add/delete/modify tags. +module Admin + class TagsController < ApplicationController + before_action :require_admin + before_action :set_locale_to_english + + def index + @tags = Tag.includes(:category).order(:name).group_by(&:category) + end + + def create + @tag = Tag.new(tag_params) + + if @tag.save + flash[:notice] = "Tag #{@tag.name} was successfully created." + else + flash[:alert] = "There was a problem creating the new tag." + end + redirect_to admin_tags_path + end + + def destroy + @tag = Tag.find(params[:id]) + @tag.destroy + redirect_to admin_tags_path + end + + private + def tag_params + params.require(:tag).permit(:name, :category_id, :locale) + end + end +end diff --git a/app/controllers/admin_applications_controller.rb b/app/controllers/admin_applications_controller.rb deleted file mode 100644 index d6c844ed..00000000 --- a/app/controllers/admin_applications_controller.rb +++ /dev/null @@ -1,64 +0,0 @@ -#This controller manages the selection process of applications for a specific event (if selection -#process is being handled by Tavis), only accessable for admins. -class AdminApplicationsController < ApplicationController - before_action :require_admin - before_action :get_application - before_action :skip_validation, except: [:destroy] - - def show - end - - #(events/:event_id/applications/:id/approve) - to approve an application as admin - def approve - get_event - @application.update_attributes(status: 'approved') - add_to_approved_tickets_count - redirect_to admin_event_path(@application.event_id), - notice: t('.application_approved', applicant_name: @application.name) - end - - #(events/:event_id/applications/:id/reject) - to reject an application as admin - def reject - @application.update_attributes(status: 'rejected') - redirect_to admin_event_path(@application.event_id), - flash: { info: t('.application_rejected', applicant_name: @application.name) } - end - - #(events/:event_id/applications/:id/revert) - to set an application back to pending as admin - def revert - remove_from_approved_tickets_count - @application.update_attributes(status: 'pending') - redirect_to admin_event_path(@application.event_id), - flash: { info: t('.application_pending', applicant_name: @application.name) } - end - - def destroy - @application.destroy - redirect_to event_admin_path(@event.id) - end - - private - - def get_application - get_event - @application = @event.applications.find(params[:id]) - end - - def get_event - @event = Event.find(params[:event_id]) - end - - def skip_validation - @application.skip_validation = true - end - - def add_to_approved_tickets_count - @event.update_attributes(approved_tickets: @event.approved_tickets + 1) - end - - def remove_from_approved_tickets_count - if @application.status == 'approved' - @event.update_attributes(approved_tickets: @event.approved_tickets - 1) - end - end -end diff --git a/app/controllers/admin_events_controller.rb b/app/controllers/admin_events_controller.rb deleted file mode 100644 index 9629aea4..00000000 --- a/app/controllers/admin_events_controller.rb +++ /dev/null @@ -1,102 +0,0 @@ -require "report_exporter" - -class AdminEventsController < ApplicationController - before_action :get_event, except: [:index, :annual_events_report] - before_action :require_admin - before_action :set_approved_tickets_count, only: [:show] - - #Admin page view with all submitted events and admin statistics: - def index - @application_process_options_handler = ApplicationProcessOptionsHandler.find(1) - @events = Event.all - @new_users = User.all.created_last_30_days - @total_organizers = Event.all.total_organizers - @countries = Event.all.pluck(:country).compact - @countries_statistics = CountriesStatistics.new(@events).to_json - @country_rank = CountriesStatistics.new(@events).country_rank - @categorized_events = { - "Unapproved events" => Event.unapproved.upcoming.order(:deadline), - "Approved events" => Event.approved.upcoming.order(:deadline), - "Past approved events"=> Event.approved.past.order(deadline: :desc).active, - "Past unapproved events" => Event.unapproved.past.order(:deadline).active - } - @approved_events_deadline = { - "Open deadline:" => Event.approved.upcoming.open.order(:deadline), - "Closed deadline:" => Event.approved.upcoming.closed.order(:deadline) - } - - respond_to do |format| - format.html - format.csv { send_data ReportExporter.events_report, filename: "events_report_#{DateTime.now.strftime("%F")}.csv" } - end - end - - def annual_events_report - respond_to do |format| - format.csv { send_data ReportExporter.annual_events_report, filename: "anual_events_report_#{DateTime.now.strftime("%F")}.csv" } - end - end - - #Event show view for admins (events/:id/admin)- shows event details, an overview over the status of - #applications (if selection is handled by Travis) and allows selection process for applications as well as csv-download - def show - @categorized_applications = { - "Pending applications" => @event.applications.submitted.pending, - "Approved applications" => @event.applications.approved, - "Rejected applications" => @event.applications.rejected - } - - respond_to do |format| - format.html - format.csv { send_data @event.to_csv, filename: "#{@event.name} #{DateTime.now.strftime("%F")}.csv" } - end - end - - #to approve/unapprove an event: - def approve - @event.toggle(:approved) - @event.save! - if @event.approved? - tweet_event_check - inform_applicants_country - inform_applicants_field_of_interest - redirect_to admin_url, notice: t('.event_approved', event_name: @event.name) - else - redirect_to admin_url, notice: t('.event_unapproved', event_name: @event.name) - end - end - - def destroy - @event.destroy - redirect_to admin_url - end - - private - - def get_event - @event = Event.find(params[:id]) - end - - def inform_applicants_country - User.where(country: @event.country).where(country_email_notifications: true).each do |user| - UserNotificationsMailer.new_local_event(@event, user).deliver_later - end - end - - def inform_applicants_field_of_interest - @event.interested_users.where(tag_email_notifications: true).each do |user| - UserNotificationsMailer.new_field_specific_event(@event, user).deliver_later - end - end - - def tweet_event_check - Tweet.create(event_id: @event.id, published: false) if params[:approve][:tweet] == "0" - end - - def set_approved_tickets_count - if @event.approved_tickets == 0 - approved_tickets = Application.where(event_id: @event.id, status: 'approved').count - @event.update_attributes(approved_tickets: approved_tickets) - end - end -end diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 515c4c0e..063beb85 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -15,6 +15,10 @@ def set_locale I18n.locale = params[:locale] || :en end + def set_locale_to_english + I18n.locale = :en + end + def require_admin redirect_to root_path unless admin_user? end diff --git a/app/controllers/applications_controller.rb b/app/controllers/applications_controller.rb index 3beff30f..bb296545 100644 --- a/app/controllers/applications_controller.rb +++ b/app/controllers/applications_controller.rb @@ -100,7 +100,7 @@ def get_event def ensure_correct_user @applicant = User.find_by(id: @application.applicant_id) - unless @applicant == current_user || (admin_user? && @application.submitted) + unless @applicant == current_user redirect_to root_path end end diff --git a/app/controllers/events_controller.rb b/app/controllers/events_controller.rb index a839e619..55b7d54f 100644 --- a/app/controllers/events_controller.rb +++ b/app/controllers/events_controller.rb @@ -50,7 +50,7 @@ def create AdminMailer.submitted_event(@event, user.email).deliver_later end OrganizerMailer.submitted_event(@event).deliver_later - redirect_to events_url, notice: t('.thank_you', event_name: @event.name) + redirect_to events_path, notice: t('.thank_you', event_name: @event.name) else render :new end @@ -91,23 +91,9 @@ def get_event end def event_params - if current_user.admin? - admin_event_params - else - organizer_event_params - end - end - - def organizer_event_params params.require(:event).permit permitted_params_for_event_organizers end - def admin_event_params - params.require(:event).permit( - permitted_params_for_event_organizers + [:approved] - ) - end - def permitted_params_for_event_organizers [ :organizer_name, :organizer_email, :organizer_email_confirmation, diff --git a/app/controllers/tags_controller.rb b/app/controllers/tags_controller.rb deleted file mode 100644 index 41c1af65..00000000 --- a/app/controllers/tags_controller.rb +++ /dev/null @@ -1,31 +0,0 @@ -#Handles Tag management - Event organizers can choose from a pool of existing tags -#and add them to their event. Only Admins can access the tags_index_view to add/delete/modify tags. -class TagsController < ApplicationController - before_action :require_admin - - def index - @tags = Tag.includes(:category).order(:name).group_by(&:category) - end - - def create - @tag = Tag.new(tag_params) - - if @tag.save - flash[:notice] = t('.tag_created', tag_name: @tag.name) - else - flash[:alert] = t('.tag_problem') - end - redirect_to tags_path - end - - def destroy - @tag = Tag.find(params[:id]) - @tag.destroy - redirect_to tags_path - end - - private - def tag_params - params.require(:tag).permit(:name, :category_id, :locale) - end -end diff --git a/app/helpers/admin_events_helper.rb b/app/helpers/admin_events_helper.rb index a1e35bf2..1b1abfa5 100644 --- a/app/helpers/admin_events_helper.rb +++ b/app/helpers/admin_events_helper.rb @@ -1,5 +1,5 @@ module AdminEventsHelper def download_csv_link(event) - link_to t('.download_csv'), event_admin_path(id: event.id, format: :csv), class: "btn btn-save", title: t('.download_data') + link_to t('.download_csv'), admin_event_path(id: event.id, format: :csv), class: "btn btn-save", title: t('.download_data') end end diff --git a/app/helpers/events_helper.rb b/app/helpers/events_helper.rb index 0d78120b..9dedc75e 100644 --- a/app/helpers/events_helper.rb +++ b/app/helpers/events_helper.rb @@ -1,5 +1,4 @@ module EventsHelper - def event_image(event) if event.logo && event.logo != '' image_tag event.logo, skip_pipeline: true @@ -9,15 +8,11 @@ def event_image(event) end #Used in events/edit and events/show: - def breadcrumb_locals_according_to_user_status if current_user && @event.organizer_id == current_user.id { your_events: t('.your_events') } - elsif current_user && current_user.admin? - { admin: t('.admin_link') } else { events: t('.events_link') } end end - end diff --git a/app/models/application.rb b/app/models/application.rb index c7cb978f..7d457b69 100644 --- a/app/models/application.rb +++ b/app/models/application.rb @@ -31,4 +31,8 @@ def self.rejected def self.active where(deleted: false) end + + def draft? + !submitted + end end diff --git a/app/models/event.rb b/app/models/event.rb index 4994fb8c..0942c24b 100644 --- a/app/models/event.rb +++ b/app/models/event.rb @@ -84,6 +84,10 @@ def past? end_date < Time.now end + def deleted? + deleted + end + def location [city, state_province, country].reject(&:blank?).join(", ") end @@ -110,7 +114,7 @@ def owned_by?(user) end def editable_by?(user) - user.admin? || (owned_by?(user) && open?) + owned_by?(user) && open? end def uneditable_by?(user) @@ -118,7 +122,7 @@ def uneditable_by?(user) end def deletable_by?(user) - user.admin? || owned_by?(user) + owned_by?(user) end def self.country_with_most_events(country_rank) diff --git a/app/services/create_categories_service.rb b/app/services/create_categories_service.rb index 379a6e65..dce6873e 100644 --- a/app/services/create_categories_service.rb +++ b/app/services/create_categories_service.rb @@ -3,12 +3,14 @@ def self.create_categories categories = YAML.load_file("config/categories.yml") categories.each do |category_name, tag_names| category = Category.find_or_create_by(name: category_name) - tag_names.each do |tag_name| + tag_names.each do |tag_name| tag = Tag.find_or_create_by(name: tag_name, category: category) if tag.previous_changes.any? - puts "Created tag: #{tag.name} (belongs to category: #{category.name})." + unless Rails.env.test? + puts "Created tag: #{tag.name} (belongs to category: #{category.name})." + end end end end end -end \ No newline at end of file +end diff --git a/app/views/admin/_admin_navigation.html.erb b/app/views/admin/_admin_navigation.html.erb new file mode 100644 index 00000000..046da17d --- /dev/null +++ b/app/views/admin/_admin_navigation.html.erb @@ -0,0 +1,9 @@ + diff --git a/app/views/admin/applications/show.html.erb b/app/views/admin/applications/show.html.erb new file mode 100644 index 00000000..a9c65838 --- /dev/null +++ b/app/views/admin/applications/show.html.erb @@ -0,0 +1,45 @@ +<% provide :title, "Admin - Application for #{@event.name}" %> + +<%= render partial: "shared/breadcrumbs", + locals: { + admin: "Admin", + event: @event, + application_by: "Application by", + applicant_name: @application.name + } %> + +

<%= "Application for #{@event.name}" %>

+ +<%= render partial: "applications/application_details", locals: {application: @application, event_name: @event.name} %> + +
+ <% if @event.application_process == "selection_by_travis" %> +

+ Application Status: + <%= @application.status %> +

+ + <% if @application.event.closed? && !@event.past? %> + <% if @application.status == 'pending' %> + <%= link_to "Approve", approve_admin_event_application_path(@application.event_id, @application.id), + method: :post, class: "btn btn-save approve-application", + title: "approve" %> + <%= link_to "Reject", reject_admin_event_application_path(@application.event_id, @application.id), + method: :post, class: "btn btn-external reject-application", + title: "reject" %> + <% elsif @application.status == 'approved' || @application.status == 'rejected' %> + <%= link_to "Revert", revert_event_application_path(@application.event_id, @application.id), + method: :post, class: "btn btn-edit revert-application", + title: "revert" %> + <% end %> + <% end %> + <% end %> + + <%= link_to "Delete Application", event_application_path(@event.id, @application.id), + class: "btn btn-delete", method: :delete, + data: {confirm: "Are you sure?"} %> +
+ +

+ <%= link_to "Show Event Details", admin_event_path(@event.id) %> +

diff --git a/app/views/admin/events/_event_row.html.erb b/app/views/admin/events/_event_row.html.erb new file mode 100644 index 00000000..eefb2a69 --- /dev/null +++ b/app/views/admin/events/_event_row.html.erb @@ -0,0 +1,54 @@ +
  • +

    + <%= event_image event %> + <%= link_to event.name, admin_event_path(id: event.id), title: event.name %> +

    + +

    + <%= event.application_process.humanize %> +

    + +

    + <%= format_date(event.deadline) %> +

    + +
    + <% if event.unapproved && event.open? %> + <%= form_for :approve, + url: approve_admin_event_path(event), + html: { method: :post } do |form| %> + + + <%= form.check_box :tweet, checked: true %> + + + + <%= form.submit(class: "icon-approve", title: "approve") %> + + + <% end %> + <% elsif event.approved && event.open? %> + <%= link_to approve_admin_event_path(event), + method: :post, class: "icon tooltip-large", + title: "Unapprove" do %> + + <% end %> + <% end %> + + <%= link_to edit_admin_event_path(id: event.id), class: "icon tooltip", title: "Edit" do %> + + <% end %> + + <%= link_to url_for(action: :destroy, id: event.id), method: :delete, + data: {confirm: "Are you sure?"}, class: "icon tooltip", title: "Delete" do %> + + <% end %> +
    + +

    + <% if event.approved %> + <%= link_to "Download CSV", admin_event_path(id: event.id, format: :csv), + class: "btn btn-save", title: "Download Data" %> + <% end %> +

    +
  • diff --git a/app/views/admin/events/edit.html.erb b/app/views/admin/events/edit.html.erb new file mode 100644 index 00000000..61e01394 --- /dev/null +++ b/app/views/admin/events/edit.html.erb @@ -0,0 +1,19 @@ +<% provide :title, "Admin - Edit #{@event.name}" %> + +<%= render partial: "shared/breadcrumbs", locals: {admin: "Admin", edit_event: "Edit Event"} %> + +

    Edit <%= @event.name %>

    + +<% if @event.errors.any? %> +
    +

    <%= pluralize(@event.errors.count, "error", "errors") %>

    + + +
    +<% end %> + +<%= render partial: "events/form", locals: {submit_tag_text: "Submit Changes", form_url: admin_event_path(@event)} %> diff --git a/app/views/admin/events/index.html.erb b/app/views/admin/events/index.html.erb new file mode 100644 index 00000000..766defa3 --- /dev/null +++ b/app/views/admin/events/index.html.erb @@ -0,0 +1,62 @@ +<% provide :title, "Admin - Events" %> + +<%= render partial: "admin/admin_navigation" %> + +<%= render partial: "shared/breadcrumbs", locals: {admin: "Admin", title: "Events"} %> + +

    Events

    + +
    +

    Manage "Selection by Diversity Tickets"

    + <%= form_for @application_process_options_handler, url: update_process_path do |form| %> + <%= form.check_box :selection_by_dt_enabled, value: selection_by_dt_enabled? %> + Enable selection by Diversity Tickets? +
    + <%= form.submit(class: "btn btn-save", value: 'Save', data: { + confirm: selection_by_dt_enabled? ? 'Are you sure you want to disable selection by Diversity Tickets?' : 'Are you sure you want to enable selection by Diversity Tickets?' + }) %> +
    + <% end %> +
    + +
    +

    Unapproved Events

    +
    +
      + <% if @unapproved_events.empty? %> +

      <%= t(".no_events_to_approve")%>

      + <% else %> + <% @unapproved_events.each do |event| %> + <%= render partial: "event_row", locals: { event: event } %> + <% end %> + <% end %> +
    +
    +
    + +
    +

    Approved Events

    +
    +
    +

    Open deadline

    +
      + <% unless @approved_open_events.empty? %> + <% @approved_open_events.each do |event| %> + <%= render partial: "event_row", locals: { event: event } %> + <% end %> + <% end %> +
    +
    + +
    +

    Closed deadline

    +
      + <% unless @approved_closed_events.empty? %> + <% @approved_closed_events.each do |event| %> + <%= render partial: "event_row", locals: { event: event } %> + <% end %> + <% end %> +
    +
    +
    +
    diff --git a/app/views/admin/events/past.html.erb b/app/views/admin/events/past.html.erb new file mode 100644 index 00000000..0230ada8 --- /dev/null +++ b/app/views/admin/events/past.html.erb @@ -0,0 +1,33 @@ +<% provide :title, "Admin - Past Events" %> + +<%= render partial: "admin/admin_navigation" %> + +<%= render partial: "shared/breadcrumbs", locals:{ title: "Past Events", admin: "Admin" } %> + +

    Past Events

    + +
    +

    Past Approved Events

    +
    +
      + <% unless @approved_events.empty? %> + <% @approved_events.each do |event| %> + <%= render partial: "event_row", locals: { event: event } %> + <% end %> + <% end %> +
    +
    +
    + +
    +

    Past Unapproved Events

    +
    +
      + <% unless @unapproved_events.empty? %> + <% @unapproved_events.each do |event| %> + <%= render partial: "event_row", locals: { event: event } %> + <% end %> + <% end %> +
    +
    +
    diff --git a/app/views/admin/events/reports.html.erb b/app/views/admin/events/reports.html.erb new file mode 100644 index 00000000..576529fc --- /dev/null +++ b/app/views/admin/events/reports.html.erb @@ -0,0 +1,46 @@ +<% provide :title, "Admin - Reports" %> + +<%= render partial: "admin/admin_navigation" %> + +<%= render partial: "shared/breadcrumbs", locals:{ title: "Reports", admin: "Admin" } %> + +

    Reports

    + +
    +

    <%= "Downloads" %>

    + <%= link_to "Download events report", admin_events_path(format: :csv), class: "btn btn-save"%> + <%= link_to "Download annual events report", annual_admin_events_path(format: :csv), class: "btn btn-save"%> +
    + +
    +

    <%= "Statistics" %>

    + + +
    +
    +
    +   + Countries that hosted events +
    +
    + <%= javascript_tag "new CustomizedMap(#{@countries_statistics});" %> +
    +
    +
    diff --git a/app/views/admin_events/show.html.erb b/app/views/admin/events/show.html.erb similarity index 56% rename from app/views/admin_events/show.html.erb rename to app/views/admin/events/show.html.erb index ae38e570..03fd0028 100644 --- a/app/views/admin_events/show.html.erb +++ b/app/views/admin/events/show.html.erb @@ -1,6 +1,6 @@ -<% provide :title, t('.title') %> +<% provide :title, "Admin - #{@event.name}" %> -<%= render partial: "shared/breadcrumbs", locals:{ admin: t('.admin_link'), event: @event } %> +<%= render partial: "shared/breadcrumbs", locals:{ admin: "Admin", event: @event } %>

    Details for <%= @event.name %>

    @@ -16,7 +16,7 @@ <% unless @event.application_process == "application_by_organizer" %>
    -

    <%=t(".applications")%>

    +

    Applications

    <%= pluralize_highlight_count(@event.applications.submitted.count, "application") %> currently
    <%= pluralize_highlight_count(@event.applications.drafts.count, "draft") %> currently @@ -33,34 +33,36 @@
  • <%= event_image application.event %> - <%= link_to application.name, show_admin_event_application_path(id: application.id, event_id: application.event_id), title: application.event.name %> + <%= link_to application.name, + admin_event_application_path(id: application.id, event_id: application.event_id), + title: application.event.name %>

    <% unless @event.application_process == "selection_by_organizer" %> <% if (application.status == "approved") || (application.status == "rejected") %> - <%= link_to revert_event_application_path(application.event_id, application.id), - method: :post, class: "btn btn-edit revert-application", - title: t(".revert").downcase do %> - <%= t(".revert") %> - <% end %> + <%= link_to revert_admin_event_application_path(application.event_id, application.id), + method: :post, class: "btn btn-edit revert-application", + title: "revert" do %> + Revert + <% end %> <% else %> - <%= link_to approve_event_application_path(application.event_id, application.id), - method: :post, class: "btn btn-save approve-application", - title: t(".approve").downcase do %> - <%= t(".approve") %> + <%= link_to approve_admin_event_application_path(application.event_id, application.id), + method: :post, class: "btn btn-save approve-application", + title: "approve" do %> + Approve <% end %> - <%= link_to reject_event_application_path(application.event_id, application.id), - method: :post, class: "btn btn-external reject-application", - title: t(".reject").downcase do %> - <%=t(".reject")%> + <%= link_to reject_admin_event_application_path(application.event_id, application.id), + method: :post, class: "btn btn-external reject-application", + title: "reject" do %> + Reject <% end %> <% end %> <% end %> <%= link_to admin_event_application_path(application.id, application.event_id), method: :delete, - data: { confirm: t(".are_you_sure")}, class: "btn btn-delete delete-application", title: t(".delete").downcase do %> - <%= t(".delete")%> + data: {confirm: "Are you sure"}, class: "btn btn-delete delete-application", title: "delete" do %> + Delete <% end %>

  • @@ -76,11 +78,11 @@

    <%=t(".organizer_details")%>

    - <%=t('.organizer_name')%> + Organizer Name <%= @event.organizer_name %>
    - <%=t('.organizer_email')%> + Organizer Email <%= @event.organizer_email %>
    @@ -88,9 +90,9 @@ <%= render partial: "events/event" %>
    - <%= link_to t(".delete_event"), event_path(@event.id), method: :delete, - data: {confirm: t(".are_you_sure")}, class: "btn btn-delete" %> - <%= link_to t(".edit_event"), edit_event_path(@event.id), class: "btn btn-edit" %> + <%= link_to "Delete event", event_path(@event.id), method: :delete, + data: {confirm: "Are you sure?"}, class: "btn btn-delete" %> + <%= link_to "Edit event", edit_event_path(@event.id), class: "btn btn-edit" %> <% if @event.approved? %> <%= download_csv_link(@event) %> <% else %> @@ -98,11 +100,11 @@ <%= form_for :approve, url: approve_admin_event_path(@event), html: { method: :post } do |form| %> - <%= form.submit(t('.approve_event'), class: "btn btn-save", title: t(".approve").downcase) %> + <%= form.submit("Approve", class: "btn btn-save", title:"approve") %> <%= form.check_box :tweet, checked: true %> - - <%= t('.tweet_event') %> + + Tweet event <% end %> diff --git a/app/views/tags/index.html.erb b/app/views/admin/tags/index.html.erb similarity index 58% rename from app/views/tags/index.html.erb rename to app/views/admin/tags/index.html.erb index d728bb9e..d3670f97 100644 --- a/app/views/tags/index.html.erb +++ b/app/views/admin/tags/index.html.erb @@ -1,8 +1,10 @@ -<% provide :title, t('.title') %> +<% provide :title, "Admin - Tags Management" %> -<%= render partial: "shared/breadcrumbs", locals:{ title: t('.title') } %> +<%= render partial: "admin/admin_navigation" %> -

    <%= t('.title') %>

    +<%= render partial: "shared/breadcrumbs", locals: {title: "Tags Management", admin: "Admin"} %> + +

    Tags Management

    <% @tags.each do |category, tags| %> @@ -12,13 +14,9 @@
      <% tags.each do |tag| %>
    • - <% if tag.category.name != "programming languages" %> - <%= t("tags.#{tag.category.name}.#{tag.name.downcase}") %> - <% else %> - <%= tag.name %> - <% end %> + <%= tag.name %> <%= link_to url_for(action: :destroy, id: tag.id), method: :delete, - data: { confirm: t('.are_you_sure')}, class: "icon tooltip", title: "delete" do %> + data: {confirm: "Are you sure?"}, class: "icon tooltip", title: "delete" do %> <% end %>
    • diff --git a/app/views/admin_applications/show.html.erb b/app/views/admin_applications/show.html.erb deleted file mode 100644 index 20262dfb..00000000 --- a/app/views/admin_applications/show.html.erb +++ /dev/null @@ -1,61 +0,0 @@ -<% provide :title, t('.title') %> - -<%= render partial: "shared/breadcrumbs", locals:{ admin: t('.admin_link'), event: @event, application_by: t('.application_by', applicant_name: @application.name) } %> - -

      <%=t('.application_for', event_name: @event.name)%>

      - -
      -

      - - <%= t('.attendee_info_1', event_name: @event.name) %> - - <%= @application.attendee_info_1 %> -

      - -

      - <%= t('.attendee_info_2') %> - <%= @application.attendee_info_2 %> -

      - -

      - <%= t(".name") %> - <%= @application.name %> -

      - -

      - <%= t(".email") %> - <%= @application.email %> -

      - - <% if @application.visa_needed %> -

      - <%= t(".visa_need") %> -

      - <% end %> -
      - -
      - <% if @event.application_process == "selection_by_travis" %> -

      <%=t('.application_status', application_status: @application.status)%>

      - <% if @application.event.closed? && !@event.past? %> - <% if @application.status == 'pending' %> - <%= link_to t(".approve"), approve_event_application_path(@application.event_id, @application.id), - method: :post, class: "btn btn-save approve-application", - title: t(".approve").downcase %> - <%= link_to t(".reject"), reject_event_application_path(@application.event_id, @application.id), - method: :post, class: "btn btn-external reject-application", - title: t(".reject").downcase %> - <% elsif @application.status == 'approved' || @application.status == 'rejected' %> - <%= link_to t(".revert"), revert_event_application_path(@application.event_id, @application.id), - method: :post, class: "btn btn-edit revert-application", - title: t(".revert").downcase %> - <% end %> - <% end %> - <% end %> - <%= link_to t('.delete_application'), event_application_path(@event.id, @application.id), - class: "btn btn-delete", method: :delete, - data: { confirm: t(".are_you_sure") } %> -
      -

      - <%= link_to t(".show_event_details"), event_path(@event.id) %> -

      diff --git a/app/views/admin_events/_statistics.html.erb b/app/views/admin_events/_statistics.html.erb deleted file mode 100644 index d9935685..00000000 --- a/app/views/admin_events/_statistics.html.erb +++ /dev/null @@ -1,36 +0,0 @@ -
      -

      <%= t('.statistics') %>

      -
        -
      • <%= t('.total_conferences') %><%= @events.count %>
      • -
      • <%= t('.conferences_since')%><%= Time.zone.now.year %>: <%= @events.created_current_year.count %>
      • -
      • <%= t('.total_organizers') %><%= @total_organizers %>
      • -
      • <%= t('.new_users_last_30_days') %> <%= @new_users.count %>
      • -
      -
        -
      • - <%= t('.most_conferences') %> - -
          - <% @country_rank.each.with_index do |country, index| %> - <% break if index >= 3 || index == @country_rank.length %> -
        1. <%= index + 1 %>. <%= @country_rank[index][0] %> (<%= @country_rank[index][1] %>)
        2. - <% end %> -
        -
        -
      • -
      -
      - - <%= t('.show_statistics_map') %> - - -
      -
      -   - <%=t('.countries_hosted_events') %> -
      -
      - <%= javascript_tag "new CustomizedMap(#{@countries_statistics});" %> -
      -
      -
      diff --git a/app/views/admin_events/index.html.erb b/app/views/admin_events/index.html.erb deleted file mode 100644 index e0d07059..00000000 --- a/app/views/admin_events/index.html.erb +++ /dev/null @@ -1,134 +0,0 @@ -<% provide :title, t('.title') %> - -<%= render partial: "shared/breadcrumbs", locals:{ title: t('.title') } %> - -

      <%=t('.title')%>

      - -<%= render partial: 'statistics' %> - -

      - <%= link_to t('.download_events_report'), admin_path(format: :csv), - class: "btn btn-save"%> - - <%= link_to t('.download_annual_events_report'), admin_annual_path(format: :csv), - class: "btn btn-save"%> -

      - - -
      -

      Manage "Selection by Diversity Tickets"

      - <%= form_for @application_process_options_handler, url: update_process_path do |form| %> - <%= form.check_box :selection_by_dt_enabled, value: selection_by_dt_enabled? %> - Enable selection by Diversity Tickets? -
      - <%= form.submit(class: "btn btn-save", value: 'Save', data: { - confirm: selection_by_dt_enabled? ? 'Are you sure you want to disable selection by Diversity Tickets?' : 'Are you sure you want to enable selection by Diversity Tickets?' - }) %> -
      - <% end %> -
      - -<% @categorized_events.each do |heading, events| %> -
      -

      <%= heading %>

      - -
      -
        - <% if events.empty? %> -

        <%= t(".no_events_to_approve")%>

        -
      - <% elsif heading == "Approved events" %> - <% @approved_events_deadline.each do |heading, events| %> - <% unless events.empty? %> -
      -

      <%= heading %>

      - <% events.each do |event| %> -
    • -

      - <%= event_image event %> - <%= link_to event.name, event_admin_path(id: event.id), title: event.name %> -

      -

      - <%= event.application_process.humanize %> -

      -

      - <%= format_date(event.deadline) %> -

      -
      - <%= link_to approve_admin_event_path(event), - method: :post, class: "icon tooltip-large", - title: t('.unapprove') do %> - - <% end %> - - <%= link_to edit_event_path(id: event.id), class: "icon tooltip", title: t('.edit') do %> - - <% end %> - <%= link_to url_for(action: :destroy, id: event.id), method: :delete, - data: { confirm: t('.are_you_sure')}, class: "icon tooltip", title: t('.delete') do %> - - <% end %> -
      -

      - <%= download_csv_link(event) %> -

      -
    • - <% end %> -
      - <% end %> - <% end %> - <% else %> - <% events.each do |event| %> -
    • -

      - <%= event_image event %> - <%= link_to event.name, event_admin_path(id: event.id), title: event.name %> -

      -

      - <%= event.application_process.humanize %> -

      -

      - <%= format_date(event.deadline) %> -

      -
      - <% if event.unapproved %> - <%= form_for :approve, - url: approve_admin_event_path(event), - html: { method: :post } do |form| %> - - - <%= form.check_box :tweet, checked: true %> - - - <%= form.submit(class: "icon-approve", title: "approve") %> - <% end %> - <% else %> - <%= link_to approve_admin_event_path(event), - method: :post, class: "icon tooltip-large", - title: t('.unapprove') do %> - - <% end %> - <% end %> - - <%= link_to edit_event_path(id: event.id), class: "icon tooltip", title: t('.edit') do %> - - - <% end %> - <%= link_to url_for(action: :destroy, id: event.id), method: :delete, - data: { confirm: t('.are_you_sure')}, class: "icon tooltip", title: t('.delete') do %> - - <% end %> -
      -

      - <% if event.approved %> - <%= link_to t('.download_csv'), event_admin_path(id: event.id, format: :csv), - class: "btn btn-save", title: t('.download_data') %> - <% end %> -

      -
    • - <% end %> - <% end %> -
    -
    -
    -<% end %> diff --git a/app/views/admin_mailer/passed_event_deadline.text.erb b/app/views/admin_mailer/passed_event_deadline.text.erb index 20d65318..195bd2d8 100644 --- a/app/views/admin_mailer/passed_event_deadline.text.erb +++ b/app/views/admin_mailer/passed_event_deadline.text.erb @@ -6,4 +6,4 @@ Application Process: <%= @event.application_process.humanize %> Follow the link below to select the winners: -<%= event_admin_url(@event.id, locale: "en") %> +<%= admin_event_url(@event.id, locale: "en") %> diff --git a/app/views/admin_mailer/submitted_event.text.erb b/app/views/admin_mailer/submitted_event.text.erb index 7c868608..1434a605 100644 --- a/app/views/admin_mailer/submitted_event.text.erb +++ b/app/views/admin_mailer/submitted_event.text.erb @@ -8,4 +8,4 @@ Application Process: <%= @event.application_process.humanize %> Follow the link below to view details: -<%= event_admin_url(@event.id, locale: "en") %> +<%= admin_event_url(@event.id, locale: "en") %> diff --git a/app/views/admin_mailer/upcoming_event_deadline.text.erb b/app/views/admin_mailer/upcoming_event_deadline.text.erb index 7502e56d..47016dbd 100644 --- a/app/views/admin_mailer/upcoming_event_deadline.text.erb +++ b/app/views/admin_mailer/upcoming_event_deadline.text.erb @@ -5,4 +5,4 @@ Application Process: <%= @event.application_process.humanize %> Follow the link below to view details: -<%= event_admin_url(@event.id, locale: "en") %> +<%= admin_event_url(@event.id, locale: "en") %> diff --git a/app/views/applications/_application_details.html.erb b/app/views/applications/_application_details.html.erb new file mode 100644 index 00000000..6f933641 --- /dev/null +++ b/app/views/applications/_application_details.html.erb @@ -0,0 +1,29 @@ +
    +

    + + <%= t('applications.show.attendee_info_1', event_name: event_name) %> + + <%= application.attendee_info_1 %> +

    + +

    + <%=t('applications.show.attendee_info_2')%> + <%= application.attendee_info_2 %> +

    + +

    + <%=t('applications.show.name')%> + <%= application.name %> +

    + +

    + <%=t('applications.show.email')%> + <%= application.email %> +

    + + <% if application.visa_needed %> +

    + <%=t('applications.show.visa_needed')%> +

    + <% end %> +
    diff --git a/app/views/applications/show.html.erb b/app/views/applications/show.html.erb index d290ded0..2202ecbc 100644 --- a/app/views/applications/show.html.erb +++ b/app/views/applications/show.html.erb @@ -1,42 +1,15 @@ <% provide :title, t('.title') %> -<% if current_user.admin? %> - <%= render partial: "shared/breadcrumbs", locals:{ admin: t('.admin_link'), event: @event, application_by: t('.application_by', applicant_name: @application.name) } %> -<% else %> - <%= render partial: "shared/breadcrumbs", locals:{ your_applications: t('.your_applications'), application_for: t('.application_for', event_name: @event.name) } %> -<% end %> +<%= render partial: "shared/breadcrumbs", + locals: { + your_applications: t('.your_applications'), + application_for: t('.application_for', + event_name: @event.name) + } %>

    <%= t('.application_for', event_name: @event.name) %>

    -
    -

    - - <%= t('.attendee_info_1', event_name: @event.name) %> - - <%= @application.attendee_info_1 %> -

    - -

    - <%=t('.attendee_info_2')%> - <%= @application.attendee_info_2 %> -

    - -

    - <%=t('.name')%> - <%= @application.name %> -

    - -

    - <%=t('.email')%> - <%= @application.email %> -

    - - <% if @application.visa_needed %> -

    - <%=t('.visa_needed')%> -

    - <% end %> -
    +<%= render partial: "application_details", locals: {application: @application, event_name: @event.name} %> <% if @application.event.open? %> <% if !@application.submitted %> @@ -80,28 +53,7 @@ data: { confirm: t('.are_you_sure') } %> <% end %> -<% if current_user.admin? %> -
    -

    Application status: <%= @application.status %>

    - <%= link_to t('.delete_application'), event_application_path(@event.id, @application.id), - class: "btn btn-delete", method: :delete, - data: { confirm: t('.are_you_sure') } %> - <% if @application.submitted == true && !@event.past? %> - <% if @application.status == 'pending' %> - <%= link_to t('.approve').capitalize, approve_event_application_path(@application.event_id, @application.id), - method: :post, class: "btn btn-save approve-application", - title: t('.approve') %> - <%= link_to t('.reject').capitalize, reject_event_application_path(@application.event_id, @application.id), - method: :post, class: "btn btn-external reject-application", - title: t('.reject') %> - <% elsif @application.status == 'approved' || @application.status == 'rejected' %> - <%= link_to t('.revert').capitalize, revert_event_application_path(@application.event_id, @application.id), - method: :post, class: "btn btn-edit revert-application", - title: t('.revert') %> - <% end %> - <% end %> -
    -<% end %> -

    - <%= link_to t('.show_event_details'), event_path(@event.id) %> -

    + +

    + <%= link_to t('.show_event_details'), event_path(@event.id) %> +

    diff --git a/app/views/events/edit.html.erb b/app/views/events/edit.html.erb index 277aea10..8b0985bf 100644 --- a/app/views/events/edit.html.erb +++ b/app/views/events/edit.html.erb @@ -5,7 +5,6 @@ <%= render partial: "shared/breadcrumbs", locals: Hash[key => value, edit_event: t('.edit_event')] %> -

    <%= t('.edit') %> <%= @event.name %>

    <% if @event.errors.any? %> @@ -20,5 +19,4 @@ <% end %> - <%= render partial: "form", locals: {submit_tag_text: t('.submit_changes'), form_url: event_path(@event)} %> diff --git a/app/views/events/show.html.erb b/app/views/events/show.html.erb index 96cb258b..e7d9691b 100644 --- a/app/views/events/show.html.erb +++ b/app/views/events/show.html.erb @@ -5,13 +5,12 @@ <%= render partial: "shared/breadcrumbs", locals: Hash[key => value, event: @event, approval_pending: t('.approval_pending')] %> -

    <%= event_image @event %><%= @event.name %>

    <%= render partial: "events/event" %> - <% if current_user && (@event.organizer_id == current_user.id || current_user.admin?) %> + <% if current_user && @event.organizer_id == current_user.id %> <% if @event.closed? %>

    diff --git a/app/views/layouts/_header.html.erb b/app/views/layouts/_header.html.erb index 9bd415f6..c7777137 100644 --- a/app/views/layouts/_header.html.erb +++ b/app/views/layouts/_header.html.erb @@ -22,7 +22,6 @@