Skip to content

Commit

Permalink
Merge pull request #1416 from compsy/develop
Browse files Browse the repository at this point in the history
[Deploy] Deploy new version
  • Loading branch information
emerencia committed Mar 9, 2020
2 parents a33acd9 + a6c5346 commit 2d27994
Show file tree
Hide file tree
Showing 108 changed files with 5,829 additions and 2,222 deletions.
1 change: 1 addition & 0 deletions .dockerignore
@@ -1,2 +1,3 @@
tmp
node_modules
log
12 changes: 12 additions & 0 deletions .rubocop.yml
Expand Up @@ -32,6 +32,18 @@ Rails/Blank:
Layout/LineLength:
Max: 120

Layout/EndOfLine:
EnforcedStyle: lf

Style/HashEachMethods:
Enabled: false

Style/HashTransformKeys:
Enabled: false

Style/HashTransformValues:
Enabled: false

# Default is 5
Metrics/ParameterLists:
Max: 6
Expand Down
4 changes: 4 additions & 0 deletions Gemfile
Expand Up @@ -130,6 +130,8 @@ group :test do

# Cleans the database after specs
gem 'database_cleaner'
gem 'database_cleaner-active_record'
gem 'database_cleaner-mongoid'

# Integration testing
gem 'capybara', '>= 3.31.0'
Expand All @@ -150,6 +152,8 @@ group :production, :staging do
gem 'daemons'
end

gem 'addressable'

gem 'workless', git: 'https://github.com/compsy/workless.git', branch: 'fixes'

