diff --git a/app/controllers/registrations_controller.rb b/app/controllers/registrations_controller.rb index ff58a25..78ecb7c 100644 --- a/app/controllers/registrations_controller.rb +++ b/app/controllers/registrations_controller.rb @@ -15,9 +15,9 @@ IdentifierScheme.all.each do |scheme| oauth = session["devise.#{scheme.name.downcase}_data"] unless session["devise.#{scheme.name.downcase}_data"].nil? end - + @user = User.new - + unless oauth.nil? # The OAuth provider could not be determined or there was no unique UID! if oauth[:provider].nil? || oauth[:uid].nil? @@ -26,7 +26,7 @@ else # Connect the new user with the identifier sent back by the OAuth provider flash[:notice] = t('identifier_schemes.new_login_success') - UserIdentifier.create(identifier_scheme: oauth[:provider].upcase, + UserIdentifier.create(identifier_scheme: oauth[:provider].upcase, identifier: oauth[:uid], user: @user) end @@ -78,6 +78,7 @@ @identifier_schemes = IdentifierScheme.where(active: true).order(:name) @languages = Language.sorted_by_abbreviation do_update(require_password=needs_password?(current_user, params)) + update_preferences(current_user, params) else render(:file => File.join(Rails.root, 'public/403.html'), :status => 403, :layout => false) end @@ -165,22 +166,43 @@ end end + def update_preferences(current_user, params) + prefs = params[:prefs] + # Set all preferences to false + current_user.prefs.each do |key, value| + value.each_key do |k| + current_user.prefs[key][k] = false + end + end + + # Sets the preferences the user wants to true + if prefs + prefs.each_key do |key| + prefs[key].each_key do |k| + current_user.prefs[key.to_sym][k.to_sym] = true + end + end + end + + current_user.save + end + def sign_up_params - params.require(:user).permit(:email, :password, :password_confirmation, + params.require(:user).permit(:email, :password, :password_confirmation, :firstname, :surname, :recovery_email, - :accept_terms, :other_organisation) + :accept_terms, :other_organisation, :prefs) end def update_params params.require(:user).permit(:firstname, :org_id, :other_organisation, - :language_id, :surname) + :language_id, :surname, :prefs) end def password_update params.require(:user).permit(:email, :firstname, :current_password, :org_id, :language_id, :password, :password_confirmation, :surname, - :other_organisation) + :other_organisation, :prefs) end end diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 7e4304c..57b504f 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -21,10 +21,6 @@ @perms = user_perms & [Perm.grant_permissions, Perm.modify_templates, Perm.modify_guidance, Perm.use_api, Perm.change_org_details] end - def update_preferences - - end - ## # POST - updates the permissions for a user # redirects to the admin_index action diff --git a/app/views/devise/registrations/_password_details.html.erb b/app/views/devise/registrations/_password_details.html.erb index e69de29..8ac19a3 100644 --- a/app/views/devise/registrations/_password_details.html.erb +++ b/app/views/devise/registrations/_password_details.html.erb @@ -0,0 +1,37 @@ +
+ <%= _('If you would like to change your password please complete the following fields.') %> + +
+ + + +
+ +
+ + + +
+ +
+ + + +
+ +
+
+ + +
+
+
\ No newline at end of file diff --git a/app/views/devise/registrations/_personal_details.html.erb b/app/views/devise/registrations/_personal_details.html.erb index b72279d..2c54efa 100644 --- a/app/views/devise/registrations/_personal_details.html.erb +++ b/app/views/devise/registrations/_personal_details.html.erb @@ -1,155 +1,115 @@

<%= _("Please note that your email address is used as your username. If you change this, remember to use your new email address on sign in.") %>

