-
Notifications
You must be signed in to change notification settings - Fork 24
feat: Adds Legal Agreements object for dynamic agreements #429
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
Merged
Merged
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
7e9cf5d
feat: Adds Legal Agreements object for dynamic agreements
cbaudouinjr e62bc73
Merge branch '2.1' into hm-377
cbaudouinjr c5e97bf
fix: Fixes several bugs with agreement error checking
cbaudouinjr 6733064
Merge branch 'hm-377' of github.com:codeRIT/hackathon-manager into hm…
cbaudouinjr e9667dc
fix: Fixes several Hound issues
cbaudouinjr 9f6687c
fix: Fixes some more Hound issues
cbaudouinjr 04203db
Update app/views/application/_unaccepted_agreements_notice.html.haml
cbaudouinjr 2882c29
fix: Fixes Peter's requests
cbaudouinjr cb13563
Fix agreement checkbox wrap with small names
peterkos 3341245
Fix straggling merge conflict error
peterkos 22249c5
Removed agreements card
peterkos 1a50f1f
Force validation for agreement on questionnaire pg
peterkos File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 |
---|---|---|
|
@@ -38,3 +38,6 @@ | |
|
||
# macOS | ||
.DS_Store | ||
|
||
# Redis | ||
dump.rdb |
This file contains hidden or 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 hidden or 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,66 @@ | ||
class Manage::AgreementsController < Manage::ApplicationController | ||
before_action :require_director | ||
before_action :set_agreement, only: [:show, :edit, :update, :destroy] | ||
|
||
respond_to :html, :json | ||
|
||
# GET /agreements | ||
def index | ||
@agreements = Agreement.all | ||
end | ||
|
||
# GET /agreements/new | ||
def new | ||
@agreement = Agreement.new | ||
end | ||
|
||
# GET /agreements/1/edit | ||
def edit | ||
end | ||
|
||
# POST /agreements | ||
def create | ||
if !agreement_params['agreement_url'].start_with?('http://', 'https://') | ||
flash[:alert] = "Agreement URL must start with http:// or https://" | ||
redirect_to new_manage_agreement_path | ||
else | ||
@agreement = Agreement.new(agreement_params) | ||
@agreement.save | ||
flash[:notice] = "#{@agreement.name} was successfully created." | ||
redirect_to manage_agreements_path | ||
end | ||
end | ||
|
||
# PATCH/PUT /agreements/1 | ||
def update | ||
if !agreement_params['agreement_url'].nil? && !agreement_params['agreement_url'].start_with?('http://', 'https://') | ||
flash[:alert] = "Agreement URL must start with http:// or https://" | ||
redirect_to edit_manage_agreement_url | ||
else | ||
@agreement.update_attributes(agreement_params) | ||
flash[:notice] = nil | ||
redirect_to manage_agreements_path | ||
end | ||
end | ||
|
||
# DELETE /agreements/1 | ||
def destroy | ||
@agreement.destroy | ||
flash[:notice] = 'Agreement was successfully destroyed.' | ||
respond_with(:manage, @agreement, location: manage_agreements_path) | ||
end | ||
|
||
private | ||
|
||
# Use callbacks to share common setup or constraints between actions. | ||
def set_agreement | ||
@agreement = Agreement.find(params[:id]) | ||
end | ||
|
||
# Only allow a trusted parameter "white list" through. | ||
def agreement_params | ||
params.require(:agreement).permit( | ||
:name, :agreement_url | ||
) | ||
end | ||
end |
This file contains hidden or 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 |
---|---|---|
|
@@ -12,6 +12,7 @@ def datatable | |
end | ||
|
||
def show | ||
@agreements = Agreement.all | ||
respond_with(:manage, @questionnaire) | ||
end | ||
|
||
|
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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,13 @@ | ||
class Agreement < ApplicationRecord | ||
include ActionView::Helpers::UrlHelper | ||
validates_presence_of :name | ||
validates_presence_of :agreement_url | ||
|
||
strip_attributes | ||
|
||
has_and_belongs_to_many :questionnaires | ||
|
||
def formatted_agreement | ||
"I read and accept the #{link_to name, agreement_url, target: '_blank'} agreement.".html_safe | ||
end | ||
end |
This file contains hidden or 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 |
---|---|---|
|
@@ -18,19 +18,19 @@ class Questionnaire < ApplicationRecord | |
belongs_to :user | ||
belongs_to :school | ||
belongs_to :bus_list, optional: true | ||
has_and_belongs_to_many :agreements | ||
|
||
validates_uniqueness_of :user_id | ||
|
||
validates_presence_of :phone, :date_of_birth, :school_id, :experience, :shirt_size, :interest | ||
validates_presence_of :gender, :major, :level_of_study, :graduation_year, :race_ethnicity | ||
validates_presence_of :agreement_accepted, message: "Please read & accept" | ||
validates_presence_of :code_of_conduct_accepted, message: "Please read & accept" | ||
validates_presence_of :data_sharing_accepted, message: "Please read & accept" | ||
|
||
DIETARY_SPECIAL_NEEDS_MAX_LENGTH = 500 | ||
validates_length_of :dietary_restrictions, maximum: DIETARY_SPECIAL_NEEDS_MAX_LENGTH | ||
validates_length_of :special_needs, maximum: DIETARY_SPECIAL_NEEDS_MAX_LENGTH | ||
|
||
validate :agreements_present | ||
|
||
# if HackathonManager.field_enabled?(:why_attend) | ||
# validates_presence_of :why_attend | ||
# end | ||
|
@@ -215,6 +215,26 @@ def verbal_status | |
end | ||
end | ||
|
||
def agreements_present | ||
if (Agreement.all - agreements).any? | ||
errors.add(:agreements, "must be accepted.") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this no longer works haha #437 |
||
end | ||
end | ||
|
||
def all_agreements_accepted? | ||
(Agreement.all - agreements).empty? | ||
end | ||
|
||
def unaccepted_agreements | ||
Agreement.all - agreements | ||
end | ||
|
||
def as_json(options = {}) | ||
result = super | ||
result['all_agreements_accepted'] = all_agreements_accepted? | ||
result | ||
end | ||
|
||
private | ||
|
||
def clean_for_non_rsvp | ||
|
10 changes: 10 additions & 0 deletions
10
app/views/application/_unaccepted_agreements_notice.html.haml
This file contains hidden or 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,10 @@ | ||
.alert#disclaimer | ||
%h1.section-title | ||
%span.emphasized.fa.fa-exclamation-circle | ||
Missing | ||
%span.emphasized Agreements | ||
%p | ||
You have unaccepted agreements. You will not be allowed at #{HackathonConfig['name']} until all agreements have been accepted. Please | ||
%strong | ||
#{link_to "edit your application", edit_questionnaires_path} | ||
and review all agreements before attending. |
This file contains hidden or 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 hidden or 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 hidden or 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,10 @@ | ||
.form-container | ||
= bs_horizontal_simple_form_for(@agreement, url: url_for(action: @agreement.new_record? ? "create" : "update", controller: "agreements")) do |f| | ||
= f.error_notification | ||
|
||
.form-inputs | ||
= f.input :name | ||
= f.input :agreement_url, hint: "Should be a full https:// URL to a web page or .pdf file", label: t(:agreement_url, scope: 'pages.manage.agreements') | ||
|
||
.form-actions | ||
= f.button :submit, class: 'btn-primary' |
This file contains hidden or 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,3 @@ | ||
= render "layouts/manage/page_title", title: t(:edit, scope: 'pages.manage.agreements') | ||
|
||
= render 'form' |
This file contains hidden or 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,28 @@ | ||
= render "layouts/manage/page_title", title: t(:title, scope: 'pages.manage.agreements') do | ||
= link_to "New Agreement", new_manage_agreement_path, class: "btn btn-sm btn-outline-secondary" | ||
|
||
%p.text-muted | ||
= t(:notice, scope: 'pages.manage.agreements', hackathon_name: HackathonConfig['name']) | ||
.mb-4 | ||
%table.table.table-striped.table-hover | ||
%thead | ||
%tr | ||
%th | ||
%th | ||
%th | ||
= t(:name, scope: 'pages.manage.agreements') | ||
%th | ||
= t(:agreement_url, scope: 'pages.manage.agreements') | ||
|
||
%tbody | ||
- @agreements.each do |agreement| | ||
%tr | ||
%td | ||
= link_to '<i class="fa fa-pencil"></i>'.html_safe, edit_manage_agreement_path(agreement) | ||
%td | ||
= link_to '<i class="fa fa-trash"></i>'.html_safe, manage_agreement_path(agreement), method: :delete, data: { confirm: "Are you sure? The agreement will be permanently deleted. This action is irreversible." } | ||
%td | ||
%strong | ||
= agreement.name | ||
%td | ||
= agreement.agreement_url |
This file contains hidden or 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,3 @@ | ||
= render "layouts/manage/page_title", title: t(:new, scope: 'pages.manage.agreements') | ||
|
||
= render 'form' |
This file contains hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.