Skip to content

Commit

Permalink
Merge branch '2.0' into hm-242
Browse files Browse the repository at this point in the history
  • Loading branch information
cbaudouinjr committed Sep 20, 2020
2 parents b5ad3b8 + d87269d commit 3f2a30c
Show file tree
Hide file tree
Showing 27 changed files with 154 additions and 110 deletions.
5 changes: 5 additions & 0 deletions app/assets/stylesheets/forms/_forms.sass
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,11 @@ hr
.btn
margin-bottom: 30px

.text-overflow-center
text-align: center
display: flex
justify-content: center

.simple_form
@include css4
color: var(--grey)
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/manage/application_controller.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
class Manage::ApplicationController < ApplicationController
before_action :logged_in
before_action :require_director_or_organizer_or_volunteer
before_action :limit_write_access_to_directors, only: ["edit", "update", "new", "create", "destroy", "convert_to_admin", "deliver", "merge", "perform_merge", "toggle_bus_captain", "duplicate", "update_acc_status", "send_update_email", "live_preview"]
before_action :limit_write_access_to_directors, only: ["edit", "update", "new", "create", "destroy", "deliver", "merge", "perform_merge", "toggle_bus_captain", "duplicate", "update_acc_status", "send_update_email", "live_preview"]
skip_before_action :verify_authenticity_token, if: :json_request?

def logged_in
Expand Down
9 changes: 1 addition & 8 deletions app/controllers/manage/questionnaires_controller.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
class Manage::QuestionnairesController < Manage::ApplicationController
include QuestionnairesControllable

before_action :set_questionnaire, only: [:show, :edit, :update, :destroy, :check_in, :convert_to_director, :update_acc_status]
before_action :set_questionnaire, only: [:show, :edit, :update, :destroy, :check_in, :update_acc_status]

respond_to :html, :json

Expand Down Expand Up @@ -95,13 +95,6 @@ def check_in
redirect_to index_redirect_path
end

def convert_to_director
user = @questionnaire.user
@questionnaire.destroy
user.update_attributes(role: :director)
redirect_to edit_manage_user_path(user)
end

def destroy
@questionnaire.destroy
respond_with(:manage, @questionnaire)
Expand Down
1 change: 1 addition & 0 deletions app/controllers/questionnaires_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ def create
if current_user.reload.questionnaire.present?
return redirect_to questionnaires_path, notice: 'Application already exists.'
end
return unless HackathonConfig['accepting_questionnaires']
@questionnaire = Questionnaire.new(convert_school_name_to_id(questionnaire_params))
@questionnaire.user_id = current_user.id

Expand Down
9 changes: 8 additions & 1 deletion app/mailers/user_mailer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,15 @@ def bulk_message_email(message_id, user_id, message = nil, use_examples = false)

def incomplete_reminder_email(user_id)
@user = User.find_by_id(user_id)
return if @user.blank? || @user.director? || @user.questionnaire || Time.now.to_date > Date.parse(HackathonConfig["last_day_to_apply"])
return if @user.blank? || @user.director? || @user.questionnaire || Time.now.in_time_zone.to_date > Date.parse(HackathonConfig["last_day_to_apply"]).in_time_zone.to_date

Message.queue_for_trigger("user.24hr_incomplete_application", @user.id)
end

def rsvp_reminder_email(user_id)
@user = User.find_by_id(user_id)
return if @user.blank? || !@user.questionnaire.acc_status == "accepted" || Time.now.in_time_zone.to_date > Date.parse(HackathonConfig["event_start_date"]).in_time_zone.to_date

Message.queue_for_trigger("questionnaire.rsvp_reminder", @user.id)
end
end
1 change: 1 addition & 0 deletions app/models/message.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ class Message < ApplicationRecord
"questionnaire.late_waitlist" => "Questionnaire Status: Waitlisted, Late",
"questionnaire.rsvp_confirmed" => "Questionnaire Status: RSVP Confirmed",
"questionnaire.rsvp_denied" => "Questionnaire Status: RSVP Denied",
"questionnaire.rsvp_reminder" => "Questionnaire: RSVP Reminder",
"user.24hr_incomplete_application" => "User: Incomplete application (24 hours later)",
"bus_list.new_captain_confirmation" => "Bus List: New captain confirmation",
"bus_list.notes_update" => "Bus List: Updated notes (manually triggered)"
Expand Down
15 changes: 15 additions & 0 deletions app/models/questionnaire.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ class Questionnaire < ApplicationRecord
before_validation :clean_negative_dietary_restrictions
after_create :queue_triggered_email_create
after_update :queue_triggered_email_update
after_update :queue_triggered_email_rsvp_reminder
after_save :update_school_questionnaire_count
after_destroy :update_school_questionnaire_count