group :development do
Expand Down
67 changes: 43 additions & 24 deletions Gemfile.lock
Expand Up @@ -58,7 +58,7 @@ GEM
erubi (~> 1.4)
rails-dom-testing (~> 2.0)
rails-html-sanitizer (~> 1.0, >= 1.0.3)
active_interaction (3.7.1)
active_interaction (3.8.0)
activemodel (>= 4, < 7)
active_model_serializers (0.10.10)
actionpack (>= 4.1, < 6.1)
Expand All @@ -81,19 +81,19 @@ GEM
tzinfo (~> 1.1)
addressable (2.7.0)
public_suffix (>= 2.0.2, < 5.0)
appsignal (2.10.2)
appsignal (2.10.4)
rack
arel (8.0.0)
ast (2.4.0)
autoprefixer-rails (9.7.2)
autoprefixer-rails (9.7.4)
execjs
babel-source (5.8.35)
babel-transpiler (0.7.0)
babel-source (>= 4.0, < 6)
execjs (~> 2.0)
bcrypt (3.1.13)
bindex (0.8.1)
bson (4.6.0)
bson (4.8.2)
builder (3.2.4)
byebug (11.1.1)
capybara (3.31.0)
Expand Down Expand Up @@ -128,7 +128,17 @@ GEM
tins (~> 1.6)
crass (1.0.6)
daemons (1.3.1)
database_cleaner (1.8.2)
database_cleaner (1.8.3)
database_cleaner-active_record (1.8.0)
activerecord
database_cleaner (~> 1.8.0)
database_cleaner-mongo (1.8.0)
database_cleaner (~> 1.8.0)
mongo
database_cleaner-mongoid (1.8.1)
database_cleaner (~> 1.8.0)
database_cleaner-mongo (~> 1.8.0)
mongoid
delayed_job (4.1.8)
activesupport (>= 3.0, < 6.1)
delayed_job_active_record (4.1.4)
Expand All @@ -142,16 +152,18 @@ GEM
dotenv-rails (2.7.5)
dotenv (= 2.7.5)
railties (>= 3.2, < 6.1)
dry-auto_inject (0.6.1)
dry-auto_inject (0.7.0)
dry-container (>= 0.3.4)
dry-configurable (0.9.0)
dry-configurable (0.11.3)
concurrent-ruby (~> 1.0)
dry-core (~> 0.4, >= 0.4.7)
dry-equalizer (~> 0.2)
dry-container (0.7.2)
concurrent-ruby (~> 1.0)
dry-configurable (~> 0.1, >= 0.1.3)
dry-core (0.4.9)
concurrent-ruby (~> 1.0)
dry-equalizer (0.3.0)
erubi (1.9.0)
erubis (2.7.0)
excon (0.72.0)
Expand Down Expand Up @@ -202,7 +214,7 @@ GEM
ruby_parser (~> 3.5)
http-cookie (1.0.3)
domain_name (~> 0.5)
httparty (0.17.3)
httparty (0.18.0)
mime-types (~> 3.0)
multi_xml (>= 0.5.2)
i18n (1.8.2)
Expand All @@ -213,13 +225,13 @@ GEM
jaro_winkler (1.5.4)
jbuilder (2.10.0)
activesupport (>= 5.0.0)
json (2.2.0)
json (2.3.0)
json-schema (2.8.1)
addressable (>= 2.4)
jsonapi-renderer (0.2.2)
jwt (2.2.1)
launchy (2.4.3)
addressable (~> 2.3)
launchy (2.5.0)
addressable (~> 2.7)
libv8 (7.3.492.27.1)
listen (3.1.5)
rb-fsevent (~> 0.9, >= 0.9.4)
Expand All @@ -233,7 +245,7 @@ GEM
loofah (2.4.0)
crass (~> 1.0.2)
nokogiri (>= 1.5.9)
lumberjack (1.0.13)
lumberjack (1.2.4)
mail (2.7.1)
mini_mime (>= 0.1.1)
mailgun-ruby (1.2.0)
Expand All @@ -252,23 +264,23 @@ GEM
minitest (5.14.0)
modernizr-rails (2.7.1)
moneta (1.0.0)
mongo (2.11.1)
bson (>= 4.6.0, < 5.0.0)
mongoid (7.0.5)
mongo (2.11.4)
bson (>= 4.4.2, < 5.0.0)
mongoid (7.1.0)
activemodel (>= 5.1, < 6.1)
mongo (>= 2.5.1, < 3.0.0)
mongo (>= 2.7.0, < 3.0.0)
multi_json (1.14.1)
multi_xml (0.6.0)
nenv (0.3.0)
netrc (0.11.0)
nio4r (2.5.2)
nokogiri (1.10.8)
nokogiri (1.10.9)
mini_portile2 (~> 2.4.0)
notiffany (0.1.3)
nenv (~> 0.1)
shellany (~> 0.0)
parallel (1.19.1)
parser (2.7.0.2)
parser (2.7.0.4)
ast (~> 2.4.0)
pg (1.1.4)
platform-api (2.2.0)
Expand Down Expand Up @@ -322,7 +334,7 @@ GEM
rainbow (3.0.0)
rake (13.0.1)
rb-fsevent (0.10.3)
rb-inotify (0.10.0)
rb-inotify (0.10.1)
ffi (~> 1.0)
react-rails (2.6.1)
babel-transpiler (>= 0.7.0)
Expand All @@ -347,6 +359,7 @@ GEM
http-cookie (>= 1.0.2, < 2.0)
mime-types (>= 1.16, < 4.0)
netrc (~> 0.8)
rexml (3.2.4)
rspec (3.9.0)
rspec-core (~> 3.9.0)
rspec-expectations (~> 3.9.0)
Expand Down Expand Up @@ -379,11 +392,12 @@ GEM
rswag-ui (2.2.0)
actionpack (>= 3.1, < 6.1)
railties (>= 3.1, < 6.1)
rubocop (0.79.0)
rubocop (0.80.1)
jaro_winkler (~> 1.5.1)
parallel (~> 1.10)
parser (>= 2.7.0.1)
rainbow (>= 2.2.2, < 4.0)
rexml
ruby-progressbar (~> 1.7)
unicode-display_width (>= 1.4.0, < 1.7)
rubocop-performance (1.5.2)
Expand Down Expand Up @@ -433,6 +447,7 @@ GEM
actionpack (>= 4.0)
activesupport (>= 4.0)
sprockets (>= 3.0.0)
sync (0.5.0)
syslog_protocol (0.9.2)
temple (0.8.2)
term-ansicolor (1.7.1)
Expand All @@ -441,7 +456,8 @@ GEM
thread_safe (0.3.6)
tilt (2.0.10)
timecop (0.9.1)
tins (1.22.2)
tins (1.24.1)
sync
tzinfo (1.2.6)
thread_safe (~> 0.1)
tzinfo-data (1.2019.3)
Expand All @@ -454,9 +470,9 @@ GEM
unicode-display_width (1.6.1)
warden (1.2.8)
rack (>= 2.0.6)
warden-jwt_auth (0.4.0)
warden-jwt_auth (0.4.1)
dry-auto_inject (~> 0.6)
dry-configurable (~> 0.8)
dry-configurable (~> 0.11, >= 0.11.3)
jwt (~> 2.1)
warden (~> 1.2)
web-console (3.7.0)
Expand Down Expand Up @@ -484,6 +500,7 @@ PLATFORMS
DEPENDENCIES
active_interaction
active_model_serializers (>= 0.10.10)
addressable
animate-rails!
appsignal
bcrypt
Expand All @@ -495,6 +512,8 @@ DEPENDENCIES
coveralls (>= 0.8.21)
daemons
database_cleaner
database_cleaner-active_record
database_cleaner-mongoid
delayed_job_active_record
dotenv-rails (>= 2.7.5)
factory_bot_rails (>= 5.1.1)
Expand Down Expand Up @@ -557,4 +576,4 @@ RUBY VERSION
ruby 2.6.3p62

