-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Co-authored-by: Gary Tou <[email protected]>
- Loading branch information
1 parent
32ee248
commit 7fd5295
Showing
26 changed files
with
357 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
.button-group { | ||
display: flex; | ||
} | ||
|
||
.button-group > * { | ||
margin-right: 1.5rem; | ||
} | ||
|
||
.button--success { | ||
background-color: limegreen; | ||
} | ||
|
||
.button--neutral { | ||
background-color: darkgray; | ||
} | ||
|
||
.button--danger { | ||
background-color: crimson; | ||
} | ||
|
||
.button { | ||
padding: 0.5rem !important; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
.hackathon-snippet { | ||
border: 3px solid; | ||
padding: 0.5rem; | ||
display: flex; | ||
} | ||
|
||
.hackathon-snippet__title { | ||
margin: 0 !important; | ||
font-weight: normal; | ||
} | ||
|
||
.hackathon-snippet__time { | ||
margin-left: auto; | ||
text-decoration: none !important; | ||
} | ||
|
||
.hackathon > * { | ||
margin-top: 1rem; | ||
} | ||
|
||
.hackathon--pending { | ||
border-color: darkgray; | ||
} | ||
|
||
.hackathon--approved { | ||
border-color: limegreen; | ||
} | ||
|
||
.hackathon--rejected { | ||
border-color: red; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
.timeline__event { | ||
padding: 0.5rem; | ||
margin-bottom: 0.5rem; | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
$spacing-unit: 1rem; | ||
|
||
@each $direction in (top, bottom, left, right) { | ||
.push--#{$direction} { | ||
margin-#{$direction}: $spacing-unit; | ||
} | ||
|
||
.push-double--#{$direction} { | ||
margin-#{$direction}: $spacing-unit * 2; | ||
} | ||
|
||
.push-half--#{$direction} { | ||
margin-#{$direction}: $spacing-unit / 2; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,7 @@ | ||
.heading--small { | ||
font-size: 1.5rem; | ||
} | ||
|
||
.heading--medium { | ||
font-size: 2rem; | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
class Admin::BaseController < ApplicationController | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
class Admin::Hackathons::ApprovalsController < Admin::BaseController | ||
include HackathonScoped | ||
|
||
def create | ||
@hackathon.approve | ||
redirect_to admin_hackathon_path(@hackathon) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
class Admin::Hackathons::HoldsController < Admin::BaseController | ||
include HackathonScoped | ||
|
||
def create | ||
@hackathon.hold | ||
redirect_to admin_hackathon_path(@hackathon) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
class Admin::Hackathons::RejectionsController < Admin::BaseController | ||
include HackathonScoped | ||
|
||
def create | ||
@hackathon.reject | ||
redirect_to admin_hackathon_path(@hackathon) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
class Admin::HackathonsController < Admin::BaseController | ||
before_action :set_hackathon, only: [:show, :edit, :update, :destroy] | ||
|
||
def index | ||
@pagy, @hackathons = pagy(Hackathon.all.order(created_at: :desc)) | ||
end | ||
|
||
def show | ||
end | ||
|
||
def edit | ||
end | ||
|
||
def update | ||
if @hackathon.update(hackathon_params) | ||
redirect_to admin_hackathon_path(@hackathon) | ||
else | ||
render :edit, status: :unprocessable_entity, notice: @hackathon.errors.full_messages.to_sentence | ||
end | ||
end | ||
|
||
def destroy | ||
if @hackathon.destroy | ||
redirect_to admin_hackathons_path, notice: "#{@hackathon.name} has been deleted." | ||
else | ||
render :show, status: :unprocessable_entity, notice: @hackathon.errors.full_messages.first | ||
end | ||
end | ||
|
||
private | ||
|
||
def hackathon_params | ||
params.require(:hackathon).permit( | ||
:name, | ||
:website, | ||
:logo, | ||
:banner, | ||
:starts_at, | ||
:ends_at, | ||
:address, | ||
:expected_attendees, | ||
:offers_financial_assistance, | ||
:requested_swag, | ||
swag_mailing_address_attributes: [ | ||
:line1, | ||
:line2, | ||
:city, | ||
:province, | ||
:postal_code, | ||
:country_code | ||
], | ||
applicant: [ | ||
:name, | ||
:email_address | ||
] | ||
) | ||
end | ||
|
||
def set_hackathon | ||
@hackathon = Hackathon.find(params[:id]) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,6 @@ | ||
class ApplicationController < ActionController::Base | ||
include Pagy::Backend | ||
|
||
include SetCurrentRequestDetails | ||
include Authenticate | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
module Hackathon::Reviewable | ||
extend ActiveSupport::Concern | ||
|
||
included do | ||
scope :reviewed_by, ->(user) { | ||
joins(:events) | ||
.where(events: | ||
{action: [:approved, :rejected, :held], | ||
creator: user}) | ||
} | ||
end | ||
|
||
def reviewers | ||
events.where(action: [:approved, :rejected, :held]).collect(&:creator) | ||
end | ||
|
||
def approve | ||
transaction do | ||
record :approved | ||
update! status: :approved | ||
end | ||
end | ||
|
||
def reject | ||
transaction do | ||
record :rejected | ||
update! status: :rejected | ||
end | ||
end | ||
|
||
def hold | ||
transaction do | ||
record :held_for_review | ||
update! status: :pending | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,12 @@ | ||
class MailingAddress < ApplicationRecord | ||
validates :line1, :city, :country_code, presence: true | ||
validates :country_code, inclusion: {in: ISO3166::Country.codes} | ||
|
||
def full | ||
components = [] | ||
components << [line1, line2].compact.join(" ") | ||
components << city << province << postal_code << country_code | ||
|
||
components.compact.join(", ") | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<%= link_to admin_hackathon_path(hackathon) do %> | ||
<article id="<%= dom_id(hackathon) %>" class="hackathon-snippet hackathon--<%= hackathon.status %>"> | ||
<h2 class="heading--small hackathon-snippet__title"><%= hackathon.name %></h2> | ||
<span class="hackathon-snippet__time">created <%= local_time_ago(hackathon.created_at) %></span> | ||
</article> | ||
<% end %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<h1>Hackathons</h1> | ||
|
||
<% @hackathons.each do |hackathon| %> | ||
<%= render "snippet", hackathon: %> | ||
<% end %> | ||
|
||
<%== pagy_nav(@pagy) %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
<% content_for :title, @hackathon.name %> | ||
|
||
<% content_for :nav do %> | ||
<%= link_to "◀ Back to Hackathons", admin_hackathons_path, class: "button" %> | ||
<% end %> | ||
|
||
<div id="<%= dom_id(@hackathon) %>" class="hackathon"> | ||
<h1 class="heading--medium"> | ||
<%= @hackathon.name %> | ||
</h1> | ||
|
||
<% if @hackathon.logo.present? || @hackathon.banner.present? %> | ||
<section style="display: flex;"> | ||
<% if @hackathon.logo.present? %> | ||
<div> | ||
<h2 class="heading--small">Logo</h2> | ||
<%= image_tag @hackathon.logo, size: 128 %> | ||
</div> | ||
<% end %> | ||
|
||
<% if @hackathon.banner.present? %> | ||
<div> | ||
<h2 class="heading--small">Banner</h2> | ||
<%= image_tag @hackathon.banner, height: 128 %> | ||
</div> | ||
<% end %> | ||
</section> | ||
<% end %> | ||
|
||
<div> | ||
Status: | ||
<%= @hackathon.status %> | ||
</div> | ||
|
||
<div> | ||
High School Led: | ||
<%= @hackathon.high_school_led? ? "Yes" : "No" %> | ||
</div> | ||
|
||
<div> | ||
Applicant: | ||
<%= "#{@hackathon.applicant.name}, " if @hackathon.applicant.name.present? %> | ||
<%= @hackathon.applicant.email_address %> | ||
</div> | ||
|
||
<div> | ||
Website: | ||
<%= @hackathon.website %> | ||
</div> | ||
|
||
<div> | ||
Starts <%= local_time_ago(@hackathon.starts_at) %>, | ||
ends <%= local_time_ago(@hackathon.ends_at) %> | ||
</div> | ||
|
||
<div> | ||
Expected Attendees: | ||
<%= @hackathon.expected_attendees %> <%= @hackathon.modality.humanize(capitalize: false) %> | ||
</div> | ||
|
||
<div> | ||
Location: | ||
|
||
<%= @hackathon.address %> | ||
|
||
<% if @hackathon.latitude %> | ||
<span title="latitude, longitude">- <%= @hackathon.latitude %>, <%= @hackathon.longitude %></span> | ||
<% end %> | ||
</div> | ||
|
||
<div> | ||
<% if @hackathon.requested_swag? %> | ||
Swag requested for: <%= @hackathon.swag_mailing_address.full %> | ||
<% else %> | ||
No swag requested. | ||
<% end %> | ||
</div> | ||
|
||
<div class="button-group"> | ||
<% if @hackathon.pending? %> | ||
<%= button_to "Approve", admin_hackathon_approval_path(@hackathon), class: "button--success" %> | ||
<%= button_to "Reject", admin_hackathon_rejection_path(@hackathon), class: "button--danger" %> | ||
<% end %> | ||
<% unless @hackathon.pending? %> | ||
<%= button_to "Hold for review", admin_hackathon_hold_path(@hackathon), class: "button--neutral" %> | ||
<% end %> | ||
</div> | ||
|
||
<section> | ||
<%= render "events/timeline", {eventable: @hackathon} %> | ||
</section> | ||
</div> |
Oops, something went wrong.