Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor admin panel #521

Merged
merged 1 commit into from
Oct 22, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion app/assets/javascripts/application.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
20 changes: 0 additions & 20 deletions app/assets/javascripts/map-expander.js

This file was deleted.

150 changes: 150 additions & 0 deletions app/assets/stylesheets/admin.scss
Original file line number Diff line number Diff line change
@@ -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%);
}
}
}
1 change: 1 addition & 0 deletions app/assets/stylesheets/application.css.scss
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
101 changes: 0 additions & 101 deletions app/assets/stylesheets/events.scss
Original file line number Diff line number Diff line change
Expand Up @@ -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%);
}
}
}
10 changes: 0 additions & 10 deletions app/assets/stylesheets/map.scss
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,4 @@ div.map-statistics {
}
}
}
.map-expander-btn {
&:active, &:hover {
color: $green;
cursor: pointer;
}
.rotated {
transform: rotate(180deg);
background-position: 12px 2px;
}
}
}
76 changes: 76 additions & 0 deletions app/controllers/admin/applications_controller.rb
Original file line number Diff line number Diff line change
@@ -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
Loading