Expand Down Expand Up @@ -249,4 +250,18 @@ def queue_triggered_email_update
def queue_triggered_email_create
Message.queue_for_trigger("questionnaire.#{acc_status}", user_id)
end

def queue_triggered_email_rsvp_reminder
if saved_change_to_acc_status? && acc_status == "accepted"
days_remaining = Date.parse(HackathonConfig["event_start_date"]).in_time_zone.to_date - Time.now.in_time_zone.to_date
if days_remaining > 14
deliver_date = 7.days.from_now
elsif days_remaining > 10
deliver_date = 5.days.from_now
elsif days_remaining > 3
deliver_date = 2.days.from_now
end
UserMailer.rsvp_reminder_email(user_id).deliver_later(wait_until: deliver_date) if deliver_date.present?
end
end
end
2 changes: 1 addition & 1 deletion app/views/devise/passwords/edit.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
.form-container.password
.section-title.center
Change Your
%span.emphasized Password
.emphasized Password
= simple_form_for(resource, as: resource_name, url: password_path(resource_name), html: { method: :put }) do |f|
= f.error_notification
= f.input :reset_password_token, as: :hidden
Expand Down
2 changes: 1 addition & 1 deletion app/views/devise/passwords/new.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
.form-container.password
%h1.section-title.center
Reset Your
%span.emphasized Password
.emphasized Password

= render 'form'
2 changes: 1 addition & 1 deletion app/views/devise/registrations/new.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
.form-container.signup
%h1.section-title.center
Register for
%span.emphasized= HackathonConfig['name']
.emphasized.text-overflow-center= HackathonConfig['name']

- if !HackathonConfig['accepting_questionnaires'] || HackathonConfig['disclaimer_message'].present?
#disclaimer
Expand Down
2 changes: 1 addition & 1 deletion app/views/devise/sessions/new.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
.form-container.login
%h1.section-title.center
Sign in to
%span.emphasized= HackathonConfig['name']
.emphasized.text-overflow-center= HackathonConfig['name']
= render 'form'
2 changes: 1 addition & 1 deletion app/views/manage/configs/edit.html.haml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
:ruby
text_field_vars = %w()
markdown_field_vars = %w(bus_captain_notes thanks_for_rsvp_message thanks_for_applying_message disclaimer_message)
markdown_field_vars = %w(bus_captain_notes thanks_for_rsvp_message thanks_for_applying_message questionnaires_closed_message disclaimer_message)
css_field_vars = %w(custom_css)
form_field_vars = %w(disabled_fields)

Expand Down
12 changes: 7 additions & 5 deletions app/views/manage/questionnaires/_form.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -11,23 +11,25 @@
.card-body
- if @questionnaire&.user&.provider == 'mlh'
%h6.card-subtitle.mb-2
%span.badge.badge-info Provided by My MLH
%span.badge.badge-info Provided by MyMLH
= f.simple_fields_for :user, @questionnaire.user do |u|
= u.input :first_name, input_html: { "data-validate" => "presence" }, label: "First Name", autofocus: true
= u.input :last_name, input_html: { "data-validate" => "presence" }, label: "Last Name"
= f.input :email, input_html: { "data-validate" => "presence email", value: @questionnaire.user.try(:email) }, required: true, hint: 'Can be an existing user (without a questionnaire) or a new user. If this is a new user, they will receive a randomly-generated password that they must request a password reset for.'
= f.input :phone, input_html: { "data-validate" => "presence" }
= f.input :date_of_birth, start_year: Date.today.year - 18, end_year: Date.today.year - 90, order: [:month, :day, :year], input_html: { "data-validate" => "presence" }

= f.input :school_id, as: :school_selection, input_html: { "data-validate" => "presence" }
= f.input :level_of_study, input_html: { "data-validate" => "presence" }
= f.input :major, input_html: { "data-validate" => "presence" }
= f.input :shirt_size, as: :select, collection: Questionnaire::POSSIBLE_SHIRT_SIZES, include_blank: "(select one...)", input_html: { "data-validate" => "presence" }
= f.input :gender, input_html: { "data-validate" => "presence" }
= f.input :dietary_restrictions, label: "Dietary restrictions"
= f.input :special_needs, label: "Special needs"