+ +
+ <%= _('You can edit any of the details below.') %> -<%= form_for(resource, as: resource_name, url: registration_path(resource_name), html: {method: :put, class: "roadmap-form white_background"}) do |f| %> - -
- <%= _('You can edit any of the details below.') %> + <%#= hidden_field_tag :unlink_flag, "false", id: "unlink_flag" %> - <%= hidden_field_tag :unlink_flag, "false", id: "unlink_flag" %> +
+ + + +
+
+ + +
+
+ + +
+ +
+ + + +
+ +
+ + <%= render partial: "shared/accessible_combobox", + locals: {name: "#{resource_name}[org_name]", + id: "#{resource_name}_org_name", + default_selection: @default_org, + models: @orgs, + attribute: 'name', + classes: 'fixed-width-large left-indent'} %> +
+ + <% if MANY_LANGUAGES %> +
+ <% lang = current_user.language.nil? ? FastGettext.default_locale : current_user.language.abbreviation %> + + +
+ <% end %> + + <% @identifier_schemes.each do |scheme| %> + <% + if scheme.name != 'shibboleth' || + (scheme.name == 'shibboleth' && Rails.application.config.shibboleth_enabled) + %>
- - - -
- -
- - -
-
- - -
- -
- - - -
- -
- - <%= render partial: "shared/accessible_combobox", - locals: {name: "#{resource_name}[org_name]", - id: "#{resource_name}_org_name", - default_selection: @default_org, - models: @orgs, - attribute: 'name', - classes: 'fixed-width-large left-indent'} %> -
- - <% if MANY_LANGUAGES %> -
- <% lang = current_user.language.nil? ? FastGettext.default_locale : current_user.language.abbreviation %> - - -
- <% end %> - - <% @identifier_schemes.each do |scheme| %> -
- -
- <%= render partial: 'external_identifier', - locals: {scheme: scheme, - id: current_user.identifier_for(scheme)} %> -
-
- <% end %> - - <% unless @user.api_token.blank? %> -
- <%= f.label :api_token, _('API token') %> -
<%= @user.api_token %>
- - -
<%= link_to( _('How to use the API'), controller: "token_permission_types", action: "index")%>
-
- <% end %> - -
- - <%= _('If you would like to change your password please complete the following fields.') %> - -
- - - -
- -
- - - -
- -
- - - -
- -
-
- - + +
+ <%= render partial: 'external_identifier', + locals: {scheme: scheme, + id: current_user.identifier_for(scheme)} %>
+ <% end %> + <% end %> -
- - <%= render partial: 'shared/accessible_submit_button', - locals: {id: 'update', - val: 'Save', - disabled_initially: true, - classes: 'small-input-button', - tooltip: _('Enter all of the required information above')} %> -
-
+ <% unless @user.api_token.blank? %> +
+ <%= f.label :api_token, _('API token') %> +
<%= @user.api_token %>
-<% end %> + +
<%= link_to( _('How to use the API'), controller: "token_permission_types", action: "index")%>
+
+ <% end %> +
+ diff --git a/app/views/devise/registrations/edit.html.erb b/app/views/devise/registrations/edit.html.erb index 44733a9..f79598a 100644 --- a/app/views/devise/registrations/edit.html.erb +++ b/app/views/devise/registrations/edit.html.erb @@ -1,172 +1,49 @@ <% javascript "devise/registrations/edit.js" %> - -
+

<%= _('Edit profile') %>

-

- <%= _("Please note that your email address is used as your username. If you change this, remember to use your new email address on sign in.") %> -

- <%= form_for(resource, as: resource_name, url: registration_path(resource_name), html: {method: :put, class: "roadmap-form white_background"}) do |f| %> - -
- <%= _('You can edit any of the details below.') %> +
+ - <%= hidden_field_tag :unlink_flag, "false", id: "unlink_flag" %> - -
- - - +
+
+ <%= render partial: 'devise/registrations/personal_details', f: f %>
-
- - -
-
- - + -
- - - + +
+
-
- - <%= render partial: "shared/accessible_combobox", - locals: {name: "#{resource_name}[org_name]", - id: "#{resource_name}_org_name", - default_selection: @default_org, - models: @orgs, - attribute: 'name', - classes: 'fixed-width-large left-indent'} %> -
+
- <% if MANY_LANGUAGES %> -
- <% lang = current_user.language.nil? ? FastGettext.default_locale : current_user.language.abbreviation %> - - -
- <% end %> - - <% @identifier_schemes.each do |scheme| %> - <% - if scheme.name != 'shibboleth' || - (scheme.name == 'shibboleth' && Rails.application.config.shibboleth_enabled) - %> -
- -
- <%= render partial: 'external_identifier', - locals: {scheme: scheme, - id: current_user.identifier_for(scheme)} %> -
-
- <% end %> - <% end %> - - <% unless @user.api_token.blank? %> -
- <%= f.label :api_token, _('API token') %> -
<%= @user.api_token %>
- - -
<%= link_to( _('How to use the API'), controller: "token_permission_types", action: "index")%>
-
- <% end %> - -
- - <%= _('If you would like to change your password please complete the following fields.') %> - -
- - - -
- -
- - - -
- -
- - - -
- -
-
- - -
-
- -
- - <%= render partial: 'shared/accessible_submit_button', - locals: {id: 'update', - val: 'Save', - disabled_initially: true, - classes: 'small-input-button', - tooltip: _('Enter all of the required information above')} %> -
-
- +
+ + <%= render partial: 'shared/accessible_submit_button', + locals: {id: 'update', + val: 'Save', + disabled_initially: true, + classes: 'small-input-button', + tooltip: _('Enter all of the required information above')} %> +
<% end %> -
- - - - +
\ No newline at end of file diff --git a/app/views/users/_notification_preferences.html.erb b/app/views/users/_notification_preferences.html.erb index 5a79ec9..603b6df 100644 --- a/app/views/users/_notification_preferences.html.erb +++ b/app/views/users/_notification_preferences.html.erb @@ -1,59 +1,65 @@ -

