diff --git a/app/controllers/static_pages_controller.rb b/app/controllers/static_pages_controller.rb index 6435da8..49e279e 100644 --- a/app/controllers/static_pages_controller.rb +++ b/app/controllers/static_pages_controller.rb @@ -15,15 +15,9 @@ def roadmap end - - def locale - puts 'test locale' - end - # GET /plans/publicly_available - # ----------------------------------------------------------- def public_plans - @plans = Plan.where(visibility: :publicly_visible).order(title: :asc) + @plans = Plan.publicly_visible end # GET /plans/[:plan_slug]/public_export diff --git a/app/helpers/plans_helper.rb b/app/helpers/plans_helper.rb index bca0305..cf5a0c6 100644 --- a/app/helpers/plans_helper.rb +++ b/app/helpers/plans_helper.rb @@ -4,18 +4,18 @@ # -------------------------------------------------------- def plan_list_column_heading(column) if column.kind_of?(Array) - heading = (column.first.kind_of?(String) ? column.first : t("helpers.project.columns.unknown")) + heading = (column.first.kind_of?(String) ? column.first : _(' - ')) elsif column.kind_of?(String) heading = column else - heading = t("helpers.project.columns.unknown") + heading = _(' - ') end klass = (['name', 'description'].include?(heading) ? :dmp_th_big : :dmp_th_small) - content_tag(:th, t("helpers.project.columns.#{heading}"), class: klass) + content_tag(:th, t("helpers.project.columns.#{heading}"), class: klass) # parametrised YAML keys are no longer possible with gettext, TODO end # Populate a variable column for the project list @@ -27,14 +27,12 @@ klass, content = case col when 'name' [ "dmp_td_big", link_to(plan.title, plan_path(plan), class: "dmp_table_link") ] - when 'owner' user = plan.owner - text = if user.nil? - t("helpers.project.columns.unknown") + _(' - ') elsif user == current_user - t("helpers.me") + _('Me') else user.name end @@ -42,24 +40,32 @@ [ "tmp_td_small", text ] when 'shared' shared_num = plan.users.count - 1 - text = shared_num > 0 ? (t("helpers.yes_label") + " (with #{shared_num} people) ") : t("helpers.no_label") + text = shared_num > 0 ? (_('Yes') + " (with #{shared_num} people) ") : _('No') # Hardcoded strings are not internationalised [ "dmp_td_small", text ] when 'visibility' - ["dmp_td_small", (plan.visibility.nil? ? I18n.t("helpers.project.visibilities.labels.organisationally_visible") : I18n.t("helpers.project.visibilities.labels.#{plan.visibility}"))] + text = if plan.visibility == 'organisationally_visible' + _('Organisational') + elsif plan.visibility == 'publicly_visible' + _('Public') + elsif plan.visibility == 'is_test' + _('Test/Practice') + elsif plan.visibility == 'privately_visible' + _('Private') + end + ["dmp_td_small", text ] when 'last_edited' [ "dmp_td_small", l(plan.latest_update.to_date, formats: :short) ] when 'description' - [ "dmp_td_medium", (plan.try(col) || t("helpers.settings.unknown")) ] + [ "dmp_td_medium", (plan.try(col) || _(' - ')) ] when 'non_link_name' [ "dmp_td_big", plan.title ] when 'template' ["dmp_td_big", plan.template.title] when 'organisation' - ["dmp_td_medium", (plan.owner.org.nil? ? t("helpers.settings.unknown") : plan.owner.org.name) ] + ["dmp_td_medium", plan.template.org.name] # This will trigger 2 queries for each function call, i.e. one for templates and another for orgs tables else - [ "dmp_td_small", (plan.try(col) || t("helpers.settings.unknown")) ] + [ "dmp_td_small", (plan.try(col) || _(' - ')) ] end - content_tag(:td, content, class: klass) end diff --git a/app/models/plan.rb b/app/models/plan.rb index f569070..ac9b2b0 100644 --- a/app/models/plan.rb +++ b/app/models/plan.rb @@ -17,6 +17,8 @@ has_many :exported_plans has_many :roles + + # COMMENTED OUT THE DIRECT CONNECTION HERE TO Users to prevent assignment of users without an access_level specified (currently defaults to creator) # has_many :users, through: :roles @@ -46,6 +48,10 @@ FONT_HEIGHT_CONVERSION_FACTOR = 0.35278 #convert font point size to mm FONT_WIDTH_HEIGHT_RATIO = 0.4 #Assume glyph width averages 2/5 the height + # Scope queries + # Note that in ActiveRecord::Enum the mappings are exposed through a class method with the pluralized attribute name (e.g visibilities rather than visibility) + scope :publicly_visible, -> { where(:visibility => visibilities[:publicly_visible]).order(:title => :asc) } + ## # Settings for the template has_settings :export, class_name: 'Settings::Template' do |s| diff --git a/app/views/static_pages/public_plans.html.erb b/app/views/static_pages/public_plans.html.erb index 0e1dda0..fe615e5 100644 --- a/app/views/static_pages/public_plans.html.erb +++ b/app/views/static_pages/public_plans.html.erb @@ -1,41 +1,39 @@ <%- model_class = Plan -%>
- <%= raw t("public_plans_page.body_text_html", {app_name: Rails.configuration.branding[:application][:name]}) %> + <%= _('Public DMPs are plans created using the DMPTool and shared publicly by their owners. They are not vetted for quality, completeness, or adherence to funder guidelines.') %>
| + | <%= _('Name') %> | +<%= _('Template') %> | +<%= _('Organization') %> | +<%= _('Owner') %> | +|
|---|---|---|---|---|---|
| - <%= link_to t("helpers.project.tab_export"), "#{public_export_path(plan)}", :class => "dmp_table_link" %> + <%= link_to _('Export'), public_export_path(plan), :class => "dmp_table_link" %> |
- <%= raw t("public_plans_page.no_plans_body_text_html")%> + <%= _("There are no public DMPs.")%>
<% end %> diff --git a/config/locale/en_GB/app.po b/config/locale/en_GB/app.po index df3f025..141713c 100644 --- a/config/locale/en_GB/app.po +++ b/config/locale/en_GB/app.po @@ -2255,7 +2255,7 @@ #helpers.project.columns.organisation msgid "Organization" -msgstr "Organization" +msgstr "Organisation" #helpers.project.filter.placeholder msgid "Filter plans"