BUNDLED WITH
1.17.3
2.1.4
14 changes: 7 additions & 7 deletions README.md
Expand Up @@ -353,7 +353,7 @@ The `content` attribute of a `Questionnaire` is a Hash with two keys, `:question
For all questions, it is allowed to use HTML tags in the texts.
Also, you may use any of the special variables defined in the previous section.

All questions now support a `combines_with` attribute. The value of this attribute should be an array of (other) questionnaire IDs. This is used to indicate to the distributions engine that an additional conditional distribution histogram, combining the values of the question and the ones that it combines with, should also be calculated.
All questions except checkboxes now support a `combines_with` attribute. The value of this attribute should be an array of (other) questionnaire IDs. This is used to indicate to the distributions engine that an additional conditional distribution histogram, combining the values of the question and the ones that it combines with, should also be calculated.

### Type: Checkbox
Required and allowed options (minimal example and maximal example):
Expand Down Expand Up @@ -744,19 +744,19 @@ Required and allowed options (minimal example and maximal example):
required: true,
tooltip: 'some tooltip',
placeholder: 'Place holder',
min: [2018, 06, 14],
max: [2018, 07, 20],
min: '2018/06/14',
max: '2018/07/20',
default_date: '2018/07/20',
section_end: true
}]
```

The `min` and `max` properties can be either two arrays as in the above example, or they can be of the following form: `min: -15, max: true` meaning that the max is today, and the minimum date is 15 days ago (max can also be set to false, which removes any limits).

Please note that there is currently a bug in the date picker when you specify dates as arrays.
So if you want june 14th, as a start date, use [2018, 5, 14], i.e., subtract one from the month.
The `min` and `max` properties can be either strings as in the above example, or they can be of the following form: `min: -15, max: true` meaning that the max is today, and the minimum date is 15 days ago (max can also be set to false, which removes any limits).

If the `today` property is present, then the default value for the date is set to today. (e.g., `today: true`)

The `default_date` property can be used to set a default date. The `default_date` and `today` properties should never both be used.

