Skip to content

Commit dcc0676

Browse files
authored
Merge pull request #423 from DigitalCurationCentre/xsrust/bugfixes
Xsrust/bugfixes
2 parents 4f82275 + 17b6eff commit dcc0676

File tree

15 files changed

+155
-100
lines changed

15 files changed

+155
-100
lines changed

app/controllers/phases_controller.rb

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,11 @@ def admin_show
118118
if params.has_key?(:question_id)
119119
@question_id = params[:question_id].to_i
120120
end
121+
if @phase.template.customization_of.present?
122+
@original_org = Template.where(dmptemplate_id: @phase.template.customization_of).first.org
123+
else
124+
@original_org = @phase.template.org
125+
end
121126
end
122127

123128

@@ -179,6 +184,11 @@ def admin_update
179184
@section_id = (params[:section_id].nil? ? nil : params[:section_id].to_i)
180185
@question_id = (params[:question_id].nil? ? nil : params[:question_id].to_i)
181186
flash[:notice] = failed_update_error(@phase, _('phase'))
187+
if @phase.template.customization_of.present?
188+
@original_org = Template.where(dmptemplate_id: @phase.template.customization_of).first.org
189+
else
190+
@original_org = @phase.template.org
191+
end
182192
render 'admin_show'
183193
end
184194
end
@@ -203,6 +213,11 @@ def admin_destroy
203213
@section_id = (params[:section_id].nil? ? nil : params[:section_id].to_i)
204214
@question_id = (params[:question_id].nil? ? nil : params[:question_id].to_i)
205215
flash[:notice] = failed_destroy_error(@phase, _('phase'))
216+
if @phase.template.customization_of.present?
217+
@original_org = Template.where(dmptemplate_id: @phase.template.customization_of).first.org
218+
else
219+
@original_org = @phase.template.org
220+
end
206221
render 'admin_show'
207222
end
208223
end

app/controllers/questions_controller.rb

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,18 +35,23 @@ def admin_create
3535
@question_id = @question.id
3636

3737
flash[:notice] = failed_create_error(@question, _('question'))
38+
if @phase.template.customization_of.present?
39+
@original_org = Template.where(dmptemplate_id: @phase.template.customization_of).first.org
40+
else
41+
@original_org = @phase.template.org
42+
end
3843
render template: 'phases/admin_show'
3944
end
4045
rescue ActionController::ParameterMissing => e
41-
flash[:notice] = e.message
46+
flash[:notice] = e.message
4247
end
4348
end
4449

4550
#update a question of a template
4651
def admin_update
4752
@question = Question.find(params[:id])
4853
authorize @question
49-
guidance = @question.get_guidance_annotation(current_user.org_id)
54+
guidance = @question.get_guidance_annotation(current_user.org_id)
5055
if params["question-guidance-#{params[:id]}"].present?
5156
if guidance.blank?
5257
guidance = @question.annotations.build
@@ -76,6 +81,11 @@ def admin_update
7681
@question_id = @question.id
7782

7883
flash[:notice] = failed_update_error(@question, _('question'))
84+
if @phase.template.customization_of.present?
85+
@original_org = Template.where(dmptemplate_id: @phase.template.customization_of).first.org
86+
else
87+
@original_org = @phase.template.org
88+
end
7989
render template: 'phases/admin_show'
8090
end
8191
end
@@ -89,7 +99,7 @@ def admin_destroy
8999
if @question.destroy
90100
@phase.template.dirty = true
91101
@phase.template.save!
92-
102+
93103
redirect_to admin_show_phase_path(id: @phase.id, section_id: @section.id, edit: 'true'), notice: _('Information was successfully deleted.')
94104
else
95105
redirect_to admin_show_phase_path(id: @phase.id, section_id: @section.id, edit: 'true'), notice: failed_destroy_error(@question, 'question')