.col-xl-6
.card.mb-4
.card-header Special notices
.card-body
= f.input :shirt_size, as: :select, collection: Questionnaire::POSSIBLE_SHIRT_SIZES, include_blank: "(select one...)", input_html: { "data-validate" => "presence" }
= f.input :dietary_restrictions, label: "Dietary restrictions"
= f.input :special_needs, label: "Special needs"
.card.mb-4
.card-header Resume
.card-body
Expand Down
6 changes: 0 additions & 6 deletions app/views/manage/questionnaires/show.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,6 @@
.btn-group{role: "group"}
- if current_user.director?
= link_to 'Edit', edit_manage_questionnaire_path(@questionnaire), class: 'btn btn-sm btn-outline-secondary'
- if current_user.director?
.btn-group{role: "group"}
%button.btn.btn-sm.btn-outline-secondary.dropdown-toggle#title-actions{"aria-expanded" => "false", "aria-haspopup" => "true", "data-toggle" => "dropdown", type: "button"}
.fa.fa-cog
.dropdown-menu.dropdown-menu-right{"aria-labelledby" => "title-actions"}
= link_to 'Convert to Director', convert_to_director_manage_questionnaire_path(@questionnaire), method: :patch, data: { confirm: "Are you sure? The questionnaire for \"#{@questionnaire.user.full_name}\" will be permanently erased, and \"#{@questionnaire.email}\" will become a director. This action is irreversible." }, class: 'dropdown-item'

= render 'overview'

Expand Down
28 changes: 22 additions & 6 deletions app/views/questionnaires/new.html.haml
Original file line number Diff line number Diff line change
@@ -1,7 +1,23 @@
- title "Apply"
.form-container
%h1.section-title
Apply for
%span.emphasized= HackathonConfig['name']
- title "Application"
- if HackathonConfig['accepting_questionnaires']
.form-container
%h1.section-title
Apply for
.emphasized.text-overflow-center= HackathonConfig['name']
= render 'form'
- else
.form-container
#disclaimer
%h1.section-title
Applications Closed
%p
- if HackathonConfig['questionnaires_closed_message'].present?
= markdown(HackathonConfig['questionnaires_closed_message'])
- else
Sorry, we are no longer accepting new applications to
%strong
#{HackathonConfig['name']}.
%br
%p.session-link.right
Don't need your account? #{link_to "Delete my account", user_registration_path, data: { confirm: "Are you sure? Your account and any related data will be permanently erased." }, method: :delete}

= render 'form'
1 change: 1 addition & 0 deletions config/app.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ defaults: &defaults
disclaimer_message: ""
thanks_for_applying_message: ""
thanks_for_rsvp_message: ""
questionnaires_closed_message: ""
bus_captain_notes: ""
custom_css: ""

Expand Down
4 changes: 3 additions & 1 deletion config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ en:
school:
is_home: The "home" school is separated from all other schools on dashboard metrics.
hackathon_config:
accepting_questionnaires: Specify that questionnaires are being accepted. This does <strong>not</strong> block applying; it only changes messaging around it.
accepting_questionnaires: Specify and allow questionnaires to be accepted.
last_day_to_apply: 'Last date to apply to your hackathon (format: YYYY-MM-DD)'
event_start_date: 'Start date of your hackathon (format: YYYY-MM-DD)'
auto_late_waitlist: Automatically set application status to "late waitlist" for new applications
Expand All @@ -72,6 +72,7 @@ en:
disclaimer_message: Optional message that appears before signing up & applying. Supports markdown.
thanks_for_applying_message: Optional message that appears after completing an application. Supports markdown.
thanks_for_rsvp_message: Optional message that appears after RSVP'ing as attending. Supports markdown.
questionnaires_closed_message: Message that replaces the new questionnaire form. Supports markdown.
bus_captain_notes: Optional message that appears on the bus captain's bus list page. Supports markdown.
custom_css: CSS to inject into the &lt;head&gt; of every public page
placeholders:
Expand Down Expand Up @@ -117,6 +118,7 @@ en:
custom_css: Custom CSS
homepage_url: Homepage URL
thanks_for_rsvp_message: Thanks For RSVP Message
questionnaires_closed_message: Questionnaires Closed Message
pages:
manage:
dashboard:
Expand Down
1 change: 0 additions & 1 deletion config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@
resources :questionnaires do
post :datatable, on: :collection
patch :check_in, on: :member
patch :convert_to_director, on: :member
patch :update_acc_status, on: :member
patch :bulk_apply, on: :collection
end
Expand Down
12 changes: 12 additions & 0 deletions db/seed_messages/questionnaire--rsvp_reminder.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
## Missing RSVP

