Skip to content

Commit 01f549e

Browse files
Hackathon applications (#77)
With this, we're allowing unauthenticated submissions as well. If this ever becomes a problem, our amazing event tracking system will make it easy to do forensics, response, etc. because it shows if an (authenticated) user is inducing an event and associated request details.
1 parent 4d4c6ad commit 01f549e

40 files changed

+427
-46
lines changed

Gemfile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,11 @@ gem "airrecord" # Airtable client
1616

1717
# Assets
1818
gem "sprockets-rails"
19+
gem "sass-rails"
1920
gem "importmap-rails"
2021
gem "turbo-rails"
2122
gem "stimulus-rails"
23+
gem "local_time"
2224
gem "premailer-rails" # Inline CSS for emails
2325

2426
# Active Storage

Gemfile.lock

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,7 @@ GEM
166166
railties (>= 5.2)
167167
rexml
168168
lint_roller (1.1.0)
169+
local_time (2.1.0)
169170
loofah (2.21.3)
170171
crass (~> 1.0.2)
171172
nokogiri (>= 1.12.0)
@@ -280,6 +281,16 @@ GEM
280281
ffi (~> 1.12)
281282
ruby2_keywords (0.0.5)
282283
rubyzip (2.3.2)
284+
sass-rails (6.0.0)
285+
sassc-rails (~> 2.1, >= 2.1.1)
286+
sassc (2.4.0)
287+
ffi (~> 1.9)
288+
sassc-rails (2.1.2)
289+
railties (>= 4.0.0)
290+
sassc (>= 2.0)
291+
sprockets (> 3.0)
292+
sprockets-rails
293+
tilt
283294
selenium-webdriver (4.11.0)
284295
rexml (~> 3.2, >= 3.2.5)
285296
rubyzip (>= 1.2.2, < 3.0)
@@ -312,6 +323,7 @@ GEM
312323
stimulus-rails (1.2.2)
313324
railties (>= 6.0.0)
314325
thor (1.2.2)
326+
tilt (2.2.0)
315327
timeout (0.4.0)
316328
turbo-rails (1.4.0)
317329
actionpack (>= 6.0.0)
@@ -359,13 +371,15 @@ DEPENDENCIES
359371
importmap-rails
360372
jbuilder
361373
letter_opener_web
374+
local_time
362375
pagy
363376
pg
364377
premailer-rails
365378
puma
366379
rack-mini-profiler
367380
rails (~> 7.0.6)
368381
redis
382+
sass-rails
369383
selenium-webdriver
370384
shoulda
371385
spring
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
@keyframes appear-then-fade {
2+
0%,100% {
3+
opacity: 0
4+
}
5+
6+
6%,66% {
7+
opacity: 1
8+
}
9+
}

app/assets/stylesheets/application.css

Lines changed: 0 additions & 15 deletions
This file was deleted.
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
@import "*";
2+
@import "components/*";
3+
4+
body {
5+
overflow-y: scroll;
6+
scrollbar-gutter: stable;
7+
}
8+
9+
.field_with_errors {
10+
border: darkred 1px solid;
11+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
.flash-notice {
2+
position: fixed;
3+
top: 5rem;
4+
width: 100%;
5+
display: flex;
6+
justify-content: center;
7+
}
8+
9+
.flash-notice__content {
10+
background-color: rgba(35, 28, 51, 0.75);
11+
animation: appear-then-fade 6s 250ms both;
12+
border-radius: 5rem;
13+
padding: .5rem 1.5rem;
14+
display: flex;
15+
align-items: center;
16+
color: gainsboro;
17+
backdrop-filter: blur(3px) contrast(0.5)
18+
}

app/assets/stylesheets/spacing.css

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
.push--top {
2+
margin-top: 1rem;
3+
}

app/assets/stylesheets/text.scss

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
.heading--medium {
2+
font-size: 2rem;
3+
}
4+
5+
.text--small {
6+
font-size: 1rem;
7+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
module HackathonScoped
2+
extend ActiveSupport::Concern
3+
4+
included do
5+
before_action :set_hackathon, except: [:index, :new, :create]
6+
end
7+
8+
private
9+
10+
def set_hackathon
11+
@hackathon = Hackathon.find(params[:hackathon_id])
12+
end
13+
end
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
class Hackathons::SubmissionsController < ApplicationController
2+
skip_before_action :redirect_if_unauthenticated, only: %i[new create]
3+
4+
def index
5+
@hackathons = Hackathon.not_approved.where applicant: Current.user
6+
7+
redirect_to new_hackathons_submission_path if @hackathons.none?
8+
end
9+
10+
def new
11+
@hackathon = Hackathon.new
12+
@hackathon.build_swag_mailing_address
13+
end
14+
15+
def create
16+
@hackathon = Hackathon.new(
17+
hackathon_params.except(:applicant, :offers_financial_assistance, :requested_swag)
18+
)
19+
20+
if hackathon_params[:requested_swag] == "0"
21+
@hackathon.swag_mailing_address = nil
22+
end
23+
24+
@hackathon.applicant = User.find_or_initialize_by(hackathon_params[:applicant])
25+
26+
if @hackathon.save context: :submit
27+
if hackathon_params[:offers_financial_assistance]
28+
@hackathon.tag_with! "Offers Financial Assistance"
29+
end
30+
31+
redirect_to new_hackathons_submission_path, notice: "Your hackathon has been submitted for approval!"
32+
else
33+
render :new, status: :unprocessable_entity
34+
end
35+
end
36+
37+
def show
38+
@hackathon = Hackathon.not_approved.where(applicant: Current.user).find(params[:id])
39+
end
40+
41+
private
42+
43+
def hackathon_params
44+
params.require(:hackathon).permit(
45+
:name,
46+
:website,
47+
:logo,
48+
:banner,
49+
:starts_at,
50+
:ends_at,
51+
:address,
52+
:expected_attendees,
53+
:offers_financial_assistance,
54+
:requested_swag,
55+
swag_mailing_address_attributes: [
56+
:line1,
57+
:line2,
58+
:city,
59+
:province,
60+
:postal_code,
61+
:country_code
62+
],
63+
applicant: [
64+
:email_address
65+
]
66+
)
67+
end
68+
end

0 commit comments

Comments
 (0)