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 @@
+
+ Admin
+
+ <%= navbar_link_to "Events", admin_events_path %>
+ <%= navbar_link_to "Past Events", past_admin_events_path %>
+ <%= navbar_link_to "Tags", admin_tags_path %>
+ <%= navbar_link_to "Reports", reports_admin_events_path %>
+
+
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") %>
+
+
+ <% @event.errors.messages.each do |field, messages| %>
+ <%= @event.class.human_attribute_name(field) %> <%= join_messages(messages) %>
+ <% end %>
+
+
+<% 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 %>
+
+
+
+
+
+
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" %>
+
+ Total conferences:<%= @events.count %>
+ <%= "Conferences since #{Time.zone.now.year}:" %><%= @events.created_current_year.count %>
+ Total organizers:<%= @total_organizers %>
+ New users in the last 30 days:<%= @new_users.count %>
+
+
+
+ Most conferences
+
+
+ <% @country_rank.each.with_index do |country, index| %>
+ <% break if index >= 3 || index == @country_rank.length %>
+ <%= index + 1 %>. <%= @country_rank[index][0] %> (<%= @country_rank[index][1] %>)
+ <% end %>
+
+
+
+
+
+
+
+
+ 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 %>
- <%= index + 1 %>. <%= @country_rank[index][0] %> (<%= @country_rank[index][1] %>)
- <% 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 %>
-
-
-
- <% 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 @@
<% if admin_user? %>
<%= navbar_link_to t('.admin'), admin_path %>
- <%= navbar_link_to t('.tags'), tags_path %>
<% end %>
<%= navbar_link_to t('.your_events'), user_path(current_user) %>
<%= navbar_link_to t('.your_applications'), user_applications_path(current_user) %>
diff --git a/app/views/shared/_breadcrumbs.html.erb b/app/views/shared/_breadcrumbs.html.erb
index 551404b2..a4ccdbe9 100644
--- a/app/views/shared/_breadcrumbs.html.erb
+++ b/app/views/shared/_breadcrumbs.html.erb
@@ -1,14 +1,11 @@
- <%= link_to t('.home_link'), root_path %> >
-
- <% if local_assigns.has_key? :title %>
- <%= title %>
-
- <% elsif local_assigns.has_key? :admin %>
+ <% if local_assigns.has_key? :admin %>
<%= link_to admin, admin_path %> >
- <% if local_assigns.has_key? :application_by %>
- <%= link_to event.name, event_admin_path(event.id) %> >
- <%= application_by %>
+ <% if local_assigns.has_key? :title %>
+ <%= title %>
+ <% elsif local_assigns.has_key? :application_by %>
+ <%= link_to event.name, admin_event_path(event.id) %> >
+ <%= "#{application_by} #{applicant_name}" %>
<% elsif local_assigns.has_key? :edit_event %>
<%= edit_event %>
<% else %>
@@ -17,42 +14,48 @@
<%= approval_pending %>
<% end %>
<% end %>
+ <% else %>
+ <%= link_to t('.home_link'), root_path %> >
- <% elsif local_assigns.has_key? :events %>
- <%= link_to events, events_path %> >
- <% if local_assigns.has_key? :edit_event %>
- <%= edit_event %>
- <% elsif local_assigns.has_key? :approval_pending %>
- <%= event.name %>
- <% if !event.approved? %>
- <%= approval_pending %>
- <% end %>
- <% else %>
- <%= link_to event.name, event_path(event) %> >
- <% if local_assigns.has_key? :application_for %>
- <%= application_for %>
+ <% if local_assigns.has_key? :events %>
+ <%= link_to events, events_path %> >
+ <% if local_assigns.has_key? :edit_event %>
+ <%= edit_event %>
+ <% elsif local_assigns.has_key? :approval_pending %>
+ <%= event.name %>
+ <% if !event.approved? %>
+ <%= approval_pending %>
+ <% end %>
<% else %>
- <%= application %>
+ <%= link_to event.name, event_path(event) %> >
+ <% if local_assigns.has_key? :application_for %>
+ <%= application_for %>
+ <% else %>
+ <%= application %>
+ <% end %>
<% end %>
- <% end %>
- <% elsif local_assigns.has_key? :your_applications %>
- <%= link_to your_applications, user_applications_path(current_user.id) %> >
- <% if local_assigns.has_key? :draft_for %>
- <%= draft_for %>
- <% else %>
- <%= application_for %>
- <% end %>
+ <% elsif local_assigns.has_key? :your_applications %>
+ <%= link_to your_applications, user_applications_path(current_user.id) %> >
+ <% if local_assigns.has_key? :draft_for %>
+ <%= draft_for %>
+ <% else %>
+ <%= application_for %>
+ <% end %>
- <% elsif local_assigns.has_key? :your_events %>
- <%= link_to your_events, user_path(current_user) %> >
- <% if local_assigns.has_key? :event %>
- <%= event.name %>
- <% if !event.approved? %>
- <%= approval_pending %>
+ <% elsif local_assigns.has_key? :your_events %>
+ <%= link_to your_events, user_path(current_user) %> >
+ <% if local_assigns.has_key? :event %>
+ <%= event.name %>
+ <% if !event.approved? %>
+ <%= approval_pending %>
+ <% end %>
+ <% else %>
+ <%= edit_event %>
<% end %>
- <% else %>
- <%= edit_event %>
+
+ <% elsif local_assigns.has_key? :title %>
+ <%= title %>
<% end %>
<% end %>
diff --git a/config/locales/en.yml b/config/locales/en.yml
index 25a02981..0ea86922 100644
--- a/config/locales/en.yml
+++ b/config/locales/en.yml
@@ -63,73 +63,6 @@ en:
blank: "can't be blank"
invalid: "should be a full URL, e.g. https://myconference.com"
- admin_applications:
- application_approved: "%{applicant_name}'s application has been approved!"
- application_pending: "%{applicant_name}'s application has been changed to pending"
- application_rejected: "%{applicant_name}'s application has been rejected"
- show:
- admin_link: "Admin"
- application_by: "Application by %{applicant_name}"
- application_for: "Application for %{event_name}"
- application_status: "Application status: %{application_status}"
- approve: "Approve"
- are_you_sure: "Are you sure you want to delete this application?"
- attendee_info_1: "Why do you want to attend %{event_name} and what especially do you look forward to learning?"
- attendee_info_2: "Please share with us why you're applying for a diversity ticket."
- delete_application: "Delete application"
- email: "Email"
- home_link: "Home"
- name: "Name"
- reject: "Reject"
- revert: "Revert"
- show_event_details: 'Show event details'
- title: "Admin"
- visa_need: "I need a Visa."
-
- admin_events:
- event_approved: "%{event_name} has been approved!"
- event_unapproved: "%{event_name} has been unapproved"
- index:
- are_you_sure: "Are you sure?"
- approve: "approve"
- edit: "edit"
- delete: "delete"
- download_annual_events_report: "Download annual events report"
- download_csv: "Download CSV"
- download_data: "Download data"
- download_events_report: "Download events report"
- no_events_to_approve: "We currently don't have any events to approve"
- title: "Admin page"
- unapprove: "unapprove"
- show:
- admin_link: "Admin"
- applications: "Applications"
- approve: "Approve"
- approve_event: "Approve event"
- are_you_sure: "Are you sure?"
- delete: "Delete"
- delete_event: "Delete event"
- download_csv: "Download CSV"
- download_data: "Download data"
- edit_event: "Edit event"
- home_link: "Home"
- organizer_details: "Organizer details"
- organizer_email: "Email"
- organizer_name: "Name"
- title: "Admin"
- tweet_event: "Tweet it"
- reject: "Reject"
- revert: "Revert"
- statistics:
- conferences_since: "Conferences since "
- countries_hosted_events: "Countries that hosted events"
- most_conferences: "Most conferences"
- new_users_last_30_days: "New users in the last 30 days:"
- total_conferences: "Total conferences:"
- total_organizers: "Total organizers:"
- show_statistics_map: "Show statistics map"
- statistics: "Statistics"
-
applications:
already_applied: "You have already applied for %{event_name}"
application_deleted: "You cannot view your application as the event you applied for has been removed from Diversity Tickets"
@@ -188,7 +121,6 @@ en:
home_link: "Home"
title: "New application"
show:
- admin_link: "Admin"
application_by: "Application by %{applicant_name}"
application_for: "Application for %{event_name}"
approve: "Approve"
@@ -337,7 +269,6 @@ en:
your_application: "Your application"
your_draft: "Your draft"
edit:
- admin_link: "Admin"
edit: "Edit"
edit_event: "Edit event"
events_link: "Events"
@@ -381,7 +312,6 @@ en:
submit_your_event: "Submit your event"
title: "Preview event"
show:
- admin_link: "Admin"
applications_closed: "Sorry, applications for %{event_name} are closed."
apply_at: "Apply at %{event_name}"
apply_for_ticket: "Apply for a ticket"
@@ -574,12 +504,6 @@ en:
people: "People"
tech: "Tech"
security: "Security"
- index:
- are_you_sure: "Are you sure?"
- title: "Tags management"
- tag_created: "Tag %{tag_name} was successfully created."
- tag_problem: "There was a problem creating the new tag."
-
users:
account_deleted: "Your account has been deleted successfully."
diff --git a/config/locales/es.yml b/config/locales/es.yml
index ed45f0a7..4c33e299 100644
--- a/config/locales/es.yml
+++ b/config/locales/es.yml
@@ -77,73 +77,6 @@ es:
blank: ": Por favor, introduce una página web"
invalid: "URL completa, por ejemplo: https://miconferencia.com"
- admin_applications:
- application_approved: "¡La solicitud de %{applicant_name} ha sido aprobada!"
- application_pending: 'La solicitud de %{applicant_name} ha vuelto a "pendiente"'
- application_rejected: "La solicitud de %{applicant_name} ha sido rechazada"
- show:
- admin_link: "Admin"
- application_by: "Solicitud de %{applicant_name}"
- application_for: "Solicitud para %{event_name}"
- application_status: "Estado de la solicitud: %{application_status}"
- approve: "Aprobar"
- are_you_sure: "¿Estás segura/o de que quieres eliminar esta solicitud?"
- attendee_info_1: "¿Por qué quieres acudir a %{event_name} y qué es lo que te gustaría aprender?"
- attendee_info_2: "Por favor, explícanos por qué te gustaría recibir un Diversity Ticket"
- delete_application: "Borrar solicitud"
- name: "Nombre"
- email: "Email"
- home_link: "Inicio"
- reject: "Denegar"
- revert: "Revertir"
- show_event_details: "Mostrar detalles del evento"
- title: "Admin"
- visa_need: "Necesito una visa"
-
- admin_events:
- event_approved: "¡%{event_name} ha sido aprobado!"
- event_unapproved: "%{event_name} ha sido desaprobado"
- index:
- are_you_sure: "¿Estás seguro/a?"
- approve: aprobar
- delete: "eliminar"
- download_annual_events_report: "Descargar informe anual de eventos"
- download_csv: "Descargar CSV"
- download_events_report: "Descargar informe de eventos"
- download_data: "Descargar datos"
- edit: "editar"
- no_events_to_approve: "No existe ningún evento pendiente de revisión"
- title: "Página de administrador"
- unapprove: "desaprobar"
- show:
- admin_link: "Admin"
- applications: "Solicitudes"
- approve: "Aprobar"
- approve_event: "Aprobar evento"
- are_you_sure: "¿Estás segura/o?"
- edit_event: "Editar evento"
- delete: "Borrar"
- delete_event: "Borrar evento"
- download_csv: "Descargar CSV"
- download_data: "Descargar datos"
- home_link: "Inicio"
- organizer_details: "Detalles del organizador"
- organizer_email: "Email"
- organizer_name: "Nombre"
- title: "Admin"
- tweet_event: "Twittéalo"
- reject: "Rechazar"
- revert: "Revertir"
- statistics:
- conferences_since: "Conferencias desde "
- countries_hosted_events: "Países donde hubo eventos"
- most_conferences: "Mayoría de conferencias"
- new_users_last_30_days: "Usuarios nuevos en los últimos 30 días"
- total_conferences: "Número total de conferencias:"
- total_organizers: "Número total de organizadores:"
- show_statistics_map: "Mostrar mapa de estadísticas"
- statistics: "Estadísticas"
-
applications:
already_applied: "Ya has realizado una solicitud para %{event_name}"
application_deleted: "No puedes visualizar tu solicitud porque el evento ha sido eliminado de Diversity Tickets"
@@ -202,7 +135,6 @@ es:
home_link: "Inicio"
title: "Nueva solicitud"
show:
- admin_link: "Admin"
application_by: "Solicitud de %{applicant_name}"
application_for: "Solicitud para %{event_name}"
approve: "Aprobar"
@@ -353,7 +285,6 @@ es:
your_application: "Tu solicitud"
your_draft: "Tu boceto"
edit:
- admin_link: "Admin"
edit: "Editar"
edit_event: "Editar evento"
events_link: "Eventos"
@@ -397,7 +328,6 @@ es:
submit_your_event: "Subir tu evento"
title: "Previsualizar evento"
show:
- admin_link: "Admin"
applications_closed: "Lo siento, las solicitudes para %{event_name} están cerradas."
apply_at: "Inscríbete en %{event_name}"
apply_for_ticket: "Solicita un ticket"
@@ -548,11 +478,6 @@ es:
people: "Humanidades"
tech: "Tecnología"
security: "Securidad"
- index:
- are_you_sure: "¿Estás segura/o?"
- title: "Gestión de tags"
- tag_created: "El tag %{tag_name} se ha creado con éxito."
- tag_problem: "Ha habido un problema creando el nuevo tag."
users:
account_deleted: "Tu cuenta se ha eliminado con éxito"
diff --git a/config/locales/fr.yml b/config/locales/fr.yml
index be21c0c3..d2889fda 100644
--- a/config/locales/fr.yml
+++ b/config/locales/fr.yml
@@ -63,73 +63,6 @@ fr:
blank: "obligatoire"
invalid: "doit être une URL complète, comme https://maconference.fr"
- admin_applications:
- application_approved: "La candidature de %{applicant_name} a été approuvée"
- application_pending: "La candidature de %{applicant_name} est en attente"
- application_rejected: "La candidature de %{applicant_name} a été rejetée"
- show:
- admin_link: "Admin"
- application_by: "Candidature de %{applicant_name}"
- application_for: "Candidature pour %{event_name}"
- application_status: "Statut de la candidature : %{application_status}"
- approve: "Approuver"
- are_you_sure: "Êtes-vous sûr·e de vouloir supprimer cette candidature ?"
- attendee_info_1: "Pourquoi souhaitez-vous participer à %{event_name} et que souhaitez-vous tout particulièrement y apprendre ?"
- attendee_info_2: "Qu'est-ce qui vous rend éligible à un billet diversité ? (1-2 phrases suffisent, ne partagez que ce avec quoi vous êtes à l'aise)"
- delete_application: "Supprimer la candidature"
- email: "Courriel"
- home_link: "Accueil"
- name: "Nom"
- reject: "Rejeter"
- revert: "Annuler"
- show_event_details: "Afficher les détails de l'événement"
- title: "Admin"
- visa_need: "J'ai besoin d'un visa."
-
- admin_events:
- event_approved: "%{event_name} a été approuvé !"
- event_unapproved: "%{event_name} n'a pas été approuvé."
- index:
- are_you_sure: "Êtes-vous sûr·e ?"
- approve: "Approuver"
- edit: "Modifier"
- delete: "Supprimer"
- download_annual_events_report: "Télécharger le rapport annuel des événements"
- download_csv: "Télécharger CSV"
- download_data: "Télécharger les données"
- download_events_report: "Télécharger le rapport des événements"
- no_events_to_approve: "Nous n'avons actuellement aucun événement à approuver."
- title: "Page d'admin"
- unapprove: "refuser"
- show:
- admin_link: "Admin"
- applications: "Candidature"
- approve: "Approuver"
- approve_event: "Approuver l'événement"
- are_you_sure: "Êtes-vous sûr·e ?"
- delete: "Supprimer"
- delete_event: "Supprimer l'événement"
- download_csv: "Télécharger CSV"
- download_data: "Télécharger les données"
- edit_event: "Modifier l'événement"
- home_link: "Accueil"
- organizer_details: "Détails de l'organisateur"
- organizer_email: "Courriel"
- organizer_name: "Nom"
- title: "Admin"
- tweet_event: "Tweetez le"
- reject: "Rejeter"
- revert: "Annuler"
- statistics:
- conferences_since: "Événements depuis "
- countries_hosted_events: "Pays hôtes"
- most_conferences: "Le + d'événements"
- new_users_last_30_days: "Nouveaux inscrits les 30 derniers jours:"
- total_conferences: "Nombre total d'événements:"
- total_organizers: "Nombre total d'organisateurs:"
- show_statistics_map: "Afficher la carte statistique"
- statistics: "Statistiques"
-
applications:
already_applied: "Vous avez déjà postulé à une place pour %{event_name}"
application_deleted: "Vous ne pouvez pas voir votre candidature car l'événement en question a été retiré de Diversity Tickets."
@@ -188,7 +121,6 @@ fr:
home_link: "Accueil"
title: "Nouvelle candidature"
show:
- admin_link: "Admin"
application_by: "Candidature de %{applicant_name}"
application_for: "Candidature pour %{event_name}"
approve: "Approuver"
@@ -337,7 +269,6 @@ fr:
your_application: "Votre candidature"
your_draft: "Votre brouillon"
edit:
- admin_link: "Admin"
edit: "Modifier"
edit_event: "Modifier l'événement"
events_link: "Événements"
@@ -381,7 +312,6 @@ fr:
submit_your_event: "Soumettre votre événement"
title: "Prévisualiser l'événement"
show:
- admin_link: "Admin"
applications_closed: "Désolé, les candidatures pour %{event_name} sont fermées."
apply_at: "Postuler à %{event_name}"
apply_for_ticket: "Faire une demande de billet"
@@ -526,11 +456,6 @@ fr:
people: "People"
tech: "Tech"
security: "Sécurité"
- index:
- are_you_sure: "Êtes-vous sûr·e ?"
- title: "Gestion des étiquettes"
- tag_created: "L'étiquette %{tag_name} a été créée avec succès."
- tag_problem: "Un problème est survenu durant la création de la nouvelle étiquette."
users:
account_deleted: "Votre compte a été supprimé avec succès."
diff --git a/config/routes.rb b/config/routes.rb
index 6253b4e0..4e498ab9 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -12,49 +12,55 @@
resources :events, except: [:destroy] do
resources :applications, except: [:index, :submit, :admin_destroy]
- end
-
- resources :events, except: [:destroy] do
resources :drafts, only: [:create, :update, :edit, :show]
end
- resources :admin_events, except: [:edit, :update] do
- member do
- post :approve
- end
- end
-
- resources :tags, only: [:index, :destroy, :create]
-
get '/sign_in', to: 'clearance/sessions#new', as: :sign_in
- delete '/sign_out', to: 'clearance/sessions#destroy', as: :sign_out
get '/sign_up', to: 'clearance/users#new', as: :sign_up
get '/:event_id/sign_up', to: 'clearance/users#new', as: :sign_up_event
+ delete '/sign_out', to: 'clearance/sessions#destroy', as: :sign_out
+
+ get '/users/:id/applications', to: 'users#applications', as: :user_applications
+ get 'users/:id/delete', to: 'users#confirm_delete', as: :confirm_delete
+ post 'users/:id/delete', to: 'users#delete_account', as: :delete_account
+ delete 'users/:id', to: 'users#destroy', as: :destroy_user
+
get '/past_events', to: 'events#index_past', as: :past_events
- get '/admin', to: 'admin_events#index'
- get '/admin_annual', to: 'admin_events#annual_events_report'
- delete 'events/:id', to: 'events#destroy', as: :delete_event
- patch '/events/:event_id/application/:id/submit', to: 'applications#submit', as: :submit_event_application
- get '/events/:id/admin', to: 'admin_events#show', as: :event_admin
+ get '/events/:event_id/continue_as_guest', to: 'applications#continue_as_guest', as: :continue_as_guest, constraints: { event_id: /\d.+/ }
post '/events/preview', to: 'events#preview', as: :event_preview
+ patch '/events/:event_id/application/:id/submit', to: 'applications#submit', as: :submit_event_application
+ patch '/events/:event_id/drafts/:id/submit', to: 'drafts#submit', as: :submit_draft
+ delete 'events/:id', to: 'events#destroy', as: :delete_event
+
+ root 'home#home'
get '/about', to: 'home#about', as: :about
get '/faq', to: 'home#faq', as: :faq
get '/privacy', to: 'home#privacy', as: :privacy
get '/impressum', to: 'home#impressum', as: :impressum
- get '/users/:id/applications', to: 'users#applications', as: :user_applications
- delete '/events/:event_id/application/:id', to: 'admin_applications#destroy', as: :admin_event_application
- post '/events/:event_id/applications/:id/approve', to: 'admin_applications#approve', as: :approve_event_application
- post '/events/:event_id/applications/:id/reject', to: 'admin_applications#reject', as: :reject_event_application
- post '/events/:event_id/applications/:id/revert', to: 'admin_applications#revert', as: :revert_event_application
- get '/events/:event_id/applications/:id/show_admin', to: 'admin_applications#show', as: :show_admin_event_application
- get '/events/:event_id/continue_as_guest', to: 'applications#continue_as_guest', as: :continue_as_guest, constraints: { event_id: /\d.+/ }
- delete 'users/:id', to: 'users#destroy', as: :destroy_user
- get 'users/:id/delete', to: 'users#confirm_delete', as: :confirm_delete
- post 'users/:id/delete', to: 'users#delete_account', as: :delete_account
- patch '/events/:event_id/drafts/:id/submit', to: 'drafts#submit', as: :submit_draft
- patch '/admin', to: 'application_process_options_handlers#update', as: :update_process
+ # Admin
+ namespace :admin do
+ resources :events, only: [:index, :show, :edit, :update, :destroy] do
+ member do
+ post :approve
+ end
+ collection do
+ get :past
+ get :reports
+ get :annual
+ end
+ resources :applications, only: [:show, :destroy] do
+ member do
+ post :approve
+ post :revert
+ post :reject
+ end
+ end
+ end
+ resources :tags, only: [:index, :destroy, :create]
+ end
- root 'home#home'
+ get '/admin', to: redirect('/en/admin/events')
+ patch '/admin', to: 'application_process_options_handlers#update', as: :update_process
end
end
diff --git a/test/controllers/admin/applications_controller_test.rb b/test/controllers/admin/applications_controller_test.rb
new file mode 100644
index 00000000..c4dfddf9
--- /dev/null
+++ b/test/controllers/admin/applications_controller_test.rb
@@ -0,0 +1,93 @@
+require 'test_helper'
+
+module Admin
+ class ApplicationsControllerTest < ActionController::TestCase
+ describe '#show' do
+ it 'redirects visitors' do
+ event = make_event
+ application = make_application(event)
+
+ get :show, params: { event_id: event.id, id: application.id }
+
+ assert_redirected_to sign_in_path
+ end
+
+ it 'redirects non-admin users' do
+ user = make_user
+ other_user = make_user(email: 'other@email.com')
+ sign_in_as(user)
+
+ event = make_event
+ application = make_application(event, applicant_id: other_user.id)
+
+ get :show, params: { event_id: event.id, id: application.id }
+
+ assert_redirected_to root_path
+ end
+
+ it 'shows submitted application to admin users' do
+ admin = make_admin
+ sign_in_as(admin)
+
+ event = make_event
+ application = make_application(event)
+
+ get :show, params: { event_id: event.id, id: application.id }
+
+ assert_response :success
+ end
+
+ it 'redirects admin users to root if they try to see drafted applications' do
+ admin = make_admin
+ sign_in_as(admin)
+
+ event = make_event
+ draft = make_draft(event)
+
+ get :show, params: { event_id: event.id, id: draft.id }
+
+ assert_redirected_to admin_event_path(event)
+ assert_equal(
+ "You cannot view a draft.",
+ flash[:notice]
+ )
+ end
+
+ it 'redirects admin to applications overview if the event has been deleted' do
+ user = make_user
+ event = make_event(deleted: true)
+ application = make_application(event, applicant_id: user.id)
+
+ admin = make_admin
+ sign_in_as(admin)
+
+ get :show, params: { event_id: event.id, id: application.id }
+
+ assert_redirected_to admin_path
+ assert_equal(
+ "You cannot view your application as the event you applied for has been removed from "\
+ "Diversity Tickets",
+ flash[:notice]
+ )
+ end
+ end
+
+ describe '#destroy' do
+ it 'properly redirects after successful deletion' do
+ user = make_user(admin: true)
+ sign_in_as(user)
+
+ event = make_event
+ application = make_application(event)
+ applications = event.applications
+
+ assert_equal 1, applications.count
+
+ delete :destroy, params: { event_id: event.id, id: application.id }
+
+ assert_redirected_to admin_event_path(event)
+ assert_equal 0, applications.count
+ end
+ end
+ end
+end
diff --git a/test/controllers/admin/events_controller_test.rb b/test/controllers/admin/events_controller_test.rb
new file mode 100644
index 00000000..04e423f8
--- /dev/null
+++ b/test/controllers/admin/events_controller_test.rb
@@ -0,0 +1,272 @@
+require 'test_helper'
+
+module Admin
+ class EventsControllerTest < ActionController::TestCase
+ before do
+ make_application_process_options_handler
+ end
+
+ describe '#index' do
+ it 'protect admin index from anonymous visitors, redirects to sign in' do
+ get :index
+
+ assert_redirected_to sign_in_path
+ end
+
+ it 'protect admin index from logged-in non-admins, redirects to root' do
+ user = make_user
+ sign_in_as(user)
+
+ get :index
+
+ assert_redirected_to root_path
+ end
+
+ it 'shows admin index to logged-in admins' do
+ user = make_user(admin: true)
+ sign_in_as(user)
+
+ get :index
+
+ assert_response :success
+ end
+ end
+
+ describe 'annual' do
+ it 'allows admins to download a csv file with an annual report' do
+ user = make_user(admin: true)
+ sign_in_as(user)
+
+ get :annual, format: :csv
+
+ assert_equal response.header['Content-Type'], 'text/csv'
+ assert_response :success
+ end
+
+ it 'does not allow not admins to download a csv file with an annual report' do
+ user = make_user(admin: false)
+ sign_in_as(user)
+
+ get :annual
+
+ assert_redirected_to root_path
+ end
+ end
+
+ describe '#approve' do
+ it 'correctly approves event' do
+ event = make_event
+ user = make_user(admin: true)
+ sign_in_as(user)
+
+ post :approve, params: { id: event.id , approve: { tweet: "1" } }
+
+ event.reload
+
+ assert_equal(true, event.approved?)
+ end
+
+ it 'correctly informs potential users that may be interested in the event' do
+ interested_user_1 = make_user(email: "country_user@test.de", country_email_notifications: true, country: "Germany")
+ interested_user_2 = make_user(email: "tag_user@test.de", tag_email_notifications: true)
+ category = Category.create!(name: "Interesting category")
+ tag = Tag.create!(name: "Interesting tag", category_id: category.id)
+ tagging = Tagging.create!(tag_id: tag.id , user_id: interested_user_2.id)
+
+ event = make_event
+ tagging_2 = Tagging.create!(tag_id: tag.id , event_id: event.id)
+ user = make_user(admin: true)
+ sign_in_as(user)
+
+ post :approve, params: { id: event.id , approve: { tweet: "1" } }
+
+ event.reload
+
+ emails = ActionMailer::Base.deliveries
+ emails.each { |email| @notification_country = email if email.subject == "A new event in your country!"
+ @notification_tag = email if email.subject == "A new event of your interest!" }
+ assert_equal @notification_country.to, [interested_user_1.email]
+ assert_equal @notification_tag.to, [interested_user_2.email]
+ end
+
+ it 'correctly redirects non-admin users' do
+ event = make_event
+ user = make_user(admin: false)
+ sign_in_as(user)
+
+ post :approve, params: { id: event.id , approve: { tweet: "1" } }
+
+ assert_redirected_to root_path
+
+ event.reload
+
+ assert_equal(false, event.approved?)
+ end
+
+ it 'correctly redirects visitors' do
+ event = make_event
+
+ post :approve, params: { id: event.id , approve: { tweet: "1" } }
+
+ assert_redirected_to sign_in_path
+
+ event.reload
+
+ assert_equal(false, event.approved?)
+ end
+ end
+
+ describe '#show' do
+ it 'shows the event details page to admin' do
+ admin = make_user(admin: true)
+ event = make_event
+
+ sign_in_as(admin)
+
+ get :show, params: { id: event.id }
+
+ assert_response :success
+ assert_template :show
+ end
+
+ it 'correctly redirects non-admin users' do
+ user = make_user(admin: false)
+ event = make_event
+
+ sign_in_as(user)
+
+ get :show, params: { id: event.id }
+
+ assert_redirected_to root_path
+ end
+
+ it 'correctly redirects visitors' do
+ get :show, params: { id: make_event.id }
+
+ assert_redirected_to sign_in_path
+ end
+
+ it 'shows the event details page in csv format to admin' do
+ admin = make_user(admin: true)
+ event = make_event
+
+ sign_in_as(admin)
+
+ get :show, params: { id: event.id }, format: :csv
+
+ assert_equal request.format, :csv
+ end
+ end
+
+ describe '#destroy' do
+ it 'destroys event on delete and redirects to admin page if user is admin' do
+ admin = make_user(admin: true)
+ event = make_event
+ events = Event.all
+
+ sign_in_as(admin)
+
+ assert_equal 1, events.count
+
+ get :destroy, params: { id: event.id }
+
+ assert_equal 0, events.count
+ assert_redirected_to admin_url
+ end
+ end
+
+ describe '#edit' do
+ it 'loads correctly for admin users' do
+ user = make_user(admin: true)
+ event = make_event
+ sign_in_as(user)
+
+ get :edit, params: { id: event.id }
+
+ assert_response :success
+ end
+
+ it 'redirects if user is not an admin' do
+ user = make_user(admin: false)
+ event_owner = make_user(email: 'different_address@example.org')
+ event = make_event(
+ name: 'BoringConf',
+ organizer_id: event_owner.id,
+ approved: false,
+ deadline: 5.days.from_now
+ )
+ sign_in_as(user)
+
+ get :edit, params: { id: event.id }
+
+ assert_redirected_to root_path
+ end
+ end
+
+ describe '#update' do
+ it 'loads correctly for admin users' do
+ user = make_user(admin: true)
+ event = make_event(name: 'BoringConf')
+ sign_in_as(user)
+
+ put :update, params: { id: event.id, event: {name: 'MonstersConf'} }
+
+ event.reload
+
+ assert_equal 'MonstersConf', event.name
+ assert_redirected_to admin_event_path(event)
+ end
+
+ it 'changes approval status when admin is updating' do
+ admin = make_user(admin: true)
+ event_owner = make_user(
+ admin: false,
+ email: 'different_address@example.org'
+ )
+ event = make_event(
+ approved: false,
+ organizer_id: event_owner.id,
+ deadline: 5.days.from_now
+ )
+ sign_in_as(admin)
+
+ put :update, params: { id: event.id, event: { approved: true } }
+
+ event.reload
+
+ assert_redirected_to admin_event_path(event)
+ assert_equal true, event.approved?
+ end
+
+ it 'rerenders edit when event update was not successful' do
+ admin = make_user(admin: true)
+ event_owner = make_user(
+ admin: false,
+ email: 'different_address@example.org'
+ )
+ event = make_event(
+ approved: false,
+ organizer_id: event_owner.id,
+ deadline: 5.days.from_now
+ )
+ sign_in_as(admin)
+
+ put :update, params: { id: event.id, event: { name: '' } }
+
+ assert_template :edit
+ end
+
+ it 'renders a forbidden 403 status code when unauthorized user tries to update event info' do
+ user = make_user
+ organizer = make_user( email: 'other@example.org' )
+ event = make_event( organizer_id: organizer.id )
+ sign_in_as(user)
+
+ put :update, params: { id: event.id, event: { name: 'Fakename' } }
+
+ assert_redirected_to root_path
+ assert_equal event.name, 'Event'
+ end
+ end
+ end
+end
diff --git a/test/controllers/admin/tags_controller_test.rb b/test/controllers/admin/tags_controller_test.rb
new file mode 100644
index 00000000..98ff7a28
--- /dev/null
+++ b/test/controllers/admin/tags_controller_test.rb
@@ -0,0 +1,85 @@
+require 'test_helper'
+
+module Admin
+ class TagsControllerTest < ActionController::TestCase
+ describe '#index' do
+ it 'shows all Tags already created to admins' do
+ setup do
+ 3.times { make_tag(name: "New event", category_id: 1) }
+ end
+
+ admin = make_user(admin: true)
+ sign_in_as(admin)
+
+ get :index
+
+ assert_response :success
+ assert_template 'tags/index'
+ end
+
+ it 'does not show all Tags already created to non-admins' do
+ setup do
+ 3.times { make_tag(name: "New event", category_id: 1) }
+ end
+
+ user = make_user
+ sign_in_as(user)
+
+ get :index
+
+ assert_redirected_to root_path
+ end
+ end
+
+ describe '#create' do
+ it 'allows an admin user to create a new tag with a name and a category' do
+ admin = make_user(admin: true)
+ sign_in_as(admin)
+
+ put :create, params: { tag: { name: "New Tag", category_id: 1 } }
+
+ assert_redirected_to admin_tags_path
+ assert_equal "Tag New Tag was successfully created.", flash[:notice]
+ assert_equal Tag.last.name, "New Tag"
+ end
+
+ it 'shows a flash message if there was a problem creating the tag' do
+ admin = make_user(admin: true)
+ sign_in_as(admin)
+
+ put :create, params: { tag: { name: "New Tag" } }
+
+ assert_redirected_to admin_tags_path
+ assert_equal "There was a problem creating the new tag.", flash[:alert]
+ end
+
+ it 'does not allow non-admin user to create a new tag' do
+ make_tag
+
+ user = make_user
+ sign_in_as(user)
+
+ put :create, params: { tag: { name: "Non Created Tag", category_id: 1 } }
+
+ assert_redirected_to root_path
+ assert_not_equal "Non Created Tag", Tag.last.name
+ end
+ end
+
+ describe '#destroy' do
+ it 'allows admin to delete tags' do
+ make_tag(name: "New event", category_id: 1)
+
+ all_tags = Tag.all.count
+
+ admin = make_user(admin: true)
+ sign_in_as(admin)
+
+ delete :destroy, params: { id: Tag.last.id }
+
+ assert_redirected_to admin_tags_path
+ assert_equal all_tags - 1, Tag.all.count
+ end
+ end
+ end
+end
diff --git a/test/controllers/admin_applications_controller_test.rb b/test/controllers/admin_applications_controller_test.rb
deleted file mode 100644
index d0d823f2..00000000
--- a/test/controllers/admin_applications_controller_test.rb
+++ /dev/null
@@ -1,21 +0,0 @@
-require 'test_helper'
-
-class AdminApplicationsControllerTest < ActionController::TestCase
- describe '#destroy' do
- it 'properly redirects after successful deletion' do
- user = make_user(admin: true)
- sign_in_as(user)
-
- event = make_event
- application = make_application(event)
- applications = event.applications
-
- assert_equal 1, applications.count
-
- delete :destroy, params: { event_id: event.id, id: application.id }
-
- assert_redirected_to event_admin_path(event)
- assert_equal 0, applications.count
- end
- end
-end
diff --git a/test/controllers/admin_events_controller_test.rb b/test/controllers/admin_events_controller_test.rb
deleted file mode 100644
index ea93d467..00000000
--- a/test/controllers/admin_events_controller_test.rb
+++ /dev/null
@@ -1,177 +0,0 @@
-require 'test_helper'
-
-class AdminEventsControllerTest < ActionController::TestCase
- before do
- make_application_process_options_handler
- end
-
- describe '#index' do
- it 'protect admin index from anonymous visitors, redirects to sign in' do
- get :index
-
- assert_redirected_to sign_in_path
- end
-
- it 'protect admin index from logged-in non-admins, redirects to root' do
- user = make_user
- sign_in_as(user)
-
- get :index
-
- assert_redirected_to root_path
- end
-
- it 'shows admin index to logged-in admins' do
- user = make_user(admin: true)
- sign_in_as(user)
-
- get :index
-
- assert_response :success
- end
- end
-
- describe 'annual_events_report' do
- it 'allows admins to download a csv file with an annual report' do
- user = make_user(admin: true)
- sign_in_as(user)
-
- get :annual_events_report, format: :csv
-
- assert_equal response.header['Content-Type'], 'text/csv'
- assert_response :success
- end
-
- it 'does not allow not admins to download a csv file with an annual report' do
- user = make_user(admin: false)
- sign_in_as(user)
-
- get :annual_events_report
-
- assert_redirected_to root_path
- end
-
- end
-
- describe '#approve' do
- it 'correctly approves event' do
- event = make_event
- user = make_user(admin: true)
- sign_in_as(user)
-
- post :approve, params: { id: event.id , approve: { tweet: "1" } }
-
- event.reload
-
- assert_equal(true, event.approved?)
- end
-
- it 'correctly informs potential users that may be interested in the event' do
- interested_user_1 = make_user(email: "country_user@test.de", country_email_notifications: true, country: "Germany")
- interested_user_2 = make_user(email: "tag_user@test.de", tag_email_notifications: true)
- category = Category.create!(name: "Interesting category")
- tag = Tag.create!(name: "Interesting tag", category_id: category.id)
- tagging = Tagging.create!(tag_id: tag.id , user_id: interested_user_2.id)
-
- event = make_event
- tagging_2 = Tagging.create!(tag_id: tag.id , event_id: event.id)
- user = make_user(admin: true)
- sign_in_as(user)
-
- post :approve, params: { id: event.id , approve: { tweet: "1" } }
-
- event.reload
-
- emails = ActionMailer::Base.deliveries
- emails.each { |email| @notification_country = email if email.subject == "A new event in your country!"
- @notification_tag = email if email.subject == "A new event of your interest!" }
- assert_equal @notification_country.to, [interested_user_1.email]
- assert_equal @notification_tag.to, [interested_user_2.email]
- end
-
- it 'correctly redirects non-admin users' do
- event = make_event
- user = make_user(admin: false)
- sign_in_as(user)
-
- post :approve, params: { id: event.id , approve: { tweet: "1" } }
-
- assert_redirected_to root_path
-
- event.reload
-
- assert_equal(false, event.approved?)
- end
-
- it 'correctly redirects visitors' do
- event = make_event
-
- post :approve, params: { id: event.id , approve: { tweet: "1" } }
-
- assert_redirected_to sign_in_path
-
- event.reload
-
- assert_equal(false, event.approved?)
- end
- end
-
- describe '#show' do
- it 'shows the event details page to admin' do
- admin = make_user(admin: true)
- event = make_event
-
- sign_in_as(admin)
-
- get :show, params: { id: event.id }
-
- assert_response :success
- assert_template :show
- end
-
- it 'correctly redirects non-admin users' do
- user = make_user(admin: false)
- event = make_event
-
- sign_in_as(user)
-
- get :show, params: { id: event.id }
-
- assert_redirected_to root_path
- end
-
- it 'correctly redirects visitors' do
- get :show, params: { id: make_event.id }
-
- assert_redirected_to sign_in_path
- end
-
- it 'shows the event details page in csv format to admin' do
- admin = make_user(admin: true)
- event = make_event
-
- sign_in_as(admin)
-
- get :show, params: { id: event.id }, format: :csv
-
- assert_equal request.format, :csv
- end
- end
-
- describe '#destroy' do
- it 'destroys event on delete and redirects to admin page if user is admin' do
- admin = make_user(admin: true)
- event = make_event
- events = Event.all
-
- sign_in_as(admin)
-
- assert_equal 1, events.count
-
- get :destroy, params: { id: event.id }
-
- assert_equal 0, events.count
- assert_redirected_to admin_url
- end
- end
-end
diff --git a/test/controllers/applications_controller_test.rb b/test/controllers/applications_controller_test.rb
index 1fda6ca3..e6dcc3a0 100644
--- a/test/controllers/applications_controller_test.rb
+++ b/test/controllers/applications_controller_test.rb
@@ -102,7 +102,7 @@ class ApplicationsControllerTest < ActionController::TestCase
assert_redirected_to sign_in_path
end
- it 'does not show application of other users to non-admin users' do
+ it 'does not show application of other users' do
user = make_user
other_user = make_user(email: 'other@email.com')
sign_in_as(user)
@@ -115,41 +115,6 @@ class ApplicationsControllerTest < ActionController::TestCase
assert_redirected_to root_path
end
- it 'shows submitted application to admin users' do
- admin = make_admin
- sign_in_as(admin)
-
- event = make_event
- application = make_application(event)
-
- get :show, params: { event_id: event.id, id: application.id }
-
- assert_response :success
- end
-
- it 'redirects admin users to root if they try to see drafted applications' do
- admin = make_admin
- sign_in_as(admin)
-
- event = make_event
- draft = make_draft(event)
-
- get :show, params: { event_id: event.id, id: draft.id }
-
- assert_redirected_to root_path
- end
-
- it 'raise exception if application does not exist' do
- admin = make_admin
- sign_in_as(admin)
-
- event = make_event
-
- assert_raises(ActiveRecord::RecordNotFound) do
- get :show, params: { event_id: event.id, id: 1 }
- end
- end
-
it 'redirects users to applications overview if the event has been deleted' do
user = make_user
event = make_event(organizer_id: user.id)
@@ -169,7 +134,11 @@ class ApplicationsControllerTest < ActionController::TestCase
get :show, params: { event_id: event.id, id: application.id }
assert_redirected_to user_applications_path(user.id)
- assert_equal "You cannot view your application as the event you applied for has been removed from Diversity Tickets", flash[:alert]
+ assert_equal(
+ "You cannot view your application as the event you applied for has been removed from "\
+ "Diversity Tickets",
+ flash[:alert]
+ )
end
end
@@ -180,14 +149,15 @@ class ApplicationsControllerTest < ActionController::TestCase
event = make_event
application = make_application(event, { applicant_id: user.id })
- post :update, params: { event_id: event.id,
- id: application.id,
- application: { name: "New Name",
- email: user.email,
- email_confirmation: user.email,
- terms_and_conditions: '1'
- }
- }
+ post :update, params: {
+ event_id: event.id,
+ id: application.id,
+ application: { name: "New Name",
+ email: user.email,
+ email_confirmation: user.email,
+ terms_and_conditions: '1'
+ }
+ }
application.reload
@@ -200,10 +170,11 @@ class ApplicationsControllerTest < ActionController::TestCase
event = make_event
application = make_application(event, { applicant_id: user.id })
- post :update, params: { event_id: event.id,
- id: application.id,
- application: { name: "New Name" }
- }
+ post :update, params: {
+ event_id: event.id,
+ id: application.id,
+ application: { name: "New Name" }
+ }
application.reload
@@ -218,14 +189,15 @@ class ApplicationsControllerTest < ActionController::TestCase
event = make_event
application = make_draft(event, { applicant_id: user.id })
- post :submit, params: { event_id: event.id,
- id: application.id,
- application: {
- email: user.email,
- email_confirmation: user.email,
- terms_and_conditions: '1'
- }
- }
+ post :submit, params: {
+ event_id: event.id,
+ id: application.id,
+ application: {
+ email: user.email,
+ email_confirmation: user.email,
+ terms_and_conditions: '1'
+ }
+ }
application.reload
@@ -238,9 +210,11 @@ class ApplicationsControllerTest < ActionController::TestCase
event = make_event
application = make_draft(event, applicant_id: user.id)
- post :submit, params: { event_id: event.id,
- id: application.id,
- application: { applicant_id: user.id } }
+ post :submit, params: {
+ event_id: event.id,
+ id: application.id,
+ application: { applicant_id: user.id }
+ }
application.reload
@@ -258,20 +232,24 @@ class ApplicationsControllerTest < ActionController::TestCase
application = make_draft(event, { applicant_id: user.id })
- post :submit, params: { event_id: event.id,
- id: application.id,
- application: {
- email: user.email,
- email_confirmation: user.email,
- terms_and_conditions: '1'
- }
- }
+ post :submit, params: {
+ event_id: event.id,
+ id: application.id,
+ application: {
+ email: user.email,
+ email_confirmation: user.email,
+ terms_and_conditions: '1'
+ }
+ }
reminder_email = ActionMailer::Base.deliveries.last
- assert_equal reminder_email.subject, "Your event received more applications than available tickets."
+ assert_equal(
+ reminder_email.subject,
+ "Your event received more applications than available tickets."
+ )
end
- it 'sends an email to the organizer if they have decided that want to get
- informed when the event reached the maximum number of applications only once' do
+ it 'sends an email to the organizer if they have decided that want to get'\
+ 'informed when the event reached the maximum number of applications only once' do
organizer = make_user(capacity_email_notifications: "once")
event = make_event(number_of_tickets: 1, organizer_id: organizer.id)
user = make_user(email: "applicant@test.de")
@@ -285,24 +263,29 @@ class ApplicationsControllerTest < ActionController::TestCase
application = make_draft(event, { applicant_id: user.id })
- post :submit, params: { event_id: event.id,
- id: application.id,
- application: {
- email: user.email,
- email_confirmation: user.email,
- terms_and_conditions: '1'
- }
- }
+ post :submit, params: {
+ event_id: event.id,
+ id: application.id,
+ application: {
+ email: user.email,
+ email_confirmation: user.email,
+ terms_and_conditions: '1'
+ }
+ }
reminder_emails = []
emails = ActionMailer::Base.deliveries
- emails.each { |email| reminder_emails << email if email.subject == "Your event received more applications than available tickets." }
- assert_equal 1, reminder_emails.length
+ emails.each do |email|
+ if email.subject == "Your event received more applications than available tickets."
+ reminder_emails << email
+ end
+ end
+ assert_equal 1, reminder_emails.length
end
end
describe '#destroy' do
- it 'non-admin users can delete their own applications' do
+ it 'users can delete their own applications' do
user = make_user(admin: false)
sign_in_as(user)
diff --git a/test/controllers/events_controller_test.rb b/test/controllers/events_controller_test.rb
index 8f14463a..8ba05e8f 100644
--- a/test/controllers/events_controller_test.rb
+++ b/test/controllers/events_controller_test.rb
@@ -4,11 +4,12 @@ class EventsControllerTest < ActionController::TestCase
before do
make_application_process_options_handler
end
-
+
describe '#create' do
- it 'successfully creates event and sends etest' do
+ it 'successfully creates event and sends expected emails' do
admin_user = make_admin
- sign_in_as(admin_user)
+ user = make_user
+ sign_in_as(user)
ActionMailer::Base.deliveries.clear
@@ -20,19 +21,19 @@ class EventsControllerTest < ActionController::TestCase
organizer_email_confirmation: 'ruby@example.com',
application_process: 'selection_by_travis'
})
- }
+ }
assert_equal 'Thank you for submitting Ruby Conf. We will review it shortly.', flash[:notice]
assert_redirected_to events_path
- admin_email = ActionMailer::Base.deliveries.find {|d| d.to == ['admin@woo.hoo']}
+ admin_email = ActionMailer::Base.deliveries.find { |d| d.to == ['admin@woo.hoo'] }
assert_equal admin_email.subject, 'A new event has been submitted.'
assert_match admin_email.body, /Ruby Conf/
assert_match admin_email.body, /Organizer Name: Ruby Fakename/
assert_match admin_email.body, /Organizer Email: ruby@example.com/
assert_match admin_email.body, /Application Process: Selection by travis/
- organizer_email = ActionMailer::Base.deliveries.find {|d| d.to == ['ruby@example.com']}
+ organizer_email = ActionMailer::Base.deliveries.find { |d| d.to == ['ruby@example.com'] }
assert_equal organizer_email.subject, 'You submitted a new event.'
assert_equal Event.last.name, 'Ruby Conf'
@@ -363,16 +364,6 @@ class EventsControllerTest < ActionController::TestCase
end
describe '#edit' do
- it 'loads correctly for admin users' do
- user = make_user(admin: true)
- event = make_event
- sign_in_as(user)
-
- get :edit, params: { id: event.id }
-
- assert_response :success
- end
-
it 'loads correctly for event owner' do
user = make_user(admin: false)
event = make_event(
@@ -419,19 +410,6 @@ class EventsControllerTest < ActionController::TestCase
end
describe '#update' do
- it 'loads correctly for admin users' do
- user = make_user(admin: true)
- event = make_event(name: 'BoringConf')
- sign_in_as(user)
-
- put :update, params: { id: event.id, event: {name: 'MonstersConf'} }
-
- event.reload
-
- assert_equal 'MonstersConf', event.name
- assert_redirected_to "http://test.host/"
- end
-
it 'loads correctly for event owner' do
user = make_user(admin: false)
event = make_event(
@@ -439,7 +417,7 @@ class EventsControllerTest < ActionController::TestCase
organizer_id: user.id,
approved: false,
deadline: 5.days.from_now
- )
+ )
sign_in_as(user)
put :update, params: { id: event.id, event: {name: 'MonstersConf'} }
@@ -456,7 +434,7 @@ class EventsControllerTest < ActionController::TestCase
approved: false,
organizer_id: user.id,
deadline: 5.days.from_now
- )
+ )
sign_in_as(user)
put :update, params: { id: event.id, event: {approved: true} }
@@ -467,27 +445,6 @@ class EventsControllerTest < ActionController::TestCase
assert_equal false, event.approved?
end
- it 'changes approval status when admin is updating' do
- admin = make_user(admin: true)
- event_owner = make_user(
- admin: false,
- email: 'different_address@example.org'
- )
- event = make_event(
- approved: false,
- organizer_id: event_owner.id,
- deadline: 5.days.from_now
- )
- sign_in_as(admin)
-
- put :update, params: { id: event.id, event: { approved: true } }
-
- event.reload
-
- assert_redirected_to "http://test.host/"
- assert_equal true, event.approved?
- end
-
it 'rerenders edit when event update was not successful' do
organizer = make_user
event = make_event(organizer_id: organizer.id)
@@ -500,8 +457,8 @@ class EventsControllerTest < ActionController::TestCase
it 'renders a forbidden 403 status code when unauthorized user tries to update event info' do
user = make_user
- organizer = make_user( email: 'other@example.org' )
- event = make_event( organizer_id: organizer.id )
+ organizer = make_user(email: 'other@example.org')
+ event = make_event(organizer_id: organizer.id)
sign_in_as(user)
put :update, params: { id: event.id, event: { name: 'Fakename' } }
diff --git a/test/controllers/tags_controller_test.rb b/test/controllers/tags_controller_test.rb
deleted file mode 100644
index 9f89589e..00000000
--- a/test/controllers/tags_controller_test.rb
+++ /dev/null
@@ -1,83 +0,0 @@
-require 'test_helper'
-
-class TagsControllerTest < ActionController::TestCase
- describe '#index' do
- it 'shows all Tags already created to admins' do
- setup do
- 3.times { make_tag(name: "New event", category_id: 1) }
- end
-
- admin = make_user(admin: true)
- sign_in_as(admin)
-
- get :index
-
- assert_response :success
- assert_template 'tags/index'
- end
-
- it 'does not show all Tags already created to non-admins' do
- setup do
- 3.times { make_tag(name: "New event", category_id: 1) }
- end
-
- user = make_user
- sign_in_as(user)
-
- get :index
-
- assert_redirected_to root_path
- end
- end
-
- describe '#create' do
- it 'allows an admin user to create a new tag with a name and a category' do
- admin = make_user(admin: true)
- sign_in_as(admin)
-
- put :create, params: { tag: { name: "New Tag", category_id: 1 } }
-
- assert_redirected_to tags_path
- assert_equal "Tag New Tag was successfully created.", flash[:notice]
- assert_equal Tag.last.name, "New Tag"
- end
-
- it 'shows a flash message if there was a problem creating the tag' do
- admin = make_user(admin: true)
- sign_in_as(admin)
-
- put :create, params: { tag: { name: "New Tag" } }
-
- assert_redirected_to tags_path
- assert_equal "There was a problem creating the new tag.", flash[:alert]
- end
-
- it 'does not allow non-admin user to create a new tag' do
- make_tag
-
- user = make_user
- sign_in_as(user)
-
- put :create, params: { tag: { name: "Non Created Tag", category_id: 1 } }
-
- assert_redirected_to root_path
- assert_not_equal "Non Created Tag", Tag.last.name
- end
- end
-
- describe '#destroy' do
- it 'allows admin to delete tags' do
- make_tag(name: "New event", category_id: 1)
-
- all_tags = Tag.all.count
-
- admin = make_user(admin: true)
- sign_in_as(admin)
-
- delete :destroy, params: { id: Tag.last.id }
-
- assert_redirected_to tags_path
- assert_equal all_tags - 1, Tag.all.count
- end
- end
-end
diff --git a/test/integration/admin_event_details_test.rb b/test/integration/admin_event_details_test.rb
index 2de646bb..1e0ea9c1 100644
--- a/test/integration/admin_event_details_test.rb
+++ b/test/integration/admin_event_details_test.rb
@@ -2,7 +2,6 @@
include ApplicationHelper
feature 'Admin Event Details' do
-
def setup
make_application_process_options_handler
@admin = make_admin
@@ -35,7 +34,6 @@ def setup
visit admin_event_path(@event.id)
assert_not page.has_content?('Mary')
-
end
test 'shows submitted applications on event details page for admin' do
@@ -90,7 +88,7 @@ def setup
page.first('a.btn.btn-save.approve-application').click
- assert page.has_content?("Peter's application has been approved!")
+ assert page.has_content?("Peter's application has been approved")
assert page.has_content?("Approved applications (2)")
assert page.has_content?("Pending applications (1)")
@@ -134,10 +132,10 @@ def setup
visit admin_event_path(@event.id)
- assert page.has_selector?("input[type=submit][value='Approve event']")
- click_button("Approve event")
+ assert page.has_selector?("input[type=submit][value='Approve']")
+ click_button("Approve")
- assert page.has_content?("#{@event.name} has been approved!")
+ assert page.has_content?("#{@event.name} has been approved")
end
test 'shows correct number of approved tickets' do
diff --git a/test/integration/admin_events_test.rb b/test/integration/admin_events_test.rb
index a9d93de7..e3f223c1 100644
--- a/test/integration/admin_events_test.rb
+++ b/test/integration/admin_events_test.rb
@@ -42,10 +42,10 @@
end
def unapproved_events_box
- first('.box', text: 'Unapproved events')
+ first('.box', text: 'Unapproved Events')
end
def approved_events_box
- first('.box', text: 'Approved events')
+ first('.box', text: 'Approved Events')
end
end
diff --git a/test/integration/application_page_test.rb b/test/integration/application_page_test.rb
index 369fbdd8..23e8d7aa 100644
--- a/test/integration/application_page_test.rb
+++ b/test/integration/application_page_test.rb
@@ -3,23 +3,16 @@
feature 'Application Page' do
def setup
@user = make_user
- @admin = make_admin
@event = make_event(name: 'The Event', approved: true)
@application = make_application(
- @event,
- applicant_id: @user.id,
- attendee_info_1: 'I would like to learn Ruby',
- attendee_info_2: 'I can not afford the ticket'
- )
- @admin_application = make_application(
- @event,
- applicant_id: @admin.id,
- attendee_info_1: 'I would like to learn Ruby as admin',
- attendee_info_2: 'I can not afford the ticket as admin'
- )
+ @event,
+ applicant_id: @user.id,
+ attendee_info_1: 'I would like to learn Ruby',
+ attendee_info_2: 'I can not afford the ticket'
+ )
end
- test 'shows Your applications in the breadcrumb if the user is not an admin' do
+ test 'shows Your applications in the breadcrumb' do
sign_in_as_user
visit user_applications_path(@user.id)
@@ -33,15 +26,7 @@ def setup
assert_equal 2, page.all("a[href='/en/users/#{@user.id}/applications']").count
end
- test 'shows link to delete this application if user is an admin' do
- sign_in_as_admin
-
- visit event_application_path(@event.id, @application.id)
-
- assert page.has_content?('Delete')
- end
-
- test 'shows link to Delete if user is an applicant and event-deadline has not passed' do
+ test 'shows link to Delete if user is the applicant and event-deadline has not passed' do
sign_in_as_user
visit event_application_path(@event.id, @application.id)
@@ -49,7 +34,7 @@ def setup
assert page.has_content?('Delete')
end
- test 'does not show link to Delete if user is an applicant and event-deadline has passed' do
+ test 'does not show link to Delete if user is the applicant and event-deadline has passed' do
@event.update_attributes(deadline: 1.day.ago)
sign_in_as_user
@@ -75,14 +60,6 @@ def setup
assert page.has_content?('Edit')
end
- test 'shows a button to the admin-applicant to edit their application if deadline has not passed' do
- sign_in_as_admin
-
- visit event_application_path(@event.id, @admin_application.id)
-
- assert page.has_content?('Edit')
- end
-
test 'shows no edit-button to the applicant if deadline has already passed' do
sign_in_as_user
@@ -97,7 +74,7 @@ def setup
assert_not page.has_content?('Edit')
end
- test 'does not allow non-admin-users to see other users applications' do
+ test 'does not allow user to see other users applications' do
other_user = make_user(email: 'other@email.de')
other_application = make_application(@event, applicant_id: other_user.id)
sign_in_as_user