<%= link_to 'Select all', '#' %> | - <%= link_to 'Deselect all', '#' %>

-<% byebug %> -
+

<%= link_to 'Select all', '#', id: 'select_all' %> | +<%= link_to 'Deselect all', '#', id: 'deselect_all' %>

+ +

All Users

-
+
<%#= check_box_tag 'prefs[users][permission_granted]', true, @user.prefs[:users][:permission_granted] %> <%#= label_tag 'prefs[users][permission_granted]', 'New permissions granted to me', :class => 'checkbox-label' %>
-
+
<%#= check_box_tag 'prefs[users][new_comment]', true, @user.prefs[:users][:new_comment] %> <%#= label_tag 'prefs[users][new_comment]', 'A new comment has been added to my DMP', :class => 'checkbox-label' %>
-
-
-
+
+

DMP owners and co-owners

-
+
<%#= check_box_tag 'prefs[owners_and_coowners][visibility_changed]', true, @user.prefs[:owners_and_coowners][:visibility_changed] %> <%#= label_tag 'prefs[owners_and_coowners][visibility_changed]', "My DMP's visibility has changed", :class => 'checkbox-label' %>
-
+
<%#= check_box_tag 'prefs[owners_and_coowners][user_added]', true, @user.prefs[:owners_and_coowners][:user_added] %> <%#= label_tag 'prefs[owners_and_coowners][user_added]', 'I have been made a co-owner of a DMP', :class => 'checkbox-label' %>
-
-
-
+ +

DMP administrators

-
+
<%#= check_box_tag 'prefs[admins][template_published]', true, @user.prefs[:admins][:template_published] %> <%#= label_tag 'prefs[admins][template_published]', 'An organisational template is published', :class => 'checkbox-label' %>
-
+
<%#= check_box_tag 'prefs[admins][template_unpublished]', true, @user.prefs[:admins][:template_unpublished] %> <%#= label_tag 'prefs[admins][template_unpublished]', 'An organisational template is unpublished', :class => 'checkbox-label' %>
-
-
-
- <%= button_to 'Save', user_update_preferences_path(@user), class: 'form-submit btn btn-primary' %> - <%= link_to 'Cancel', '#', class: 'btn btn-primary' %> -
+
+ + + \ No newline at end of file diff --git a/config/routes.rb b/config/routes.rb index e1a22f9..cfb0a8c 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -51,8 +51,6 @@ delete '/users/identifiers/:id', to: 'user_identifiers#destroy', as: 'destroy_user_identifier' - post 'users/update_preferences/:id', to: 'user#update_preferences', as: 'user_update_preferences' - get '/orgs/shibboleth', to: 'orgs#shibboleth_ds', as: 'shibboleth_ds' get '/orgs/shibboleth/:org_name', to: 'orgs#shibboleth_ds_passthru' # if an org id is present passthru to shib post '/orgs/shibboleth', to: 'orgs#shibboleth_ds_passthru' diff --git a/lib/assets/stylesheets/roadmap-tabs.scss b/lib/assets/stylesheets/roadmap-tabs.scss index 9913fd5..bd781df 100644 --- a/lib/assets/stylesheets/roadmap-tabs.scss +++ b/lib/assets/stylesheets/roadmap-tabs.scss @@ -2,20 +2,20 @@ /* Roadmap Tab Styling */ /* ------------------------------------------------ */ -.tabs { +.tabs #user_profile.tabs { list-style: none; margin: 0; li { display: inline; - + a { position: relative; float: left; display: block; padding: 10px 35px; margin-left: -1px; - left: 1px; + left: 1px; color: $white; background-color: $primary-color; text-decoration: none; @@ -29,7 +29,7 @@ background-color: $white; } } -.tabs:after { +.tabs:after #user_profile.tabs:after { visibility: hidden; display: block; font-size: 0; @@ -37,19 +37,18 @@ clear: both; height: 0; } -.tab-panels { +.tab-panels #user_profile.tab-panels { position: relative; - min-height: 250px; + min-height: 400px; } -.tabbed-area div.tab-panel { - background: white; - padding: 10px 20px; - min-height: 230px; +.tabbed-area div.tab-panel #user_profile.tabbed-area #user-profile.tab-panel { + padding: 10px 10px; + min-height: 300px; position: absolute; top: -1px; left: 0; width: 100%; } -.tab-panel div.active { +.tab-panel div.active #user_profile.tab-panel { z-index: 1; } \ No newline at end of file