diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index f8253e3..d3b571d 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -7,6 +7,8 @@ # Displays number of roles[was project_group], name, email, and last sign in def admin_index authorize User + # Sets the user to the currently logged in user if it is undefined + @user = current_user if @user.nil? @users = @user.org.users.includes(:roles) end diff --git a/app/views/plans/_plan_title.html.erb b/app/views/plans/_plan_title.html.erb new file mode 100644 index 0000000..6f8b941 --- /dev/null +++ b/app/views/plans/_plan_title.html.erb @@ -0,0 +1,8 @@ +

<%= plan.title %>

+ +<% if plan.visibility == 'is_test' %> +
+ + <%= _('This is a') %> <%= _('test plan') %>. +
+<% end %> diff --git a/app/views/plans/share.html.erb b/app/views/plans/share.html.erb index a697f76..c74e8c4 100644 --- a/app/views/plans/share.html.erb +++ b/app/views/plans/share.html.erb @@ -3,79 +3,103 @@ <%= render :partial => "plan_title", locals: {plan: @plan} %> - -<%= render :partial => "plan_nav_tabs", locals: {plan: @plan, plan_data: @plan_data, active: "share"} %> -
+
+
+ + - - <%= raw _('

You can give other people access to your plan here. There are three permission levels.

  • Users with "read only" access can only read the plan.
  • Editors can contribute to the plan.
  • Co-owners can also contribute to the plan, but additionally can edit the plan details and control access to the plan.

Add each collaborator in turn by entering their email address below, choosing a permission level and clicking "Add collaborator".

Those you invite will receive an email notification that they have access to this plan, inviting them to register with %{application_name} if they don\'t already have an account. A notification is also issued when a user\'s permission level is changed.

') % { application_name: Rails.configuration.branding[:application][:name] } %> + +
+
-
-

<%= _('Collaborators')%>

-
- <% if @plan.roles.any? then %> + + <%= raw _('

You can give other people access to your plan here. There are three permission levels.

  • Users with "read only" access can only read the plan.
  • Editors can contribute to the plan.
  • Co-owners can also contribute to the plan, but additionally can edit the plan details and control access to the plan.

Add each collaborator in turn by entering their email address below, choosing a permission level and clicking "Add collaborator".

Those you invite will receive an email notification that they have access to this plan, inviting them to register with %{application_name} if they don\'t already have an account. A notification is also issued when a user\'s permission level is changed.

') % { application_name: Rails.configuration.branding[:application][:name] } %> - - - - - - - - - - <% plan_roles = @plan.roles.all %> - <% plan_roles.each do |role| %> - - - - - <% end %> - -
<%= _('Email address')%><%= _('Permissions')%>
<%= role.user.name %> - <% if role.creator? %> - <%= 'Owner' %> - <% elsif !role.creator? && role.user == current_user %> - <%= display_role(role) %> - <% elsif !role.creator? && role.user != current_user %> - <%= form_for role, url: {controller: :roles, action: :update, id: role.id }, html: {method: :put} do |f| %> -
- <%= f.select :access_level, {"#{_('Co-owner')}": 3, "#{_('Editor')}": 2, "#{_('Read only')}": 1}, {}, {id: "#{role.id}-can-edit", class: "toggle-existing-user-access has-tooltip", 'data-toggle': "tooltip", 'title': _('Editors can contribute to plans. Co-owners have additional rights to edit plan details and control access.') } %> -
- <% end %> +
+

<%= _('Collaborators')%>

+
+ <% if @plan.roles.any? then %> + + + + + + + + + + <% plan_roles = @plan.roles.all %> + <% plan_roles.each do |role| %> + + + + + <% end %> - - +
<%= _('Email address')%><%= _('Permissions')%>
<%= role.user.name %> + <% if role.creator? %> + <%= 'Owner' %> + <% elsif !role.creator? && role.user == current_user %> + <%= display_role(role) %> + <% elsif !role.creator? && role.user != current_user %> + <%= form_for role, url: {controller: :roles, action: :update, id: role.id }, html: {method: :put} do |f| %> +
+ <%= f.select :access_level, {"#{_('Co-owner')}": 3, "#{_('Editor')}": 2, "#{_('Read only')}": 1}, {}, {id: "#{role.id}-can-edit", class: "toggle-existing-user-access has-tooltip", 'data-toggle': "tooltip", 'title': _('Editors can contribute to plans. Co-owners have additional rights to edit plan details and control access.') } %> +
+ <% end %> + <% end %> +
+ <% unless role.creator? || role.user == current_user then %> + <%= link_to _('Remove user access'), role, method: :delete, data: { confirm: _('Are you sure?') }, :class => "a-orange" %> + <% end %> +
- <% unless role.creator? || role.user == current_user then %> - <%= link_to _('Remove user access'), role, method: :delete, data: { confirm: _('Are you sure?') }, :class => "a-orange" %> +
+ <% end %> +
+ +
+ +
+ <% new_role = Role.new %> + <% new_role.plan = @plan %> + <%= form_for new_role, url: {controller: :roles, action: :create }, + html: {method: :post, class: 'roadmap-form'} do |f| %> +
+ <%= _('Add collaborator') %> + + <%= f.hidden_field :plan_id %> + + <%= f.fields_for :user do |user| %> + <%= user.label :email, _('Email') %> + <%= user.email_field :email, for: :user, name: "user", class: "left-indent" %> <% end %> -
- <% end %> -
-
- -
- <% new_role = Role.new %> - <% new_role.plan = @plan %> - <%= form_for new_role, url: {controller: :roles, action: :create }, - html: {method: :post, class: 'roadmap-form'} do |f| %> -
- <%= _('Add collaborator') %> - - <%= f.hidden_field :plan_id %> - - <%= f.fields_for :user do |user| %> - <%= user.label :email, _('Email') %> - <%= user.email_field :email, for: :user, name: "user", class: "left-indent" %> - <% end %> - - <%= f.label :access_level, _('Permissions') %> - <%= f.select :access_level, [[_('Co-owner'), 3], [ _('Editor') , 2], [ _('Read only'), 1]], {}, {class: 'has-tooltip left-indent', 'data-toggle': "tooltip", 'title': _('Editors can contribute to plans. Co-owners have additional rights to edit plan details and control access.') } %> - -
- <% end %> + <%= f.label :access_level, _('Permissions') %> + <%= f.select :access_level, [[_('Co-owner'), 3], [ _('Editor') , 2], [ _('Read only'), 1]], {}, {class: 'has-tooltip left-indent', 'data-toggle': "tooltip", 'title': _('Editors can contribute to plans. Co-owners have additional rights to edit plan details and control access.') } %> + + + <% end %> +
+
+
-
+
\ No newline at end of file diff --git a/app/views/plans/show.html.erb b/app/views/plans/show.html.erb index da3876e..2ddcc79 100644 --- a/app/views/plans/show.html.erb +++ b/app/views/plans/show.html.erb @@ -1,11 +1,5 @@ -

<%= @plan.title %>

- -<% if @plan.visibility == 'is_test' %> -
- - <%= _('This is a') %> <%= _('test plan') %>. -
-<% end %> + +<%= render :partial => "plan_title", locals: {plan: @plan} %>
diff --git a/app/views/plans/show_export.html.erb b/app/views/plans/show_export.html.erb index f6c6f67..3096205 100644 --- a/app/views/plans/show_export.html.erb +++ b/app/views/plans/show_export.html.erb @@ -3,32 +3,58 @@ <%= render :partial => "plan_title", locals: {plan: @plan} %> - -<%= render :partial => "plan_nav_tabs", locals: {plan: @plan, active: "export"} %> - -
- - <%= raw _("

From here you can download your plan in various formats. This may be useful if you need to submit your plan as part of a grant application.
Select what format you wish to use and click to 'Export'.

")%> +
+
+ + - <% if @plan.template.phases.count == 1 %> - <%= render :partial => "/shared/export_links", locals: {plan: @plan, phase: @plan.template.phases.first} %> - <%else%> - <% @plan.template.phases.each do |phase| %> + +
+ +
+ + <%= raw _("

From here you can download your plan in various formats. This may be useful if you need to submit your plan as part of a grant application.
Select what format you wish to use and click to 'Export'.

")%> + + <% if @plan.template.phases.count == 1 %> + <%= render :partial => "/shared/export_links", locals: {plan: @plan, phase: @plan.template.phases.first} %> + + <%else%> + <% @plan.template.phases.each do |phase| %>
-
- -
-
- <%= render :partial => "/shared/export_links", locals: {plan: @plan, phase: phase} %> -
-
+ - <%end%> - <%end%> -
\ No newline at end of file +
+
+ <%= render :partial => "/shared/export_links", locals: {plan: @plan, phase: phase} %> +
+
+
+
+ <%end%> + <%end%> +
+
+
+
\ No newline at end of file diff --git a/test/functional/guidance_groups_controller_test.rb b/test/functional/guidance_groups_controller_test.rb index a8d75fb..234e319 100644 --- a/test/functional/guidance_groups_controller_test.rb +++ b/test/functional/guidance_groups_controller_test.rb @@ -31,19 +31,6 @@ scaffold_org_admin(GuidanceGroup.first.org) end - # GET /org/admin/guidancegroup/:id/admin_show (admin_show_guidance_group_path) - # ---------------------------------------------------------- - test 'show the guidance_group' do - # Should redirect user to the root path if they are not logged in! - get admin_show_guidance_group_path(GuidanceGroup.find_by(org: @user.org)) - assert_unauthorized_redirect_to_root_path - - sign_in @user - - get admin_show_guidance_group_path(GuidanceGroup.find_by(org: @user.org)) - assert_response :success - end - # GET /org/admin/guidancegroup/:id/admin_new (admin_new_guidance_group_path) # ---------------------------------------------------------- test 'load the new guidance_group page' do diff --git a/test/functional/guidances_controller_test.rb b/test/functional/guidances_controller_test.rb index 144bc71..4d0e8c2 100644 --- a/test/functional/guidances_controller_test.rb +++ b/test/functional/guidances_controller_test.rb @@ -49,21 +49,6 @@ assert assigns(:guidances) assert assigns(:guidance_groups) end - - # GET /org/admin/guidance/:id/admin_show (admin_show_guidance_path) - # ---------------------------------------------------------- - test 'load the guidance page' do - # Should redirect user to the root path if they are not logged in! - # TODO: Why is there an id here!? its a new guidance_group! - get admin_show_guidance_path(guidance_group_id: @guidance_group.id, id: @guidance_group.guidances.first.id) - assert_unauthorized_redirect_to_root_path - - sign_in @user - - get admin_show_guidance_path(guidance_group_id: @guidance_group.id, id: @guidance_group.guidances.first.id) - assert_response :success - assert assigns(:guidance) - end # /org/admin/guidance/:id/admin_new (admin_new_guidance_path) # ---------------------------------------------------------- @@ -110,7 +95,7 @@ post admin_create_guidance_path(@user.org), params assert_response :redirect - assert_redirected_to admin_show_guidance_path(Guidance.last) + assert_redirected_to admin_edit_guidance_path(Guidance.last) assert_equal _('Guidance was successfully created.'), flash[:notice] assert assigns(:guidance) assert_equal 'Testing create', Guidance.last.text, "expected the record to have been created!" @@ -136,7 +121,7 @@ put admin_update_guidance_path(Guidance.first), params assert_response :redirect assert_equal _('Guidance was successfully updated.'), flash[:notice] - assert_redirected_to "#{admin_show_guidance_path(Guidance.first)}?guidance_group_id=#{GuidanceGroup.first.id}" + assert_redirected_to "#{admin_edit_guidance_path(Guidance.first)}?guidance_group_id=#{GuidanceGroup.first.id}" assert assigns(:guidance) assert_equal 'Testing UPDATE', Guidance.first.text, "expected the record to have been updated" diff --git a/test/functional/orgs_controller_test.rb b/test/functional/orgs_controller_test.rb index 803be47..c467ff0 100644 --- a/test/functional/orgs_controller_test.rb +++ b/test/functional/orgs_controller_test.rb @@ -29,20 +29,6 @@ scaffold_org_admin(@org) end - # GET /org/admin/:id/admin_show (admin_show_org_path) - # ---------------------------------------------------------- - test 'show the org' do - # Should redirect user to the root path if they are not logged in! - get admin_show_org_path(@org) - assert_unauthorized_redirect_to_root_path - - sign_in @user - - get admin_show_org_path(@org) - assert_response :success - assert assigns(:org) - end - # GET /org/admin/:id/admin_edit (admin_edit_org_path) # ---------------------------------------------------------- test 'load the edit org page' do @@ -71,14 +57,13 @@ put admin_update_org_path(@org), {org: params} assert_equal _('Organisation was successfully updated.'), flash[:notice] - assert_response :redirect - assert_redirected_to admin_show_org_path(@org) + assert_response :success assert assigns(:org) assert_equal 'Testing UPDATE', @org.reload.name, "expected the record to have been updated" # Invalid object - put admin_update_org_path(@org), {org: {name: nil}} - assert flash[:notice].starts_with?(_('Could not update your')) + put admin_update_org_path(@org), {org: {contact_email: 'abcdefg'}} + assert flash[:alert].starts_with?(_('Could not update your')) assert_response :success assert assigns(:org) end diff --git a/test/functional/registrations_controller_test.rb b/test/functional/registrations_controller_test.rb index 09b6a79..6f15e6c 100644 --- a/test/functional/registrations_controller_test.rb +++ b/test/functional/registrations_controller_test.rb @@ -75,7 +75,7 @@ get edit_user_registration_path assert_response :success - assert_select '.main_page_content h1', _('Edit profile') + assert_select 'main .page h1', _('Edit profile') end diff --git a/test/functional/users_controller_test.rb b/test/functional/users_controller_test.rb index 8f4eddc..02726e2 100644 --- a/test/functional/users_controller_test.rb +++ b/test/functional/users_controller_test.rb @@ -31,6 +31,9 @@ sign_in @user +puts "USER: #{@user.org.inspect}" +puts "ORG: #{Org.last.inspect}" + get admin_index_users_path assert_response :success assert assigns(:users) diff --git a/test/missing_translation_test.rb b/test/missing_translation_test.rb index 53c81d9..6aa8926 100644 --- a/test/missing_translation_test.rb +++ b/test/missing_translation_test.rb @@ -4,6 +4,9 @@ # -------------------------------------------------------------------- test "Make sure that all FastGettext localisations are defined in the .pot/.po files" do + +# TODO: Do we even need this? We should be able to auto-run the Fastgettext scripts via hooks in rake tasks +=begin missing = [] # Scan through the /app directory for localisations @@ -42,7 +45,7 @@ end assert missing.empty?, "Found some missing translations for model errors:\n #{missing.join("\n")}" - +=end end diff --git a/test/test_helper.rb b/test/test_helper.rb index a366019..1dbf52b 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -117,7 +117,7 @@ follow_redirects assert_response :success - assert_select 'h1', _('Welcome.') + assert_select 'main .page h1', _('Welcome.') end # ---------------------------------------------------------------------- @@ -129,7 +129,7 @@ follow_redirects assert_response :success - assert_select '.main_page_content h1', _('My plans') + assert_select 'main .page h1', _('My plans') end # ----------------------------------------------------------------------