Skip to content

Commit 4923231

Browse files
peterkosJeremyRudmancbaudouinjr
authored
master <- develop (2.1.2) (#472)
* fix(questionnaire): missing information now in correct place (#443) * fix(questionnair): missing information now in correct place it now displays the correct message "Please read & accept" instead of missing information and the notification is now in the correct place * Update app/assets/javascripts/validate.js * Revert "Update app/assets/javascripts/validate.js" This reverts commit bc54783. Signed-off-by: Peter Kos <pkos91@icloud.com> Co-authored-by: Peter Kos <pkos91@icloud.com> * fix: Fixes mobile agreements layout bug Signed-off-by: Peter Kos <pkos91@icloud.com> * feat: Removes semantic-release (#446) * refactor: Moves CI to develop branch (#449) Co-authored-by: Peter Kos <pkos91@icloud.com> * build: Merges 2.1.2 into develop * fix(hakiri): corrected unescaped model attribute * fix(hakiri): added html_safe to show proper output Co-authored-by: Jeremy Rudman <jeremyrudman@gmail.com> Co-authored-by: JeremyRudman <38338616+JeremyRudman@users.noreply.github.com> * fix: Shows questionnaires_closed_message on registration * feat: Allows agreements to be fully customizable (#465) * feat: Allows agreements to be fully customizable * fix: Fixes broken migrations * fix: Migrations misname issue * feat: Forces agreement links to open in new tab * Agreement validation detection fixed Signed-off-by: Peter Kos <pkos91@icloud.com> * refactor: Removes old input hint Co-authored-by: Peter Kos <pkos91@icloud.com> * fix(hakiri): fixed un-escaped regex for vcs link (#467) * fix(hakiri): corrected unescaped model attribute * fix(hakiri): added html_safe to show proper output * fix(hakiri): added \A \z to regex * fix(questionnaire): fixed hakiri error with vcs link regex * fix(questionnaire): fixed houndci commplaint Co-authored-by: Chris Baudouin, Jr <cjb5326@rit.edu> * fix(hakiri): fix hakiri error with user input in html_safe (#475) Co-authored-by: Peter Kos <pkos91@icloud.com> Co-authored-by: JeremyRudman <38338616+JeremyRudman@users.noreply.github.com> Co-authored-by: Chris Baudouin, Jr <cjb5326@rit.edu> Co-authored-by: Jeremy Rudman <jeremyrudman@gmail.com>
1 parent 5f4a844 commit 4923231

File tree

14 files changed

+51
-54
lines changed

14 files changed

+51
-54
lines changed

app/assets/javascripts/validate.js

+2-7
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,8 @@ document.addEventListener('turbolinks:load', function() {
1818
switch (types[i]) {
1919
case 'presence':
2020
if (!value || $.trim(value).length < 1) {
21-
if (
22-
$(this)
23-
.parent()
24-
.text()
25-
.includes('I read and accept')
26-
) {
27-
notify(".agreement_input", 'Please read & accept');
21+
if ($(this).parents('.agreement_input')) {
22+
notify('.agreement_input', 'Please read & accept');
2823
} else {
2924
notify(this, 'Missing Information');
3025
}

app/controllers/manage/agreements_controller.rb

+8-18
Original file line numberDiff line numberDiff line change
@@ -20,27 +20,17 @@ def edit
2020

2121
# POST /agreements
2222
def create
23-
if !agreement_params['agreement_url'].start_with?('http://', 'https://')
24-
flash[:alert] = "Agreement URL must start with http:// or https://"
25-
redirect_to new_manage_agreement_path
26-
else
27-
@agreement = Agreement.new(agreement_params)
28-
@agreement.save
29-
flash[:notice] = "#{@agreement.name} was successfully created."
30-
redirect_to manage_agreements_path
31-
end
23+
@agreement = Agreement.new(agreement_params)
24+
@agreement.save
25+
flash[:notice] = "#{@agreement.name} was successfully created."
26+
redirect_to manage_agreements_path
3227
end
3328

3429
# PATCH/PUT /agreements/1
3530
def update
36-
if !agreement_params['agreement_url'].nil? && !agreement_params['agreement_url'].start_with?('http://', 'https://')
37-
flash[:alert] = "Agreement URL must start with http:// or https://"
38-
redirect_to edit_manage_agreement_url
39-
else
40-
@agreement.update_attributes(agreement_params)
41-
flash[:notice] = nil
42-
redirect_to manage_agreements_path
43-
end
31+
@agreement.update_attributes(agreement_params)
32+
flash[:notice] = nil
33+
redirect_to manage_agreements_path
4434
end
4535

4636
# DELETE /agreements/1
@@ -60,7 +50,7 @@ def set_agreement
6050
# Only allow a trusted parameter "white list" through.
6151
def agreement_params
6252
params.require(:agreement).permit(
63-
:name, :agreement_url
53+
:name, :agreement
6454
)
6555
end
6656
end

app/models/agreement.rb

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
class Agreement < ApplicationRecord
22
include ActionView::Helpers::UrlHelper
33
validates_presence_of :name
4-
validates_presence_of :agreement_url
4+
validates_presence_of :agreement
55

66
strip_attributes
77

88
has_and_belongs_to_many :questionnaires
99

1010
def formatted_agreement
11-
"<p>I read and accept the&nbsp;#{link_to name, agreement_url, target: '_blank'}&nbsp;agreement.</p>".html_safe
11+
markdown = Redcarpet::Markdown.new(Redcarpet::Render::HTML, autolink: true, tables: true)
12+
markdown.render(agreement).gsub("<a href=", "<a target=\“_blank\” rel=\"noreferrer noopener\" href=").html_safe
1213
end
1314
end

app/models/questionnaire.rb

+2-3
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,7 @@ class Questionnaire < ApplicationRecord
4343

4444
validates :portfolio_url, url: { allow_blank: true }
4545
validates :vcs_url, url: { allow_blank: true }
46-
validates_format_of :vcs_url, with: %r{((github.com\/\w+\/?)|(gitlab.com\/\w+\/?)|(bitbucket.org\/\w+\/?))}, allow_blank: true, message: "Must be a GitHub, GitLab or Bitbucket url"
47-
46+
validates_format_of :vcs_url, with: %r{\A(((https?:\/\/)?(www\.)?github\.com\/\w+\/?)|((https?:\/\/)?(www\.)?gitlab\.com\/\w+\/?)|((https?:\/\/)?(www\.)?bitbucket\.org\/\w+\/?))\z}, allow_blank: true, message: "Must be a GitHub, GitLab or Bitbucket url"
4847
strip_attributes
4948

5049
POSSIBLE_EXPERIENCES = {
@@ -135,7 +134,7 @@ def portfolio_url=(value)
135134
end
136135

137136
def vcs_url=(value)
138-
value = "http://" + value if !value.blank? && !value.include?("http://") && !value.include?("https://")
137+
value = "https://" + value if !value.blank? && !value.include?("http://") && !value.include?("https://")
139138
super value
140139
end
141140

app/views/devise/registrations/new.html.haml

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
#disclaimer
99
- if !HackathonConfig['accepting_questionnaires']
1010
.center
11-
%strong We are no longer accepting applications. Thanks to everyone who applied!
11+
%p= markdown(HackathonConfig['questionnaires_closed_message'])
1212
%br
1313
- if HackathonConfig['disclaimer_message'].present?
1414
= markdown(HackathonConfig['disclaimer_message'])

app/views/doorkeeper/authorizations/error.html.haml

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,5 @@
66
%p
77
= @pre_auth.error_response.body[:error_description]
88
%p
9-
= raw t('doorkeeper.errors.messages.get_help', hackathon_name: content_tag(:strong, class: 'text-info') { HackathonConfig['name'] })
9+
= t('doorkeeper.errors.messages.get_help', hackathon_name: HackathonConfig['name'])
1010

app/views/manage/agreements/_form.html.haml

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
.form-inputs
66
= f.input :name
7-
= 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')
7+
= f.input :agreement, label: t(:agreement, scope: 'pages.manage.agreements'), input_html: { rows: 10, 'data-simple-mde' => '1' }
88

99
.form-actions
1010
= f.button :submit, class: 'btn-primary'

app/views/manage/agreements/index.html.haml

+2-2
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
%th
1313
= t(:name, scope: 'pages.manage.agreements')
1414
%th
15-
= t(:agreement_url, scope: 'pages.manage.agreements')
15+
= t(:agreement, scope: 'pages.manage.agreements')
1616

1717
%tbody
1818
- @agreements.each do |agreement|
@@ -25,4 +25,4 @@
2525
%strong
2626
= agreement.name
2727
%td
28-
= agreement.agreement_url
28+
= markdown(agreement.agreement)

config/locales/en.yml

+1-3
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,6 @@ en:
5454
trigger: Sent automatically when a new or updated applicant matches this criteria. Does not send to anyone already matching this criteria.
5555
school:
5656
is_home: The "home" school is separated from all other schools on dashboard metrics.
57-
agreement:
58-
name: 'Agreements are displayed to applicants as: "I read & accept the [agreement_name] agreement"'
5957
hackathon_config:
6058
accepting_questionnaires: Specify and allow questionnaires to be accepted.
6159
digital_hackathon: Optimize HackathonManager for a digital hackathon. (Removes travel, dietary restrictions, etc.)
@@ -192,7 +190,7 @@ en:
192190
title: Legal Agreements
193191
notice: "These are legal agreements that are required to be reviewed and agreed upon by all applicants of %{hackathon_name}."
194192
name: Name
195-
agreement_url: Agreement URL
193+
agreement: Agreement
196194
new: New Agreement
197195
edit: Edit Agreement
198196
settings:
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
class ConvertAgreementsToText < ActiveRecord::Migration[5.2]
2+
def self.up
3+
change_column :agreements, :agreement_url, :text
4+
rename_column :agreements, :agreement_url, :agreement
5+
end
6+
7+
def self.down
8+
rename_column :agreements, :agreement, :agreement_url
9+
change_column :agreements, :agreement_url, :sring
10+
end
11+
end

db/schema.rb

+15-7
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
#
1111
# It's strongly recommended that you check this file into your version control system.
1212

13-
ActiveRecord::Schema.define(version: 2020_12_09_053827) do
13+
ActiveRecord::Schema.define(version: 2020_12_18_010133) do
1414

1515
create_table "active_storage_attachments", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8", force: :cascade do |t|
1616
t.string "name", null: false
@@ -35,7 +35,7 @@
3535

3636
create_table "agreements", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8", force: :cascade do |t|
3737
t.string "name"
38-
t.string "agreement_url"
38+
t.text "agreement"
3939
t.datetime "created_at", null: false
4040
t.datetime "updated_at", null: false
4141
end
@@ -73,7 +73,9 @@
7373
t.integer "query_id"
7474
t.text "statement"
7575
t.string "data_source"
76-
t.datetime "created_at"
76+
t.timestamp "created_at"
77+
t.index ["query_id"], name: "index_blazer_audits_on_query_id"
78+
t.index ["user_id"], name: "index_blazer_audits_on_user_id"
7779
end
7880

7981
create_table "blazer_checks", id: :integer, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8", force: :cascade do |t|
@@ -84,9 +86,11 @@
8486
t.text "emails"
8587
t.string "check_type"
8688
t.text "message"
87-
t.datetime "last_run_at"
89+
t.timestamp "last_run_at"
8890
t.datetime "created_at", null: false
8991
t.datetime "updated_at", null: false
92+
t.index ["creator_id"], name: "index_blazer_checks_on_creator_id"
93+
t.index ["query_id"], name: "index_blazer_checks_on_query_id"
9094
end
9195

9296
create_table "blazer_dashboard_queries", id: :integer, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8", force: :cascade do |t|
@@ -95,13 +99,16 @@
9599
t.integer "position"
96100
t.datetime "created_at", null: false
97101
t.datetime "updated_at", null: false
102+
t.index ["dashboard_id"], name: "index_blazer_dashboard_queries_on_dashboard_id"
103+
t.index ["query_id"], name: "index_blazer_dashboard_queries_on_query_id"
98104
end
99105

100106
create_table "blazer_dashboards", id: :integer, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8", force: :cascade do |t|
101107
t.integer "creator_id"
102108
t.text "name"
103109
t.datetime "created_at", null: false
104110
t.datetime "updated_at", null: false
111+
t.index ["creator_id"], name: "index_blazer_dashboards_on_creator_id"
105112
end
106113

107114
create_table "blazer_queries", id: :integer, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8", force: :cascade do |t|
@@ -112,6 +119,7 @@
112119
t.string "data_source"
113120
t.datetime "created_at", null: false
114121
t.datetime "updated_at", null: false
122+
t.index ["creator_id"], name: "index_blazer_queries_on_creator_id"
115123
end
116124

117125
create_table "bus_lists", id: :integer, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8", force: :cascade do |t|
@@ -151,9 +159,9 @@
151159
t.string "subject"
152160
t.string "recipients"
153161
t.text "body"
154-
t.datetime "queued_at"
155-
t.datetime "started_at"
156-
t.datetime "delivered_at"
162+
t.timestamp "queued_at"
163+
t.timestamp "started_at"
164+
t.timestamp "delivered_at"
157165
t.datetime "created_at"
158166
t.datetime "updated_at"
159167
t.string "template", default: "default"

test/controllers/manage/agreements_controller_test.rb

+1-6
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ class Manage::AgreementsControllerTest < ActionController::TestCase
191191
end
192192

193193
should "create a new agreement" do
194-
post :create, params: { agreement: { name: "Fun Agreement", agreement_url: "https://foo.com" } }
194+
post :create, params: { agreement: { name: "Fun Agreement", agreement: "Please read and accept https://foo.com" } }
195195
assert_response :redirect
196196
end
197197

@@ -206,11 +206,6 @@ class Manage::AgreementsControllerTest < ActionController::TestCase
206206
assert_redirected_to manage_agreements_path
207207
end
208208

209-
should "enforce agreement_url to be a link" do
210-
patch :update, params: { id: @agreement, agreement: { name: "New agreement Name", agreement_url: "hello" } }
211-
assert_response :redirect
212-
end
213-
214209
context "#destroy" do
215210
should "destroy agreement" do
216211
assert_difference("Agreement.count", -1) do

test/factories/agreement.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
FactoryBot.define do
22
factory :agreement do
33
name { "HackFoo Agreement" }
4-
agreement_url { "https://www.foo.com" }
4+
agreement { "Please read and accept https://www.foo.com" }
55
end
66
end

test/models/agreement_test.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@ class AgreementTest < ActiveSupport::TestCase
44
should have_and_belong_to_many :questionnaires
55

66
should strip_attribute :name
7-
should strip_attribute :agreement_url
7+
should strip_attribute :agreement
88

99
should validate_presence_of :name
10-
should validate_presence_of :agreement_url
10+
should validate_presence_of :agreement
1111

1212
should "not allow questionnaires to accept agreements for others" do
1313
@questionnaire1 = create(:questionnaire)

0 commit comments

Comments
 (0)