-
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.
- Loading branch information
1 parent
af17b78
commit 5b15d03
Showing
23 changed files
with
288 additions
and
14 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,7 @@ | ||
.button-group { | ||
display: flex; | ||
} | ||
|
||
.button-group > * { | ||
margin-right: 1.5rem; | ||
} |
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--pending { | ||
border-color: darkgray; | ||
} | ||
|
||
.hackathon--approved { | ||
border-color: limegreen; | ||
} | ||
|
||
.hackathon--rejected { | ||
border-color: red; | ||
} | ||
|
||
.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; | ||
} |
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 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
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 |
---|---|---|
|
@@ -6,6 +6,6 @@ module User::Named | |
end | ||
|
||
def first_name | ||
name.split(" ").first | ||
name&.split(" ")&.first | ||
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,61 @@ | ||
<% content_for :title, @hackathon.name %> | ||
|
||
<div id="<%= dom_id(@hackathon) %>" class="hackathon"> | ||
<h1 class="heading--medium"> | ||
<%= @hackathon.name %> | ||
</h1> | ||
|
||
<div> | ||
Status: | ||
<%= @hackathon.status %> | ||
</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"> | ||
<%= button_to "Approve", admin_hackathon_approval_path(@hackathon) %> | ||
<%= button_to "Reject", admin_hackathon_rejection_path(@hackathon) %> | ||
<%= button_to "Hold", admin_hackathon_hold_path(@hackathon) %> | ||
</div> | ||
|
||
<section> | ||
<%= render "events/timeline", {eventable: @hackathon} %> | ||
</section> | ||
</div> |
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 @@ | ||
<% eventable.events.includes(:creator, :target).each do |event| %> | ||
<article id="<%= dom_id(event) %>" class="timeline__event"> | ||
<%= event.description %> | ||
<i><%= local_time_ago(event.created_at) %></i> | ||
</article> | ||
<% end %> |
Empty file.
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