diff --git a/Gemfile b/Gemfile index e8bf467..6b20e0f 100644 --- a/Gemfile +++ b/Gemfile @@ -5,7 +5,7 @@ gem 'rails', '4.2.0' # additional gems for rails 4 -gem 'railties'#, '= 4.2.0' +gem 'railties' gem 'responders', '~> 2.0' # allows use of respond_with and respond_to in controllers # add these gems to help with the transition: @@ -14,21 +14,17 @@ gem 'actionpack-page_caching' gem 'actionpack-action_caching' -gem 'uglifier' #, '>= 1.3.0' +gem 'uglifier' # Gems used only for assets and not required in production environments by default. -#group :assets do - # gem 'coffee-rails' -#end # Use SCSS for stylesheets gem 'sass-rails' -#gem 'sass' # Use SCSS for stylesheets gem 'less-rails' gem 'twitter-bootstrap-rails', '2.2.8' -gem 'therubyracer', '>=0.11.4', platforms: :ruby #'0.11.4', platforms: :ruby +gem 'therubyracer', '>=0.11.4', platforms: :ruby gem 'libv8' @@ -69,8 +65,7 @@ # DATABASE/SERVER # gem 'mysql2', '~> 0.3.18' -# Use unicorn as the app server -# gem 'unicorn' + #cancan for usergroups gem 'cancancan' @@ -79,8 +74,8 @@ # gem 'jquery-rails' gem 'tinymce-rails' -gem 'friendly_id' #, '~> 5.0.1' -gem 'contact_us' +gem 'friendly_id' +gem 'contact_us', '>= 1.1.1' gem 'recaptcha' gem 'turbolinks' #implementation of forms diff --git a/app/admin/dmptemplate.rb b/app/admin/dmptemplate.rb index c172563..b9d711e 100644 --- a/app/admin/dmptemplate.rb +++ b/app/admin/dmptemplate.rb @@ -39,7 +39,6 @@ end end - #action_item only: %i( show edit ) do action_item(:edit) do link_to(I18n.t('helpers.settings.title'), settings_admin_dmptemplate_path(resource.id)) end diff --git a/app/controllers/api/v0/base_controller.rb b/app/controllers/api/v0/base_controller.rb index 158c043..c3ed859 100644 --- a/app/controllers/api/v0/base_controller.rb +++ b/app/controllers/api/v0/base_controller.rb @@ -132,6 +132,7 @@ # end # end OrgTokenPermission.where(organisation_id: @user.organisation_id).find_each do |org_token_permission| + logger.debug "#{org_token_permission.token_permission_type.token_type}" if org_token_permission.token_permission_type.token_type == auth_type auth= true end diff --git a/app/controllers/api/v0/guidance_groups_controller.rb b/app/controllers/api/v0/guidance_groups_controller.rb index 393e8d6..a22c9b2 100644 --- a/app/controllers/api/v0/guidance_groups_controller.rb +++ b/app/controllers/api/v0/guidance_groups_controller.rb @@ -18,7 +18,6 @@ end def index - if has_auth(constant("api_endpoint_types.guidances")) @all_viewable_groups = GuidanceGroup.all_viewable(@user) respond_with @all_viewable_groups diff --git a/app/controllers/plans_controller.rb b/app/controllers/plans_controller.rb index 4396be1..bc9b490 100644 --- a/app/controllers/plans_controller.rb +++ b/app/controllers/plans_controller.rb @@ -168,7 +168,8 @@ @exported_plan = ExportedPlan.new.tap do |ep| ep.plan = @plan ep.user = current_user - ep.format = request.format.try(:symbol) + #ep.format = request.format.try(:symbol) + ep.format = request.format.to_sym plan_settings = @plan.settings(:export) Settings::Dmptemplate::DEFAULT_SETTINGS.each do |key, value| diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb index c39e932..1e04277 100644 --- a/app/controllers/projects_controller.rb +++ b/app/controllers/projects_controller.rb @@ -150,11 +150,14 @@ def update @project = Project.find(params[:id]) if user_signed_in? && @project.editable_by(current_user.id) then - respond_to do |format| - if @project.update_attributes(params[:project]) - format.html { redirect_to @project, notice: I18n.t('helpers.project.success_update') } - format.json { head :no_content } - else + + if @project.update_attributes(params[:project]) + respond_to do |format| + format.html { redirect_to({:action => "show", :id => @project.slug, notice: I18n.t('helpers.project.success_update') }) } + format.json { head :no_content } + end + else + respond_to do |format| format.html { render action: "edit" } format.json { render json: @project.errors, status: :unprocessable_entity } end diff --git a/app/controllers/registrations_controller.rb b/app/controllers/registrations_controller.rb index 3fdece0..d7127bb 100644 --- a/app/controllers/registrations_controller.rb +++ b/app/controllers/registrations_controller.rb @@ -1,7 +1,6 @@ # app/controllers/registrations_controller.rb class RegistrationsController < Devise::RegistrationsController - # POST /resource def create logger.debug "#{sign_up_params}" @@ -10,7 +9,7 @@ else existing_user = User.find_by_email(sign_up_params[:email]) if !existing_user.nil? then - if existing_user.dmponline3 && (existing_user.password == "" || existing_user.password.nil?) && existing_user.confirmed_at.nil? then + if (existing_user.password == "" || existing_user.password.nil?) && existing_user.confirmed_at.nil? then @user = existing_user do_update(false, true) else @@ -20,13 +19,13 @@ build_resource(sign_up_params) if resource.save if resource.active_for_authentication? - set_flash_message :notice, :signed_up if is_navigational_format? - sign_up(resource_name, resource) - respond_with resource, :location => after_sign_up_path_for(resource) + set_flash_message :notice, :signed_up if is_navigational_format? + sign_up(resource_name, resource) + respond_with resource, :location => after_sign_up_path_for(resource) else - set_flash_message :notice, :"signed_up_but_#{resource.inactive_message}" if is_navigational_format? - expire_session_data_after_sign_in! - respond_with resource, :location => after_inactive_sign_up_path_for(resource) + set_flash_message :notice, :"signed_up_but_#{resource.inactive_message}" if is_navigational_format? + #expire_session_data_after_sign_in! <-- DEPRECATED BY DEVISE + respond_with resource, :location => after_inactive_sign_up_path_for(resource) end else clean_up_passwords resource @@ -98,4 +97,9 @@ end end + def sign_up_params + params.require(:user).permit(:email, :password, :password_confirmation, :accept_terms, + :organisation_id, :other_organisation) + end + end diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 2f3bae1..1adb49e 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -14,4 +14,24 @@ def javascript(*files) content_for(:head) { javascript_include_tag(*files) } end + + def link_to_add_object(name, f, association, css_class, i) + new_object = f.object.class.reflect_on_association(association).klass.new + fields = f.fields_for(association, new_object, :child_index => "new_#{association}") do |builder| + j = i + 1 + new_object.number = j + render(association.to_s.singularize + "_fields", :f => builder) + end + link_to_function(name, "add_object(this, \"#{association}\", \"#{escape_javascript(fields)}\")", :class => css_class) + end + + def link_to_function(name, *args, &block) + html_options = args.extract_options!.symbolize_keys + + function = block_given? ? update_page(&block) : args[0] || '' + onclick = "#{"#{html_options[:onclick]}; " if html_options[:onclick]}#{function}; return false;" + href = html_options[:href] || '#' + + content_tag(:a, name, html_options.merge(:href => href, :onclick => onclick)) + end end diff --git a/app/views/admin/dmptemplates/settings.html.erb b/app/views/admin/dmptemplates/settings.html.erb index b387333..171d5bc 100644 --- a/app/views/admin/dmptemplates/settings.html.erb +++ b/app/views/admin/dmptemplates/settings.html.erb @@ -13,9 +13,9 @@
  • <%= f.label(t('helpers.settings.plans.margin')) %> - <% %i( top bottom left right ).each do |pos| %> - <%= t("helpers.settings.plans.margins.#{pos}") -%> - <%= select_tag("settings[export][formatting][margin][#{pos}]", options_for_select((0..100).to_a, @settings.formatting[:margin][pos])) %> + <% ["top", "bottom", "left", "right"].each do |pos| %> + <%= t("helpers.settings.plans.margins.#{pos}") -%> + <%= select_tag("settings[export][formatting][margin][#{pos}]", options_for_select((0..100).to_a, @settings.formatting[:margin][pos])) %> <% end %>
  • diff --git a/app/views/dmptemplates/_add_guidance.html.erb b/app/views/dmptemplates/_add_guidance.html.erb index 2364908..de49775 100644 --- a/app/views/dmptemplates/_add_guidance.html.erb +++ b/app/views/dmptemplates/_add_guidance.html.erb @@ -1,6 +1,6 @@
    - <%= form_for :guidance, :url => {:action => "admin_createguidance"}, :html => {:id => "new_guidance_form"} do |f| %> + <%= form_for :guidance, :url => {:action => "admin_create"}, :html => {:id => "new_guidance_form"} do |f| %> diff --git a/app/views/layouts/_dmponline_footer.html.erb b/app/views/layouts/_dmponline_footer.html.erb index 4ce4a31..9a21582 100644 --- a/app/views/layouts/_dmponline_footer.html.erb +++ b/app/views/layouts/_dmponline_footer.html.erb @@ -3,9 +3,9 @@ + diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index 90070ab..8307d8d 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -31,7 +31,10 @@ $("#dmp_table").tablesorter({dateFormat: "uk"}); $("#dmp_table_2").tablesorter({dateFormat: "uk"}); }); - + + // Set the JS locale equal to the one Rails has + I18n.defaultLocale = "<%= I18n.default_locale %>"; + I18n.locale = "<%= I18n.locale %>";
    <%= t("org_admin.guidance.text_label") %>