<div style="text-align: center;">
<h1>Are you coming to {{hackathon_name}}?</h1>
<h3>Let us know if we should expect you there!</h3>
<p>
<a href="{{accept_rsvp_url}}" class="button" target="_blank">Yes, I will Attend &raquo;</a>
<a href="{{deny_rsvp_url}}" class="button" target="_blank">No, I Can't Attend &raquo;</a>
<br>
<small><i>Link not working? Go to <a href="{{rsvp_url}}">{{rsvp_url}}</a></i></small>
</p>
</div>
2 changes: 2 additions & 0 deletions db/seeds.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"questionnaire.accepted" => "You've been accepted!",
"questionnaire.denied" => "Your application status",
"questionnaire.rsvp_confirmed" => "RSVP Confirmation",
"questionnaire.rsvp_reminder" => "Are you coming to #{HackathonConfig['name']}?",
"user.24hr_incomplete_application" => "Incomplete application",
"bus_list.new_captain_confirmation" => "You're a bus captain!",
"bus_list.update_notes" => "Bus Update"
Expand All @@ -25,6 +26,7 @@
"questionnaire.accepted" => "Accepted email",
"questionnaire.denied" => "Denied email",
"questionnaire.rsvp_confirmed" => "RSVP confirmed email",
"questionnaire.rsvp_reminder" => "RSVP Reminder",
"user.24hr_incomplete_application" => "Incomplete application (24-hour reminder)",
"bus_list.new_captain_confirmation" => "New bus captain confirmation",
"bus_list.update_notes" => "Bus list update"
Expand Down
1 change: 0 additions & 1 deletion docs/api-overview.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ Example for questionnaire management endpoints:
Prefix Verb URI Pattern Controller#Action
datatable_manage_questionnaires POST /manage/questionnaires/datatable(.:format) manage/questionnaires#datatable
check_in_manage_questionnaire PATCH /manage/questionnaires/:id/check_in(.:format) manage/questionnaires#check_in
convert_to_director_manage_questionnaire PATCH /manage/questionnaires/:id/convert_to_director(.:format) manage/questionnaires#convert_to_admin
update_acc_status_manage_questionnaire PATCH /manage/questionnaires/:id/update_acc_status(.:format) manage/questionnaires#update_acc_status
bulk_apply_manage_questionnaires PATCH /manage/questionnaires/bulk_apply(.:format) manage/questionnaires#bulk_apply
manage_questionnaires GET /manage/questionnaires(.:format) manage/questionnaires#index
Expand Down
16 changes: 10 additions & 6 deletions docs/deployment-dokku.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,24 +6,28 @@ title: Dokku Deployment
>These docs assume you already have a virtual machine with [Dokku](http://dokku.viewdocs.io/dokku/) running on it, and can SSH into the VM. DNS should be set up as well, but isn't required for bare minimum functionality.
>
>If you need a VM, check out [DigitalOcean](https://m.do.co/c/b5ee103e23c3) or [Linode](https://www.linode.com/?r=e90a6fb2a6999fb4ec7b60b1add3e288f97954bf) and the [Dokku docs](http://dokku.viewdocs.io/dokku/) to get started.
>
>**Student Developer?** The [GitHub Student Developer Pack](https://education.github.com/pack?sort=popularity&tag=Cloud) has several discounts for cloud hosting, Ruby tutorials, and more!
## Setting up a new deployment

Below are steps & notes to deploy HackathonManager on Dokku. Need to update an existing deployment?
Below are steps to deploy a new HackathonManager instance on Dokku. To update an existing Dokku deployment, check out our [updating docs](updating-hm.html).

If you have any questions, please don't hesitate to reach out to the [codeRIT Engineering Team](mailto:engineering@coderit.org)! This doc is very much a work in progress but we want to keep it as up to date as possible.

If you have any questions at all, please don't hesitate to reach out to the [codeRIT Engineering Team](mailto:engineering@coderit.org)! This doc is very much a work in progress but we want to keep it as up to date as possible.
## Dokku Setup

## Dokku plugins
### Plugins

Currently used and required Dokku plugins (other than the defaults):

- [MySQL](https://github.com/dokku/dokku-mysql) (data storage)
- [Redis](https://github.com/dokku/dokku-redis) (background jobs + caching)
- [dokku-letsencrypt](https://github.com/dokku/dokku-letsencrypt) (Optional: free, automated SSL certificates)

### Dokku Setup Steps
### Setup Steps

**We'll be using `hm` as the app name in these steps,** as well as sharing the same `hm` name for both the app, database, and redis name. You're free to use another names.
**We'll be using `hm` as the app name in these steps,** as well as sharing the same `hm` name for both the app, database, and redis name. You're free to use other names.

```bash
dokku apps:create hm
Expand Down Expand Up @@ -177,4 +181,4 @@ In order to support groupdate, timezone tables must be created.

```bash
mysql_tzinfo_to_sql /usr/share/zoneinfo | mysql -u $OPENSHIFT_MYSQL_DB_USERNAME -p mysql
```
```
Loading

0 comments on commit 3f2a30c

Please sign in to comment.