diff --git a/.gitignore b/.gitignore index ee170d8..c5f7c47 100644 --- a/.gitignore +++ b/.gitignore @@ -18,6 +18,12 @@ # Ignore db schema.rb # db/schema.rb +# Ignore seed DBs +db/data.yml + +# Ignore the test DB +db/test.sqlite3 + # Ignore database configuration and token secrets config/database.yml config/secrets.yml @@ -37,6 +43,9 @@ # ignore IDE files .idea/* +# Ignore MAC files +.DS_Store + # ignore yard doc files .yardoc/* diff --git a/Gemfile.lock b/Gemfile.lock index 9bc58aa..57b32ca 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,6 +1,6 @@ GIT remote: git://github.com/activeadmin/activeadmin.git - revision: 0a5a15b88bffbe5efad7ff2a072ec4fe6eb09511 + revision: f8926831429fe635d26ac8043ea5d676fb6ee637 specs: activeadmin (1.0.0.pre4) arbre (~> 1.0, >= 1.0.2) @@ -74,14 +74,14 @@ thor (~> 0.19) builder (3.2.2) byebug (9.0.5) - capybara (2.8.1) + capybara (2.9.1) addressable mime-types (>= 1.16) nokogiri (>= 1.3.3) rack (>= 1.0.0) rack-test (>= 0.5.4) xpath (~> 2.0) - caracal (1.0.6) + caracal (1.0.8) nokogiri (~> 1.6) rubyzip (~> 1.1) tilt (>= 1.4) @@ -137,7 +137,7 @@ has_scope (0.6.0) actionpack (>= 3.2, < 5) activesupport (>= 3.2, < 5) - hashie (3.4.4) + hashie (3.4.6) htmltoword (0.5.1) actionpack nokogiri @@ -181,7 +181,7 @@ mime-types-data (~> 3.2015) mime-types-data (3.2016.0521) mini_portile2 (2.1.0) - minitest (5.9.0) + minitest (5.9.1) minitest-capybara (0.8.2) capybara (~> 2.2) minitest (~> 5.0) @@ -247,7 +247,7 @@ activesupport (= 4.2.7) rake (>= 0.8.7) thor (>= 0.18.1, < 2.0) - rake (11.2.2) + rake (11.3.0) ransack (1.8.2) actionpack (>= 3.0) activerecord (>= 3.0) @@ -291,7 +291,7 @@ thor (0.19.1) thread_safe (0.3.5) tilt (2.0.5) - tinymce-rails (4.4.2) + tinymce-rails (4.4.3) railties (>= 3.1.1) twitter-bootstrap-rails (2.2.8) actionpack (>= 3.1) diff --git a/README.md b/README.md index 13ddc72..597ae17 100644 --- a/README.md +++ b/README.md @@ -1,14 +1,13 @@ ## DMP Roadmap -DMP Roadmap is a Data Management Planning tool. It allows users to create data management plans for the projects using funder specific templates and institutional guidance. Once a plan has been completed it can be downloaded and inserted into your grant proposals. +DMP Roadmap is a Data Management Planning tool. Management and development of DMP Roadmap is jointly provided by the Digital Curation Centre (DCC), http://www.dcc.ac.uk/, and the University of California Curation Center (UC3), http://www.cdlib.org/services/uc3/ -Management and development of the DMP Roadmap is jointly provided by the Digital Curation Centre (DCC), http://www.dcc.ac.uk/, and the University of California Curation Center (UC3), http://www.cdlib.org/services/uc3/ +The tool has four main functions: -The tool has four main functions -1. To help create and maintain different versions of Data Management Plans; -2. To provide useful guidance on data management issues and how to meet research funders' requirements; -3. To export attractive and useful plans in a variety of formats; -4. To allow collaborative work when creating Data Management Plans. +1. To help create and maintain different versions of Data Management Plans; +2. To provide useful guidance on data management issues and how to meet research funders' requirements; +3. To export attractive and useful plans in a variety of formats; +4. To allow collaborative work when creating Data Management Plans. #### Current Release v.0.1.0 @@ -26,7 +25,6 @@ Further details on how to install MySQL and create your first user and database. Be sure to follow the instructions for your particular environment. * Install: http://dev.mysql.com/downloads/mysql/ -* * Create a user: http://dev.mysql.com/doc/refman/5.7/en/create-user.html * Create the database: http://dev.mysql.com/doc/refman/5.7/en/creating-database.html @@ -91,13 +89,13 @@ > > bundle install #### Support -Issues should be reported here on Github https://github.com/DMPRoadmap/roadmap/issues +Issues should be reported here on [Github Issues](https://github.com/DMPRoadmap/roadmap/issues) Please be advised though that we can only provide limited support for your local installations. #### Become a contributor Fork this repository and make your modifications in a new branch. Then create a pull request to our 'development' branch. We will reject any pull request made against the 'master' branch. Once your pull request has been submitted the team will review your request and accept it if appropriate. -Join the email listserv at roadmap-l (at) listserv.ucop (dot) edu. +Join the developer email listserv at www.jiscmail.ac.uk/DMPONLINE-DEV #### License -The DMP Roadmap project uses to the MIT License. +The DMP Roadmap project uses the MIT License. diff --git a/app/assets/javascripts/application.js b/app/assets/javascripts/application.js index 052fbc2..eeea9a8 100644 --- a/app/assets/javascripts/application.js +++ b/app/assets/javascripts/application.js @@ -42,11 +42,20 @@ //accordion project details page when project has more than 1 plan $('.accordion-project').on('show', function() { - var plus = $(this).parent().find(".plus-laranja").removeClass("plus-laranja").addClass("minus-laranja"); + var plus = $(this).parent().children(".accordion-heading").find(".plus-laranja").removeClass("plus-laranja").addClass("minus-laranja"); }).on('hide', function(){ - var minus = $(this).parent().find(".minus-laranja").removeClass("minus-laranja").addClass("plus-laranja"); + var minus = $(this).parent().children(".accordion-heading").find(".minus-laranja").removeClass("minus-laranja").addClass("plus-laranja"); }); + $('.export-format-selection').click(function(e){ + e.preventDefault(); + if($(this).val() == 'pdf'){ + $('#pdf-format-options').show(); + }else{ + $('#pdf-format-options').hide(); + } + }); + //$('#3-or-4-splash').modal(); $('.typeahead').select2({ diff --git a/app/assets/stylesheets/admin.css.less b/app/assets/stylesheets/admin.css.less index 05664c9..3a52df1 100644 --- a/app/assets/stylesheets/admin.css.less +++ b/app/assets/stylesheets/admin.css.less @@ -149,7 +149,7 @@ } .main_nav_tabs{ - width: 500px; + width: 700px; float:left; position:absolute; bottom:0; @@ -227,6 +227,7 @@ top: 100%; right: 0; left:45%; + width: 100%; z-index: 99; display: none; float: right; diff --git a/app/assets/stylesheets/bootstrap_and_overrides.css.less b/app/assets/stylesheets/bootstrap_and_overrides.css.less index f630d8c..f0b730b 100644 --- a/app/assets/stylesheets/bootstrap_and_overrides.css.less +++ b/app/assets/stylesheets/bootstrap_and_overrides.css.less @@ -149,7 +149,7 @@ } .main_nav_tabs{ - width: 500px; + width: 700px; float:left; position:absolute; bottom:0; @@ -244,6 +244,7 @@ top: 100%; right: 0; left:45%; + width: 100%; z-index: 99; display: none; float: right; @@ -710,6 +711,14 @@ border-radius: 3px; } +#new_user ul li span.select2 { + float: left; +} +#select2-user_organisation_id-container { + color: @grey_very_light_colour; + border-color: @grey_very_light_colour; +} + label.remember_div{ display: inline-block; margin: 0 0 4px 12px; @@ -1564,6 +1573,19 @@ /*******************************/ /********* Exporting **********/ /*******************************/ +.plan-export-settings { + h4 { + background-color: @orange_colour; + color: @white_colour; + font-size: 1.2rem; + padding: 5px 5px 10px 10px; + + small{ + color: @white_colour; + } + } +} + #export_font{ font-family: @text_font; } diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 005e288..9069855 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -24,6 +24,7 @@ if params[:locale] # and I18n.available_locales.include? params[:locale] # throw an error if not available # if locales data is present in the parameter from url use it I18n.locale = params[:locale] + elsif user_signed_in? and !current_user[:language_id].nil? I18n.locale = Language.find_by_id(current_user[:language_id]).abbreviation # if user has set preferred language use it @@ -31,6 +32,7 @@ elsif user_signed_in? and current_user.organisation.present? and !current_user.organisation[:language_id].nil? I18n.locale = Language.find_by_id(current_user.organisation[:language_id]).abbreviation # use user's organization language, keep in mine the "OTHER ORG" edge case which should use default language + else # just use the default language, line can be commented out, included just for clarity I18n.locale = I18n.default_locale @@ -77,7 +79,10 @@ def get_plan_list_columns if user_signed_in? @selected_columns = current_user.settings(:plan_list).columns + @selected_columns = Settings::PlanList::DEFAULT_COLUMNS if @selected_columns.empty? + @all_columns = Settings::PlanList::ALL_COLUMNS end end + end diff --git a/app/controllers/organisations_controller.rb b/app/controllers/organisations_controller.rb index 839d7c4..564a1f1 100644 --- a/app/controllers/organisations_controller.rb +++ b/app/controllers/organisations_controller.rb @@ -14,6 +14,8 @@ def admin_edit @organisation = Organisation.find(params[:id]) authorize @organisation + + @languages = Language.all.order("name") end @@ -27,10 +29,17 @@ assign_params.delete(:logo) respond_to do |format| - if @organisation.update_attributes(assign_params) - format.html { redirect_to admin_show_organisation_path(params[:id]), notice: I18n.t("admin.org_updated_message") } - else - format.html { render action: "edit" } + begin + if @organisation.update_attributes(assign_params) + format.html { redirect_to admin_show_organisation_path(params[:id]), notice: I18n.t("admin.org_updated_message") } + else + flash[:noice] = @organisation.errors.collect{|e| e.message}.join('
').html_safe + format.html { render action: "admin_edit" } + end + + rescue Dragonfly::Job::Fetch::NotFound => dflye + flash[:notice] = I18n.t("admin.org_bad_logo") + format.html {render action: "admin_edit"} end end end diff --git a/app/controllers/registrations_controller.rb b/app/controllers/registrations_controller.rb index d7127bb..59b52b5 100644 --- a/app/controllers/registrations_controller.rb +++ b/app/controllers/registrations_controller.rb @@ -1,6 +1,10 @@ # app/controllers/registrations_controller.rb class RegistrationsController < Devise::RegistrationsController + def edit + @languages = Language.all.order("name") + end + # POST /resource def create logger.debug "#{sign_up_params}" @@ -57,7 +61,6 @@ end def do_update(require_password = true, confirm = false) - if require_password then successfully_updated = if needs_password?(@user, params) @user.update_with_password(params[:user]) @@ -72,6 +75,17 @@ successfully_updated = @user.update_without_password(params[:user]) end + # If the user selected a new language setting, go ahead and reset the locale + +puts "PARAMS: #{params.inspect}" + + if params[:user][:language_id] + if @user.language_id != params[:user][:language_id] + params[:locale] = Language.find(params[:user][:language_id]).abbreviation + set_locale + end + end + #unlink shibboleth from user's details if params[:unlink_flag] == 'true' then @user.update_attributes(:shibboleth_id => "") @@ -86,11 +100,11 @@ # Sign in the user bypassing validation in case his password changed sign_in @user, :bypass => true - if params[:unlink_flag] == 'true' then + #if params[:unlink_flag] == 'true' then redirect_to({:controller => "registrations", :action => "edit"}, {:notice => I18n.t('helpers.project.details_update_success')}) - else - redirect_to({:controller => "projects", :action => "index"}, {:notice => I18n.t('helpers.project.details_update_success')}) - end + #else + # redirect_to({:controller => "projects", :action => "index"}, {:notice => I18n.t('helpers.project.details_update_success')}) + #end else render "edit" diff --git a/app/controllers/sessions_controller.rb b/app/controllers/sessions_controller.rb index 5515afb..aa0b716 100644 --- a/app/controllers/sessions_controller.rb +++ b/app/controllers/sessions_controller.rb @@ -1,27 +1,15 @@ -# app/controllers/sessions_controller.rb class SessionsController < Devise::SessionsController - def create - existing_user = User.find_by_email(params[:user][:email]) + # Capture the user's shibboleth id if they're coming in from an IDP + def create + existing_user = User.find_by_email(params[:user][:email]) - if !existing_user.nil? && (existing_user.password == "" || existing_user.password.nil?) && existing_user.confirmed_at.nil? then - redirect_to :controller => :existing_users, :action => :index, :email => params[:user][:email] - else - #after authentication verify if session[:shibboleth] exists - if !params[:shibboleth_data].nil? then - existing_user.update_attributes(:shibboleth_id => session[:shibboleth_data][:uid]) - end - super - - end - end - - def destroy - current_user.plan_sections.each do |lock| - lock.delete - - end - super + if !existing_user.nil? && !params[:shibboleth_data].nil? then + #after authentication verify if session[:shibboleth] exists + existing_user.update_attributes(shibboleth_id: session[:shibboleth_data][:uid]) end + super + end + end \ No newline at end of file diff --git a/app/controllers/settings/plans_controller.rb b/app/controllers/settings/plans_controller.rb index c9a4adb..2c65aea 100644 --- a/app/controllers/settings/plans_controller.rb +++ b/app/controllers/settings/plans_controller.rb @@ -5,7 +5,7 @@ after_action :verify_authorized def show - authorize [:settings, plan] + authorize @plan respond_to do |format| format.html format.partial @@ -13,10 +13,10 @@ end def update - authorize [:settings, plan] + authorize @plan export_params = params[:export].try(:deep_symbolize_keys) - settings = plan.super_settings(:export).tap do |s| + settings = @plan.super_settings(:export).tap do |s| if params[:commit] == 'Reset' s.formatting = nil s.fields = nil @@ -29,7 +29,7 @@ if settings.save respond_to do |format| - format.html { redirect_to(export_project_path(plan.project)) } + format.html { redirect_to(export_project_path(@plan.project)) } end else settings.formatting = nil @@ -41,6 +41,8 @@ private def get_settings + @plan = Plan.find(params[:id]) + @export_settings = plan.settings(:export) end diff --git a/app/controllers/settings/projects_controller.rb b/app/controllers/settings/projects_controller.rb index 5a2d48d..6ba2cd3 100644 --- a/app/controllers/settings/projects_controller.rb +++ b/app/controllers/settings/projects_controller.rb @@ -10,6 +10,8 @@ authorize [:settings, Project] respond_to do |format| format.html + + format.json{ render json: settings_json } end end @@ -20,6 +22,8 @@ if @settings.update_attributes(columns: columns) respond_to do |format| format.html { redirect_to(projects_path) } + + format.json{ render json: settings_json } end else render(action: :show) # Expect #show to display errors etc diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 636c44a..4d6bd4f 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -3,7 +3,9 @@ def admin_index authorize User - @users = current_user.organisation.users.includes(:roles, :project_groups) + + @users = User.where(organisation: current_user.organisation).includes(:project_groups) + respond_to do |format| format.html # index.html.erb end diff --git a/app/helpers/plans_helper.rb b/app/helpers/plans_helper.rb deleted file mode 100644 index 37a6355..0000000 --- a/app/helpers/plans_helper.rb +++ /dev/null @@ -1,62 +0,0 @@ -module PlansHelper - - def project_list_head(column) - klass = case column - when 'name' then :dmp_th_big - when 'description' then :dmp_th_big - else :dmp_th_small - end - - content_tag(:th, t("helpers.project.columns.#{column}"), class: klass) - end - - def project_list_body(column, project) - klass, content = case column[0] - when 'name' - [ "dmp_td_big", link_to(project.title, project_path(project), class: "dmp_table_link") ] - - when 'owner' - user = project.owner - - text = if user.nil? - "Unknown" - elsif user == current_user - t("helpers.me") - else - user.name - end - - [ "tmp_td_small", text ] - when 'shared' - shared_num = project.project_groups.count - 1 - text = shared_num > 0 ? (t("helpers.yes_label") + " (with #{shared_num} people) ") : t("helpers.no_label") - [ "dmp_td_small", text ] - when 'last_edited' - [ "dmp_td_small", l(project.latest_update.to_date, formats: :short) ] - when 'description' - [ "dmp_td_medium", (project.try(column[0]) || "Unknown") ] - else - [ "dmp_td_small", (project.try(column[0]) || "Unknown") ] - end - - content_tag(:td, content, class: klass) - end - - # Shows whether the user has default, template-default or custom settings - # for the given plan. - def plan_settings_indicator(plan) - plan_settings = plan.super_settings(:export) - template_settings = plan.project.dmptemplate.try(:settings, :export) - - key = if plan_settings.try(:value?) - plan_settings.formatting == template_settings.formatting ? "template_formatting" : "custom_formatting" - elsif template_settings.try(:value?) - "template_formatting" - else - "default_formatting" - end - - content_tag(:small, t("helpers.settings.plans.#{key}")) - end - -end diff --git a/app/helpers/projects_helper.rb b/app/helpers/projects_helper.rb new file mode 100644 index 0000000..fd5881e --- /dev/null +++ b/app/helpers/projects_helper.rb @@ -0,0 +1,76 @@ +module ProjectsHelper + + # Build variable column headings for the project list + # -------------------------------------------------------- + def project_list_column_heading(column) + if column.kind_of?(Array) + heading = (column.first.kind_of?(String) ? column.first : t("helpers.project.columns.unknown")) + + elsif column.kind_of?(String) + heading = column + + else + heading = t("helpers.project.columns.unknown") + end + + klass = (['name', 'description'].include?(heading) ? :dmp_th_big : :dmp_th_small) + + content_tag(:th, t("helpers.project.columns.#{heading}"), class: klass) + end + + # Populate a variable column for the project list + # -------------------------------------------------------- + def project_list_column_body(column, project) + + col = (column.kind_of?(Array) ? column[0] : column) + + klass, content = case col + when 'name' + [ "dmp_td_big", link_to(project.title, project_path(project), class: "dmp_table_link") ] + + when 'owner' + user = project.owner + + text = if user.nil? + "Unknown" + elsif user == current_user + t("helpers.me") + else + user.name + end + + [ "tmp_td_small", text ] + when 'shared' + shared_num = project.project_groups.count - 1 + text = shared_num > 0 ? (t("helpers.yes_label") + " (with #{shared_num} people) ") : t("helpers.no_label") + [ "dmp_td_small", text ] + when 'last_edited' + [ "dmp_td_small", l(project.latest_update.to_date, formats: :short) ] + when 'description' + [ "dmp_td_medium", (project.try(col) || "Unknown") ] + else + [ "dmp_td_small", (project.try(col) || "Unknown") ] + end + + content_tag(:td, content, class: klass) + end + + # Shows whether the user has default, template-default or custom settings + # for the given plan. + # -------------------------------------------------------- + def plan_settings_indicator(plan) + plan_settings = plan.super_settings(:export) + template_settings = plan.project.dmptemplate.try(:settings, :export) + + key = if plan_settings.try(:value?) + plan_settings.formatting == template_settings.formatting ? "template_formatting" : "custom_formatting" + elsif template_settings.try(:value?) + "template_formatting" + else + "default_formatting" + end + + content_tag(:small, t("helpers.settings.plans.#{key}")) + end + +end diff --git a/app/mailers/user_mailer.rb b/app/mailers/user_mailer.rb index 8a60e7b..e11166a 100644 --- a/app/mailers/user_mailer.rb +++ b/app/mailers/user_mailer.rb @@ -2,7 +2,7 @@ default from: I18n.t('helpers.main_email.from') def sharing_notification(project_group) - @project_group = project_group + @project_group = project_group mail(to: @project_group.user.email, subject: I18n.t('helpers.main_email.access_given')) end diff --git a/app/models/exported_plan.rb b/app/models/exported_plan.rb index 68fe5bf..2ea784b 100644 --- a/app/models/exported_plan.rb +++ b/app/models/exported_plan.rb @@ -93,6 +93,11 @@ def as_txt output = "#{self.plan.project.title}\n\n#{self.plan.version.phase.title}\n" + +puts "SETTINGS: #{self.plan.inspect}" + + output += "\nDetails:\n#{self.plan.settings[:export][:fields][:admin].collect{|f| f.to_s}.join('\n')}\n" + self.sections.each do |section| output += "\n#{section.title}\n" diff --git a/app/models/organisation.rb b/app/models/organisation.rb index 378daa4..488debf 100644 --- a/app/models/organisation.rb +++ b/app/models/organisation.rb @@ -8,7 +8,6 @@ has_many :guidance_groups has_many :dmptemplates has_many :sections - has_many :user_org_roles has_many :users, through: :user_org_roles has_many :option_warnings has_many :suggested_answers @@ -168,7 +167,7 @@ # # @return [Array] published dmptemplates def published_templates - return dmptemplates.where("published = ?", true) + return dmptemplates.where("published = ?", 1) end def check_api_credentials diff --git a/app/models/user.rb b/app/models/user.rb index 707c29a..fa7da4d 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -13,11 +13,11 @@ has_many :answers has_many :user_org_roles has_many :project_groups, :dependent => :destroy - has_many :organisations , through: :user_org_roles + #has_many :organisations , through: :user_org_roles has_many :user_role_types, through: :user_org_roles has_one :language - + belongs_to :organisation has_many :projects, through: :project_groups do def filter(query) @@ -48,7 +48,7 @@ :firstname, :last_login,:login_count, :orcid_id, :password, :shibboleth_id, :user_status_id, :surname, :user_type_id, :organisation_id, :skip_invitation, :other_organisation, :accept_terms, :role_ids, :dmponline3, :api_token, - :language_id + :language_id, :organisation # FIXME: The duplication in the block is to set defaults. It might be better if # they could be set in Settings::PlanList itself, if possible. @@ -79,31 +79,34 @@ # @return [String] the empty string as a causality of setting api_token def organisation_id=(new_organisation_id) # DEPRICATED STRUCTURE ONLY USED HERE - if !self.user_org_roles.pluck(:organisation_id).include?(new_organisation_id.to_i) then +# if !self.user_org_roles.pluck(:organisation_id).include?(new_organisation_id.to_i) then # if the user has more than one role - if self.user_org_roles.count != 1 then - new_user_org_role = UserOrgRole.new - new_user_org_role.organisation_id = new_organisation_id - new_user_org_role.user_role_type = UserRoleType.find_by(name: constant("user_role_types.user")); - self.user_org_roles << new_user_org_role +# if self.user_org_roles.count != 1 then +# new_user_org_role = UserOrgRole.new +# new_user_org_role.organisation_id = new_organisation_id +# new_user_org_role.user_role_type = UserRoleType.find_by(name: constant("user_role_types.user")); +# self.user_org_roles << new_user_org_role # if the user has roles other than one(0/2/3?) - else +# else # set role to first role - user_org_role = self.user_org_roles.first +# user_org_role = self.user_org_roles.first # change org_id to new org_id - user_org_role.organisation_id = new_organisation_id +# user_org_role.organisation_id = new_organisation_id # save modified role - user_org_role.save +# user_org_role.save # if the user is not part of the new organisation - if !self.user_org_roles.pluck(:organisation_id).include?(new_organisation_id.to_i) then - unless self.can_change_org? +# if !self.user_org_roles.pluck(:organisation_id).include?(new_organisation_id.to_i) then +# unless self.can_change_org? # rip all permissions from user - self.roles.delete_all - self.save! - end - end - end - end +# self.roles.delete_all +# self.save! +# end +# end +# end +# end + + self.organisation = Organisation.find(new_organisation_id) + # rip api_token from user self.remove_token! end @@ -113,24 +116,25 @@ # # @return [Integer, nil] the id of the user's organisation def organisation_id - if self.organisations.count > 0 then - return self.organisations.first.id - else - return nil - end +# if self.organisations.count > 0 then +# return self.organisations.first.id +# else +# return nil +# end + (self.organisation.nil? ? nil : self.organisation.id) end ## # returns the organisation of the user or nil # # @return [Organisation, nil] the organisation of the user - def organisation - if self.organisations.count > 0 then - return self.organisations.first - else - return nil - end - end +# def organisation +# if self.organisations.count > 0 then +# return self.organisations.first +# else +# return nil +# end +# end ## # returns the last organisation in the list of organisations @@ -138,20 +142,21 @@ # # @return [Organisation, nil] the organisation for the user def current_organisation - if self.organisations.count > 0 then - return self.organisations.last - else - return nil - end +# if self.organisations.count > 0 then +# return self.organisations.last +# else +# return nil +# end + self.organisation end ## # sets a new organisation for the user # # @param new_organisation [Organisation] the new organisation for the user - def organisation=(new_organisation) - organisation_id = organisation.id - end +# def organisation=(new_organisation) +# organisation_id = organisation.id +# end ## # checks if the user is a super admin @@ -269,7 +274,7 @@ # generates a new token for the user unless the user already has a token. # modifies the user's model. def keep_or_generate_token! - if api_token.empty? + if api_token.nil? || api_token.empty? self.api_token = loop do random_token = SecureRandom.urlsafe_base64(nil, false) break random_token unless User.exists?(api_token: random_token) @@ -293,7 +298,7 @@ grant_permissions = Role.find_by(name: 'grant_permissions') modify_templates = Role.find_by(name: 'modify_templates') modify_guidance = Role.find_by(name: 'modify_guidance') - change_org_details = Role.find_by(name: 'change_org_detials') + change_org_details = Role.find_by(name: 'change_org_details') User.includes(:roles).all.each do |user| if user.roles.include? admin #add admin roles diff --git a/app/policies/guidance_group_policy.rb b/app/policies/guidance_group_policy.rb index dd3725f..422ea26 100644 --- a/app/policies/guidance_group_policy.rb +++ b/app/policies/guidance_group_policy.rb @@ -24,11 +24,11 @@ end def admin_new? - user.can_modify_guidance? && (guidance_group.organisation_id == user.organisation_id) + user.can_modify_guidance? end def admin_create? - user.can_modify_guidance? && (guidance_group.organisation_id == user.organisation_id) + user.can_modify_guidance? end def admin_destroy? diff --git a/app/policies/organisation_policy.rb b/app/policies/organisation_policy.rb index 677912c..8fb3bb2 100644 --- a/app/policies/organisation_policy.rb +++ b/app/policies/organisation_policy.rb @@ -8,15 +8,15 @@ end def admin_show? - user.can_modify_org_details? && (user.organisation_id == organisation.id) + user.can_modify_org_details? && (user.organisation.id == organisation.id) end def admin_edit? - user.can_modify_org_details? && (user.organisaiton_id == organisation.id) + user.can_modify_org_details? && (user.organisation.id == organisation.id) end def admin_update? - user.can_modify_org_details? && (user.organisaiton_id == organisation.id) + user.can_modify_org_details? && (user.organisation.id == organisation.id) end def parent? diff --git a/app/views/devise/registrations/edit.html.erb b/app/views/devise/registrations/edit.html.erb index 3ec5f66..5ff15d9 100644 --- a/app/views/devise/registrations/edit.html.erb +++ b/app/views/devise/registrations/edit.html.erb @@ -53,10 +53,15 @@ <%= t('helpers.user_details_language') %> - <%= collection_select(:user, - :language_id, Language.all.order("name"), - :id, :name, {:selected => Language.where(default_language: true).first.id}, - {:class => "typeahead org_sign_up"}) %> + + + + + <%= t("helpers.orcid_id") %> diff --git a/app/views/guidances/admin_index.html.erb b/app/views/guidances/admin_index.html.erb index f808526..76acaf2 100644 --- a/app/views/guidances/admin_index.html.erb +++ b/app/views/guidances/admin_index.html.erb @@ -75,7 +75,7 @@ <%= link_to t("helpers.view"), admin_show_guidance_group_path(guidance_gr), :class => "dmp_table_link"%>
<%= link_to t("helpers.submit.edit"), admin_edit_guidance_group_path(guidance_gr), :class => "dmp_table_link"%>
<%= link_to t("helpers.submit.delete"), admin_destroy_guidance_group_path(guidance_gr), - :confirm => t("org_admin.guidance_group.delete_message", :guidance_group_name => guidance_gr.name ), :method => :delete, :class => "dmp_table_link"%> + :data => {:confirm => t("org_admin.guidance_group.delete_message", :guidance_group_name => guidance_gr.name )}, :method => :delete, :class => "dmp_table_link"%> @@ -163,7 +163,7 @@ <%= link_to t("helpers.view"), admin_show_guidance_path(guidance), :class => "dmp_table_link"%>
<%= link_to t("helpers.submit.edit"), admin_edit_guidance_path(guidance), :class => "dmp_table_link"%>
<%= link_to t("helpers.submit.delete"), admin_destroy_guidance_path(guidance), - :confirm => t("org_admin.guidance.delete_message_html", :guidance_summary => truncate(sanitize(guidance.text,:tags => %w(br a)), :length => 20 , :omission => t('helpers.truncate_continued')) ), :method => :delete, :class => "dmp_table_link"%> + :data => {:confirm => t("org_admin.guidance.delete_message_html", :guidance_summary => truncate(sanitize(guidance.text,:tags => %w(br a)), :length => 20 , :omission => t('helpers.truncate_continued')) )}, :method => :delete, :class => "dmp_table_link"%> <%end%> diff --git a/app/views/guidances/admin_new.html.erb b/app/views/guidances/admin_new.html.erb index 9676554..bf37fe1 100644 --- a/app/views/guidances/admin_new.html.erb +++ b/app/views/guidances/admin_new.html.erb @@ -72,16 +72,16 @@ - - <%= t('org_admin.guidance.published') %> -
- <%= f.check_box :published , :as => :check_boxes%> -
-
- -
- - + + <%= t('org_admin.guidance.published') %> +
+ <%= f.check_box :published , :as => :check_boxes%> +
+
+ <%= link_to( image_tag('help_button.png'), '#', :class => 'guidance_group_subset_popover', :rel => "popover", 'data-html' => "true", 'data-content' => t('org_admin.guidance.guidance_group_published_help_text_html'))%> +
+ + <%= t('org_admin.guidance.guidance_group_label') %>
diff --git a/app/views/layouts/_dmponline_signin_signout.html.erb b/app/views/layouts/_dmponline_signin_signout.html.erb index e7ff108..654ed37 100644 --- a/app/views/layouts/_dmponline_signin_signout.html.erb +++ b/app/views/layouts/_dmponline_signin_signout.html.erb @@ -11,7 +11,7 @@ <% if current_user.can_super_admin? %>
  • <%= link_to t("helpers.admin_area"), "/admin", :class => "signIn_dropdown_link" %>
  • <%end%> - <% if current_user.can_org_admin? %> + <% if current_user.can_org_admin? && !current_user.organisation_id.nil? %>
  • <%= link_to t("org_admin.admin_area"), admin_index_dmptemplate_path(current_user.organisation_id), :class => "signIn_dropdown_link" %>
  • <%end%>
  • <%= link_to t("helpers.sign_out"), destroy_user_session_path, method: :delete, :class => "signIn_dropdown_link" %>
  • diff --git a/app/views/organisations/admin_edit.html.erb b/app/views/organisations/admin_edit.html.erb index e6d65e8..9a2548c 100644 --- a/app/views/organisations/admin_edit.html.erb +++ b/app/views/organisations/admin_edit.html.erb @@ -8,160 +8,76 @@
    - <%= form_for(@organisation, :url => admin_update_organisation_path(@organisation), :html => { :multipart => true, :id => "edit_org_details", :method => :put}) do |f| %> - - - - - - - - - - - - - <% if @organisation.logo.present? then%> - - - - - - - - - <%end%> - - - - - - - - - - - - - - - - - - - - - - - - - - -
    <%= t('org_admin.org_name') %><%= f.text_field :name, - :as => :string, - :class => 'text_field has-tooltip', 'data-toggle' => "tooltip", 'title' => t('org_admin.name_help_text') %>
    <%= t('org_admin.org_abbr') %>
    - <%= f.text_field :abbreviation, - :as => :string, - :class => 'text_field' %> -
    -
    - <%= link_to( image_tag('help_button.png'), '#', :class => 'org_abbr_popover', :rel => "popover", 'data-html' => "true", 'data-content' => t('org_admin.templates.desc_help_text_html'))%> -
    -
    -
    <%= t('org_admin.org_logo') %><%= image_tag @organisation.logo.url %>
    <%= f.check_box :remove_logo %>   <%= t('org_admin.remove_logo') %>
    <%= t('org_admin.new_org_logo') %><%= f.file_field :logo %>
    <%= t('org_admin.org_banner_text') %> - <%= text_area_tag("org_banner_text", @organisation.banner_text, class: "tinymce") %> -
    <%= t('org_admin.org_target_url') %><%= f.text_field :target_url, - :as => :string, - :class => 'text_field has-tooltip', 'data-toggle' => "tooltip", 'title' => t('org_admin.target_url_help_text') %>
    <%= t('org_admin.org_contact_email') %><%= f.text_field :contact_email, - :as => :string, - :class => 'text_field has-tooltip', 'data-toggle' => "tooltip", 'title' => t('org_admin.org_contact_email_help_text') %>
    <%= t('org_admin.org_type') %><%= @organisation.organisation_type.name %>
    + <%= form_for(@organisation, :url => admin_update_organisation_path(@organisation), :html => { :multipart => true, :id => "edit_org_details", :method => :put}) do |f| %> -
    -
    + + + + + + + + + + + + + + <% if @organisation.logo.present? %> + + + + + + + + + <%end%> + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    <%= t('org_admin.org_name') %><%= f.text_field :name, :as => :string, :class => 'text_field has-tooltip', 'data-toggle' => "tooltip", 'title' => t('org_admin.name_help_text') %>
    <%= t('org_admin.org_abbr') %> +
    + <%= f.text_field :abbreviation, :as => :string, :class => 'text_field' %> +
    +
    +
    <%= t('org_admin.org_logo') %><%= image_tag @organisation.logo.url %>
    <%= f.check_box :remove_logo %>   <%= t('org_admin.remove_logo') %>
    <%= t('org_admin.new_org_logo') %><%= f.file_field :logo %>
    <%= t('org_admin.org_banner_text') %><%= text_area_tag("org_banner_text", @organisation.banner_text, class: "tinymce") %>
    <%= t('org_admin.org_target_url') %><%= f.text_field :target_url, :as => :string, :class => 'text_field has-tooltip', 'data-toggle' => "tooltip", 'title' => t('org_admin.target_url_help_text') %>
    <%= t('org_admin.org_contact_email') %><%= f.text_field :contact_email, :as => :string, :class => 'text_field has-tooltip', 'data-toggle' => "tooltip", 'title' => t('org_admin.org_contact_email_help_text') %>
    <%= t('org_admin.org_type') %> + <%= @organisation.organisation_type.name %> +
    + +
    - -
    - <%= f.submit t('helpers.submit.save'), :class => 'btn btn-primary' %> - <%= link_to t('helpers.submit.cancel'), :back, :class => 'btn btn-primary' %> -
    - <% end %> +
    + <%= f.submit t('helpers.submit.save'), :class => 'btn btn-primary' %> + <%= link_to t('helpers.submit.cancel'), :back, :class => 'btn btn-primary' %> +
    + <% end %> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    <%= t('org_admin.org_name') %><%= f.text_field :name, - :as => :string, - :class => 'text_field has-tooltip', 'data-toggle' => "tooltip", 'title' => t('org_admin.name_help_text') %>
    <%= t('org_admin.org_abbr') %> -
    - <%= f.text_field :abbreviation, - :as => :string, - :class => 'text_field' %> -
    -
    - <%= link_to(image_tag('help_button.png'), '#', :class => 'org_abbr_popover', :rel => "popover", 'data-html' => "true", 'data-content' => t('org_admin.templates.desc_help_text_html')) %> -
    -
    -
    <%= t('org_admin.org_desc') %><%= f.text_area :description, { - :rows => 5, - :class => 'text_area has-tooltip', 'data-toggle' => "tooltip", 'data-html' => "true", 'title' => t('org_admin.desc_help_text_html')} %>
    <%= t('org_admin.org_banner_text') %> - <%= text_area_tag("org_banner_text", @organisation.banner_text, class: "tinymce") %> -
    <%= t('org_admin.org_target_url') %><%= f.text_field :target_url, - :as => :string, - :class => 'text_field has-tooltip', 'data-toggle' => "tooltip", 'title' => t('org_admin.target_url_help_text') %>
    <%= t('org_admin.org_default_language') %> -
    - <%= collection_select(:@organisation, - :language_id, Language.all.order("name"), - :id, :name, {selected: Language.where(default_language: true).first.id}, - {:class => "typeahead org_sign_up"}) %> -
    -
    - <%= link_to(image_tag('help_button.png'), '#', :class => 'org_abbr_popover', :rel => "popover", 'data-html' => "true", 'data-content' => t('org_admin.org_default_language_help_text')) %> -
    -
    -
    <%= t('org_admin.org_type') %><%= @organisation.organisation_type.name %>
    - -
    -
    - - - -
    - <%= f.submit t('helpers.submit.save'), :class => 'btn btn-primary' %> - <%= link_to t('helpers.submit.cancel'), :back, :class => 'btn btn-primary' %> -
    - -
    - <% end %>
    diff --git a/app/views/projects/_project_list_head.html.erb b/app/views/projects/_project_list_head.html.erb index a19e5d4..efb2503 100644 --- a/app/views/projects/_project_list_head.html.erb +++ b/app/views/projects/_project_list_head.html.erb @@ -1,6 +1,6 @@ <% @selected_columns.each do |column| %> - <%= project_list_head(column) %> + <%= project_list_column_heading(column) %> <% end %> <%= t("helpers.select_action")%> diff --git a/app/views/projects/_project_list_item.html.erb b/app/views/projects/_project_list_item.html.erb index 90623ca..6698fa8 100644 --- a/app/views/projects/_project_list_item.html.erb +++ b/app/views/projects/_project_list_item.html.erb @@ -1,6 +1,6 @@ <% @selected_columns.each do |column| %> - <%= project_list_body(column, project) %> + <%= project_list_column_body(column, project) %> <% end %> <% if project.editable_by(current_user.id) then %> diff --git a/app/views/projects/new.html.erb b/app/views/projects/new.html.erb index ba153a0..0824e7b 100644 --- a/app/views/projects/new.html.erb +++ b/app/views/projects/new.html.erb @@ -8,7 +8,9 @@