diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb index 96c0cc8..a653686 100644 --- a/app/controllers/projects_controller.rb +++ b/app/controllers/projects_controller.rb @@ -1,6 +1,6 @@ class ProjectsController < ApplicationController before_filter :get_plan_list_columns, only: %i( index ) - after_action :verify_authorized, except: [:publicly_available, :public_export] + after_action :verify_authorized respond_to :html @@ -26,12 +26,6 @@ end end end - - # GET /projects/publicly_available - # ----------------------------------------------------------- - def public_plans - @projects = Project.public_visibility.order(title: :asc) - end # GET /projects/1 # GET /projects/1.json @@ -39,10 +33,15 @@ def show @project = Project.find(params[:id]) authorize @project + @show_form = false if params[:show_form] == "yes" then @show_form = true end + + @visibilities = Visibility.all + @default_visibility = @visibilities.select{ |v| v.default }.first + if user_signed_in? && @project.readable_by(current_user.id) then respond_to do |format| format.html # show.html.erb @@ -133,32 +132,6 @@ end end - # GET /projects/[:project_slug]/public_export - # ------------------------------------------------------------- - def public_export - @project = Project.find(params[:id]) - - # Force PDF response - - request.format = :pdf - - # if the project is designated as public - if @project.is_public? - generate_export - - else - - # If the user is signed in and this is their plan - if user_signed_in? && @project.readable_by(current_user) - generate_export - else - - # Otherwise redirect to the home page with an unauthorized message - redirect_to root_path, notice: I18n.t('helpers.settings.plans.errors.no_access_account') - end - end - end - # POST /projects # POST /projects.json # ----------------------------------------------------------- @@ -206,9 +179,13 @@ def update @project = Project.find(params[:id]) authorize @project - + if user_signed_in? && @project.editable_by(current_user.id) then - if @project.update_attributes(project_params) + attrs = project_params + + attrs[:visibility] = Visibility.find(attrs[:visibility]) unless attrs[:visibility].nil? + + if @project.update_attributes(attrs) respond_to do |format| format.html { redirect_to({:action => "show", :id => @project.slug, notice: I18n.t('helpers.project.success_update') }) } end @@ -343,7 +320,7 @@ def project_params params.require(:project).permit(:title, :grant_number, :identifier, :description, :principal_investigator, :principal_investigator_identifier, - :data_contact, :funder_name, :is_test, :is_public, + :data_contact, :funder_name, :visibility, :dmptemplate_id, :organisation_id, :funder_id, :institution_id, :guidance_group_ids, :project_group_ids) end @@ -421,14 +398,12 @@ # ----------------------------------------------------------- def generate_export - plan = @project.plans.first - @exported_plan = ExportedPlan.new.tap do |ep| - ep.plan = plan + ep.plan = @plan ep.user = current_user ||= nil #ep.format = request.format.try(:symbol) ep.format = request.format.to_sym - plan_settings = plan.settings(:export) + plan_settings = @plan.settings(:export) Settings::Dmptemplate::DEFAULT_SETTINGS.each do |key, value| ep.settings(:export).send("#{key}=", plan_settings.send(key)) @@ -439,22 +414,22 @@ file_name = @exported_plan.project_name respond_to do |format| - format.html - format.xml - format.json - format.csv { send_data @exported_plan.as_csv, filename: "#{file_name}.csv" } - format.text { send_data @exported_plan.as_txt, filename: "#{file_name}.txt" } + format.html + format.xml + format.json + format.csv { send_data @exported_plan.as_csv, filename: "#{file_name}.csv" } + format.text { send_data @exported_plan.as_txt, filename: "#{file_name}.txt" } format.docx { headers["Content-Disposition"] = "attachment; filename=\"#{file_name}.docx\""} - format.pdf do - @formatting = plan.settings(:export).formatting - render pdf: file_name, - margin: @formatting[:margin], - footer: { - center: t('helpers.plan.export.pdf.generated_by'), - font_size: 8, - spacing: (@formatting[:margin][:bottom] / 2) - 4, - right: '[page] of [topage]' - } + format.pdf do + @formatting = @plan.settings(:export).formatting + render pdf: file_name, + margin: @formatting[:margin], + footer: { + center: t('helpers.plan.export.pdf.generated_by'), + font_size: 8, + spacing: (@formatting[:margin][:bottom] / 2) - 4, + right: '[page] of [topage]' + } end end end diff --git a/app/controllers/static_pages_controller.rb b/app/controllers/static_pages_controller.rb index 8408cfe..c55f473 100644 --- a/app/controllers/static_pages_controller.rb +++ b/app/controllers/static_pages_controller.rb @@ -15,4 +15,63 @@ def roadmap end + # GET /projects/publicly_available + # ----------------------------------------------------------- + def public_plans + public_visibility = Visibility.find_by(name: 'public') + @projects = Project.where(visibility: public_visibility).order(title: :asc) + end + + # GET /projects/[:project_slug]/public_export + # ------------------------------------------------------------- + def public_export + @project = Project.find(params[:id]) + + # Force PDF response + request.format = :pdf + + # if the project is designated as public + if @project.visibility == Visibility.find_by(name: 'public') + @plan = @project.plans.first + + if !@plan.nil? + @exported_plan = ExportedPlan.new.tap do |ep| + ep.plan = @plan + ep.user = current_user ||= nil + #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| + ep.settings(:export).send("#{key}=", plan_settings.send(key)) + end + end + + @exported_plan.save! # FIXME: handle invalid request types without erroring? + file_name = @exported_plan.project_name + + respond_to do |format| + format.pdf do + @formatting = @plan.settings(:export).formatting + render pdf: file_name, + margin: @formatting[:margin], + footer: { + center: t('helpers.plan.export.pdf.generated_by'), + font_size: 8, + spacing: (@formatting[:margin][:bottom] / 2) - 4, + right: '[page] of [topage]' + } + end + end + + else + # the project has no plans for some reason + redirect_to public_plans_path, notice: I18n.t('helpers.settings.projects.errors.no_plan') + end + + else + # Otherwise redirect to the home page with an unauthorized message + redirect_to public_plans_path, notice: I18n.t('helpers.settings.plans.errors.no_access_account') + end + end end \ No newline at end of file diff --git a/app/models/exported_plan.rb b/app/models/exported_plan.rb index 797e0a8..3782b52 100644 --- a/app/models/exported_plan.rb +++ b/app/models/exported_plan.rb @@ -55,9 +55,13 @@ end def orcid - scheme = IdentifierScheme.find_by(name: 'orcid') + scheme = IdentifierScheme.find_by(name: 'orcid') + if self.user.nil? + '' + else orcid = self.user.user_identifiers.where(identifier_scheme: scheme).first (orcid.nil? ? '' : orcid.identifier) + end end # sections taken from fields settings diff --git a/app/models/project.rb b/app/models/project.rb index 0b50de6..06e51ec 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -6,27 +6,14 @@ #associations between tables belongs_to :dmptemplate belongs_to :organisation + + belongs_to :visibility + has_many :plans has_many :project_groups, :dependent => :destroy has_and_belongs_to_many :guidance_groups, join_table: "project_guidance" friendly_id :title, use: [:slugged, :history, :finders] - - scope :public_visibility, -> { where(is_public: true) } - - # Set the is_public flag to false if we are making this a test plan - # ----------------------------------------------------------------- - def is_test=(val) - self[:is_public] = false if (val == 1 || val == true) && is_public? # val comes in as 1 or 0 - self[:is_test] = val - end - - # Set the is_test flag to false if we are making this plan public - # ----------------------------------------------------------------- - def is_public=(val) - self[:is_test] = false if (val == 1 || val == true) && is_test? # val comes in as 1 or 0 - self[:is_public] = val - end ## # returns the title of the project @@ -35,9 +22,9 @@ def to_s "#{title}" end - + after_create :create_plans - + ## # sets a new funder for the project # defaults to the first dmptemplate if the current template is nill and the funder has more than one dmptemplate @@ -332,39 +319,41 @@ self.dmptemplate.try(:organisation).try(:abbreviation) end + + # ================================================================== private + ## + # adds a user to the project + # if no flags are specified, the user is given read privleges + # + # @param user_id [Integer] the user to be given privleges + # @param is_editor [Boolean] whether or not the user can edit the project + # @param is_administrator [Boolean] whether or not the user can administrate the project + # @param is_creator [Boolean] wheter or not the user created the project + # @return [Array] + def add_user(user_id, is_editor = false, is_administrator = false, is_creator = false) + group = ProjectGroup.new + group.user_id = user_id + group.project_creator = is_creator + group.project_editor = is_editor + group.project_administrator = is_administrator + project_groups << group + end - ## - # adds a user to the project - # if no flags are specified, the user is given read privleges - # - # @param user_id [Integer] the user to be given privleges - # @param is_editor [Boolean] whether or not the user can edit the project - # @param is_administrator [Boolean] whether or not the user can administrate the project - # @param is_creator [Boolean] wheter or not the user created the project - # @return [Array] - def add_user(user_id, is_editor = false, is_administrator = false, is_creator = false) - group = ProjectGroup.new - group.user_id = user_id - group.project_creator = is_creator - group.project_editor = is_editor - group.project_administrator = is_administrator - project_groups << group - end - - ## - # creates a plan for each phase in the dmptemplate associated with this project - # unless the phase is unpublished, it creates a new plan, and a new version of the plan and adds them to the project's plans - # - # @return [Array] - def create_plans - dmptemplate.phases.each do |phase| - latest_published_version = phase.latest_published_version - unless latest_published_version.nil? - new_plan = Plan.new - new_plan.version = latest_published_version - plans << new_plan - end - end - end + ## + # creates a plan for each phase in the dmptemplate associated with this project + # unless the phase is unpublished, it creates a new plan, and a new version of the plan and adds them to the project's plans + # + # @return [Array] + def create_plans + dmptemplate.phases.each do |phase| + latest_published_version = phase.latest_published_version + unless latest_published_version.nil? + new_plan = Plan.new + new_plan.version = latest_published_version + plans << new_plan + end + end + end + end diff --git a/app/models/visibility.rb b/app/models/visibility.rb new file mode 100644 index 0000000..26f7270 --- /dev/null +++ b/app/models/visibility.rb @@ -0,0 +1,5 @@ +class Visibility < ActiveRecord::Base + has_many :projects + + validates :name, uniqueness: true, presence: true +end \ No newline at end of file diff --git a/app/views/layouts/_navigation.html.erb b/app/views/layouts/_navigation.html.erb index 9f97b09..41afc99 100644 --- a/app/views/layouts/_navigation.html.erb +++ b/app/views/layouts/_navigation.html.erb @@ -99,12 +99,12 @@ - <% if current_path == "/plans/publicly_available" then %> + <% if current_path == "/plans/public_plans" then %>
  • <% else %>
  • <% end %> - <%= t("helpers.publicly_available_label") %> + <%= t("helpers.public_plans_label") %>
  • diff --git a/app/views/projects/_project_details.html.erb b/app/views/projects/_project_details.html.erb index a57b3c6..8c77cd5 100644 --- a/app/views/projects/_project_details.html.erb +++ b/app/views/projects/_project_details.html.erb @@ -76,13 +76,10 @@ - <%= t('helpers.project.project_is_test') %> - <%= (@project.is_test? ? t('helpers.yes') : t('helpers.no')) %> + <%= t('helpers.project.visibility') %> + <%= (@project.visibility.nil? ? t("helpers.project.visibilities.#{@default_visibility.name}") : t("helpers.project.visibilities.#{@project.visibility.name}")) %> - - <%= t('helpers.project.project_is_public') %> - <%= (@project.is_public? ? t('helpers.yes') : t('helpers.no')) %> - + @@ -147,13 +144,19 @@ - <%= t('helpers.project.project_is_test') %> - <%= f.check_box :is_test, {class: 'check_box', title: t('helpers.project.project_is_test_help_text'), autocomplete: 'off'} %> + <%= t('helpers.project.visibility') %> + + <% selected = (@project.visibility.nil? ? @default_visibility.id : @project.visibility.id) %> + + <% @visibilities.collect{ |v| {name: v.name, id: v.id} }.each do |visibility| %> +
    + /> + <%= t("helpers.project.visibilities.#{visibility[:name]}") %> +
    + <% end %> + - - <%= t('helpers.project.project_is_public') %> - <%= f.check_box :is_public, {class: 'check_box', title: t('helpers.project.project_is_public_help_text'), autocomplete: 'off'} %> - + <% end %> diff --git a/app/views/projects/public_export.html.erb b/app/views/projects/public_export.html.erb new file mode 100644 index 0000000..37f1a18 --- /dev/null +++ b/app/views/projects/public_export.html.erb @@ -0,0 +1,41 @@ +<%- model_class = Project -%> + + +<%= render :partial => "/projects/project_title", locals: {project: @project} %> + + +<%= render :partial => "project_nav_tabs", locals: {project: @project, active: "export_page"} %> + + +
    + + <%= raw t('helpers.project.export_text_html')%> + + + <% if @project.plans.any? %> + <% if @project.plans.count == 1 then %> + <% @project.plans.each do |plan| %> + <%= render :partial => "/shared/export_links", locals: {plan: plan} %> + <% end %> + <%else%> + <% @project.plans.each do |plan| %> +
    +
    + +
    +
    + <%= render :partial => "/shared/export_links", locals: {plan: plan} %> +
    +
    +
    +
    + <%end%> + <%end%> + <%end%> + +
    \ No newline at end of file diff --git a/app/views/projects/publicly_available.html.erb b/app/views/projects/publicly_available.html.erb deleted file mode 100644 index a2e94ed..0000000 --- a/app/views/projects/publicly_available.html.erb +++ /dev/null @@ -1,41 +0,0 @@ -<%- model_class = Project -%> -

    - <%= t("helpers.project.publicly_available_title") %> -

    - - -<% if @projects.count > 0 %> -

    - <%= raw t("helpers.project.publicly_available_text", {app_name: Rails.configuration.branding[:application][:name]}) %> -

    - - - - - <% ['name', 'template', 'organisation', 'owner'].each do |column| %> - <%= project_list_column_heading(column) %> - <% end %> - - - - - <% @projects.each do |project| %> - - <% ['non_link_name', 'template', 'organisation', 'owner'].each do |column| %> - <%= project_list_column_body(column, project) %> - <% end %> - - - - <% end %> - -
    - <%= link_to t("helpers.project.tab_export"), "#{public_export_project_path(project)}", :class => "dmp_table_link" %> -
    - - -<% else %> -

    - <%= raw t("helpers.project.project_text_when_no_project")%> -

    -<% end %> diff --git a/app/views/static_pages/public_plans.html.erb b/app/views/static_pages/public_plans.html.erb new file mode 100644 index 0000000..16cdb15 --- /dev/null +++ b/app/views/static_pages/public_plans.html.erb @@ -0,0 +1,41 @@ +<%- model_class = Project -%> +

    + <%= raw t("public_plans_page.title") %> +

    + + +<% if @projects.count > 0 %> +

    + <%= raw t("public_plans_page.body_text_html", {app_name: Rails.configuration.branding[:application][:name]}) %> +

    + + + + + <% ['name', 'template', 'organisation', 'owner'].each do |column| %> + <%= project_list_column_heading(column) %> + <% end %> + + + + + <% @projects.each do |project| %> + + <% ['non_link_name', 'template', 'organisation', 'owner'].each do |column| %> + <%= project_list_column_body(column, project) %> + <% end %> + + + + <% end %> + +
    + <%= link_to t("helpers.project.tab_export"), "#{public_export_path(project)}", :class => "dmp_table_link" %> +
    + + +<% else %> +

    + <%= raw t("public_plans_page.no_plans_body_text_html")%> +

    +<% end %> diff --git a/config/locales/de.yml b/config/locales/de.yml index b9a1613..d5c3577 100644 --- a/config/locales/de.yml +++ b/config/locales/de.yml @@ -289,6 +289,7 @@ news_label: "Aktuelles" help_label: "Hilfe" contact_label: "Kontakt" + public_plans_label: "Öffentliche DMPs" jisc: "Das DCC wird untertützt von" greeting: "Hallo" @@ -511,13 +512,14 @@ project_identifier_help_text: "Eine Identifikationskürzel, wie es von Förderern oder Institutionen vergeben wird." project_static_info: "Dieser Plan basiert auf:" projects_title: "Meine Pläne" - default_visibility: "Organisatorische" - test_visibility: "Test" - public_visibility: "Öffentlichkeit" - project_is_test: "Test oder praxisplan?" - project_is_test_help_text: "Dieser Plan ist für die Prüfung oder Praxis puposes. Es wird von anderen Benutzern nicht angezeigt werden, es sei denn, Sie explizit freigeben sie mit ihnen (es wird jedoch in Website-Statistiken berücksichtigt werden)." - project_is_public: "Öffentlich im Internet verfügbar?" - project_is_public_help_text: "Ihr Plan erscheint auf der Seite Public DMPs dieser Website." + + visibility: "Sichtweite" + visibilities: + test: "Test oder Praxis Plan" + private: "Private (Besitzer, Miteigentümer und Admins) Siehe unsere Nutzungsbedingungen." + organisational: "Mit anderen innerhalb Ihrer Organisation" + public: "Öffentlich im Internet. Ihr DMP erscheint auf der Public DMPs Seite dieser Seite." + project_settings_text: "Die hier ausgewählten Einträge werden in der Tabelle unten angezeigt. Sie können die Daten durch jeden ihrer Tabellenköpfe sortieren oder filtern, indem Sie eine Zeichenkette in der Suchbox eingeben." project_text_when_no_project: "

    Willkommen.
    Sie können nun ihren ersten DMP erstellen.
    Wählen Sie 'Plan erstellen' weiter unten aus, um zu beginnen.

    " project_text_when_project: "

    Die folgende Tabelle listet alle von Ihnen erstellten und von anderen mit Ihnen geteilten Pläne.
    Diese können jederzeit bearbeitet, geteilt, exportiert und gelöscht werden.

    " @@ -585,6 +587,9 @@ description: "Beschreibung" unknown: " - " visibility: "Sichtweite" + name: 'Name' + template: 'Vorlage' + organisation: 'Organisation' filter: placeholder: "Filter Pläne" submit: "Filter" @@ -617,6 +622,7 @@ no_name: "'Name' muss in der Liste von Spalten enthalten sein." duplicate: "Doppelter Spaltenname. Bitte jede Spalte nur einmal einfügen." unknown: "Unbekannter Spaltenname." + no_plan: "Der Plan ist unvollständig." plans: title: "Dateiname" reset: "Zurücksetzen" diff --git a/config/locales/en-UK.yml b/config/locales/en-UK.yml index e3cc3b7..814afe1 100644 --- a/config/locales/en-UK.yml +++ b/config/locales/en-UK.yml @@ -338,9 +338,7 @@ about_us_label: "About" roadmap_label: "Future plans" help_label: "Help" - -#----- - publicly_available_label: "Public DMPs" + publicly_plans_label: "Public DMPs" contact_label: "Contact" jisc: "The %{organisation_abbreviation} is funded by" @@ -581,17 +579,13 @@ project_identifier_help_text: "A pertinent ID as determined by the funder and/or institution." project_static_info: "This plan is based on:" projects_title: "My plans" - default_visibility: "Organizational" - test_visibility: "Test" - public_visibility: "Public" - project_is_test: "Test or practice plan?" - project_is_test_help_text: "This plan is for testing or practice puposes. It will not be viewable by other users unless you explicitly share it with them (it will however be factored into site statistics)." - project_is_public: "Publicly available on the web?" - project_is_public_help_text: "Your plan will appear on the Public DMPs page of this site." -#----- - publicly_available_title: "Public DMPs" - publicly_available_text: "Public DMPs are plans created using %{app_name} and shared publicly by their owners. They are not vetted for quality, completeness, or adherence to funder guidelines." + visibility: "Visibility" + visibilities: + test: "Test or Practice Plan" + private: "Private (owners, co-owners, and admins only) See our Terms of Use." + organisational: "With others within your organization" + public: "Publicly on the web. Your DMP will appear on the Public DMPs page of this site." project_settings_text: "The items you select here will be displayed in the table below. You can sort the data by each of these headings or filter by entering a text string in the search box." project_text_when_no_project: "

    Welcome.
    You are now ready to create your first DMP.
    Click the 'Create plan' button below to begin.

    " @@ -646,9 +640,9 @@ description: "Description" unknown: " - " visibility: "Visibility" -#----- - template: "Template" - organisation: "Organisation" + name: 'Name' + template: 'Template' + organisation: 'Organization' filter: placeholder: "Filter plans" @@ -693,6 +687,7 @@ no_name: "'name' must be included in column list." duplicate: "Duplicate column name. Please only include each column once." unknown: "Unknown column name." + no_plan: "The plan is incomplete." plans: title: "File Name" reset: "Reset" diff --git a/config/locales/en-US.yml b/config/locales/en-US.yml index b3acd75..5bc3a01 100644 --- a/config/locales/en-US.yml +++ b/config/locales/en-US.yml @@ -327,6 +327,7 @@ roadmap_label: "Future plans" help_label: "Help" contact_label: "Contact" + public_plans_label: "Public DMPs" jisc: "The %{organisation_abbreviation} is funded by" format: "format" @@ -563,13 +564,14 @@ project_identifier_help_text: "A pertinent ID as determined by the funder and/or institution." project_static_info: "This plan is based on:" projects_title: "My plans" - default_visibility: "Organizational" - test_visibility: "Test" - public_visibility: "Public" - project_is_test: "Test or practice plan?" - project_is_test_help_text: "This plan is for testing or practice puposes. It will not be viewable by other users unless you explicitly share it with them (it will however be factored into site statistics)." - project_is_public: "Publicly available on the web?" - project_is_public_help_text: "Your plan will appear on the Public DMPs page of this site." + + visibility: "Visibility" + visibilities: + test: "Test or Practice Plan" + private: "Private (owners, co-owners, and admins only) See our Terms of Use." + organisational: "With others within your organization" + public: "Publicly on the web. Your DMP will appear on the Public DMPs page of this site." + project_settings_text: "The items you select here will be displayed in the table below. You can sort the data by each of these headings or filter by entering a text string in the search box." project_text_when_no_project: "

    Welcome.
    You are now ready to create your first DMP.
    Click the 'Create plan' button below to begin.

    " project_text_when_project: "

    The table below lists the plans that you have created, and any that have been shared with you by others.
    These can be edited, shared, exported or deleted at anytime.

    " @@ -623,6 +625,9 @@ description: "Description" unknown: " - " visibility: "Visibility" + name: 'Name' + template: 'Template' + organisation: 'Organization' filter: placeholder: "Filter plans" submit: "Filter" @@ -666,6 +671,7 @@ no_name: "'name' must be included in column list." duplicate: "Duplicate column name. Please only include each column once." unknown: "Unknown column name." + no_plan: "The plan is incomplete." plans: title: "File Name" reset: "Reset" diff --git a/config/locales/es.yml b/config/locales/es.yml index 454f87e..87d3142 100644 --- a/config/locales/es.yml +++ b/config/locales/es.yml @@ -280,6 +280,7 @@ roadmap_label: "Hoja de ruta" help_label: "Ayuda" contact_label: "Contacto" + public_plans_label: "DMP públicos" jisc: "El DCC está financiado por" sign_in: "Conectar" @@ -453,13 +454,14 @@ project_identifier_help_text: "El ID tal como lo determinó la institución u organismo financiador." project_static_info: "Este plan está basado en:" projects_title: "Mis planes" - default_visibility: "Organizativo" - test_visibility: "Prueba" - public_visibility: "Público" - project_is_test: "¿Plan de prueba o práctica?" - project_is_test_help_text: "Este plan es para probar o hacer puposes. No será visible por otros usuarios a menos que explícitamente lo comparta con ellos (sin embargo, se tendrá en cuenta en las estadísticas del sitio)." - project_is_public: "¿Publicamente disponible en la web?" - project_is_public_help_text: "Su plan aparecerá en la página Public DMPs de este sitio." + + visibility: "Visibilidad" + visibilities: + test: "Plan de prueba o práctica" + private: "Privado (propietarios, copropietarios y administradores solamente) Consulte nuestras Condiciones de uso." + organisational: "Con otros miembros de su organización" + public: "Publicamente en la web. Su DMP aparecerá en la página Public DMPs de este sitio." + project_settings_text: "Los items que seleccione se mostarán en la siguiente tabla. Puede ordenar los datos según sus encabezados o filtrar tecleando textos en la caja de búsqueda." project_text_when_no_project: "

    Bienvenido.
    Ya está listo para crear su primer PGD.
    Haga clic en el botón 'Crear un plan' para comenzar.

    " project_text_when_project: "

    La siguiente tabla lista los planes que usted ha creado, así como los que otros investigadores hayan compartido con usted.
    Se pueden editar, compartir, exportar o borrar en cualquier momento.

    " @@ -512,6 +514,9 @@ data_contact: "Datos de contacto del plan" description: "Descripción" visibility: 'Visibilidad' + name: 'Nombre' + template: 'Plantilla' + organisation: 'Organización' filter: placeholder: "Filtro de planes" submit: "Filtrar" @@ -542,6 +547,7 @@ no_name: "'nombre' tiene que estar en la lista de columnas." duplicate: "Nombre de columna duplicado. Por favor, indique cada columna sólo una vez." unknown: "Nombre de columna desconocido." + no_plan: "El plan es incompleto." plans: title: Título del plan reset: "Reiniciar" diff --git a/config/locales/fr.yml b/config/locales/fr.yml index 0569738..84f60a2 100644 --- a/config/locales/fr.yml +++ b/config/locales/fr.yml @@ -281,6 +281,7 @@ roadmap_label: "Feuille de route" help_label: "Aide" contact_label: "Contact" + public_plans_label: "DMP Publics" jisc: "Le DCC est financé par" sign_in: "Connexion" @@ -458,13 +459,14 @@ project_identifier_help_text: "Un identifiant approprié conforme aux prescriptions de l'organisme financeur ou de l'établissement." project_static_info: "Ce plan s'inspire de :" projects_title: "Mes plans" - default_visibility: "Organisationnel" - test_visibility: "Tester" - public_visibility: "Public" - project_is_test: "Test ou un plan de pratique?" - project_is_test_help_text: "Ce plan est destiné aux essais ou à la pratique. Il ne sera pas visible par d'autres utilisateurs à moins que vous ne le partagiez explicitement avec eux (il sera cependant pris en compte dans les statistiques du site)." - project_is_public: "Publiquement disponible sur le web?" - project_is_public_help_text: "Votre plan apparaîtra sur la page Public DMPs de ce site." + + visibility: "Visibilité" + visibilities: + test: "Test ou plan de pratique" + private: "Privé (propriétaires, copropriétaires et administrateurs uniquement) Consultez nos Conditions d'utilisation." + organisational: "Avec d'autres membres de votre organisation" + public: "Publiquement sur le web. Votre DMP apparaîtra sur la page Public DMPs de ce site." + project_settings_text: "Les éléments que vous sélectionnez ici s'afficherontt dans le tableaiu ci-après. Vous pouvez trier les données à partir de chacune de ces en-tête ou les filtrer en tapant une chaîne de caractères dans la zone de recherche." project_text_when_no_project: "

    Bienvenue.
    Vous voilà prêt à créer votre premier DMP.
    Cliquez sur le bouton 'Créer un plan' ci-dessous pour commencer.

    " project_text_when_project: "

    Dans le tableau ci-dessous figurent les plans que vous avez créés, ainsi que ceux que vous partagez avec d'autres.
    Vous pouvez à tout moment les modifier, les partager, les exporter, les effacer...

    " @@ -517,12 +519,15 @@ data_contact: "Interlocuteur pour les données du plan" description: "Description" visibility: "Visibilité" + name: 'Prénom' + template: 'Modèle' + organisation: 'Organisation' filter: placeholder: "Filtrer les plans" submit: "Filtrer" cancel: "Annuler" no_matches: "Pas de plans pour '%{filter}'" - + plan: export: pdf: @@ -554,6 +559,7 @@ no_name: "'name' doit figurer dans la liste des colonnes." duplicate: "Nom de colonne en doublon. Merci de n'ajouter qu'une seule colonne." unknown: "Nom de colonne inconnu." + no_plan: "Le plan est incomplet." plans: title: Titre du plan reset: "Réinitialiser" diff --git a/config/locales/static_pages/de.static.yml.example b/config/locales/static_pages/de.static.yml.example index af105a5..3bf5260 100644 --- a/config/locales/static_pages/de.static.yml.example +++ b/config/locales/static_pages/de.static.yml.example @@ -183,4 +183,9 @@

    Bei Benutzung dieser Anwendung stimmen Sie den Nutzungsbedingungen zu.

    -
    " \ No newline at end of file + " + + public_plans_page: + title: "Öffentliche DMPs" + no_plans_body_text_html: "Es wurden noch keine DMPs veröffentlicht." + body_text_html: "Öffentliche DMPs sind Pläne, die mit dem DMPTool erstellt und öffentlich von ihren Eigentümern veröffentlicht werden. Sie werden nicht auf Qualität, Vollständigkeit oder die Einhaltung der funder Richtlinien überprüft." diff --git a/config/locales/static_pages/en-UK.static.yml.example b/config/locales/static_pages/en-UK.static.yml.example index 9ed7419..54e5f2a 100644 --- a/config/locales/static_pages/en-UK.static.yml.example +++ b/config/locales/static_pages/en-UK.static.yml.example @@ -214,4 +214,9 @@
    -

    Use of the tool indicates that you understand and agree to these terms and conditions.

    " \ No newline at end of file +

    Use of the tool indicates that you understand and agree to these terms and conditions.

    " + + public_plans_page: + title: "Public DMPs" + no_plans_body_text_html: "No DMPs have been made public yet." + body_text_html: "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." diff --git a/config/locales/static_pages/en-US.static.yml.example b/config/locales/static_pages/en-US.static.yml.example index ffb60d4..fa41df8 100644 --- a/config/locales/static_pages/en-US.static.yml.example +++ b/config/locales/static_pages/en-US.static.yml.example @@ -215,3 +215,7 @@

    Use of the tool indicates that you understand and agree to these terms and conditions.

    " + + public_plans_page: + title: "Public DMPs" + body_text_html: "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." \ No newline at end of file diff --git a/config/locales/static_pages/fr.static.yml.example b/config/locales/static_pages/fr.static.yml.example index 11fdf18..b48a7c2 100644 --- a/config/locales/static_pages/fr.static.yml.example +++ b/config/locales/static_pages/fr.static.yml.example @@ -155,4 +155,9 @@
    -

    En utilisant l'outil, vous comprenez et acceptez ces conditions.

    " \ No newline at end of file +

    En utilisant l'outil, vous comprenez et acceptez ces conditions.

    " + + public_plans_page: + title: "DMP publics" + no_plans_body_text_html: "Aucun DMP n'a été rendu public." + body_text_html: "Les DMP publics sont des plans créés à l'aide de DMPTool et partagés publiquement par leurs propriétaires. Ils ne sont pas vérifiés pour la qualité, l'exhaustivité ou l'adhésion aux lignes directrices des bailleurs de fonds." diff --git a/config/routes.rb b/config/routes.rb index 59286ba..44a4334 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -47,8 +47,10 @@ get "help" => 'static_pages#help' get "roadmap" => 'static_pages#roadmap' get "terms" => 'static_pages#termsuse' + get "public_plans" => 'static_pages#public_plans' + get "public_export/:id" => 'static_pages#public_export', as: 'public_export' + get "existing_users" => 'existing_users#index' - get "public_plans" => 'projects#public_plans' #post 'contact_form' => 'contacts', as: 'localized_contact_creation' #get 'contact_form' => 'contacts#new', as: 'localized_contact_form' @@ -148,7 +150,6 @@ member do get 'share' get 'export' - get 'public_export' post 'invite' end collection do diff --git a/db/migrate/20170103171414_add_test_and_public_to_projects.rb b/db/migrate/20170103171414_add_test_and_public_to_projects.rb deleted file mode 100644 index e62cc69..0000000 --- a/db/migrate/20170103171414_add_test_and_public_to_projects.rb +++ /dev/null @@ -1,6 +0,0 @@ -class AddTestAndPublicToProjects < ActiveRecord::Migration - def change - add_column :projects, :is_test, :boolean, default: false - add_column :projects, :is_public, :boolean, default: false - end -end diff --git a/db/migrate/20170103221846_add_indexes_for_is_test_and_is_public_to_projects.rb b/db/migrate/20170103221846_add_indexes_for_is_test_and_is_public_to_projects.rb deleted file mode 100644 index 1768ab2..0000000 --- a/db/migrate/20170103221846_add_indexes_for_is_test_and_is_public_to_projects.rb +++ /dev/null @@ -1,5 +0,0 @@ -class AddIndexesForIsTestAndIsPublicToProjects < ActiveRecord::Migration - def change - add_index :projects, [:id, :is_test, :is_public] - end -end diff --git a/db/migrate/20170105165111_create_visibilities.rb b/db/migrate/20170105165111_create_visibilities.rb new file mode 100644 index 0000000..5e72ee1 --- /dev/null +++ b/db/migrate/20170105165111_create_visibilities.rb @@ -0,0 +1,11 @@ +class CreateVisibilities < ActiveRecord::Migration + def change + create_table :visibilities do |t| + t.string :name + t.boolean :default, default: false + t.timestamps + end + + add_reference :projects, :visibility, foreign_key: true + end +end diff --git a/db/schema.rb b/db/schema.rb index 9ef95ef..218a45e 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,95 +11,95 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 20170103221846) do +ActiveRecord::Schema.define(version: 20170105165111) do create_table "answers", force: :cascade do |t| - t.text "text", limit: 65535 - t.integer "plan_id", limit: 4 - t.integer "user_id", limit: 4 - t.integer "question_id", limit: 4 + t.text "text" + t.integer "plan_id" + t.integer "user_id" + t.integer "question_id" t.datetime "created_at" t.datetime "updated_at" end create_table "answers_options", id: false, force: :cascade do |t| - t.integer "answer_id", limit: 4, null: false - t.integer "option_id", limit: 4, null: false + t.integer "answer_id", null: false + t.integer "option_id", null: false end - add_index "answers_options", ["answer_id", "option_id"], name: "index_answers_options_on_answer_id_and_option_id", using: :btree + add_index "answers_options", ["answer_id", "option_id"], name: "index_answers_options_on_answer_id_and_option_id" create_table "comments", force: :cascade do |t| - t.integer "user_id", limit: 4 - t.integer "question_id", limit: 4 - t.text "text", limit: 65535 + t.integer "user_id" + t.integer "question_id" + t.text "text" t.datetime "created_at" t.datetime "updated_at" t.boolean "archived" - t.integer "plan_id", limit: 4 - t.integer "archived_by", limit: 4 + t.integer "plan_id" + t.integer "archived_by" end create_table "dmptemplates", force: :cascade do |t| - t.string "title", limit: 255 - t.text "description", limit: 65535 + t.string "title" + t.text "description" t.boolean "published" - t.integer "user_id", limit: 4 - t.integer "organisation_id", limit: 4 + t.integer "user_id" + t.integer "organisation_id" t.datetime "created_at" t.datetime "updated_at" - t.string "locale", limit: 255 + t.string "locale" t.boolean "is_default" end create_table "dmptemplates_guidance_groups", id: false, force: :cascade do |t| - t.integer "dmptemplate_id", limit: 4 - t.integer "guidance_group_id", limit: 4 + t.integer "dmptemplate_id" + t.integer "guidance_group_id" end create_table "exported_plans", force: :cascade do |t| - t.integer "plan_id", limit: 4 - t.integer "user_id", limit: 4 - t.string "format", limit: 255 + t.integer "plan_id" + t.integer "user_id" + t.string "format" t.datetime "created_at" t.datetime "updated_at" end create_table "file_types", force: :cascade do |t| - t.string "name", limit: 255 - t.string "icon_name", limit: 255 - t.integer "icon_size", limit: 4 - t.string "icon_location", limit: 255 + t.string "name" + t.string "icon_name" + t.integer "icon_size" + t.string "icon_location" t.datetime "created_at" t.datetime "updated_at" end create_table "file_uploads", force: :cascade do |t| - t.string "name", limit: 255 - t.string "title", limit: 255 - t.text "description", limit: 65535 - t.integer "size", limit: 4 + t.string "name" + t.string "title" + t.text "description" + t.integer "size" t.boolean "published" - t.string "location", limit: 255 - t.integer "file_type_id", limit: 4 + t.string "location" + t.integer "file_type_id" t.datetime "created_at" t.datetime "updated_at" end create_table "friendly_id_slugs", force: :cascade do |t| - t.string "slug", limit: 255, null: false - t.integer "sluggable_id", limit: 4, null: false + t.string "slug", null: false + t.integer "sluggable_id", null: false t.string "sluggable_type", limit: 40 t.datetime "created_at" end - add_index "friendly_id_slugs", ["slug", "sluggable_type"], name: "index_friendly_id_slugs_on_slug_and_sluggable_type", unique: true, using: :btree - add_index "friendly_id_slugs", ["sluggable_id"], name: "index_friendly_id_slugs_on_sluggable_id", using: :btree - add_index "friendly_id_slugs", ["sluggable_type"], name: "index_friendly_id_slugs_on_sluggable_type", using: :btree + add_index "friendly_id_slugs", ["slug", "sluggable_type"], name: "index_friendly_id_slugs_on_slug_and_sluggable_type", unique: true + add_index "friendly_id_slugs", ["sluggable_id"], name: "index_friendly_id_slugs_on_sluggable_id" + add_index "friendly_id_slugs", ["sluggable_type"], name: "index_friendly_id_slugs_on_sluggable_type" create_table "guidance_groups", force: :cascade do |t| - t.string "name", limit: 255 - t.integer "organisation_id", limit: 4 + t.string "name" + t.integer "organisation_id" t.datetime "created_at" t.datetime "updated_at" t.boolean "optional_subset" @@ -107,106 +107,106 @@ end create_table "guidance_in_group", id: false, force: :cascade do |t| - t.integer "guidance_id", limit: 4, null: false - t.integer "guidance_group_id", limit: 4, null: false + t.integer "guidance_id", null: false + t.integer "guidance_group_id", null: false end - add_index "guidance_in_group", ["guidance_id", "guidance_group_id"], name: "index_guidance_in_group_on_guidance_id_and_guidance_group_id", using: :btree + add_index "guidance_in_group", ["guidance_id", "guidance_group_id"], name: "index_guidance_in_group_on_guidance_id_and_guidance_group_id" create_table "guidances", force: :cascade do |t| - t.text "text", limit: 65535 - t.integer "guidance_group_id", limit: 4 + t.text "text" + t.integer "guidance_group_id" t.datetime "created_at" t.datetime "updated_at" - t.integer "question_id", limit: 4 + t.integer "question_id" t.boolean "published" end create_table "identifier_schemes", force: :cascade do |t| - t.string "name", limit: 255 - t.string "description", limit: 255 + t.string "name" + t.string "description" t.boolean "active" t.datetime "created_at" t.datetime "updated_at" end create_table "languages", force: :cascade do |t| - t.string "abbreviation", limit: 255 - t.string "description", limit: 255 - t.string "name", limit: 255 + t.string "abbreviation" + t.string "description" + t.string "name" t.boolean "default_language" end create_table "option_warnings", force: :cascade do |t| - t.integer "organisation_id", limit: 4 - t.integer "option_id", limit: 4 - t.text "text", limit: 65535 + t.integer "organisation_id" + t.integer "option_id" + t.text "text" t.datetime "created_at" t.datetime "updated_at" end create_table "options", force: :cascade do |t| - t.integer "question_id", limit: 4 - t.string "text", limit: 255 - t.integer "number", limit: 4 + t.integer "question_id" + t.string "text" + t.integer "number" t.boolean "is_default" t.datetime "created_at" t.datetime "updated_at" end create_table "org_token_permissions", force: :cascade do |t| - t.integer "organisation_id", limit: 4 - t.integer "token_permission_type_id", limit: 4 + t.integer "organisation_id" + t.integer "token_permission_type_id" t.datetime "created_at" t.datetime "updated_at" end create_table "organisation_types", force: :cascade do |t| - t.string "name", limit: 255 - t.text "description", limit: 65535 + t.string "name" + t.text "description" t.datetime "created_at" t.datetime "updated_at" end create_table "organisations", force: :cascade do |t| - t.string "name", limit: 255 - t.string "abbreviation", limit: 255 - t.string "target_url", limit: 255 - t.integer "organisation_type_id", limit: 4 - t.string "domain", limit: 255 - t.string "wayfless_entity", limit: 255 - t.integer "stylesheet_file_id", limit: 4 + t.string "name" + t.string "abbreviation" + t.string "target_url" + t.integer "organisation_type_id" + t.string "domain" + t.string "wayfless_entity" + t.integer "stylesheet_file_id" t.datetime "created_at" t.datetime "updated_at" - t.integer "parent_id", limit: 4 + t.integer "parent_id" t.boolean "is_other" - t.string "sort_name", limit: 255 - t.text "banner_text", limit: 65535 - t.string "logo_file_name", limit: 255 - t.integer "region_id", limit: 4 - t.integer "language_id", limit: 4 - t.string "logo_uid", limit: 255 - t.string "logo_name", limit: 255 - t.string "contact_email", limit: 255 + t.string "sort_name" + t.text "banner_text" + t.string "logo_file_name" + t.integer "region_id" + t.integer "language_id" + t.string "logo_uid" + t.string "logo_name" + t.string "contact_email" end create_table "phases", force: :cascade do |t| - t.string "title", limit: 255 - t.text "description", limit: 65535 - t.integer "number", limit: 4 - t.integer "dmptemplate_id", limit: 4 + t.string "title" + t.text "description" + t.integer "number" + t.integer "dmptemplate_id" t.datetime "created_at" t.datetime "updated_at" - t.string "slug", limit: 255 + t.string "slug" end - add_index "phases", ["dmptemplate_id"], name: "index_phases_on_dmptemplate_id", using: :btree - add_index "phases", ["slug"], name: "index_phases_on_slug", unique: true, using: :btree + add_index "phases", ["dmptemplate_id"], name: "index_phases_on_dmptemplate_id" + add_index "phases", ["slug"], name: "index_phases_on_slug", unique: true create_table "plan_sections", force: :cascade do |t| - t.integer "user_id", limit: 4 - t.integer "section_id", limit: 4 - t.integer "plan_id", limit: 4 + t.integer "user_id" + t.integer "section_id" + t.integer "plan_id" t.datetime "created_at" t.datetime "updated_at" t.datetime "release_time" @@ -214,8 +214,8 @@ create_table "plans", force: :cascade do |t| t.boolean "locked" - t.integer "project_id", limit: 4 - t.integer "version_id", limit: 4 + t.integer "project_id" + t.integer "version_id" t.datetime "created_at" t.datetime "updated_at" end @@ -223,242 +223,242 @@ create_table "project_groups", force: :cascade do |t| t.boolean "project_creator" t.boolean "project_editor" - t.integer "user_id", limit: 4 - t.integer "project_id", limit: 4 + t.integer "user_id" + t.integer "project_id" t.datetime "created_at" t.datetime "updated_at" t.boolean "project_administrator" end create_table "project_guidance", id: false, force: :cascade do |t| - t.integer "project_id", limit: 4, null: false - t.integer "guidance_group_id", limit: 4, null: false + t.integer "project_id", null: false + t.integer "guidance_group_id", null: false end - add_index "project_guidance", ["project_id", "guidance_group_id"], name: "index_project_guidance_on_project_id_and_guidance_group_id", using: :btree + add_index "project_guidance", ["project_id", "guidance_group_id"], name: "index_project_guidance_on_project_id_and_guidance_group_id" create_table "projects", force: :cascade do |t| - t.string "title", limit: 255 - t.integer "dmptemplate_id", limit: 4 + t.string "title" + t.integer "dmptemplate_id" t.datetime "created_at" t.datetime "updated_at" - t.string "slug", limit: 255 - t.integer "organisation_id", limit: 4 - t.string "grant_number", limit: 255 - t.string "identifier", limit: 255 - t.text "description", limit: 65535 - t.string "principal_investigator", limit: 255 - t.string "principal_investigator_identifier", limit: 255 - t.string "data_contact", limit: 255 - t.string "funder_name", limit: 255 - t.boolean "is_test", default: false - t.boolean "is_public", default: false + t.string "slug" + t.integer "organisation_id" + t.string "grant_number" + t.string "identifier" + t.text "description" + t.string "principal_investigator" + t.string "principal_investigator_identifier" + t.string "data_contact" + t.string "funder_name" + t.integer "visibility_id" end - add_index "projects", ["id", "is_test", "is_public"], name: "index_projects_on_id_and_is_test_and_is_public", using: :btree - add_index "projects", ["slug"], name: "index_projects_on_slug", unique: true, using: :btree + add_index "projects", ["slug"], name: "index_projects_on_slug", unique: true create_table "question_formats", force: :cascade do |t| - t.string "title", limit: 255 - t.text "description", limit: 65535 + t.string "title" + t.text "description" t.datetime "created_at" t.datetime "updated_at" end create_table "questions", force: :cascade do |t| - t.text "text", limit: 65535 - t.text "default_value", limit: 65535 - t.text "guidance", limit: 65535 - t.integer "number", limit: 4 - t.integer "parent_id", limit: 4 - t.integer "dependency_id", limit: 4 - t.text "dependency_text", limit: 65535 - t.integer "section_id", limit: 4 + t.text "text" + t.text "default_value" + t.text "guidance" + t.integer "number" + t.integer "parent_id" + t.integer "dependency_id" + t.text "dependency_text" + t.integer "section_id" t.datetime "created_at" t.datetime "updated_at" - t.integer "question_format_id", limit: 4 - t.boolean "option_comment_display", default: true + t.integer "question_format_id" + t.boolean "option_comment_display", default: true end create_table "questions_themes", id: false, force: :cascade do |t| - t.integer "question_id", limit: 4, null: false - t.integer "theme_id", limit: 4, null: false + t.integer "question_id", null: false + t.integer "theme_id", null: false end - add_index "questions_themes", ["question_id", "theme_id"], name: "index_questions_themes_on_question_id_and_theme_id", using: :btree + add_index "questions_themes", ["question_id", "theme_id"], name: "index_questions_themes_on_question_id_and_theme_id" create_table "region_groups", force: :cascade do |t| - t.integer "super_region_id", limit: 4 - t.integer "region_id", limit: 4 + t.integer "super_region_id" + t.integer "region_id" end create_table "regions", force: :cascade do |t| - t.string "abbreviation", limit: 255 - t.string "description", limit: 255 - t.string "name", limit: 255 + t.string "abbreviation" + t.string "description" + t.string "name" end create_table "roles", force: :cascade do |t| - t.string "name", limit: 255 + t.string "name" t.datetime "created_at" t.datetime "updated_at" t.boolean "role_in_plans" - t.integer "resource_id", limit: 4 - t.string "resource_type", limit: 255 + t.integer "resource_id" + t.string "resource_type" end - add_index "roles", ["name"], name: "index_roles_on_name", using: :btree - add_index "roles", ["name"], name: "index_roles_on_name_and_resource_type_and_resource_id", using: :btree + add_index "roles", ["name"], name: "index_roles_on_name" + add_index "roles", ["name"], name: "index_roles_on_name_and_resource_type_and_resource_id" create_table "sections", force: :cascade do |t| - t.string "title", limit: 255 - t.text "description", limit: 65535 - t.integer "number", limit: 4 - t.integer "version_id", limit: 4 - t.integer "organisation_id", limit: 4 + t.string "title" + t.text "description" + t.integer "number" + t.integer "version_id" + t.integer "organisation_id" t.datetime "created_at" t.datetime "updated_at" t.boolean "published" end create_table "settings", force: :cascade do |t| - t.string "var", limit: 255, null: false - t.text "value", limit: 65535 - t.integer "target_id", limit: 4, null: false - t.string "target_type", limit: 255, null: false + t.string "var", null: false + t.text "value" + t.integer "target_id", null: false + t.string "target_type", null: false t.datetime "created_at" t.datetime "updated_at" end - add_index "settings", ["target_type", "target_id", "var"], name: "index_settings_on_target_type_and_target_id_and_var", unique: true, using: :btree + add_index "settings", ["target_type", "target_id", "var"], name: "index_settings_on_target_type_and_target_id_and_var", unique: true create_table "splash_logs", force: :cascade do |t| - t.string "destination", limit: 255 + t.string "destination" t.datetime "created_at" t.datetime "updated_at" end create_table "suggested_answers", force: :cascade do |t| - t.integer "question_id", limit: 4 - t.integer "organisation_id", limit: 4 - t.text "text", limit: 65535 + t.integer "question_id" + t.integer "organisation_id" + t.text "text" t.datetime "created_at" t.datetime "updated_at" t.boolean "is_example" end create_table "themes", force: :cascade do |t| - t.string "title", limit: 255 - t.text "description", limit: 65535 + t.string "title" + t.text "description" t.datetime "created_at" t.datetime "updated_at" - t.string "locale", limit: 255 + t.string "locale" end create_table "themes_in_guidance", id: false, force: :cascade do |t| - t.integer "theme_id", limit: 4 - t.integer "guidance_id", limit: 4 + t.integer "theme_id" + t.integer "guidance_id" end create_table "token_permission_types", force: :cascade do |t| - t.string "token_type", limit: 255 - t.text "text_description", limit: 65535 + t.string "token_type" + t.text "text_description" t.datetime "created_at" t.datetime "updated_at" end create_table "user_identifiers", force: :cascade do |t| - t.string "identifier", limit: 255 + t.string "identifier" t.datetime "created_at" t.datetime "updated_at" - t.integer "user_id", limit: 4 - t.integer "identifier_scheme_id", limit: 4 + t.integer "user_id" + t.integer "identifier_scheme_id" end - add_index "user_identifiers", ["identifier_scheme_id"], name: "fk_rails_fe95df7db0", using: :btree - add_index "user_identifiers", ["user_id"], name: "fk_rails_65c9a98cdb", using: :btree - create_table "user_role_types", force: :cascade do |t| - t.string "name", limit: 255 - t.text "description", limit: 65535 + t.string "name" + t.text "description" t.datetime "created_at" t.datetime "updated_at" end create_table "user_statuses", force: :cascade do |t| - t.string "name", limit: 255 - t.text "description", limit: 65535 + t.string "name" + t.text "description" t.datetime "created_at" t.datetime "updated_at" end create_table "user_types", force: :cascade do |t| - t.string "name", limit: 255 - t.text "description", limit: 65535 + t.string "name" + t.text "description" t.datetime "created_at" t.datetime "updated_at" end create_table "users", force: :cascade do |t| - t.string "firstname", limit: 255 - t.string "surname", limit: 255 - t.string "email", limit: 255, default: "", null: false - t.string "orcid_id", limit: 255 - t.string "shibboleth_id", limit: 255 - t.integer "user_type_id", limit: 4 - t.integer "user_status_id", limit: 4 + t.string "firstname" + t.string "surname" + t.string "email", default: "", null: false + t.string "orcid_id" + t.string "shibboleth_id" + t.integer "user_type_id" + t.integer "user_status_id" t.datetime "created_at" t.datetime "updated_at" - t.string "encrypted_password", limit: 255, default: "" - t.string "reset_password_token", limit: 255 + t.string "encrypted_password", default: "" + t.string "reset_password_token" t.datetime "reset_password_sent_at" t.datetime "remember_created_at" - t.integer "sign_in_count", limit: 4, default: 0 + t.integer "sign_in_count", default: 0 t.datetime "current_sign_in_at" t.datetime "last_sign_in_at" - t.string "current_sign_in_ip", limit: 255 - t.string "last_sign_in_ip", limit: 255 - t.string "confirmation_token", limit: 255 + t.string "current_sign_in_ip" + t.string "last_sign_in_ip" + t.string "confirmation_token" t.datetime "confirmed_at" t.datetime "confirmation_sent_at" - t.string "invitation_token", limit: 255 + t.string "invitation_token" t.datetime "invitation_created_at" t.datetime "invitation_sent_at" t.datetime "invitation_accepted_at" - t.string "other_organisation", limit: 255 + t.string "other_organisation" t.boolean "dmponline3" t.boolean "accept_terms" - t.integer "organisation_id", limit: 4 - t.string "api_token", limit: 255 - t.integer "invited_by_id", limit: 4 - t.string "invited_by_type", limit: 255 - t.integer "language_id", limit: 4 + t.integer "organisation_id" + t.string "api_token" + t.integer "invited_by_id" + t.string "invited_by_type" + t.integer "language_id" end - add_index "users", ["confirmation_token"], name: "index_users_on_confirmation_token", unique: true, using: :btree - add_index "users", ["email"], name: "index_users_on_email", unique: true, using: :btree - add_index "users", ["invitation_token"], name: "index_users_on_invitation_token", unique: true, using: :btree - add_index "users", ["reset_password_token"], name: "index_users_on_reset_password_token", unique: true, using: :btree + add_index "users", ["confirmation_token"], name: "index_users_on_confirmation_token", unique: true + add_index "users", ["email"], name: "index_users_on_email", unique: true + add_index "users", ["invitation_token"], name: "index_users_on_invitation_token", unique: true + add_index "users", ["reset_password_token"], name: "index_users_on_reset_password_token", unique: true create_table "users_roles", id: false, force: :cascade do |t| - t.integer "user_id", limit: 4 - t.integer "role_id", limit: 4 + t.integer "user_id" + t.integer "role_id" end - add_index "users_roles", ["user_id", "role_id"], name: "index_users_roles_on_user_id_and_role_id", using: :btree + add_index "users_roles", ["user_id", "role_id"], name: "index_users_roles_on_user_id_and_role_id" create_table "versions", force: :cascade do |t| - t.string "title", limit: 255 - t.text "description", limit: 65535 + t.string "title" + t.text "description" + t.integer "number" + t.integer "phase_id" + t.datetime "created_at" + t.datetime "updated_at" t.boolean "published" - t.integer "number", limit: 4 - t.integer "phase_id", limit: 4 + end + + add_index "versions", ["phase_id"], name: "index_versions_on_phase_id" + + create_table "visibilities", force: :cascade do |t| + t.string "name" + t.boolean "default", default: false t.datetime "created_at" t.datetime "updated_at" end - add_index "versions", ["phase_id"], name: "index_versions_on_phase_id", using: :btree - - add_foreign_key "user_identifiers", "identifier_schemes" - add_foreign_key "user_identifiers", "users" end diff --git a/db/seeds.rb b/db/seeds.rb index 526cf3a..d8d159f 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -6,6 +6,14 @@ d1 = DateTime.new(2015, 6, 22) +visibilities = { + test: {name: 'test', default: false}, + private: {name: 'private', default: false}, + organisational: {name: 'organisational', default: true}, + public: {name: 'public', default: false} +} +visibilities.map{ |v| Visibility.create!(v) } + languages = { 'English(UK)' => { abbreviation: 'en-UK', diff --git a/test/fixtures/plans.yml b/test/fixtures/plans.yml index dbd8f76..ee53434 100644 --- a/test/fixtures/plans.yml +++ b/test/fixtures/plans.yml @@ -1,9 +1,9 @@ -test_project_1_plan_1: - locked: false - project: test_project_1 - version: funder_template_2_phase_1_version_1 +<% projects = YAML::load(ERB.new(File.read('./test/fixtures/projects.yml')).result) %> +<% versions = YAML::load(ERB.new(File.read('./test/fixtures/versions.yml')).result) %> -test_project_2_plan_2: +<% projects.each do |lbl, hash| %> +<%= lbl %>_plan: + project: <%= lbl %> + version: version.first locked: false - project: test_project_2 - version: funder_template_2_phase_1_version_1 \ No newline at end of file +<% end %> \ No newline at end of file diff --git a/test/fixtures/projects.yml b/test/fixtures/projects.yml index a9950d3..09b7f37 100644 --- a/test/fixtures/projects.yml +++ b/test/fixtures/projects.yml @@ -1,27 +1,8 @@ -# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/Fixtures.html -#two: -# title: MyString -# note: MyText -# locked: false -# dmptemplate_id: 1 +<% templates = YAML::load(ERB.new(File.read('./test/fixtures/dmptemplates.yml')).result) %> -test_project_1: - title: 'Test Project 1' - dmptemplate: funder_template_3 +<% templates.each do |lbl, hash| %> +<%= lbl %>_project: + title: <%= "#{lbl} Project" %> + dmptemplate: <%= lbl %> organisation: complete - grant_number: 'ABCD' - identifier: '1234567890' - description: 'The first test project' - principal_investigator_identifier: '1234-ABCD' - data_contact: 'someone@test.project.edu' - funder_name: 'Funder 2' - is_test: false - is_public: false - -test_project_2: - title: 'Test Project 2' - dmptemplate: funder_template_3 - organisation: complete - funder_name: 'Funder 2' - is_test: true - is_public: false \ No newline at end of file +<% end %> \ No newline at end of file diff --git a/test/fixtures/visibilities.yml b/test/fixtures/visibilities.yml new file mode 100644 index 0000000..55faa6e --- /dev/null +++ b/test/fixtures/visibilities.yml @@ -0,0 +1,15 @@ +test: + name: 'test' + default: false + +private: + name: 'private' + default: false + +organisational: + name: 'organisational' + default: true + +public: + name: 'public' + default: false \ No newline at end of file diff --git a/test/functional/projects_controller_test.rb b/test/functional/projects_controller_test.rb index 3626c0a..260bdb7 100644 --- a/test/functional/projects_controller_test.rb +++ b/test/functional/projects_controller_test.rb @@ -1,52 +1,6 @@ require 'test_helper' class ProjectsControllerTest < ActionDispatch::IntegrationTest - - include Devise::Test::IntegrationHelpers - - setup do - @project = Project.first - end - - # ---------------------------------------------------------- - test "should export the publicly available plan" do - @project.is_public = true - @project.save! - - get public_export_project_path(locale: I18n.locale, id: @project) - - # Should be redirected to the plans controller's export function - assert_redirected_to "#{export_project_plan_path(@project, @project.plans.first)}", "expected to be redirected to the exported plan" - follow_redirect! - - assert_redirected_to "blah" - assert_response :success - assert_equal Mime::PDF, response.content_type - end - - # ---------------------------------------------------------- - test "should NOT export a non-public plan to unauthorized users" do - # Set the is_public flag to false and try to access it when not logged in - @project.is_public = false - @project.save! - - get public_export_project_path(locale: I18n.locale, id: @project) - - assert_redirected_to "#{root_path}?locale=#{I18n.locale}", "expected to be redirected to the home page!" - assert_equal I18n.t('helpers.settings.plans.errors.no_access_account'), flash[:notice], "Expected an unauthorized message when trying to export a plan (via the public_export route) when the plan is not actually public" - - # Set the is_public flag to false and assign ownership to a different user and then try to access it as a non-owner - @project.assign_creator(User.last) - @project.save! - - sign_in User.first - - get public_export_project_path(locale: I18n.locale, id: @project) - - assert_redirected_to "#{root_path}?locale=#{I18n.locale}", "expected to be redirected to the home page!" - assert_equal I18n.t('helpers.settings.plans.errors.no_access_account'), flash[:notice], "Expected an unauthorized message when trying to export a plan (via the public_export route) when the plan is not actually public" - end - =begin test "should get index" do diff --git a/test/functional/static_pages_controller_test.rb b/test/functional/static_pages_controller_test.rb new file mode 100644 index 0000000..3450cc5 --- /dev/null +++ b/test/functional/static_pages_controller_test.rb @@ -0,0 +1,50 @@ +class StaticPagesControllerTest < ActionDispatch::IntegrationTest + + include Devise::Test::IntegrationHelpers + + setup do + @project = Project.first + + @test_visibility = Visibility.find_by(name: 'test') + @public_visibility = Visibility.find_by(name: 'public') + end + + # ---------------------------------------------------------- + test "should export the publicly available plan" do + @project.visibility = @public_visibility + @project.save! + +# get public_export_path(locale: I18n.locale, id: @project) + + # Should be redirected to the plans controller's export function +# assert_redirected_to "#{export_project_plan_path(@project, @project.plans.first)}", "expected to be redirected to the exported plan" +# follow_redirect! + +# assert_redirected_to "blah" +# assert_response :success +# assert_equal Mime::PDF, response.content_type + end + + # ---------------------------------------------------------- + test "should NOT export a non-public plan to unauthorized users" do + # Set the is_public flag to false and try to access it when not logged in + @project.visibility = @test_visibility + @project.save! + + get public_export_path(locale: I18n.locale, id: @project) + + assert_redirected_to "#{public_plans_path}", "expected to be redirected to the home page!" + assert_equal I18n.t('helpers.settings.plans.errors.no_access_account'), flash[:notice], "Expected an unauthorized message when trying to export a plan (via the public_export route) when the plan is not actually public" + + # Set the is_public flag to false and assign ownership to a different user and then try to access it as a non-owner + @project.assign_creator(User.last) + @project.save! + + sign_in User.first + + get public_export_path(locale: I18n.locale, id: @project) + + assert_redirected_to "#{public_plans_path}", "expected to be redirected to the home page!" + assert_equal I18n.t('helpers.settings.plans.errors.no_access_account'), flash[:notice], "Expected an unauthorized message when trying to export a plan (via the public_export route) when the plan is not actually public" + end +end \ No newline at end of file diff --git a/test/routing_test.rb b/test/routing_test.rb index ac6f955..eeb10a6 100644 --- a/test/routing_test.rb +++ b/test/routing_test.rb @@ -29,18 +29,15 @@ target = {controller: "static_pages", action: "termsuse", locale: "#{I18n.locale}"} assert_routing terms_path(locale: I18n.locale), target end - - # Routing for Public DMPs - # ------------------------------------------------------------------- - test 'GET /public_plans should resolve to ProjectsController#public_plans' do - target = {controller: "projects", action: "public_plans", locale: "#{I18n.locale}"} + test 'GET /public_plans should resolve to StaticPagesController#public_plans' do + target = {controller: "static_pages", action: "public_plans", locale: "#{I18n.locale}"} assert_routing public_plans_path(locale: I18n.locale), target end - test 'GET /projects/[:project_id]/plans/[:id]/public_export should resolve to PlansController#public_export' do + test 'GET /public_export should resolve to StaticPagesController#public_export' do project = Project.includes(:plans).where.not(plans: {id: nil}).first - target = {controller: "projects", action: "public_export", locale: "#{I18n.locale}", id: project.id.to_s} + target = {controller: "static_pages", action: "public_export", locale: "#{I18n.locale}", id: project.id.to_s} - assert_routing public_export_project_path(locale: I18n.locale, id: project), target + assert_routing public_export_path(locale: I18n.locale, id: project), target end # OAuth - Based on providers identified in the en-UK locale file diff --git a/test/unit/project_test.rb b/test/unit/project_test.rb index 47d62d5..72cbb5c 100644 --- a/test/unit/project_test.rb +++ b/test/unit/project_test.rb @@ -13,24 +13,9 @@ }) end - # ---------------------------------------------------------------------------- - test "is_public flag should be false if is_test is true" do - @project.is_public = true - @project.save! - assert_equal true, @project.is_public?, "expected the is_public flag to initially be true" - - @project.is_test = true - assert_equal false, @project.is_public?, "expected the is_public flag to switch to false" - end - - # ---------------------------------------------------------------------------- - test "is_test flag should be false if is_public is true" do - @project.is_test = true - @project.save! - assert_equal true, @project.is_test?, "expected the is_test flag to initially be true" - - @project.is_public = true - assert_equal false, @project.is_test?, "expected the is_test flag to switch to false" + # --------------------------------------------------- + test "can manage belongs_to relationship with Visibility" do + verify_belongs_to_relationship(@project, Visibility.first) end end