### Type: Unsubscribe
Including an unsubscribe question type will display a card that allows the user to unsubscribe from the protocol.
Typically, you want only one `unsubscribe` question in your questionnaire, as the first item in the questionnaire.
Expand Down
4 changes: 2 additions & 2 deletions app/assets/javascripts/materialize_loader.js
Expand Up @@ -39,8 +39,8 @@ $(function() {
if ($(self).data('default-date'))
default_date = new Date(Date.parse($(self).data('default-date')));
$(self).datepicker({
minDate: $(self).data('min'),
maxDate: $(self).data('max'),
minDate: new Date(Date.parse($(self).data('min'))),
maxDate: new Date(Date.parse($(self).data('max'))),
defaultDate: default_date, // This is so we can set a default date already filled out,
setDefaultDate: $(self).data('set-default-date'), // allowing the user to skip the input
format: 'yyyy-mm-dd',
Expand Down
9 changes: 9 additions & 0 deletions app/assets/stylesheets/questionnaire.scss
Expand Up @@ -295,3 +295,12 @@ button[type="submit"] {
blockquote {
color: #666;
}

.datepicker-container {
.select-dropdown.dropdown-trigger {
text-decoration: underline;
&:hover {
text-decoration: none;
}
}
}
3 changes: 2 additions & 1 deletion app/background_tasks/send_invitations.rb
Expand Up @@ -10,6 +10,7 @@ def run
next if response.expired?
next unless response.measurement.should_invite?
next unless response.protocol_subscription.active?
next unless response.person.account_active?

person_id = response.protocol_subscription.person_id
response_sets[person_id] += [response]
Expand All @@ -35,7 +36,7 @@ def schedule_invite(invitation_set)

def schedule_reminder(invitation_set)
reminder_delay = invitation_set.reminder_delay
return if reminder_delay.blank?
return if reminder_delay.blank? || reminder_delay.zero?

SendInvitationsJob.set(wait: reminder_delay).perform_later invitation_set
end
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/concerns/is_logged_in.rb
Expand Up @@ -6,7 +6,7 @@ module IsLoggedIn

# rubocop:disable Rails/LexicallyScopedActionFilter
included do
before_action :verify_current_user, except: %i[interactive interactive_render]
before_action :verify_current_user, except: %i[interactive interactive_render from_json]
end
# rubocop:enable Rails/LexicallyScopedActionFilter

Expand Down
2 changes: 1 addition & 1 deletion app/controllers/concerns/is_logged_in_with_any_method.rb
Expand Up @@ -6,7 +6,7 @@ module IsLoggedInWithAnyMethod

# rubocop:disable Rails/LexicallyScopedActionFilter
included do
before_action :verify, except: %i[interactive interactive_render]
before_action :verify, except: %i[interactive interactive_render from_json]
end
# rubocop:enable Rails/LexicallyScopedActionFilter

Expand Down
10 changes: 8 additions & 2 deletions app/controllers/questionnaire_controller.rb
Expand Up @@ -6,7 +6,7 @@ class QuestionnaireController < ApplicationController
MAX_DRAWING_LENGTH = 65_536
include Concerns::IsLoggedIn
protect_from_forgery prepend: true, with: :exception, except: :create
skip_before_action :verify_authenticity_token, only: %i[interactive_render]
skip_before_action :verify_authenticity_token, only: %i[interactive_render from_json]
before_action :log_csrf_error, only: %i[create]
before_action :set_response, only: %i[show destroy]
# TODO: verify cookie for show as well
Expand All @@ -29,13 +29,19 @@ def interactive
@default_content = ''
end

# This method is used to post results from the interactive questionnaire previewer
def from_json
flash[:success] = 'Success! If this were an actual questionnaire, your response would have been saved.'
redirect_to :interactive_questionnaire_index
end

def interactive_render
@content = QuestionnaireGenerator.new.generate_questionnaire(
response_id: nil,
content: @raw_questionnaire_content,
title: 'Test questionnaire',
submit_text: 'Opslaan',
action: '/api/v1/questionnaire/from_json',
action: '/questionnaire/from_json',
unsubscribe_url: nil
)

Expand Down
4 changes: 4 additions & 0 deletions app/generators/date_generator.rb
Expand Up @@ -36,6 +36,10 @@ def mydate_data(question)
data[:'default-date'] = Time.zone.today
data[:'set-default-date'] = true
end
if question[:default_date].present?
data[:'default-date'] = Date.parse(question[:default_date])
data[:'set-default-date'] = false
end
data
end

Expand Down

0 comments on commit 2d27994

Please sign in to comment.