Skip to content

Commit ac88afc

Browse files
authored
Merge pull request #329 from DigitalCurationCentre/vyruss/bugfixes
Vyruss/bugfixes
2 parents e1915e0 + cfafe38 commit ac88afc

File tree

10 files changed

+328
-140
lines changed

10 files changed

+328
-140
lines changed

app/controllers/admin/annotations_controller.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,14 @@ class AnnotationsController < Admin::ApplicationController
55
#
66
# def index
77
# super
8-
# @resources = SuggestedAnswer.
8+
# @resources = Annotation.
99
# page(params[:page]).
1010
# per(10)
1111
# end
1212

1313
# Define a custom finder by overriding the `find_resource` method:
1414
# def find_resource(param)
15-
# SuggestedAnswer.find_by!(slug: param)
15+
# Annotation.find_by!(slug: param)
1616
# end
1717

1818
# See https://administrate-prototype.herokuapp.com/customizing_controller_actions

app/controllers/registrations_controller.rb

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,10 @@ def create
4040
redirect_to after_sign_up_error_path_for(resource), alert: _('You must accept the terms and conditions to register.')
4141
else
4242
existing_user = User.find_by_email(sign_up_params[:email])
43-
if !existing_user.nil? then
44-
if (existing_user.password == "" || existing_user.password.nil?) && existing_user.confirmed_at.nil? then
45-
@user = existing_user
46-
do_update(false, true)
43+
if !existing_user.nil? # If email exists
44+
if (existing_user.password == "" || existing_user.password.nil?) && existing_user.confirmed_at.nil? # If user has not accepted invitation yet
45+
existing_user.destroy # Only solution for now
46+
super
4747
else
4848
redirect_to after_sign_up_error_path_for(resource), alert: _('That email address is already registered.')
4949
end
@@ -91,16 +91,16 @@ def needs_password?(user, params)
9191
end
9292

9393
def do_update(require_password = true, confirm = false)
94-
if require_password # user is changing email or password
95-
if current_user.email != params[:user][:email] # if user changing email
96-
if params[:user][:current_password].blank? # password needs to be present
94+
if require_password # user is changing email or password
95+
if current_user.email != params[:user][:email] # if user is changing email
96+
if params[:user][:current_password].blank? # password needs to be present
9797
message = _('Please enter your password to change email address.')
9898
successfully_updated = false
9999
else
100100
successfully_updated = current_user.update_with_password(password_update)
101101
end
102-
elsif params[:user][:password].present? # user is changing password
103-
successfully_updated = false # shared across first 3 conditions
102+
elsif params[:user][:password].present? # if user is changing password
103+
successfully_updated = false # shared across first 3 conditions
104104
if params[:user][:current_password].blank?
105105
message = _('Please enter your current password')
106106
elsif params[:user][:password_confirmation].blank?
@@ -110,10 +110,10 @@ def do_update(require_password = true, confirm = false)
110110
else
111111
successfully_updated = current_user.update_with_password(password_update)
112112
end
113-
else # potentially unreachable... but I dont like to leave off the else
113+
else # potentially unreachable... but I dont like to leave off the else
114114
successfully_updated = current_user.update_with_password(password_update)
115115
end
116-
else # password not required
116+
else # password not required
117117
successfully_updated = current_user.update_without_password(update_params)
118118
end
119119

@@ -125,7 +125,7 @@ def do_update(require_password = true, confirm = false)
125125
#render the correct page
126126
if successfully_updated
127127
if confirm
128-
current_user.skip_confirmation!
128+
current_user.skip_confirmation! # will error out if confirmable is turned off in user model
129129
current_user.save!
130130
end
131131
session[:locale] = current_user.get_locale unless current_user.get_locale.nil?