app/controllers/sections_controller.rb

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ def admin_create
1212
if @section.save
1313
@section.phase.template.dirty = true
1414
@section.phase.template.save!
15-
15+
1616
redirect_to admin_show_phase_path(id: @section.phase_id,
1717
:section_id => @section.id, edit: 'true'), notice: _('Information was successfully created.')
1818
else
@@ -22,6 +22,11 @@ def admin_create
2222
@section_id = @section.id
2323
@question_id = nil
2424
flash[:notice] = failed_create_error(@section, _('section'))
25+
if @phase.template.customization_of.present?
26+
@original_org = Template.where(dmptemplate_id: @phase.template.customization_of).first.org
27+
else
28+
@original_org = @phase.template.org
29+
end
2530
render template: 'phases/admin_show'
2631
end
2732
end
@@ -36,7 +41,7 @@ def admin_update
3641
if @section.update_attributes(params[:section])
3742
@section.phase.template.dirty = true
3843
@section.phase.template.save!
39-
44+
4045
redirect_to admin_show_phase_path(id: @phase.id, section_id: @section.id , edit: 'true'), notice: _('Information was successfully updated.')
4146
else
4247
@edit = (@phase.template.org == current_user.org)
@@ -45,6 +50,11 @@ def admin_update
4550
@section_id = @section.id
4651
@question_id = nil
4752
flash[:notice] = failed_update_error(@section, _('section'))
53+
if @phase.template.customization_of.present?
54+
@original_org = Template.where(dmptemplate_id: @phase.template.customization_of).first.org
55+
else
56+
@original_org = @phase.template.org
57+
end
4858
render template: 'phases/admin_show'
4959
end
5060
end
@@ -55,22 +65,27 @@ def admin_destroy
5565
@section = Section.includes(phase: :template).find(params[:section_id])
5666
authorize @section
5767
@phase = @section.phase
58-
68+
5969
if @section.destroy
6070
@phase.template.dirty = true
6171
@phase.template.save!
62-
72+
6373
redirect_to admin_show_phase_path(id: @phase.id, edit: 'true' ), notice: _('Information was successfully deleted.')
6474
else
6575
@edit = (@phase.template.org == current_user.org)
6676
@open = true
6777
@sections = @phase.sections
6878
@section_id = @section.id
6979
@question_id = nil
70-
80+
7181
flash[:notice] = failed_destroy_error(@section, _('section'))
82+
if @phase.template.customization_of.present?
83+
@original_org = Template.where(dmptemplate_id: @phase.template.customization_of).first.org
84+
else
85+
@original_org = @phase.template.org
86+
end
7287
render template: 'phases/admin_show'
7388
end
7489
end
75-
90+
7691
end

app/controllers/templates_controller.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ def admin_transfer_customization
117117
if section.modifiable
118118
# this is a custom section
119119
section_copy = Section.deep_copy(section)
120-
customization_phase = new_customization.phases.includes(:sections.where(number: phase.number).first)
120+
customization_phase = new_customization.phases.includes(:sections).where(number: phase.number).first
121121
section_copy.phase_id = customization_phase.id
122122
# custom sections get added to the end
123123
section_copy.number = customization_phase.sections.length + 1

app/models/template.rb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@ def self.org_customizations(dmptemplate_id, org_id)
5555
Template.where(customization_of: dmptemplate_id, org_id: org_id).order(version: :desc).valid.first
5656
end
5757

58-
5958
##
6059
# deep copy the given template and all of it's associations
6160
#

app/views/layouts/_signin_signout.html.erb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,9 @@
1212
<li><%= link_to _('Super admin area'), "/admin", class: "signIn_dropdown_link" %></li>
1313
<% end %>
1414
<% if current_user.can_org_admin? && !current_user.org_id.nil? %>
15-
<% if current_user.can_modify_templates? %>
15+
<% if current_user.can_modify_org_details? && current_user.org.abbreviation.blank? %>
16+
<li><%= link_to _("Admin area"), admin_show_org_path(current_user.org_id), class: "signIn_dropdown_link" %></li>
17+
<% elsif current_user.can_modify_templates?%>
1618
<li><%= link_to _("Admin area"), admin_index_template_path(current_user.org_id), class: "signIn_dropdown_link" %></li>
1719
<% elsif current_user.can_modify_guidance? %>
1820
<li><%= link_to _("Admin area"), admin_index_guidance_path(current_user.org_id), class: "signIn_dropdown_link" %></li>

app/views/orgs/admin_show.html.erb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,10 @@
2828
<td class="first"><%= _('Abbreviation') %></td>
2929
<td><%= @org.abbreviation %></td>
3030
</tr>
31+
<% else %>
32+
<tr>
33+
<td class="first"><%= _('Abbreviation') %></td>
34+
<td><emph><%= _('Please add an abbreviation to your org for display with annotations!')%></emph></td>
3135
<% end %>
3236