app/dashboards/annotation_dashboard.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ class AnnotationDashboard < Administrate::BaseDashboard
1212
question: Field::BelongsTo,
1313
id: Field::Number,
1414
text: Field::Text,
15-
type: Field::integer,
15+
type: Field::String.with_options(searchable: false),
1616
created_at: Field::DateTime,
1717
updated_at: Field::DateTime,
1818
}.freeze
@@ -51,10 +51,10 @@ class AnnotationDashboard < Administrate::BaseDashboard
5151
:type,
5252
].freeze
5353

54-
# Overwrite this method to customize how suggested answers are displayed
54+
# Overwrite this method to customize how annotations are displayed
5555
# across all pages of the admin dashboard.
5656
#
57-
# def display_resource(suggested_answer)
58-
# "SuggestedAnswer ##{suggested_answer.id}"
57+
# def display_resource(annotation)
58+
# "Annotation ##{annotation.id}"
5959
# end
6060
end
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<form class="search">
2+
<span class="search__icon">
3+
<%= image_tag "administrate/search.svg", alt: "search", width: 16, height: 16 %>
4+
</span>
5+
<input
6+
type="text"
7+
name="search"
8+
class="search__input"
9+
placeholder="Search"
10+
value="<%= search_term %>"
11+
aria-label="Search"
12+
/>
13+
<span class="search__hint">
14+
Press enter to search
15+
</span>
16+
<span class="search__clear">
17+
<%= link_to clear_search_params do %>
18+
<%= image_tag "administrate/cancel.svg", alt: "cancel-search", width: 16, height: 16 %>
19+
<% end %>
20+
</span>
21+
</form>

config/locale/app.pot

Lines changed: 42 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ msgid ""
88
msgstr ""
99
"Project-Id-Version: app 1.0.0\n"
1010
"Report-Msgid-Bugs-To: \n"
11-
"POT-Creation-Date: 2017-05-15 20:57+0000\n"
12-
"PO-Revision-Date: 2017-05-15 20:57+0000\n"
11+
"POT-Creation-Date: 2017-05-19 17:36+0100\n"
12+
"PO-Revision-Date: 2017-05-19 17:36+0100\n"
1313
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
1414
"Language-Team: LANGUAGE <[email protected]>\n"
1515
"Language: \n"
@@ -24,7 +24,10 @@ msgstr ""
2424
msgid " - "
2525
msgstr ""
2626

27-
msgid " I accept the <a href=\"/%{current_locale}/terms\" target=\"_blank\">terms and conditions</a> *"
27+
msgid " Guidance"
28+
msgstr ""
29+
30+
msgid " I accept the <a href=\"/terms\" target=\"_blank\">terms and conditions</a> *"
2831
msgstr ""
2932

3033
msgid " Plan"
@@ -252,6 +255,9 @@ msgstr ""
252255
msgid "Add collaborator"
253256
msgstr ""
254257

258+
msgid "Add example answer"
259+
msgstr ""
260+
255261
msgid "Add guidance"
256262
msgstr ""
257263

@@ -273,9 +279,6 @@ msgstr ""
273279
msgid "Add section"
274280
msgstr ""
275281

276-
msgid "Add suggested answer/ example"
277-
msgstr ""
278-
279282
msgid "Additional comment area will be displayed."
280283
msgstr ""
281284

@@ -303,6 +306,9 @@ msgstr ""
303306
msgid "Answered"
304307
msgstr ""
305308

309+
msgid "Answered "
310+
msgstr ""
311+
306312
msgid "Answered at"
307313
msgstr ""
308314

@@ -342,6 +348,9 @@ msgstr ""
342348
msgid "Before you get started, we need to ask a few questions to set you up with the best DMP template for your needs."
343349
msgstr ""
344350

351+
msgid "Begin typing to see a filtered list"
352+
msgstr ""
353+
345354
msgid "Below is a list of users registered for your organisation. You can sort the data by each field."
346355
msgstr ""
347356

@@ -465,6 +474,9 @@ msgstr ""
465474
msgid "Display additional comment area."
466475
msgstr ""
467476