3337
<% if @org.banner_text.present? then %>

app/views/questions/_show_question.html.erb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@
6363

6464
<!-- Suggested answer or Example-->
6565
<% if !question.section.phase.template.org.funder? %>
66-
<% example_answer = question.get_example_answer(current_user.org_id) %>
66+
<% example_answer = question.get_example_answer(@original_org.id) %>
6767
<% if example_answer.present? && example_answer.text.present? %>
6868
<tr>
6969
<td class="first_template">
@@ -74,7 +74,7 @@
7474
<% end %>
7575
<% end %>
7676
<!-- Guidance linked to this question -->
77-
<% guidance = question.get_guidance_annotation(current_user.org_id) %>
77+
<% guidance = question.get_guidance_annotation(@original_org.id) %>
7878
<% if guidance.present? %>
7979
<tr>
8080
<td class="first_template"><%= _('Guidance')%></td>

config/initializers/fast_gettext.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ def get_default_locale
1212
return language.nil? ? 'en_GB' : language.abbreviation
1313
end
1414

15-
FastGettext.add_text_domain 'app', :path => 'config/locale', :type => :po, :ignore_fuzzy => true
15+
FastGettext.add_text_domain 'app', :path => 'config/locale', :type => :po, :ignore_fuzzy => true, :report_warning => false
1616
FastGettext.default_text_domain = 'app'
1717
FastGettext.default_available_locales = get_available_locales()
1818
FastGettext.default_locale = get_default_locale()

config/locale/app.pot

Lines changed: 15 additions & 15 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-06-08 14:43+0000\n"
12-
"PO-Revision-Date: 2017-06-08 14:43+0000\n"
11+
"POT-Creation-Date: 2017-06-15 12:42+0000\n"
12+
"PO-Revision-Date: 2017-06-15 12:42+0000\n"
1313
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
1414
"Language-Team: LANGUAGE <[email protected]>\n"
1515
"Language: \n"
@@ -351,6 +351,9 @@ msgstr ""
351351
msgid "Bad Credentials"
352352
msgstr ""
353353

354+
msgid "Bad Parameters"
355+
msgstr ""
356+
354357
msgid "Before submitting, please consider:"
355358
msgstr ""
356359

@@ -435,6 +438,9 @@ msgstr ""
435438
msgid "Create a template"
436439
msgstr ""
437440

441+
msgid "Create account"
442+
msgstr ""
443+
438444
msgid "Create plan"
439445
msgstr ""
440446

@@ -966,6 +972,9 @@ msgstr ""
966972
msgid "Plan was successfully updated."
967973
msgstr ""
968974

975+
msgid "Please add an abbreviation to your org for display with annotations!"
976+
msgstr ""
977+
969978
msgid "Please enter a First name."
970979
msgstr ""
971980

@@ -1188,9 +1197,6 @@ msgstr ""
11881197
msgid "Sign out"
11891198
msgstr ""
11901199

1191-
msgid "Create account"
1192-
msgstr ""
1193-
11941200
msgid "Signed in as "
11951201
msgstr ""
11961202

@@ -1650,6 +1656,9 @@ msgstr ""
16501656
msgid "must have access to guidances api"
16511657
msgstr ""
16521658

1659+
msgid "must have access to plans api"
1660+
msgstr ""
1661+
16531662
msgid "no research organisation is associated with this plan"
16541663
msgstr ""
16551664

@@ -1698,14 +1707,5 @@ msgstr ""
16981707
msgid "user"
16991708
msgstr ""
17001709

1701-
msgid "{\"Error\":\"Organisation does not exist\"}"
1702-
msgstr ""
1703-
1704-
msgid "{\"Error\":\"Organisation has more than one template and template name unspecified or invalid\"}"
1705-
msgstr ""
1706-
1707-
msgid "{\"Error\":\"Organisation specified is not a funder\"}"
1708-
msgstr ""
1709-
1710-
msgid "{\"Error\":\"You do not have authorisation to view this endpoint\"}"
1710+
msgid "user must be in your organisation"
17111711
msgstr ""

0 commit comments

Comments
 (0)