477+
msgid "Draft"
478+
msgstr ""
479+
468480
msgid "Dropdown"
469481
msgstr ""
470482

@@ -474,6 +486,9 @@ msgstr ""
474486
msgid "Edit"
475487
msgstr ""
476488

489+
msgid "Edit Example of Answer"
490+
msgstr ""
491+
477492
msgid "Edit User Privileges"
478493
msgstr ""
479494

@@ -495,9 +510,6 @@ msgstr ""
495510
msgid "Edit question"
496511
msgstr ""
497512

498-
msgid "Edit suggested answer/ example"
499-
msgstr ""
500-
501513
msgid "Edit template details"
502514
msgstr ""
503515

@@ -537,6 +549,12 @@ msgstr ""
537549
msgid "Error!"
538550
msgstr ""
539551

552+
msgid "Example Answer"
553+
msgstr ""
554+
555+
msgid "Example of Answer"
556+
msgstr ""
557+
540558
msgid "Example of answer"
541559
msgstr ""
542560

@@ -942,6 +960,9 @@ msgstr ""
942960
msgid "Please enter your current password below when changing your email address."
943961
msgstr ""
944962

963+
msgid "Please enter your email"
964+
msgstr ""
965+
945966
msgid "Please enter your first name."
946967
msgstr ""
947968

@@ -969,9 +990,6 @@ msgstr ""
969990
msgid "Please select one"
970991
msgstr ""
971992

972-
msgid "Policy Expectations"
973-
msgstr ""
974-
975993
msgid "Preview"
976994
msgstr ""
977995

@@ -1233,9 +1251,6 @@ msgstr ""
12331251
msgid "This document was generated by %{application_name}"
12341252
msgstr ""
12351253

1236-
msgid "This must be a valid email address - a message will be sent to it for confirmation."
1237-
msgstr ""
1238-
12391254
msgid "This must match what you entered in the previous field."
12401255
msgstr ""
12411256

@@ -1392,12 +1407,18 @@ msgstr ""
13921407
msgid "You are about to delete a suggested answer/ example for '%{question_text}'. Are you sure?"
13931408
msgstr ""
13941409

1410+
msgid "You are about to delete an example answer for '%{question_text}'. Are you sure?"
1411+
msgstr ""
1412+
13951413
msgid "You are not authorized to perform this action."
13961414
msgstr ""
13971415

13981416
msgid "You are viewing a historical version of this template. You will not be able to make changes."
13991417
msgstr ""
14001418

1419+
msgid "You can add an example answer to help users respond. These will be presented above the answer box and can be copied/ pasted."
1420+
msgstr ""
1421+
14011422
msgid "You can add an example or suggested answer to help users respond. These will be presented above the answer box and can be copied/ pasted."
14021423
msgstr ""
14031424

@@ -1527,6 +1548,9 @@ msgstr ""
15271548
msgid "by"
15281549
msgstr ""
15291550

1551+
msgid "by "
1552+
msgstr ""
1553+
15301554
msgid "can't be blank"
15311555
msgstr ""
15321556

@@ -1539,6 +1563,9 @@ msgstr ""
15391563
msgid "e.g. School/ Department"
15401564
msgstr ""
15411565

1566+
msgid "example answer"
1567+
msgstr ""
1568+
15421569
msgid "from now"
15431570
msgstr ""
15441571

@@ -1596,9 +1623,6 @@ msgstr ""
15961623
msgid "or copy"
15971624
msgstr ""
15981625

1599-
msgid "org_admin.templates.edit_phase_label"
1600-
msgstr ""
1601-
16021626
msgid "organisation"
16031627
msgstr ""
16041628

@@ -1632,9 +1656,6 @@ msgstr ""
16321656
msgid "select at least one theme"
16331657
msgstr ""
16341658

1635-
msgid "suggested answer"
1636-
msgstr ""
1637-
16381659
msgid "template"
16391660
msgstr ""
16401661

0 commit comments

Comments
 (0)