diff --git a/html/Ability.html b/html/Ability.html deleted file mode 100644 index d808822..0000000 --- a/html/Ability.html +++ /dev/null @@ -1,388 +0,0 @@ - - - - - - -class Ability - DMPonline4 Documentation - - - - - - - - - - - - - - - - -
-

class Ability

- -
- -
- - - - -
- - - - - - - - - - -
-

Public Class Methods

- - -
- -
- new(user) - click to toggle source -
- - -
- - - - - -
-
# File app/models/ability.rb, line 4
-def initialize(user)
-  # Define abilities for the passed in user here. For example:
-
-  #
-
-    user ||= User.new # guest user (not logged in)
-
-    if user.has_role? :admin
-      can :manage, :all
-    else
-      can :read, :all
-    end
-
-  can :manage_settings, User do |viewed_user|
-    viewed_user.present? && user.id == viewed_user.id
-  end
-  #
-
-  # The first argument to `can` is the action you are giving the user 
-
-  # permission to do.
-
-  # If you pass :manage it will apply to every action. Other common actions
-
-  # here are :read, :create, :update and :destroy.
-
-  #
-
-  # The second argument is the resource the user can perform the action on. 
-
-  # If you pass :all it will apply to every resource. Otherwise pass a Ruby
-
-  # class of the resource.
-
-  #
-
-  # The third argument is an optional hash of conditions to further filter the
-
-  # objects.
-
-  # For example, here the user can only update published articles.
-
-  #
-
-  #   can :update, Article, :published => true
-
-  #
-
-  # See the wiki for details:
-
-  # https://github.com/ryanb/cancan/wiki/Defining-Abilities
-
- 
-end
-
- -
- - - - -
- - -
- -
- -
- - - - diff --git a/html/ActiveAdmin.html b/html/ActiveAdmin.html deleted file mode 100644 index aeb8dc4..0000000 --- a/html/ActiveAdmin.html +++ /dev/null @@ -1,272 +0,0 @@ - - - - - - -module ActiveAdmin - DMPonline4 Documentation - - - - - - - - - - - - - - - - -
-

module ActiveAdmin

- -
- -
- - - - -
- - - - - - - - - - -
- -
- - - - diff --git a/html/ActiveAdmin/Views.html b/html/ActiveAdmin/Views.html deleted file mode 100644 index 8b4e4fe..0000000 --- a/html/ActiveAdmin/Views.html +++ /dev/null @@ -1,272 +0,0 @@ - - - - - - -module ActiveAdmin::Views - DMPonline4 Documentation - - - - - - - - - - - - - - - - -
-

module ActiveAdmin::Views

- -
- -
- - - - -
- - - - - - - - - - -
- -
- - - - diff --git a/html/ActiveAdmin/Views/Pages.html b/html/ActiveAdmin/Views/Pages.html deleted file mode 100644 index cc0eccd..0000000 --- a/html/ActiveAdmin/Views/Pages.html +++ /dev/null @@ -1,272 +0,0 @@ - - - - - - -module ActiveAdmin::Views::Pages - DMPonline4 Documentation - - - - - - - - - - - - - - - - -
-

module ActiveAdmin::Views::Pages

- -
- -
- - - - -
- - - - - - - - - - -
- -
- - - - diff --git a/html/ActiveAdmin/Views/Pages/Base.html b/html/ActiveAdmin/Views/Pages/Base.html deleted file mode 100644 index 0920d9a..0000000 --- a/html/ActiveAdmin/Views/Pages/Base.html +++ /dev/null @@ -1,331 +0,0 @@ - - - - - - -class ActiveAdmin::Views::Pages::Base - DMPonline4 Documentation - - - - - - - - - - - - - - - - -
-

class ActiveAdmin::Views::Pages::Base

- -
- -

lib/active_admin_views_pages_base.rb

- -
- - - - -
- - - - - - - - - - -
-

Private Instance Methods

- - - - - -
- -
- -
- - - - diff --git a/html/AdminUser.html b/html/AdminUser.html deleted file mode 100644 index 25177a0..0000000 --- a/html/AdminUser.html +++ /dev/null @@ -1,279 +0,0 @@ - - - - - - -class AdminUser - DMPonline4 Documentation - - - - - - - - - - - - - - - - -
-

class AdminUser

- -
- -
- - - - -
- - - - - - - - - - -
- -
- - - - diff --git a/html/Answer.html b/html/Answer.html deleted file mode 100644 index 0693ae3..0000000 --- a/html/Answer.html +++ /dev/null @@ -1,279 +0,0 @@ - - - - - - -class Answer - DMPonline4 Documentation - - - - - - - - - - - - - - - - -
-

class Answer

- -
- -
- - - - -
- - - - - - - - - - -
- -
- - - - diff --git a/html/AnswersController.html b/html/AnswersController.html deleted file mode 100644 index b017bbd..0000000 --- a/html/AnswersController.html +++ /dev/null @@ -1,360 +0,0 @@ - - - - - - -class AnswersController - DMPonline4 Documentation - - - - - - - - - - - - - - - - -
-

class AnswersController

- -
- -
- - - - -
- - - - - - - - - - -
-

Public Instance Methods

- - -
- -
- create() - click to toggle source -
- - -
- -

POST /answers POST /answers.json

- - - -
-
# File app/controllers/answers_controller.rb, line 5
-def create
-        @answer = Answer.new(params[:answer])
-        if (user_signed_in?) && @answer.plan.editable_by(current_user.id) then
-                old_answer = @answer.plan.answer(@answer.question_id, false)
-                proceed = false
-                @answer.text = params["answer-text-#{@answer.question_id}".to_sym]
-                if (old_answer.nil? && @answer.text != "") || ((!old_answer.nil?) && (old_answer.text != @answer.text)) then
-                        proceed = true
-                end
-    
-                if (@answer.question.question_format.title == I18n.t("helpers.checkbox") || 
-        @answer.question.question_format.title == I18n.t("helpers.multi_select_box") ||
-        @answer.question.question_format.title == I18n.t("helpers.radio_buttons") || 
-        @answer.question.question_format.title == I18n.t("helpers.dropdown")) then
-                        if (old_answer.nil? && @answer.option_ids.count > 0) || ((!old_answer.nil?) && (old_answer.option_ids - @answer.option_ids).count != 0 && (@answer.option_ids - old_answer.option_ids).count != 0) then
-                                proceed = true
-                        end
-                end
-                if proceed
-                        respond_to do |format|
-                                if @answer.save
-                                        format.html { redirect_to :back, status: :found, notice: 'Answer was successfully recorded.' }
-                                        format.json { render json: @answer, status: :created, location: @answer }
-                                else
-                                        format.html { redirect_to :back, notice: 'There was an error saving the answer.' }
-                                        format.json { render json: @answer.errors, status: :unprocessable_entity }
-                                end
-                        end
-                else
-                        respond_to do |format|
-                                format.html { redirect_to :back, notice: 'No change in answer content - not saved.' }
-                                format.json { render json: @answer.errors, status: :unprocessable_entity }
-                        end
-                end
-        else
-                render(:file => File.join(Rails.root, 'public/403.html'), :status => 403, :layout => false)
-        end
-end
-
- -
- - - - -
- - -
- -
- -
- - - - diff --git a/html/ApplicationController.html b/html/ApplicationController.html deleted file mode 100644 index 4e977fd..0000000 --- a/html/ApplicationController.html +++ /dev/null @@ -1,529 +0,0 @@ - - - - - - -class ApplicationController - DMPonline4 Documentation - - - - - - - - - - - - - - - - -
-

class ApplicationController

- -
- -
- - - - -
- - - - - - - - - - -
-

Public Instance Methods

- - -
- -
- after_sign_in_error_path_for(resource) - click to toggle source -
- - -
- - - - - -
-
# File app/controllers/application_controller.rb, line 32
-def after_sign_in_error_path_for(resource)
-  session[:previous_url] || root_path
-end
-
- -
- - - - -
- - -
- -
- after_sign_in_path_for(resource) - click to toggle source -
- - -
- - - - - -
-
# File app/controllers/application_controller.rb, line 24
-def after_sign_in_path_for(resource)
-  session[:previous_url] || root_path
-end
-
- -
- - - - -
- - -
- -
- after_sign_up_error_path_for(resource) - click to toggle source -
- - -
- - - - - -
-
# File app/controllers/application_controller.rb, line 36
-def after_sign_up_error_path_for(resource)
-  session[:previous_url] || root_path
-end
-
- -
- - - - -
- - -
- -
- after_sign_up_path_for(resource) - click to toggle source -
- - -
- - - - - -
-
# File app/controllers/application_controller.rb, line 28
-def after_sign_up_path_for(resource)
-  session[:previous_url] || root_path
-end
-
- -
- - - - -
- - -
- -
- authenticate_admin!() - click to toggle source -
- - -
- - - - - -
-
# File app/controllers/application_controller.rb, line 40
-def authenticate_admin!
-        redirect_to root_path unless user_signed_in? && current_user.can_super_admin?
-end
-
- -
- - - - -
- - -
- -
- get_plan_list_columns() - click to toggle source -
- - -
- - - - - -
-
# File app/controllers/application_controller.rb, line 44
-def get_plan_list_columns
-        if user_signed_in?
-                @selected_columns = current_user.settings(:plan_list).columns
-                @all_columns = Settings::PlanList::ALL_COLUMNS
-        end
-end
-
- -
- - - - -
- - -
- -
- store_location() - click to toggle source -
- - -
- - - - - -
-
# File app/controllers/application_controller.rb, line 13
-def store_location
- # store last url - this is needed for post-login redirect to whatever the user last visited.
-
-        if (request.fullpath != "/users/sign_in" && \
-                request.fullpath != "/users/sign_up" && \
-                request.fullpath != "/users/password" && \
-    request.fullpath != "/users/sign_up?nosplash=true" && \
-                !request.xhr?) # don't store ajax calls
-
-          session[:previous_url] = request.fullpath 
-        end
-end
-
- -
- - - - -
- - -
- -
- -
- - - - diff --git a/html/ApplicationHelper.html b/html/ApplicationHelper.html deleted file mode 100644 index c5ea91c..0000000 --- a/html/ApplicationHelper.html +++ /dev/null @@ -1,453 +0,0 @@ - - - - - - -module ApplicationHelper - DMPonline4 Documentation - - - - - - - - - - - - - - - - -
-

module ApplicationHelper

- -
- -
- - - - -
- - - - - - - - - - -
-

Public Instance Methods

- - -
- -
- devise_mapping() - click to toggle source -
- - -
- - - - - -
-
# File app/helpers/application_helper.rb, line 10
-def devise_mapping
-        @devise_mapping ||= Devise.mappings[:user]
-end
-
- -
- - - - -
- - -
- -
- javascript(*files) - click to toggle source -
- - -
- - - - - -
-
# File app/helpers/application_helper.rb, line 14
-def javascript(*files)
-  content_for(:head) { javascript_include_tag(*files) }
-end
-
- -
- - - - -
- - - - - -
- -
- resource() - click to toggle source -
- - -
- - - - - -
-
# File app/helpers/application_helper.rb, line 6
-def resource
-        @resource ||= User.new
-end
-
- -
- - - - -
- - -
- -
- resource_name() - click to toggle source -
- - -
- - - - - -
-
# File app/helpers/application_helper.rb, line 2
-def resource_name
-        :user
-end
-
- -
- - - - -
- - -
- -
- -
- - - - diff --git a/html/Comment.html b/html/Comment.html deleted file mode 100644 index 9f7cf6b..0000000 --- a/html/Comment.html +++ /dev/null @@ -1,325 +0,0 @@ - - - - - - -class Comment - DMPonline4 Documentation - - - - - - - - - - - - - - - - -
-

class Comment

- -
- -
- - - - -
- - - - - - - - - - -
-

Public Instance Methods

- - -
- -
- to_s() - click to toggle source -
- - -
- - - - - -
-
# File app/models/comment.rb, line 11
-def to_s
-    "#{text}"
-end
-
- -
- - - - -
- - -
- -
- -
- - - - diff --git a/html/CommentsController.html b/html/CommentsController.html deleted file mode 100644 index 7c5267e..0000000 --- a/html/CommentsController.html +++ /dev/null @@ -1,538 +0,0 @@ - - - - - - -class CommentsController - DMPonline4 Documentation - - - - - - - - - - - - - - - - -
-

class CommentsController

- -
- -
- - - - -
- - - - - - - - - - -
-

Public Instance Methods

- - -
- -
- archive() - click to toggle source -
- - -
- -

ARCHIVE /comments/1 ARCHIVE /comments/1.json

- - - -
-
# File app/controllers/comments_controller.rb, line 73
-def archive
-  @comment = Comment.find(params[:comment][:id])
-  @comment.archived = true
-  @comment.archived_by = params[:comment][:archived_by]
-  
-  @plan = Plan.find(@comment.plan_id)
-  @project = Project.find(@plan.project_id)
-
-  respond_to do |format|
-    if @comment.update_attributes(params[:comment])
-      session[:question_id_comments] = @comment.question_id
-      format.html { redirect_to edit_project_plan_path(@project, @plan), status: :found, notice: 'Comment has been removed.' }     
-    end   
-  end
-end
-
- -
- - - - -
- - -
- -
- create() - click to toggle source -
- - -
- -

POST /comments POST /comments.json

- - - -
-
# File app/controllers/comments_controller.rb, line 32
-def create
- if user_signed_in? then
-      @comment = Comment.new(params[:new_comment])
-      @comment.text = params["#{params[:new_comment][:question_id]}new_comment_text"]
-      @comment.question_id = params[:new_comment][:question_id]
-      @comment.user_id = params[:new_comment][:user_id]
-      @comment.plan_id = params[:new_comment][:plan_id]
-      
-      @plan = Plan.find(@comment.plan_id)
-      @project = Project.find(@plan.project_id)
-      
-      respond_to do |format|
-        if @comment.save
-          session[:question_id_comments] = @comment.question_id
-          format.html { redirect_to edit_project_plan_path(@project, @plan), status: :found, notice: 'Comment was successfully created.' }
-          format.json { head :no_content  }
-        end
-      end
-  end    
-end
-
- -
- - - - -
- - -
- -
- edit() - click to toggle source -
- - -
- -

GET /comments/1/edit

- - - -
-
# File app/controllers/comments_controller.rb, line 26
-def edit
-  @comment = Comment.find(params[:id])
-end
-
- -
- - - - -
- - -
- -
- index() - click to toggle source -
- - -
- -

GET /comments GET /comments.json

- - - -
-
# File app/controllers/comments_controller.rb, line 4
-def index
-  @comments = Comment.all
-
-  respond_to do |format|
-    format.html # index.html.erb
-
-    format.json { render json: @comments }
-  end
-end
-
- -
- - - - -
- - -
- -
- show() - click to toggle source -
- - -
- -

GET /comments/1 GET /comments/1.json

- - - -
-
# File app/controllers/comments_controller.rb, line 15
-def show
-  @comment = Comment.find(params[:id])
-
-  respond_to do |format|
-    format.html # show.html.erb
-
-    format.json { render json: @comment }
-  end
-end
-
- -
- - - - -
- - -
- -
- update() - click to toggle source -
- - -
- -

PUT /comments/1 PUT /comments/1.json

- - - -
-
# File app/controllers/comments_controller.rb, line 55
-def update
-  @comment = Comment.find(params[:comment][:id])
-  @comment.text = params["#{params[:comment][:id]}_comment_text"]
-  
-  @plan = Plan.find(@comment.plan_id)
-  @project = Project.find(@plan.project_id)
-  
-  respond_to do |format|
-    if @comment.update_attributes(params[:comment])
-      session[:question_id_comments] = @comment.question_id
-      format.html { redirect_to edit_project_plan_path(@project, @plan), status: :found, notice: 'Comment was successfully updated.' }
-      format.json { head :no_content }
-    end
-  end
-end
-
- -
- - - - -
- - -
- -
- -
- - - - diff --git a/html/ConfirmationsController.html b/html/ConfirmationsController.html deleted file mode 100644 index 11e2609..0000000 --- a/html/ConfirmationsController.html +++ /dev/null @@ -1,325 +0,0 @@ - - - - - - -class ConfirmationsController - DMPonline4 Documentation - - - - - - - - - - - - - - - - -
-

class ConfirmationsController

- -
- -
- - - - -
- - - - - - - - - - -
-

Protected Instance Methods

- - -
- -
- after_confirmation_path_for(resource_name, resource) - click to toggle source -
- - -
- - - - - -
-
# File app/controllers/confirmations_controller.rb, line 5
-def after_confirmation_path_for(resource_name, resource)
-  root_path
-end
-
- -
- - - - -
- - -
- -
- -
- - - - diff --git a/html/ContactsController.html b/html/ContactsController.html deleted file mode 100644 index 5cbc8c6..0000000 --- a/html/ContactsController.html +++ /dev/null @@ -1,350 +0,0 @@ - - - - - - -class ContactsController - DMPonline4 Documentation - - - - - - - - - - - - - - - - -
-

class ContactsController

- -
- -
- - - - -
- - - - - - - - - - -
-

Public Instance Methods

- - -
- -
- create() - click to toggle source -
- - -
- - - - - -
-
# File app/controllers/contacts_controller.rb, line 2
-def create
-        @contact = ContactUs::Contact.new(params[:contact_us_contact])
-        if (!user_signed_in?)
-                if verify_recaptcha(:message => "You have not added the validation words correctly") && @contact.save
-                        flash[:notice] = t('contact_us.notices.success')
-                        if user_signed_in? then
-                             redirect_to :controller => 'projects', :action => 'index'
-                     else
-                             redirect_to(root_path)
-                     end
-                else
-                     flash[:alert]  = t('contact_us.notices.error')
-                     render_new_page
-                end
-        else
-                if @contact.save
-                        flash[:notice] = t('contact_us.notices.success')
-                        if user_signed_in? then
-                             redirect_to :controller => 'projects', :action => 'index'
-                     else
-                             redirect_to(root_path)
-                     end
-                else
-                     flash[:alert] = t('contact_us.notices.error')
-                     render_new_page
-                end
-        end           
-end
-
- -
- - - - -
- - -
- -
- -
- - - - diff --git a/html/CustomFailure.html b/html/CustomFailure.html deleted file mode 100644 index 00e20d5..0000000 --- a/html/CustomFailure.html +++ /dev/null @@ -1,361 +0,0 @@ - - - - - - -class CustomFailure - DMPonline4 Documentation - - - - - - - - - - - - - - - - -
-

class CustomFailure

- -
- -
- - - - -
- - - - - - - - - - -
-

Public Instance Methods

- - -
- -
- redirect_url() - click to toggle source -
- - -
- - - - - -
-
# File lib/custom_failure.rb, line 2
-def redirect_url
-  root_path
-end
-
- -
- - - - -
- - -
- -
- respond() - click to toggle source -
- - -
- - - - - -
-
# File lib/custom_failure.rb, line 6
-def respond
-  if http_auth?
-    http_auth
-  else
-    redirect
-  end
-end
-
- -
- - - - -
- - -
- -
- -
- - - - diff --git a/html/DMPonline4.html b/html/DMPonline4.html deleted file mode 100644 index 299d664..0000000 --- a/html/DMPonline4.html +++ /dev/null @@ -1,274 +0,0 @@ - - - - - - -module DMPonline4 - DMPonline4 Documentation - - - - - - - - - - - - - - - - -
-

module DMPonline4

- -
- -
- - - - -
- - - - - - - - - - -
- -
- - - - diff --git a/html/DMPonline4/Application.html b/html/DMPonline4/Application.html deleted file mode 100644 index 35ca2cd..0000000 --- a/html/DMPonline4/Application.html +++ /dev/null @@ -1,280 +0,0 @@ - - - - - - -class DMPonline4::Application - DMPonline4 Documentation - - - - - - - - - - - - - - - - -
-

class DMPonline4::Application

- -
- -
- - - - -
- - - - - - - - - - -
- -
- - - - diff --git a/html/Dmptemplate.html b/html/Dmptemplate.html deleted file mode 100644 index 3de2e67..0000000 --- a/html/Dmptemplate.html +++ /dev/null @@ -1,602 +0,0 @@ - - - - - - -class Dmptemplate - DMPonline4 Documentation - - - - - - - - - - - - - - - - -
-

class Dmptemplate

- -
- -
- - - - -
- - - - - - - - - - -
-

Public Class Methods

- - -
- -
- funders_and_own_templates(org_id) - click to toggle source -
- - -
- -

returns an array with all funders and own institutional templates

- - - -
-
# File app/models/dmptemplate.rb, line 63
-def self.funders_and_own_templates(org_id)
-        funders_templates = self.funders_templates
-
-#verify if org type is not a funder
-
-current_org = Organisation.find(org_id)
-if current_org.organisation_type.name != I18n.t("helpers.org_type.funder") then 
-    own_institutional_templates = self.own_institutional_templates(org_id)
-        else
-    own_institutional_templates = []
-end    
-    
-        templates_list = Array.new
-        templates_list += own_institutional_templates
-        templates_list += funders_templates
-        templates_list = templates_list.sort_by { |f| f['title'].downcase }
-                        
-        return templates_list
-end
-
- -
- - - - -
- - -
- -
- funders_templates() - click to toggle source -
- - -
- -

returns all funders templates

- - - -
-
# File app/models/dmptemplate.rb, line 44
-    def self.funders_templates
-            new_org_obejcts = OrganisationType.find_by_name(I18n.t("helpers.org_type.funder")).organisations
-      org_templates = Array.new
-    
-    new_org_obejcts.each do |neworg|
-    org_templates += neworg.dmptemplates
-end
-
-return org_templates        
-    end
-
- -
- - - - -
- - -
- -
- own_institutional_templates(org_id) - click to toggle source -
- - -
- -

returns all institutional templates bellowing to the current user's org

- - - -
-
# File app/models/dmptemplate.rb, line 57
-def self.own_institutional_templates(org_id)
-        new_templates = self.where("organisation_id = ?", org_id)
-        return new_templates
-end
-
- -
- - - - -
- - -
- -
- templates_org_type(ot) - click to toggle source -
- - -
- - - - - -
-
# File app/models/dmptemplate.rb, line 32
-def self.templates_org_type(ot)
-  new_org_obejcts = OrganisationType.find_by_name(ot).organisations
-  
-  org_templates = Array.new
-  new_org_obejcts.each do |neworg|
-     org_templates += neworg.dmptemplates.where("published = ?", true)
-  end
-  
-  return org_templates
-end
-
- -
- - - - -
- - -
- -
-

Public Instance Methods

- - -
- -
- has_customisations?(org_id, temp) - click to toggle source -
- - -
- -

verify if a template has customisation by current user's org

- - - -
-
# File app/models/dmptemplate.rb, line 88
-def has_customisations?(org_id, temp)
-        if temp.organisation_id != org_id then
-                temp.phases.each do |phase|
-                        phase.versions.each do |version|
-                                version.sections.each do |section|
-                                        return true if section.organisation_id == org_id 
-                                                                                
-                                end        
-                        end
-                        return false 
-                end
-        else
-                return false         
-        end   
-end
-
- -
- - - - -
- - -
- -
- has_published_versions?() - click to toggle source -
- - -
- -

verify if there are any publish version for the template

- - - -
-
# File app/models/dmptemplate.rb, line 106
-def has_published_versions?
-        phases.each do |phase|
-                return true if !phase.latest_published_version.nil?
-        end
-        return false 
-end
-
- -
- - - - -
- - -
- -
- org_type() - click to toggle source -
- - -
- - - - - -
-
# File app/models/dmptemplate.rb, line 82
-def org_type
-        org_type = organisation.organisation_type.name
-        return org_type
-end
-
- -
- - - - -
- - -
- -
- to_s() - click to toggle source -
- - -
- - - - - -
-
# File app/models/dmptemplate.rb, line 28
-def to_s
-  "#{title}"
-end
-
- -
- - - - -
- - -
- -
- -
- - - - diff --git a/html/DmptemplatesController.html b/html/DmptemplatesController.html deleted file mode 100644 index f4c7d37..0000000 --- a/html/DmptemplatesController.html +++ /dev/null @@ -1,1427 +0,0 @@ - - - - - - -class DmptemplatesController - DMPonline4 Documentation - - - - - - - - - - - - - - - - -
-

class DmptemplatesController

- -
-
Project: -
-

DMPonline v4

-
Description: -
-

This controller is responsible for all the actions in the admin interface -under templates (e.g. phases, versions, sections, questions, suggested -answer) (index; show; create; edit; delete)

-
Copyright: -
-

Digital Curation Centre

-
- -
- - - - -
- - - - - - - - - - -
-

Public Instance Methods

- - -
- -
- admin_addphase() - click to toggle source -
- - -
- -

add a new phase to a template

- - - -
-
# File app/controllers/dmptemplates_controller.rb, line 187
-def admin_addphase
-        if user_signed_in? && current_user.can_org_admin? then
-                @dmptemplate = Dmptemplate.find(params[:id])
-                @phase = Phase.new
-                if @dmptemplate.phases.count == 0 then
-                        @phase.number = '1'
-                else
-                        @phase.number = @dmptemplate.phases.count + 1
-                end
-
-                respond_to do |format|
-      format.html
-    end
-        end
-end
-
- -
- - - - -
- - -
- -
- admin_cloneversion() - click to toggle source -
- - -
- -

clone a version of a template

- - - -
-
# File app/controllers/dmptemplates_controller.rb, line 293
-def admin_cloneversion
-        if user_signed_in? && current_user.can_org_admin? then
-@old_version = Version.find(params[:version_id])
-                @version = @old_version.amoeba_dup
-                @phase = @version.phase
-
-    respond_to do |format|
-      if @version.save
-        format.html { redirect_to admin_phase_dmptemplate_path(@phase, :version_id => @version.id, :edit => 'true'), notice: I18n.t('org_admin.templates.updated_message') }
-        format.json { head :no_content }
-      else
-        format.html { render action: "admin_phase" }
-        format.json { render json: @version.errors, status: :unprocessable_entity }
-      end
-    end
-        end
-end
-
- -
- - - - -
- - -
- -
- admin_create() - click to toggle source -
- - -
- -

POST /dmptemplates POST /dmptemplates.json

- - - -
-
# File app/controllers/dmptemplates_controller.rb, line 81
-def admin_create
-  if user_signed_in? && current_user.can_org_admin? then
-          @dmptemplate = Dmptemplate.new(params[:dmptemplate])
-          @dmptemplate.organisation_id = current_user.organisation.id
-          @dmptemplate.description = params['template-desc']
-
-          respond_to do |format|
-            if @dmptemplate.save
-              format.html { redirect_to admin_template_dmptemplate_path(@dmptemplate), notice: I18n.t('org_admin.templates.created_message') }
-              format.json { render json: @dmptemplate, status: :created, location: @dmptemplate }
-            else
-              format.html { render action: "admin_new" }
-              format.json { render json: @dmptemplate.errors, status: :unprocessable_entity }
-            end
-          end
-  else
-                      render(:file => File.join(Rails.root, 'public/403.html'), :status => 403, :layout => false)
-              end
-end
-
- -
- - - - -
- - -
- -
- admin_createphase() - click to toggle source -
- - -
- -

create a phase

- - - -
-
# File app/controllers/dmptemplates_controller.rb, line 204
-      def admin_createphase
-  if user_signed_in? && current_user.can_org_admin? then
-             @phase = Phase.new(params[:phase])
-          @phase.description = params["phase-desc"]
-          @version = @phase.versions.build
-          @version.title = "#{@phase.title} v.1"
-          @version.phase_id = @phase.id
-          @version.number = 1
-          @version.published = false
-
-          respond_to do |format|
-            if @phase.save
-              format.html { redirect_to admin_phase_dmptemplate_path(:id => @phase.id, :version_id => @version.id, :edit => 'true'), notice: I18n.t('org_admin.templates.created_message') }
-              format.json { head :no_content }
-            else
-              format.html { render action: "admin_phase" }
-              format.json { render json: @phase.errors, status: :unprocessable_entity }
-            end
-                      end
-              end
-end
-
- -
- - - - -
- - -
- -
- admin_createquestion() - click to toggle source -
- - -
- -

create a question

- - - -
-
# File app/controllers/dmptemplates_controller.rb, line 386
-      def admin_createquestion
-  if user_signed_in? && current_user.can_org_admin? then
-             @question = Question.new(params[:question])
-          @question.guidance = params["new-question-guidance"]
-          @question.default_value = params["new-question-default-value"]
-
-
-          respond_to do |format|
-            if @question.save
-              format.html { redirect_to admin_phase_dmptemplate_path(:id => @question.section.version.phase_id, :version_id => @question.section.version_id, :section_id => @question.section_id, :question_id => @question.id, :edit => 'true'), notice: I18n.t('org_admin.templates.created_message') }
-              format.json { head :no_content }
-            else
-              format.html { render action: "admin_phase" }
-              format.json { render json: @question.errors, status: :unprocessable_entity }
-            end
-                      end
-              end
-end
-
- -
- - - - -
- - -
- -
- admin_createsection() - click to toggle source -
- - -
- -

create a section

- - - -
-
# File app/controllers/dmptemplates_controller.rb, line 328
-      def admin_createsection
-  if user_signed_in? && current_user.can_org_admin? then
-             @section = Section.new(params[:section])
-          @section.description = params["section-desc"]
-
-          respond_to do |format|
-            if @section.save
-              format.html { redirect_to admin_phase_dmptemplate_path(:id => @section.version.phase_id, :version_id => @section.version_id, :section_id => @section.id, :edit => 'true'), notice: I18n.t('org_admin.templates.created_message') }
-              format.json { head :no_content }
-            else
-              format.html { render action: "admin_phase" }
-              format.json { render json: @section.errors, status: :unprocessable_entity }
-            end
-                      end
-              end
-end
-
- -
- - - - -
- - -
- -
- admin_createsuggestedanswer() - click to toggle source -
- - -
- -

SUGGESTED ANSWERS create suggested answers

- - - -
-
# File app/controllers/dmptemplates_controller.rb, line 446
-   def admin_createsuggestedanswer
-   if user_signed_in? && current_user.can_org_admin? then
-           @suggested_answer = SuggestedAnswer.new(params[:suggested_answer])
-
-       respond_to do |format|
-         if @suggested_answer.save
-           format.html { redirect_to admin_phase_dmptemplate_path(:id => @suggested_answer.question.section.version.phase_id, :version_id => @suggested_answer.question.section.version_id, :section_id => @suggested_answer.question.section_id, :question_id => @suggested_answer.question.id, :edit => 'true'), notice: I18n.t('org_admin.templates.created_message') }
-           format.json { head :no_content }
-         else
-           format.html { render action: "admin_phase" }
-           format.json { render json: @suggested_answer.errors, status: :unprocessable_entity }
-         end
-           end
-    end
-end
-
- -
- - - - -
- - -
- -
- admin_destroy() - click to toggle source -
- - -
- -

DELETE /dmptemplates/1 DELETE /dmptemplates/1.json

- - - -
-
# File app/controllers/dmptemplates_controller.rb, line 105
-def admin_destroy
-      if user_signed_in? && current_user.can_org_admin? then
-             @dmptemplate = Dmptemplate.find(params[:id])
-          @dmptemplate.destroy
-
-          respond_to do |format|
-            format.html { redirect_to admin_index_dmptemplate_path }
-            format.json { head :no_content }
-          end
-             else
-                      render(:file => File.join(Rails.root, 'public/403.html'), :status => 403, :layout => false)
-              end
-      end
-
- -
- - - - -
- - -
- -
- admin_destroyphase() - click to toggle source -
- - -
- -

delete a version, sections and questions

- - - -
-
# File app/controllers/dmptemplates_controller.rb, line 246
-def admin_destroyphase
-if user_signed_in? && current_user.can_org_admin? then
-       @phase = Phase.find(params[:phase_id])
-       @dmptemplate = @phase.dmptemplate
-    @phase.destroy
-
-    respond_to do |format|
-      format.html { redirect_to admin_template_dmptemplate_path(@dmptemplate), notice: I18n.t('org_admin.templates.destroyed_message') }
-      format.json { head :no_content }
-    end
-       end
-end
-
- -
- - - - -
- - -
- -
- admin_destroyquestion() - click to toggle source -
- - -
- -

delete a version, sections and questions

- - - -
-
# File app/controllers/dmptemplates_controller.rb, line 428
-def admin_destroyquestion
-if user_signed_in? && current_user.can_org_admin? then
-       @question = Question.find(params[:question_id])
-       @section = @question.section
-                @version = @section.version
-       @phase = @version.phase
-    @question.destroy
-
-    respond_to do |format|
-      format.html { redirect_to admin_phase_dmptemplate_path(:id => @phase.id, :version_id => @version.id, :section_id => @section.id, :edit => 'true'), notice: I18n.t('org_admin.templates.destroyed_message') }
-      format.json { head :no_content }
-    end
-       end
-end
-
- -
- - - - -
- - -
- -
- admin_destroysection() - click to toggle source -
- - -
- -

delete a section and questions

- - - -
-
# File app/controllers/dmptemplates_controller.rb, line 368
-def admin_destroysection
-if user_signed_in? && current_user.can_org_admin? then
-       @section = Section.find(params[:section_id])
-       @version = @section.version
-       @phase = @version.phase
-    @section.destroy
-
-    respond_to do |format|
-      format.html { redirect_to admin_phase_dmptemplate_path(:id => @phase.id, :version_id => @version.id,  :edit => 'true' ), notice: I18n.t('org_admin.templates.destroyed_message') }
-      format.json { head :no_content }
-    end
-       end
-end
-
- -
- - - - -
- - -
- -
- admin_destroysuggestedanswer() - click to toggle source -
- - -
- -

delete a suggested answer

- - - -
-
# File app/controllers/dmptemplates_controller.rb, line 484
-def admin_destroysuggestedanswer
-if user_signed_in? && current_user.can_org_admin? then
-       @suggested_answer = SuggestedAnswer.find(params[:suggested_answer])
-       @question = @suggested_answer.question
-       @section = @question.section
-                @version = @section.version
-       @phase = @version.phase
-    @suggested_answer.destroy
-
-    respond_to do |format|
-      format.html { redirect_to admin_phase_dmptemplate_path(:id => @phase.id, :version_id => @version.id, :section_id => @section.id, :edit => 'true'), notice: I18n.t('org_admin.templates.destroyed_message') }
-      format.json { head :no_content }
-    end
-       end
-end
-
- -
- - - - -
- - -
- -
- admin_destroyversion() - click to toggle source -
- - -
- -

delete a version, sections and questions

- - - -
-
# File app/controllers/dmptemplates_controller.rb, line 312
-def admin_destroyversion
-if user_signed_in? && current_user.can_org_admin? then
-       @version = Version.find(params[:version_id])
-       @phase = @version.phase
-    @version.destroy
-
-    respond_to do |format|
-      format.html { redirect_to admin_phase_dmptemplate_path(@phase), notice: I18n.t('org_admin.templates.destroyed_message') }
-      format.json { head :no_content }
-    end
-       end
-end
-
- -
- - - - -
- - -
- -
- admin_index() - click to toggle source -
- - -
- -

GET /dmptemplates GET /dmptemplates.json

- - - -
-
# File app/controllers/dmptemplates_controller.rb, line 9
-def admin_index
-  if user_signed_in? && current_user.can_org_admin? then
-      #institutional templates
-
-          @dmptemplates_own = Dmptemplate.own_institutional_templates(current_user.organisation_id)
-
-          #funders templates
-
-          @dmptemplates_funders = Dmptemplate.funders_templates
-
-   respond_to do |format|
-            format.html # index.html.erb
-
-         end
-  else
-                      render(:file => File.join(Rails.root, 'public/403.html'), :status => 403, :layout => false)
-              end
-end
-
- -
- - - - -
- - -
- -
- admin_new() - click to toggle source -
- - -
- -

GET /dmptemplates/new GET /dmptemplates/new.json

- - - -
-
# File app/controllers/dmptemplates_controller.rb, line 66
-def admin_new
-  if user_signed_in? && current_user.can_org_admin? then
-          @dmptemplate = Dmptemplate.new
-
-          respond_to do |format|
-            format.html # new.html.erb
-
-            format.json { render json: @dmptemplate }
-          end
-  else
-                      render(:file => File.join(Rails.root, 'public/403.html'), :status => 403, :layout => false)
-              end
-end
-
- -
- - - - -
- - -
- -
- admin_phase() - click to toggle source -
- - -
- -

show and edit a phase of the template

- - - -
-
# File app/controllers/dmptemplates_controller.rb, line 124
-def admin_phase
-        if user_signed_in? && current_user.can_org_admin? then
-
-                @phase = Phase.find(params[:id])
-
-                if !params.has_key?(:version_id) then
-                        @edit = 'false'
-                        #check for the most recent published version, if none is available then return the most recent one
-
-                        versions = @phase.versions.where('published = ?', true).order('updated_at DESC')
-                        if versions.any?() then
-                                @version = versions.first
-                        else
-                                @version = @phase.versions.order('updated_at DESC').first
-                        end
-                        # When the version_id is passed as an argument
-
-                else
-                        @edit = params[:edit]
-                        @version = Version.find(params[:version_id])
-                end
-
-                #verify if there are any sections if not create one
-
-                @sections = @version.sections
-                if !@sections.any?() || @sections.count == 0 then
-                        @section = @version.sections.build
-                        @section.title = ''
-                        @section.version_id = params[:version_id]
-                        @section.number = 1
-                        @section.organisation_id = current_user.organisation.id
-                        @section.published = true
-                        @section.save
-                end
-
-                #verify if section_id has been passed, if so then open that section
-
-                if params.has_key?(:section_id) then
-                        @open = true
-                        @section_id = params[:section_id].to_i
-                end
-
-                if params.has_key?(:question_id) then
-                        @question_id = params[:question_id].to_i
-                end
-
-                respond_to do |format|
-                        format.html
-                end
-        end
-end
-
- -
- - - - -
- - -
- -
- admin_previewphase() - click to toggle source -
- - -
- -

preview a phase

- - - -
-
# File app/controllers/dmptemplates_controller.rb, line 173
-def admin_previewphase
-        if user_signed_in? && current_user.can_org_admin? then
-                
-                @version = Version.find(params[:id])
-                
-                        
-                respond_to do |format|
-                        format.html
-                end
-        end   
-end
-
- -
- - - - -
- - -
- -
- admin_template() - click to toggle source -
- - -
- -

GET /dmptemplates/1 GET /dmptemplates/1.json

- - - -
-
# File app/controllers/dmptemplates_controller.rb, line 27
-def admin_template
-  if user_signed_in? && current_user.can_org_admin? then
-          @dmptemplate = Dmptemplate.find(params[:id])
-
-          respond_to do |format|
-            format.html # show.html.erb
-
-            format.json { render json: @dmptemplate }
-          end
-  else
-                      render(:file => File.join(Rails.root, 'public/403.html'), :status => 403, :layout => false)
-              end
-end
-
- -
- - - - -
- - -
- -
- admin_update() - click to toggle source -
- - -
- -

PUT /dmptemplates/1 PUT /dmptemplates/1.json

- - - -
-
# File app/controllers/dmptemplates_controller.rb, line 44
-def admin_update
-      if user_signed_in? && current_user.can_org_admin? then
-              @dmptemplate = Dmptemplate.find(params[:id])
-              @dmptemplate.description = params["template-desc"]
-
-                respond_to do |format|
-            if @dmptemplate.update_attributes(params[:dmptemplate])
-              format.html { redirect_to admin_template_dmptemplate_path(params[:dmptemplate]), notice: I18n.t('org_admin.templates.updated_message') }
-              format.json { head :no_content }
-            else
-              format.html { render action: "edit" }
-              format.json { render json: @dmptemplate.errors, status: :unprocessable_entity }
-            end
-             end
-      else
-                      render(:file => File.join(Rails.root, 'public/403.html'), :status => 403, :layout => false)
-      end
-end
-
- -
- - - - -
- - -
- -
- admin_updatephase() - click to toggle source -
- - -
- -

update a phase of a template

- - - -
-
# File app/controllers/dmptemplates_controller.rb, line 228
-def admin_updatephase
-        if user_signed_in? && current_user.can_org_admin? then
-        @phase = Phase.find(params[:id])
-        @phase.description = params["phase-desc"]
-
-    respond_to do |format|
-      if @phase.update_attributes(params[:phase])
-        format.html { redirect_to admin_phase_dmptemplate_path(@phase), notice: I18n.t('org_admin.templates.updated_message') }
-        format.json { head :no_content }
-      else
-        format.html { render action: "admin_phase" }
-        format.json { render json: @phase.errors, status: :unprocessable_entity }
-      end
-    end
-        end
-end
-
- -
- - - - -
- - -
- -
- admin_updatequestion() - click to toggle source -
- - -
- -

update a question of a template

- - - -
-
# File app/controllers/dmptemplates_controller.rb, line 406
-def admin_updatequestion
-        if user_signed_in? && current_user.can_org_admin? then
-               @question = Question.find(params[:id])
-                        @question.guidance = params["question-guidance-#{params[:id]}"]
-                        @question.default_value = params["question-default-value-#{params[:id]}"]
-       @section = @question.section
-                        @version = @section.version
-                        @phase = @version.phase
-
-                        respond_to do |format|
-              if @question.update_attributes(params[:question])
-                format.html { redirect_to admin_phase_dmptemplate_path(:id => @phase.id, :version_id => @version.id, :section_id => @section.id, :question_id => @question.id, :edit => 'true'), notice: I18n.t('org_admin.templates.updated_message') }
-                format.json { head :no_content }
-              else
-                format.html { render action: "admin_phase" }
-                format.json { render json: @question.errors, status: :unprocessable_entity }
-              end
-            end
-                end
-        end
-
- -
- - - - -
- - -
- -
- admin_updatesection() - click to toggle source -
- - -
- -

update a section of a template

- - - -
-
# File app/controllers/dmptemplates_controller.rb, line 347
-def admin_updatesection
-        if user_signed_in? && current_user.can_org_admin? then
-               @section = Section.find(params[:id])
-               @section.description = params["section-desc-#{params[:id]}"]
-       @version = @section.version
-                        @phase = @version.phase
-
-                        respond_to do |format|
-              if @section.update_attributes(params[:section])
-                format.html { redirect_to admin_phase_dmptemplate_path(:id => @phase.id, :version_id => @version.id, :section_id => @section.id , :edit => 'true'), notice: I18n.t('org_admin.templates.updated_message') }
-                format.json { head :no_content }
-              else
-                format.html { render action: "admin_phase" }
-                format.json { render json: @section.errors, status: :unprocessable_entity }
-              end
-            end
-                end
-end
-
- -
- - - - -
- - -
- -
- admin_updatesuggestedanswer() - click to toggle source -
- - -
- -

update a suggested answer of a template

- - - -
-
# File app/controllers/dmptemplates_controller.rb, line 463
-def admin_updatesuggestedanswer
-        if user_signed_in? && current_user.can_org_admin? then
-               @suggested_answer = SuggestedAnswer.find(params[:id])
-    @question = @suggested_answer.question
-    @section = @question.section
-    @version = @section.version
-    @phase = @version.phase
-
-                        respond_to do |format|
-              if @suggested_answer.update_attributes(params[:suggested_answer])
-                format.html { redirect_to admin_phase_dmptemplate_path(:id => @phase.id, :version_id => @version.id, :section_id => @section.id, :question_id => @question.id, :edit => 'true'), notice: I18n.t('org_admin.templates.updated_message') }
-                format.json { head :no_content }
-              else
-                format.html { render action: "admin_phase" }
-                format.json { render json: @suggested_answer.errors, status: :unprocessable_entity }
-              end
-            end
-                end
-        end
-
- -
- - - - -
- - -
- -
- admin_updateversion() - click to toggle source -
- - -
- -

update a version of a template

- - - -
-
# File app/controllers/dmptemplates_controller.rb, line 262
-def admin_updateversion
-        if user_signed_in? && current_user.can_org_admin? then
-               @version = Version.find(params[:id])
-    @version.description = params["version-desc"]
-    @phase = @version.phase
-
-    if @version.published && !@phase.dmptemplate.published then
-        @phase.dmptemplate.published = true
-    end
-    
-    @all_versions = @phase.versions.where('published = ?', true)
-    @all_versions.each do |v|
-        if v.id != @version.id && v.published == true then
-            v.published = false
-            v.save
-        end
-    end
-
-            respond_to do |format|
-              if @version.update_attributes(params[:version])
-                format.html { redirect_to admin_phase_dmptemplate_path(@phase, :version_id =>  @version.id, :edit => 'false'), notice: I18n.t('org_admin.templates.updated_message') }
-                format.json { head :no_content }
-              else
-                format.html { render action: "admin_phase" }
-                format.json { render json: @version.errors, status: :unprocessable_entity }
-              end
-            end
-                end
-        end
-
- -
- - - - -
- - -
- -
- -
- - - - diff --git a/html/ExistingUsersController.html b/html/ExistingUsersController.html deleted file mode 100644 index a3baca4..0000000 --- a/html/ExistingUsersController.html +++ /dev/null @@ -1,325 +0,0 @@ - - - - - - -class ExistingUsersController - DMPonline4 Documentation - - - - - - - - - - - - - - - - -
-

class ExistingUsersController

- -
- -
- - - - -
- - - - - - - - - - -
-

Public Instance Methods

- - -
- -
- index() - click to toggle source -
- - -
- - - - - -
-
# File app/controllers/existing_users_controller.rb, line 2
-def index
-        @email = params[:email]
-end
-
- -
- - - - -
- - -
- -
- -
- - - - diff --git a/html/ExportedPlan.html b/html/ExportedPlan.html deleted file mode 100644 index e7911e1..0000000 --- a/html/ExportedPlan.html +++ /dev/null @@ -1,846 +0,0 @@ - - - - - - -class ExportedPlan - DMPonline4 Documentation - - - - - - - - - - - - - - - - -
-

class ExportedPlan

- -
- -
- - - - -
- - - - - - -
-

Constants

-
- -
VALID_FORMATS - -
- - -
-
- - - - - - -
-

Public Instance Methods

- - -
- -
- admin_details() - click to toggle source -
- - -
- - - - - -
-
# File app/models/exported_plan.rb, line 71
-def admin_details
-  @admin_details ||= self.settings(:export).fields[:admin]
-end
-
- -
- - - - -
- - -
- -
- as_csv() - click to toggle source -
- - -
- -

Export formats

- - - -
-
# File app/models/exported_plan.rb, line 77
-def as_csv
-  CSV.generate do |csv|
-    csv << ["Section","Question","Answer","Selected option(s)","Answered by","Answered at"]
-    self.sections.each do |section|
-      self.questions_for_section(section).each do |question|
-        answer = self.plan.answer(question.id)
-        options_string = answer.options.collect {|o| o.text}.join('; ')
-
-        csv << [section.title, question.text, sanitize_text(answer.text), options_string, answer.try(:user).try(:name), answer.created_at]
-      end
-    end
-  end
-end
-
- -
- - - - -
- - -
- -
- as_txt() - click to toggle source -
- - -
- - - - - -
-
# File app/models/exported_plan.rb, line 91
-def as_txt
-  output = "#{self.plan.project.title}\n\n#{self.plan.version.phase.title}\n"
-
-  self.sections.each do |section|
-    output += "\n#{section.title}\n"
-
-    self.questions_for_section(section).each do |question|
-      output += "\n#{question.text}\n"
-      answer = self.plan.answer(question.id, false)
-
-      if answer.nil? || answer.text.nil? then
-        output += "Question not answered.\n"
-      else
-        output += answer.options.collect {|o| o.text}.join("\n")
-        if question.option_comment_display == true then
-          output += "\n#{sanitize_text(answer.text)}\n"
-        else
-          output += "\n"
-        end  
-      end
-    end
-  end
-
-  output
-end
-
- -
- - - - -
- - -
- -
- funder() - click to toggle source -
- - -
- - - - - -
-
# File app/models/exported_plan.rb, line 46
-def funder
-  org = self.plan.project.dmptemplate.try(:organisation)
-  org.name if org.present? && org.organisation_type.try(:name) == I18n.t('helpers.org_type.funder')
-end
-
- -
- - - - -
- - -
- -
- grant_title() - click to toggle source -
- - -
- - - - - -
-
# File app/models/exported_plan.rb, line 30
-def grant_title
-  self.plan.project.grant_number
-end
-
- -
- - - - -
- - -
- -
- institution() - click to toggle source -
- - -
- - - - - -
-
# File app/models/exported_plan.rb, line 51
-def institution
-  plan.project.organisation.try(:name)
-end
-
- -
- - - - -
- - -
- -
- principal_investigator() - click to toggle source -
- - -
- - - - - -
-
# File app/models/exported_plan.rb, line 34
-def principal_investigator
-  self.plan.project.principal_investigator
-end
-
- -
- - - - -
- - -
- -
- project_data_contact() - click to toggle source -
- - -
- - - - - -
-
# File app/models/exported_plan.rb, line 38
-def project_data_contact
-  self.plan.project.data_contact
-end
-
- -
- - - - -
- - -
- -
- project_description() - click to toggle source -
- - -
- - - - - -
-
# File app/models/exported_plan.rb, line 42
-def project_description
-  self.plan.project.description
-end
-
- -
- - - - -
- - -
- -
- project_identifier() - click to toggle source -
- - -
- - - - - -
-
# File app/models/exported_plan.rb, line 26
-def project_identifier
-  self.plan.project.identifier
-end
-
- -
- - - - -
- - -
- -
- project_name() - click to toggle source -
- - -
- -

Getters to match Settings::Dmptemplate::VALID_ADMIN_FIELDS

- - - -
-
# File app/models/exported_plan.rb, line 20
-def project_name
-  name = self.plan.project.title
-  name += " - #{self.plan.title}" if self.plan.project.dmptemplate.phases.count > 1
-  name
-end
-
- -
- - - - -
- - -
- -
- questions_for_section(section_id) - click to toggle source -
- - -
- - - - - -
-
# File app/models/exported_plan.rb, line 67
-def questions_for_section(section_id)
-  questions.where(section_id: section_id)
-end
-
- -
- - - - -
- - -
- -
- sections() - click to toggle source -
- - -
- -

sections taken from fields settings

- - - -
-
# File app/models/exported_plan.rb, line 56
-def sections
-  sections = self.plan.sections
-
-  return [] if questions.empty?
-
-  section_ids = questions.pluck(:section_id).uniq
-  sections = sections.select {|section| section_ids.member?(section.id) }
-
-  sections.sort_by(&:number)
-end
-
- -
- - - - -
- - -
- -
-

Private Instance Methods

- - -
- -
- questions() - click to toggle source -
- - -
- - - - - -
-
# File app/models/exported_plan.rb, line 119
-def questions
-  @questions ||= begin
-    question_settings = self.settings(:export).fields[:questions]
-
-    return [] if question_settings.is_a?(Array) && question_settings.empty?
-
-    questions = if question_settings.present? && question_settings != :all
-      Question.where(id: question_settings)
-    else
-      Question.where(section_id: self.plan.sections.collect {|s| s.id })
-    end
-
-    questions.order(:number)
-  end
-end
-
- -
- - - - -
- - -
- -
- sanitize_text(text) - click to toggle source -
- - -
- - - - - -
-
# File app/models/exported_plan.rb, line 135
-def sanitize_text(text)
-  if (!text.nil?) then ActionView::Base.full_sanitizer.sanitize(text.gsub(/&nbsp;/,"")) end
-end
-
- -
- - - - -
- - -
- -
- -
- - - - diff --git a/html/FileType.html b/html/FileType.html deleted file mode 100644 index 749a3b5..0000000 --- a/html/FileType.html +++ /dev/null @@ -1,279 +0,0 @@ - - - - - - -class FileType - DMPonline4 Documentation - - - - - - - - - - - - - - - - -
-

class FileType

- -
- -
- - - - -
- - - - - - - - - - -
- -
- - - - diff --git a/html/FileUpload.html b/html/FileUpload.html deleted file mode 100644 index a91679c..0000000 --- a/html/FileUpload.html +++ /dev/null @@ -1,279 +0,0 @@ - - - - - - -class FileUpload - DMPonline4 Documentation - - - - - - - - - - - - - - - - -
-

class FileUpload

- -
- -
- - - - -
- - - - - - - - - - -
- -
- - - - diff --git a/html/Guidance.html b/html/Guidance.html deleted file mode 100644 index f65c3d8..0000000 --- a/html/Guidance.html +++ /dev/null @@ -1,426 +0,0 @@ - - - - - - -class Guidance - DMPonline4 Documentation - - - - - - - - - - - - - - - - -
-

class Guidance

- -
-
Project: -
-

DMPonline v4

-
Description: -
-

This class keeps the information organisations enter to support users when -answering questions. It always belongs to a guidance group class and it -can be linked directly to a question or through one or more themes

-
Created: -
-

07/07/2014

-
Copyright: -
-

Digital Curation Centre

-
- -
- - - - -
- - - - - - - - - - -
-

Public Class Methods

- - -
- -
- by_organisation(org_id) - click to toggle source -
- - -
- -

all guidance that belong to an organisation

- - - -
-
# File app/models/guidance.rb, line 40
-def self.by_organisation(org_id)
-        all_guidance = Guidance.all
-        org_guidance = Array.new
-    
-        all_guidance.each do |guidance|
-           if guidance.in_group_belonging_to?(org_id) then
-                        org_guidance << guidance
-           end
-        end
-        
-        return org_guidance
-        
-end
-
- -
- - - - -
- - -
- -
-

Public Instance Methods

- - -
- -
- get_guidance_group_templates?(guidance_group) - click to toggle source -
- - -
- - - - - -
-
# File app/models/guidance.rb, line 55
-def get_guidance_group_templates? (guidance_group)
-                templates = guidancegroups.where("guidance_group_id (?)", guidance_group.id).template 
-                return templates
-        end
-
- -
- - - - -
- - -
- -
- in_group_belonging_to?(organisation_id) - click to toggle source -
- - -
- -

verifies if one guidance belongs to a org

- - - -
-
# File app/models/guidance.rb, line 29
-def in_group_belonging_to?(organisation_id)
-        guidance_groups.each do |guidance_group|
-                if guidance_group.organisation_id == organisation_id then
-                        return true
-                end
-        end
-        return false
-end
-
- -
- - - - -
- - -
- -
- -
- - - - diff --git a/html/GuidanceGroup.html b/html/GuidanceGroup.html deleted file mode 100644 index 0907393..0000000 --- a/html/GuidanceGroup.html +++ /dev/null @@ -1,404 +0,0 @@ - - - - - - -class GuidanceGroup - DMPonline4 Documentation - - - - - - - - - - - - - - - - -
-

class GuidanceGroup

- -
- -
- - - - -
- - - - - - - - - - -
-

Public Class Methods

- - -
- -
- guidance_groups_excluding(excluded_orgs) - click to toggle source -
- - -
- - - - - -
-
# File app/models/guidance_group.rb, line 28
-def self.guidance_groups_excluding(excluded_orgs)
-        excluded_org_ids = Array.new
-        excluded_orgs.each do |org|
-                excluded_org_ids << org.id
-        end
-        return_orgs =  GuidanceGroup.where("organisation_id NOT IN (?)", excluded_org_ids)
-        return return_orgs
-end
-
- -
- - - - -
- - -
- -
-

Public Instance Methods

- - -
- -
- display_name() - click to toggle source -
- - -
- - - - - -
-
# File app/models/guidance_group.rb, line 20
-def display_name
-        if organisation.guidance_groups.count > 1
-                return "#{organisation.name}: #{name}"
-        else
-                return organisation.name
-        end
-end
-
- -
- - - - -
- - -
- -
- to_s() - click to toggle source -
- - -
- - - - - -
-
# File app/models/guidance_group.rb, line 16
-def to_s
-        "#{display_name}"
-end
-
- -
- - - - -
- - -
- -
- -
- - - - diff --git a/html/GuidanceGroupsController.html b/html/GuidanceGroupsController.html deleted file mode 100644 index 7283e1a..0000000 --- a/html/GuidanceGroupsController.html +++ /dev/null @@ -1,547 +0,0 @@ - - - - - - -class GuidanceGroupsController - DMPonline4 Documentation - - - - - - - - - - - - - - - - -
-

class GuidanceGroupsController

- -
- -
- - - - -
- - - - - - - - - - -
-

Public Instance Methods

- - -
- -
- admin_create() - click to toggle source -
- - -
- -

POST /guidance_groups POST /guidance_groups.json

- - - -
-
# File app/controllers/guidance_groups_controller.rb, line 34
-def admin_create
-  if user_signed_in? && current_user.can_org_admin? then
-          @guidance_group = GuidanceGroup.new(params[:guidance_group])
-          @guidance_group.organisation_id = current_user.organisation_id
-      
-          respond_to do |format|
-            if @guidance_group.save
-              format.html { redirect_to admin_index_guidance_path, notice: I18n.t('org_admin.guidance_group.created_message') }
-              format.json { render json: @guidance_group, status: :created, location: @guidance_group }
-            else
-              format.html { render action: "new" }
-              format.json { render json: @guidance_group.errors, status: :unprocessable_entity }
-            end
-          end
-  else
-                      render(:file => File.join(Rails.root, 'public/403.html'), :status => 403, :layout => false)
-              end 
-end
-
- -
- - - - -
- - -
- -
- admin_destroy() - click to toggle source -
- - -
- -

DELETE /guidance_groups/1 DELETE /guidance_groups/1.json

- - - -
-
# File app/controllers/guidance_groups_controller.rb, line 87
-def admin_destroy
-      if user_signed_in? && current_user.can_org_admin? then
-             @guidance_group = GuidanceGroup.find(params[:id])
-          @guidance_group.destroy
-      
-          respond_to do |format|
-            format.html { redirect_to admin_index_guidance_path, notice: I18n.t('org_admin.guidance_group.destroyed_message') }
-            format.json { head :no_content }
-          end
-             else
-                      render(:file => File.join(Rails.root, 'public/403.html'), :status => 403, :layout => false)
-              end 
-      
-      end
-
- -
- - - - -
- - -
- -
- admin_edit() - click to toggle source -
- - -
- -

GET /guidance_groups/1/edit

- - - -
-
# File app/controllers/guidance_groups_controller.rb, line 55
-def admin_edit
-      if user_signed_in? && current_user.can_org_admin? then
-    @guidance_group = GuidanceGroup.find(params[:id])
-  else
-                      render(:file => File.join(Rails.root, 'public/403.html'), :status => 403, :layout => false)
-              end 
-end
-
- -
- - - - -
- - -
- -
- admin_new() - click to toggle source -
- - -
- -

GET add new guidance groups

- - - -
-
# File app/controllers/guidance_groups_controller.rb, line 21
-    def admin_new
-if user_signed_in? && current_user.can_org_admin? then
-        @guidance_group = GuidanceGroup.new
-           
-        respond_to do |format|
-          format.html # new.html.erb
-
-          format.json { render json: @guidance }
-        end
-    end
-    end
-
- -
- - - - -
- - -
- -
- admin_show() - click to toggle source -
- - -
- -

GET /guidance_groups/1 GET /guidance_groups/1.json

- - - -
-
# File app/controllers/guidance_groups_controller.rb, line 6
-def admin_show
-  if user_signed_in? && current_user.can_org_admin? then
-          @guidance_group = GuidanceGroup.find(params[:id])
-      
-          respond_to do |format|
-            format.html 
-            format.json { render json: @guidance_group }
-          end
-  else
-                      render(:file => File.join(Rails.root, 'public/403.html'), :status => 403, :layout => false)
-              end 
-end
-
- -
- - - - -
- - -
- -
- admin_update() - click to toggle source -
- - -
- -

PUT /guidance_groups/1 PUT /guidance_groups/1.json

- - - -
-
# File app/controllers/guidance_groups_controller.rb, line 65
-def admin_update
-              if user_signed_in? && current_user.can_org_admin? then
-              @guidance_group = GuidanceGroup.find(params[:id])
-          @guidance_group.organisation_id = current_user.organisation_id
-
-          respond_to do |format|
-            if @guidance_group.update_attributes(params[:guidance_group])
-              format.html { redirect_to admin_index_guidance_path(params[:guidance_group]), notice: I18n.t('org_admin.guidance_group.updated_message') }
-              format.json { head :no_content }
-            else
-              format.html { render action: "edit" }
-              format.json { render json: @guidance_group.errors, status: :unprocessable_entity }
-            end
-          end
-  else
-                      render(:file => File.join(Rails.root, 'public/403.html'), :status => 403, :layout => false)
-              end 
-end
-
- -
- - - - -
- - -
- -
- -
- - - - diff --git a/html/GuidancesController.html b/html/GuidancesController.html deleted file mode 100644 index 7e036ea..0000000 --- a/html/GuidancesController.html +++ /dev/null @@ -1,810 +0,0 @@ - - - - - - -class GuidancesController - DMPonline4 Documentation - - - - - - - - - - - - - - - - -
-

class GuidancesController

- -
- -
- - - - -
- - - - - - - - - - -
-

Public Instance Methods

- - -
- -
- admin_create() - click to toggle source -
- - -
- -

POST /guidances POST /guidances.json

- - - -
-
# File app/controllers/guidances_controller.rb, line 155
-def admin_create
-  if user_signed_in? && current_user.can_org_admin? then
-          @guidance = Guidance.new(params[:guidance])
-          @guidance.text = params["guidance-text"]
-          @guidance.question_id = params["question_id"]
-
-          respond_to do |format|
-            if @guidance.save
-              format.html { redirect_to admin_show_guidance_path(@guidance), notice: I18n.t('org_admin.guidance.created_message') }
-              format.json { render json: @guidance, status: :created, location: @guidance }
-            else
-              format.html { render action: "new" }
-              format.json { render json: @guidance.errors, status: :unprocessable_entity }
-            end
-          end
-  else
-                      render(:file => File.join(Rails.root, 'public/403.html'), :status => 403, :layout => false)
-              end
-end
-
- -
- - - - -
- - -
- -
- admin_destroy() - click to toggle source -
- - -
- -

DELETE /guidances/1 DELETE /guidances/1.json

- - - -
-
# File app/controllers/guidances_controller.rb, line 202
-def admin_destroy
-      if user_signed_in? && current_user.can_org_admin? then
-             @guidance = Guidance.find(params[:id])
-          @guidance.destroy
-
-          respond_to do |format|
-            format.html { redirect_to admin_index_guidance_path }
-            format.json { head :no_content }
-          end
-             else
-                      render(:file => File.join(Rails.root, 'public/403.html'), :status => 403, :layout => false)
-              end
-
-      end
-
- -
- - - - -
- - -
- -
- admin_edit() - click to toggle source -
- - -
- -

GET /guidances/1/edit

- - - -
-
# File app/controllers/guidances_controller.rb, line 112
-def admin_edit
-      if user_signed_in? && current_user.can_org_admin? then
-    @guidance = Guidance.find(params[:id])
-    @dmptemplates = Dmptemplate.funders_and_own_templates(current_user.organisation_id)
-                      @phases = nil
-                      @dmptemplates.each do |template|
-                              if @phases.nil? then
-                                      @phases = template.phases.find(:all,:order => 'number ASC')
-                              else
-                                      @phases = @phases + template.phases.find(:all,:order => 'number ASC')
-                              end
-                      end
-                      @versions = nil
-                      @phases.each do |phase|
-                              if @versions.nil? then
-                                      @versions = phase.versions.find(:all,:order => 'title ASC')
-                              else
-                                      @versions = @versions + phase.versions.find(:all,:order => 'title ASC')
-                              end
-                      end
-                      @sections = nil
-                      @versions.each do |version|
-                              if @sections.nil? then
-                                      @sections = version.sections.find(:all,:order => 'number ASC')
-                              else
-                                      @sections = @sections + version.sections.find(:all,:order => 'number ASC')
-                              end
-                      end
-                      @questions = nil
-                      @sections.each do |section|
-                              if @questions.nil? then
-                                      @questions = section.questions.find(:all,:order => 'number ASC')
-                              else
-                                      @questions = @questions + section.questions.find(:all,:order => 'number ASC')
-                              end
-                      end
-  else
-                      render(:file => File.join(Rails.root, 'public/403.html'), :status => 403, :layout => false)
-              end
-end
-
- -
- - - - -
- - -
- -
- admin_index() - click to toggle source -
- - -
- -

GET /guidances GET /guidances.json

- - - -
-
# File app/controllers/guidances_controller.rb, line 5
-def admin_index
-  if user_signed_in? && current_user.can_org_admin? then
-          @guidances = Guidance.by_organisation(current_user.organisation_id)
-          @guidance_groups = GuidanceGroup.where('organisation_id = ?', current_user.organisation_id )
-
-
-          respond_to do |format|
-            format.html # index.html.erb
-
-            format.json { render json: @guidances }
-          end
-  else
-                      render(:file => File.join(Rails.root, 'public/403.html'), :status => 403, :layout => false)
-              end
-end
-
- -
- - - - -
- - -
- -
- admin_new() - click to toggle source -
- - -
- - - - - -
-
# File app/controllers/guidances_controller.rb, line 33
-def admin_new
-  if user_signed_in? && current_user.can_org_admin? then
-          @guidance = Guidance.new
-                      @dmptemplates = Dmptemplate.funders_and_own_templates(current_user.organisation_id)
-                      @phases = nil
-                      @dmptemplates.each do |template|
-                              if @phases.nil? then
-                                      @phases = template.phases.find(:all,:order => 'number ASC')
-                              else
-                                      @phases = @phases + template.phases.find(:all,:order => 'number ASC')
-                              end
-                      end
-                      @versions = nil
-                      @phases.each do |phase|
-                              if @versions.nil? then
-                                      @versions = phase.versions.find(:all,:order => 'title ASC')
-                              else
-                                      @versions = @versions + phase.versions.find(:all,:order => 'title ASC')
-                              end
-                      end
-                      @sections = nil
-                      @versions.each do |version|
-                              if @sections.nil? then
-                                      @sections = version.sections.find(:all,:order => 'number ASC')
-                              else
-                                      @sections = @sections + version.sections.find(:all,:order => 'number ASC')
-                              end
-                      end
-                      @questions = nil
-                      @sections.each do |section|
-                              if @questions.nil? then
-                                      @questions = section.questions.find(:all,:order => 'number ASC')
-                              else
-                                      @questions = @questions + section.questions.find(:all,:order => 'number ASC')
-                              end
-                      end
-          respond_to do |format|
-            format.html
-          end
-      end
-      end
-
- -
- - - - -
- - -
- -
- admin_show() - click to toggle source -
- - -
- -

GET /guidances/1 GET /guidances/1.json

- - - -
-
# File app/controllers/guidances_controller.rb, line 22
-def admin_show
-  if user_signed_in? && current_user.can_org_admin? then
-          @guidance = Guidance.find(params[:id])
-
-          respond_to do |format|
-            format.html # show.html.erb
-
-            format.json { render json: @guidance }
-          end
- end
-end
-
- -
- - - - -
- - -
- -
- admin_update() - click to toggle source -
- - -
- -

PUT /guidances/1 PUT /guidances/1.json

- - - -
-
# File app/controllers/guidances_controller.rb, line 177
-def admin_update
-              if user_signed_in? && current_user.can_org_admin? then
-              @guidance = Guidance.find(params[:id])
-
-                      @guidance.text = params["guidance-text"]
-
-                      @guidance.question_id = params["question_id"]
-
-          respond_to do |format|
-            if @guidance.update_attributes(params[:guidance])
-              format.html { redirect_to admin_show_guidance_path(params[:guidance]), notice: I18n.t('org_admin.guidance.updated_message') }
-              format.json { head :no_content }
-            else
-              format.html { render action: "edit" }
-              format.json { render json: @guidance.errors, status: :unprocessable_entity }
-            end
-          end
-  else
-                      render(:file => File.join(Rails.root, 'public/403.html'), :status => 403, :layout => false)
-              end
-end
-
- -
- - - - -
- - -
- -
- update_phases() - click to toggle source -
- - -
- -

setup variables for use in the dynamic updating

- - - -
-
# File app/controllers/guidances_controller.rb, line 76
-      def update_phases
-  # updates phases, versions, sections and questions based on template selected
-
-  dmptemplate = Dmptemplate.find(params[:dmptemplate_id])
-  # map to title and id for use in our options_for_select
-
-  @phases = dmptemplate.phases.map{|a| [a.title, a.id]}.insert(0, "Select a phase")
-  @versions = dmptemplate.versions.map{|s| [s.title, s.id]}.insert(0, "Select a version")
-  @sections = dmptemplate.sections.map{|s| [s.title, s.id]}.insert(0, "Select a section")
-  @questions = dmptemplate.questions.map{|s| [s.text, s.id]}.insert(0, "Select a question")
-
-end
-
- -
- - - - -
- - -
- -
- update_questions() - click to toggle source -
- - -
- - - - - -
-
# File app/controllers/guidances_controller.rb, line 104
-def update_questions
-  # updates songs based on artist selected
-
-  section = Section.find(params[:section_id])
-  @questions = section.questions.map{|s| [s.text, s.id]}.insert(0, "Select a question")
-end
-
- -
- - - - -
- - -
- -
- update_sections() - click to toggle source -
- - -
- - - - - -
-
# File app/controllers/guidances_controller.rb, line 96
-def update_sections
-  # updates sections and questions based on version selected
-
-  version = Version.find(params[:version_id])
-  # map to name and id for use in our options_for_select
-
-  @sections = version.sections.map{|s| [s.title, s.id]}.insert(0, "Select a section")
-  @questions = version.questions.map{|s| [s.text, s.id]}.insert(0, "Select a question")
-end
-
- -
- - - - -
- - -
- -
- update_versions() - click to toggle source -
- - -
- - - - - -
-
# File app/controllers/guidances_controller.rb, line 87
-def update_versions
-   # updates versions, sections and questions based on phase selected
-
-   phase = Phase.find(params[:phase_id])
-   # map to name and id for use in our options_for_select
-
-   @versions = phase.versions.map{|s| [s.title, s.id]}.insert(0, "Select a version")
-   @sections = phase.sections.map{|s| [s.title, s.id]}.insert(0, "Select a section")
-   @questions = phase.questions.map{|s| [s.text, s.id]}.insert(0, "Select a question")
- end
-
- -
- - - - -
- - -
- -
- -
- - - - diff --git a/html/HomeController.html b/html/HomeController.html deleted file mode 100644 index dcc676f..0000000 --- a/html/HomeController.html +++ /dev/null @@ -1,363 +0,0 @@ - - - - - - -class HomeController - DMPonline4 Documentation - - - - - - - - - - - - - - - - -
-

class HomeController

- -
- -
- - - - -
- - - - - - - - - - -
-

Public Instance Methods

- - -
- -
- about_us() - click to toggle source -
- - -
- - - - - -
-
# File app/controllers/home_controller.rb, line 13
-def about_us
-end
-
- -
- - - - -
- - -
- -
- index() - click to toggle source -
- - -
- - - - - -
-
# File app/controllers/home_controller.rb, line 2
-def index
-      if user_signed_in?
-              name = current_user.name(false)
-              if name.nil? || name == "" then
-                      redirect_to edit_user_registration_path
-              else
-                      redirect_to projects_url
-              end
-      end
-end
-
- -
- - - - -
- - -
- -
- -
- - - - diff --git a/html/Object.html b/html/Object.html deleted file mode 100644 index e231136..0000000 --- a/html/Object.html +++ /dev/null @@ -1,326 +0,0 @@ - - - - - - -class Object - DMPonline4 Documentation - - - - - - - - - - - - - - - - -
-

class Object

- -
- -
- - - - -
- - - - - - - - - - -
-

Public Instance Methods

- - -
- -
- scoped_collection() - click to toggle source -
- - -
- - - - - -
-
# File app/admin/user.rb, line 118
-def scoped_collection
-  resource_class.includes(:organisations) # prevents N+1 queries to your database
-
-end
-
- -
- - - - -
- - -
- -
- -
- - - - diff --git a/html/Option.html b/html/Option.html deleted file mode 100644 index 1798432..0000000 --- a/html/Option.html +++ /dev/null @@ -1,325 +0,0 @@ - - - - - - -class Option - DMPonline4 Documentation - - - - - - - - - - - - - - - - -
-

class Option

- -
- -
- - - - -
- - - - - - - - - - -
-

Public Instance Methods

- - -
- -
- to_s() - click to toggle source -
- - -
- - - - - -
-
# File app/models/option.rb, line 12
-def to_s
-        "#{text}"
-end
-
- -
- - - - -
- - -
- -
- -
- - - - diff --git a/html/OptionWarning.html b/html/OptionWarning.html deleted file mode 100644 index 921cfe8..0000000 --- a/html/OptionWarning.html +++ /dev/null @@ -1,325 +0,0 @@ - - - - - - -class OptionWarning - DMPonline4 Documentation - - - - - - - - - - - - - - - - -
-

class OptionWarning

- -
- -
- - - - -
- - - - - - - - - - -
-

Public Instance Methods

- - -
- -
- to_s() - click to toggle source -
- - -
- - - - - -
-
# File app/models/option_warning.rb, line 9
-def to_s
-        "#{text}"
-end
-
- -
- - - - -
- - -
- -
- -
- - - - diff --git a/html/Organisation.html b/html/Organisation.html deleted file mode 100644 index d71187f..0000000 --- a/html/Organisation.html +++ /dev/null @@ -1,626 +0,0 @@ - - - - - - -class Organisation - DMPonline4 Documentation - - - - - - - - - - - - - - - - -
-

class Organisation

- -
- -
- - - - -
- - - - - - - - - - -
-

Public Class Methods

- - -
- -
- orgs_with_parent_of_type(org_type) - click to toggle source -
- - -
- -

retrieves info off a child org

- - - -
-
# File app/models/organisation.rb, line 35
-def self.orgs_with_parent_of_type(org_type)
-        parents = OrganisationType.find_by_name(org_type).organisations
-        children = Array.new
-        parents.each do |parent|
-              children += parent.children
-        end
-        return children
-end
-
- -
- - - - -
- - -
- -
- other_organisations() - click to toggle source -
- - -
- - - - - -
-
# File app/models/organisation.rb, line 45
-def self.other_organisations
-        org_types = [I18n.t('helpers.org_type.organisation')]
-        organisations_list = []
-        org_types.each do |ot|
-                new_org_obejct = OrganisationType.find_by_name(ot)
-
-                org_with_guidance = GuidanceGroup.joins(new_org_obejct.organisations)
-
-                organisations_list = organisations_list + org_with_guidance
-        end
-        return organisations_list
-end
-
- -
- - - - -
- - -
- -
-

Public Instance Methods

- - -
- -
- all_guidance_groups() - click to toggle source -
- - -
- - - - - -
-
# File app/models/organisation.rb, line 70
-def all_guidance_groups
-        ggs = guidance_groups
-        children.each do |c|
-                ggs = ggs + c.all_guidance_groups
-        end
-        return ggs
-end
-
- -
- - - - -
- - -
- -
- all_sections(version_id) - click to toggle source -
- - -
- - - - - -
-
# File app/models/organisation.rb, line 58
-def all_sections(version_id)
-        if parent.nil?
-                secs = sections.where("version_id = ?", version_id)
-                if secs.nil? then
-                        secs = Array.new
-                end
-                return secs
-        else
-                return sections.find_all_by_version_id(version_id) + parent.all_sections(version_id)
-        end
-end
-
- -
- - - - -
- - -
- -
- published_templates() - click to toggle source -
- - -
- - - - - -
-
# File app/models/organisation.rb, line 95
-def published_templates
-        return dmptemplates.find_all_by_published(1)
-end
-
- -
- - - - -
- - -
- -
- root() - click to toggle source -
- - -
- - - - - -
-
# File app/models/organisation.rb, line 78
-def root
-        if parent.nil?
-                return self
-        else
-                return parent.root
-        end
-end
-
- -
- - - - -
- - -
- -
- short_name() - click to toggle source -
- - -
- - - - - -
-
# File app/models/organisation.rb, line 26
-def short_name
-        if abbreviation.nil? then
-                return name
-        else
-                return abbreviation
-        end
-end
-
- -
- - - - -
- - -
- -
- to_s() - click to toggle source -
- - -
- - - - - -
-
# File app/models/organisation.rb, line 22
-def to_s
-        name
-end
-
- -
- - - - -
- - -
- -
- warning(option_id) - click to toggle source -
- - -
- - - - - -
-
# File app/models/organisation.rb, line 86
-def warning(option_id)
-        warning = option_warnings.find_by_option_id(option_id)
-        if warning.nil? && !parent.nil? then
-                return parent.warning(option_id)
-        else
-                return warning
-        end
-end
-
- -
- - - - -
- - -
- -
- -
- - - - diff --git a/html/OrganisationType.html b/html/OrganisationType.html deleted file mode 100644 index 1448f7c..0000000 --- a/html/OrganisationType.html +++ /dev/null @@ -1,279 +0,0 @@ - - - - - - -class OrganisationType - DMPonline4 Documentation - - - - - - - - - - - - - - - - -
-

class OrganisationType

- -
- -
- - - - -
- - - - - - - - - - -
- -
- - - - diff --git a/html/OrganisationUsersController.html b/html/OrganisationUsersController.html deleted file mode 100644 index cd53ddb..0000000 --- a/html/OrganisationUsersController.html +++ /dev/null @@ -1,334 +0,0 @@ - - - - - - -class OrganisationUsersController - DMPonline4 Documentation - - - - - - - - - - - - - - - - -
-

class OrganisationUsersController

- -
- -
- - - - -
- - - - - - - - - - -
-

Public Instance Methods

- - -
- -
- admin_index() - click to toggle source -
- - -
- - - - - -
-
# File app/controllers/organisation_users_controller.rb, line 3
-def admin_index
-        if user_signed_in? && current_user.can_org_admin? then
-                
-                respond_to do |format|
-                        format.html # index.html.erb
-
-                        format.json { render json: @organisation_users }
-                end
-        else
-                render(:file => File.join(Rails.root, 'public/403.html'), :status => 403, :layout => false)
-        end 
-end
-
- -
- - - - -
- - -
- -
- -
- - - - diff --git a/html/OrganisationsController.html b/html/OrganisationsController.html deleted file mode 100644 index 91d1f12..0000000 --- a/html/OrganisationsController.html +++ /dev/null @@ -1,707 +0,0 @@ - - - - - - -class OrganisationsController - DMPonline4 Documentation - - - - - - - - - - - - - - - - -
-

class OrganisationsController

- -
- -
- - - - -
- - - - - - - - - - -
-

Public Instance Methods

- - -
- -
- admin_edit() - click to toggle source -
- - -
- -

GET /organisations/1/edit

- - - -
-
# File app/controllers/organisations_controller.rb, line 58
-def admin_edit
-      if user_signed_in? && current_user.can_org_admin? then
-      @organisation = Organisation.find(params[:id])
-  
-  else
-              render(:file => File.join(Rails.root, 'public/403.html'), :status => 403, :layout => false)
-      end 
-end
-
- -
- - - - -
- - -
- -
- admin_show() - click to toggle source -
- - -
- -

GET /organisations/1 GET /organisations/1.json

- - - -
-
# File app/controllers/organisations_controller.rb, line 43
-def admin_show
-      if user_signed_in? && current_user.can_org_admin? then
-          @organisation = Organisation.find(params[:id])
-      
-          respond_to do |format|
-            format.html # show.html.erb
-
-            format.json { render json: @organisation }
-          end
-  else
-                      render(:file => File.join(Rails.root, 'public/403.html'), :status => 403, :layout => false)
-              end 
-              
-end
-
- -
- - - - -
- - -
- -
- admin_update() - click to toggle source -
- - -
- -

PUT /organisations/1 PUT /organisations/1.json

- - - -
-
# File app/controllers/organisations_controller.rb, line 70
-def admin_update
-  if user_signed_in? && current_user.can_org_admin? then
-      @organisation = Organisation.find(params[:id])
-      @organisation.banner_text = params["org_banner_text"]
-              
-              
-          respond_to do |format|
-            if @organisation.update_attributes(params[:organisation])
-              format.html { redirect_to admin_show_organisation_path(params[:id]), notice: I18n.t("admin.org_updated_message")  }
-              format.json { head :no_content }
-            else
-              format.html { render action: "edit" }
-              format.json { render json: @organisation.errors, status: :unprocessable_entity }
-            end
-          end
-      else
-        render(:file => File.join(Rails.root, 'public/403.html'), :status => 403, :layout => false)
-  end         
-end
-
- -
- - - - -
- - -
- -
- children() - click to toggle source -
- - -
- - - - - -
-
# File app/controllers/organisations_controller.rb, line 108
-        def children
-                @organisation = Organisation.find(params[:id])
-                #if user_signed_in? then
-
-                children = {}
-                @organisation.children.each do |child|
-                        children[child.id] = child.name
-                end
-                respond_to do |format|
-                        format.json { render json: children.to_json }
-                end
-#               else
-
-#                       render(:file => File.join(Rails.root, 'public/403.html'), :status => 403, :layout => false)
-
-#               end
-
-        end
-
- -
- - - - -
- - -
- -
- create() - click to toggle source -
- - -
- -

POST /organisations POST /organisations.json

- - - -
-
# File app/controllers/organisations_controller.rb, line 26
-def create
-  @organisation = Organisation.new(params[:organisation])
-
-  respond_to do |format|
-    if @organisation.save
-      format.html { redirect_to @organisation, notice: I18n.t("admin.org_created_message") }
-      format.json { render json: @organisation, status: :created, location: @organisation }
-    else
-      format.html { render action: "new" }
-      format.json { render json: @organisation.errors, status: :unprocessable_entity }
-    end
-  end
-end
-
- -
- - - - -
- - -
- -
- destroy() - click to toggle source -
- - -
- -

DELETE /organisations/1 DELETE /organisations/1.json

- - - -
-
# File app/controllers/organisations_controller.rb, line 92
-def destroy
-  @organisation = Organisation.find(params[:id])
-  @organisation.destroy
-
-  respond_to do |format|
-    format.html { redirect_to organisations_url }
-    format.json { head :no_content }
-  end
-end
-
- -
- - - - -
- - -
- -
- index() - click to toggle source -
- - -
- -

GET /organisations GET /organisations.json

- - - -
-
# File app/controllers/organisations_controller.rb, line 4
-def index
-  @organisations = Organisation.all
-
-  respond_to do |format|
-    format.html # index.html.erb
-
-    format.json { render json: @organisations }
-  end
-end
-
- -
- - - - -
- - -
- -
- new() - click to toggle source -
- - -
- -

GET /organisations/new GET /organisations/new.json

- - - -
-
# File app/controllers/organisations_controller.rb, line 15
-def new
-  @organisation = Organisation.new
-
-  respond_to do |format|
-    format.html # new.html.erb
-
-    format.json { render json: @organisation }
-  end
-end
-
- -
- - - - -
- - -
- -
- parent() - click to toggle source -
- - -
- - - - - -
-
# File app/controllers/organisations_controller.rb, line 102
-def parent
-      @organisation = Organisation.find(params[:id])
-      parent_org = @organisation.find_by {|o| o.parent_id }
-      return parent_org
-end
-
- -
- - - - -
- - -
- -
- templates() - click to toggle source -
- - -
- - - - - -
-
# File app/controllers/organisations_controller.rb, line 123
-        def templates
-                @organisation = Organisation.find(params[:id])
-                #if user_signed_in? then
-
-                templates = {}
-                @organisation.dmptemplates.each do |template|
-                        if template.is_published? then
-                                templates[template.id] = template.title
-                        end
-                end
-                respond_to do |format|
-                        format.json { render json: templates.to_json }
-                end
-#               else
-
-#                       render(:file => File.join(Rails.root, 'public/403.html'), :status => 403, :layout => false)
-
-#               end
-
-        end
-
- -
- - - - -
- - -
- -
- -
- - - - diff --git a/html/Page.html b/html/Page.html deleted file mode 100644 index a4a8cea..0000000 --- a/html/Page.html +++ /dev/null @@ -1,279 +0,0 @@ - - - - - - -class Page - DMPonline4 Documentation - - - - - - - - - - - - - - - - -
-

class Page

- -
- -
- - - - -
- - - - - - - - - - -
- -
- - - - diff --git a/html/PagesController.html b/html/PagesController.html deleted file mode 100644 index b067c7c..0000000 --- a/html/PagesController.html +++ /dev/null @@ -1,561 +0,0 @@ - - - - - - -class PagesController - DMPonline4 Documentation - - - - - - - - - - - - - - - - -
-

class PagesController

- -
- -
- - - - -
- - - - - - - - - - -
-

Public Instance Methods

- - -
- -
- create() - click to toggle source -
- - -
- -

POST /pages POST /pages.json

- - - -
-
# File app/controllers/pages_controller.rb, line 42
-def create
-  @page = Page.new(params[:page])
-
-  respond_to do |format|
-    if @page.save
-      format.html { redirect_to @page, notice: 'Page was successfully created.' }
-      format.json { render json: @page, status: :created, location: @page }
-    else
-      format.html { render action: "new" }
-      format.json { render json: @page.errors, status: :unprocessable_entity }
-    end
-  end
-end
-
- -
- - - - -
- - -
- -
- destroy() - click to toggle source -
- - -
- -

DELETE /pages/1 DELETE /pages/1.json

- - - -
-
# File app/controllers/pages_controller.rb, line 74
-def destroy
-  @page = Page.find(params[:id])
-  @page.destroy
-
-  respond_to do |format|
-    format.html { redirect_to pages_url }
-    format.json { head :no_content }
-  end
-end
-
- -
- - - - -
- - -
- -
- edit() - click to toggle source -
- - -
- -

GET /pages/1/edit

- - - -
-
# File app/controllers/pages_controller.rb, line 36
-def edit
-  @page = Page.find(params[:id])
-end
-
- -
- - - - -
- - -
- -
- index() - click to toggle source -
- - -
- -

GET /pages GET /pages.json

- - - -
-
# File app/controllers/pages_controller.rb, line 4
-def index
-  @pages = Page.all
-
-  respond_to do |format|
-    format.html # index.html.erb
-
-    format.json { render json: @pages }
-  end
-end
-
- -
- - - - -
- - -
- -
- new() - click to toggle source -
- - -
- -

GET /pages/new GET /pages/new.json

- - - -
-
# File app/controllers/pages_controller.rb, line 26
-def new
-  @page = Page.new
-
-  respond_to do |format|
-    format.html # new.html.erb
-
-    format.json { render json: @page }
-  end
-end
-
- -
- - - - -
- - -
- -
- show() - click to toggle source -
- - -
- -

GET /pages/1 GET /pages/1.json

- - - -
-
# File app/controllers/pages_controller.rb, line 15
-def show
-  @page = Page.find(params[:id])
-
-  respond_to do |format|
-    format.html # show.html.erb
-
-    format.json { render json: @page }
-  end
-end
-
- -
- - - - -
- - -
- -
- update() - click to toggle source -
- - -
- -

PUT /pages/1 PUT /pages/1.json

- - - -
-
# File app/controllers/pages_controller.rb, line 58
-def update
-  @page = Page.find(params[:id])
-
-  respond_to do |format|
-    if @page.update_attributes(params[:page])
-      format.html { redirect_to @page, notice: 'Page was successfully updated.' }
-      format.json { head :no_content }
-    else
-      format.html { render action: "edit" }
-      format.json { render json: @page.errors, status: :unprocessable_entity }
-    end
-  end
-end
-
- -
- - - - -
- - -
- -
- -
- - - - diff --git a/html/PasswordsController.html b/html/PasswordsController.html deleted file mode 100644 index 3364f85..0000000 --- a/html/PasswordsController.html +++ /dev/null @@ -1,325 +0,0 @@ - - - - - - -class PasswordsController - DMPonline4 Documentation - - - - - - - - - - - - - - - - -
-

class PasswordsController

- -
- -
- - - - -
- - - - - - - - - - -
-

Protected Instance Methods

- - -
- -
- after_resetting_password_path_for(resource) - click to toggle source -
- - -
- - - - - -
-
# File app/controllers/passwords_controller.rb, line 5
-    def after_resetting_password_path_for(resource)
-    root_path
-end
-
- -
- - - - -
- - -
- -
- -
- - - - diff --git a/html/Phase.html b/html/Phase.html deleted file mode 100644 index c5491a9..0000000 --- a/html/Phase.html +++ /dev/null @@ -1,457 +0,0 @@ - - - - - - -class Phase - DMPonline4 Documentation - - - - - - - - - - - - - - - - -
-

class Phase

- -
-
Project: -
-

DMPonline v4

-
Description: -
-

This model describes informmation about the phase of a plan, it's -title, order of display and which template it belongs to.

-
Created: -
-

03/09/2014

-
Copyright: -
-

Digital Curation Centre

-
- -
- - - - -
- - - - - - - - - - -
-

Public Instance Methods

- - -
- -
- has_sections() - click to toggle source -
- - -
- -

verify if a phase has a published version or a version with one or more -sections

- - - -
-
# File app/models/phase.rb, line 44
-def has_sections
-        versions = self.versions.where('published = ?', true).order('updated_at DESC')
-        if versions.any? then
-                version = versions.first
-                if !version.sections.empty? then
-                        has_section = true
-                else
-                        has_section = false
-                end  
-        else
-                version = self.versions.order('updated_at DESC').first 
-                if !version.sections.empty? then
-                        has_section = true
-                else
-                        has_section = false
-                end  
-        end
-        return has_section
-end
-
- -
- - - - -
- - -
- -
- latest_published_version() - click to toggle source -
- - -
- -

Verify if this phase has any published versions

- - - -
-
# File app/models/phase.rb, line 34
-def latest_published_version
-        versions.order("number DESC").each do |version|
-                if version.published then
-                        return version
-                end
-        end
-        return nil
-end
-
- -
- - - - -
- - -
- -
- latest_version() - click to toggle source -
- - -
- - - - - -
-
# File app/models/phase.rb, line 29
-def latest_version
-        return versions.order("number DESC").last
-end
-
- -
- - - - -
- - -
- -
- to_s() - click to toggle source -
- - -
- - - - - -
-
# File app/models/phase.rb, line 25
-def to_s
-        "#{title}"
-end
-
- -
- - - - -
- - -
- -
- -
- - - - diff --git a/html/Plan.html b/html/Plan.html deleted file mode 100644 index 9f0b894..0000000 --- a/html/Plan.html +++ /dev/null @@ -1,1393 +0,0 @@ - - - - - - -class Plan - DMPonline4 Documentation - - - - - - - - - - - - - - - - -
-

class Plan

- -
- -
- - - - -
- - - - - - -
-

Constants

-
- -
A4_PAGE_HEIGHT - -
- - -
A4_PAGE_WIDTH - -
- - -
FONT_HEIGHT_CONVERSION_FACTOR - -
- - -
FONT_WIDTH_HEIGHT_RATIO - -
- - -
ROUNDING - -
- - -
-
- - - - - - -
-

Public Instance Methods

- - -
- -
- add_guidance_to_array(guidance_array, guidance_group, theme, guidance) - click to toggle source -
- - -
- - - - - -
-
# File app/models/plan.rb, line 119
-def add_guidance_to_array(guidance_array, guidance_group, theme, guidance)
-        
-        if guidance_array[guidance_group].nil? then
-                guidance_array[guidance_group] = {}
-        end
-        if theme.nil? then
-                if guidance_array[guidance_group]["no_theme"].nil? then
-                        guidance_array[guidance_group]["no_theme"] = []
-                end
-                if !guidance_array[guidance_group]["no_theme"].include?(guidance) then
-                        guidance_array[guidance_group]["no_theme"].push(guidance)
-                end
-        else
-                if guidance_array[guidance_group][theme].nil? then
-                        guidance_array[guidance_group][theme] = []
-                end
-                if !guidance_array[guidance_group][theme].include?(guidance) then
-                        guidance_array[guidance_group][theme].push(guidance)
-                end
-        end
-        
-return guidance_array
-end
-
- -
- - - - -
- - -
- -
- administerable_by(user_id) - click to toggle source -
- - -
- - - - - -
-
# File app/models/plan.rb, line 168
-def administerable_by(user_id)
-        return project.readable_by(user_id)
-end
-
- -
- - - - -
- - -
- -
- answer(qid, create_if_missing = true) - click to toggle source -
- - -
- - - - - -
-
# File app/models/plan.rb, line 53
-def answer(qid, create_if_missing = true)
-        answer = answers.where(:question_id => qid).order("created_at DESC").first
-        question = Question.find(qid)
-        if answer.nil? && create_if_missing then
-                answer = Answer.new
-                answer.plan_id = id
-                answer.question_id = qid
-                answer.text = question.default_value
-                default_options = Array.new
-                question.options.each do |option|
-                        if option.is_default
-                                default_options << option
-                        end
-                end
-                answer.options = default_options
-        end
-        return answer
-end
-
- -
- - - - -
- - -
- -
- delete_recent_locks(user_id) - click to toggle source -
- - -
- - - - - -
-
# File app/models/plan.rb, line 291
-def delete_recent_locks(user_id)
-        plan_sections.where(:user_id => user_id).each do |lock|
-                lock.delete
-        end
-end
-
- -
- - - - -
- - -
- -
- details() - click to toggle source -
- - -
- - - - - -
-
# File app/models/plan.rb, line 230
-def details
-        details = {
-                "project_title" => project.title,
-                "phase_title" => version.phase.title,
-                "sections" => {}
-        }
-        sections.sort_by(&:"number").each do |s|
-                details["sections"][s.number] = {}
-                details["sections"][s.number]["title"] = s.title
-                details["sections"][s.number]["questions"] = {}
-                s.questions.order("number").each do |q|
-                        details["sections"][s.number]["questions"][q.number] = {}
-                        details["sections"][s.number]["questions"][q.number]["question_text"] = q.text
-                        answer = answer(q.id, false)
-                        if ! answer.nil? then
-            q_format = q.question_format
-                                if (q_format.title == t("helpers.checkbox") || q_format.title == t("helpers.multi_select_box") ||
-                                q_format.title == t("helpers.radio_buttons") || q_format.title == t("helpers.dropdown")) then
-                                        details["sections"][s.number]["questions"][q.number]["selections"] = {}
-                                        answer.options.each do |o|
-                                                details["sections"][s.number]["questions"][q.number]["selections"][o.number] = o.text
-                                        end
-                                end
-                                details["sections"][s.number]["questions"][q.number]["answer_text"] = answer.text
-                        end
-                end
-        end
-        return details
-end
-
- -
- - - - -
- - -
- -
- dmptemplate() - click to toggle source -
- - -
- - - - - -
-
# File app/models/plan.rb, line 36
-def dmptemplate
-        self.project.try(:dmptemplate) || Dmptemplate.new
-end
-
- -
- - - - -
- - -
- -
- editable_by(user_id) - click to toggle source -
- - -
- - - - - -
-
# File app/models/plan.rb, line 156
-def editable_by(user_id)
-        return project.editable_by(user_id)
-end
-
- -
- - - - -
- - -
- -
- guidance_for_question(question) - click to toggle source -
- - -
- - - - - -
-
# File app/models/plan.rb, line 81
-def guidance_for_question(question)
-        guidances = {}
-        # If project org isn't nil, get guidance by theme from any "non-subset" groups belonging to project org
-
-        unless project.organisation.nil? then
-                project.organisation.guidance_groups.each do |group|
-                        if !group.optional_subset && (group.dmptemplates.pluck(:id).include?(project.dmptemplate_id) || group.dmptemplates.count == 0) then
-                                group.guidances.each do |guidance|
-                                        guidance.themes.where("id IN (?)", question.theme_ids).each do |theme|
-                                                guidances = self.add_guidance_to_array(guidances, group, theme, guidance)
-                                        end
-                                end
-                        end
-                end
-        end
-
-        # Get guidance by theme from any guidance groups selected on creation
-
-        project.guidance_groups.each do |group|
-                if group.dmptemplates.pluck(:id).include?(project.dmptemplate_id) || group.dmptemplates.count == 0 then
-                        group.guidances.each do |guidance|
-                                guidance.themes.where("id IN (?)", question.theme_ids).each do |theme|
-                                        guidances = self.add_guidance_to_array(guidances, group, theme, guidance)
-                                end
-                        end
-                end 
-end
-        
-        # Get guidance by question where guidance group was selected on creation or if group is organisation default
-
-        question.guidances.each do |guidance|
-                guidance.guidance_groups.each do |group|
-                        if (group.organisation == project.organisation && !group.optional_subset) || project.guidance_groups.include?(group) then
-                                guidances = self.add_guidance_to_array(guidances, group, nil, guidance)
-                        end
-    end
-        end
-
-        return guidances
-end
-
- -
- - - - -
- - -
- -
- latest_update() - click to toggle source -
- - -
- - - - - -
-
# File app/models/plan.rb, line 321
-def latest_update
-        if answers.any? then
-                last_answered = answers.order("updated_at DESC").first.updated_at
-                if last_answered > updated_at then
-                        return last_answered
-                else
-                        return updated_at
-                end
-        else
-                return updated_at
-        end
-end
-
- -
- - - - -
- - -
- -
- lock_all_sections(user_id) - click to toggle source -
- - -
- - - - - -
-
# File app/models/plan.rb, line 279
-def lock_all_sections(user_id)
-        sections.each do |s|
-                lock_section(s.id, user_id, 1800)
-        end
-end
-
- -
- - - - -
- - -
- -
- lock_section(section_id, user_id, release_time = 60) - click to toggle source -
- - -
- - - - - -
-
# File app/models/plan.rb, line 297
-def lock_section(section_id, user_id, release_time = 60)
-        status = locked(section_id, user_id)
-        if ! status["locked"] then
-                plan_section = PlanSection.new
-                plan_section.plan_id = id
-                plan_section.section_id = section_id
-                plan_section.release_time = Time.now + release_time.seconds
-                plan_section.user_id = user_id
-                plan_section.save
-        elsif status["current_user"] then
-                plan_section = PlanSection.find(status["id"])
-                plan_section.release_time = Time.now + release_time.seconds
-                plan_section.save
-        else
-                return false
-        end
-end
-
- -
- - - - -
- - -
- -
- locked(section_id, user_id) - click to toggle source -
- - -
- - - - - -
-
# File app/models/plan.rb, line 260
-def locked(section_id, user_id)
-        plan_section = plan_sections.where("section_id = ? AND user_id != ? AND release_time > ?", section_id, user_id, Time.now).last
-        if plan_section.nil? then
-                status = {
-                        "locked" => false,
-                        "locked_by" => nil,
-                        "timestamp" => nil,
-                        "id" => nil
-                }
-        else
-                status = {
-                        "locked" => true,
-                        "locked_by" => plan_section.user.name,
-                        "timestamp" => plan_section.updated_at,
-                        "id" => plan_section.id
-                }
-        end
-end
-
- -
- - - - -
- - -
- -
- readable_by(user_id) - click to toggle source -
- - -
- - - - - -
-
# File app/models/plan.rb, line 160
-def readable_by(user_id)
-        if project.nil?
-                return false
-        else
-                return project.readable_by(user_id)
-        end
-end
-
- -
- - - - -
- - -
- -
- section_answers(section_id) - click to toggle source -
- - -
- - - - - -
-
# File app/models/plan.rb, line 334
-def section_answers(section_id)
-        section = Section.find(section_id)
-        section_questions = Array.new
-        counter = 0
-        section.questions.each do |q|
-                section_questions[counter] = {}
-                section_questions[counter]["id"] = q.id
-                #section_questions[counter]["multiple_choice"] = q.multiple_choice
-
-                q_answer = answer(q.id, false)
-                if q_answer.nil? then
-                        section_questions[counter]["answer_id"] = nil
-                        if q.suggested_answers.find_by_organisation_id(project.organisation_id).nil? then
-                                section_questions[counter]["answer_text"] = ""
-                        else
-                                section_questions[counter]["answer_text"] = q.default_value
-                        end
-                        section_questions[counter]["answer_timestamp"] = nil
-                        section_questions[counter]["answer_options"] = Array.new
-                else
-                        section_questions[counter]["answer_id"] = q_answer.id
-                        section_questions[counter]["answer_text"] = q_answer.text
-                        section_questions[counter]["answer_timestamp"] = q_answer.created_at
-                        section_questions[counter]["answer_options"] = q_answer.options.pluck(:id)
-                end
-                counter = counter + 1
-        end
-        return section_questions
-end
-
- -
- - - - -
- - -
- -
- sections() - click to toggle source -
- - -
- - - - - -
-
# File app/models/plan.rb, line 72
-def sections
-        unless project.organisation.nil? then
-                sections = version.global_sections + project.organisation.all_sections(version_id)
-        else
-                sections = version.global_sections
-        end
-        return sections.uniq.sort_by &:number
-end
-
- -
- - - - -
- - -
- -
- settings(key) - click to toggle source -
- - -
- -

Proxy through to the template settings (or defaults if this plan -doesn't have an associated template) if there are no settings stored -for this plan. `key` is required by rails-settings, so it's required -here, too.

- - - -
-
# File app/models/plan.rb, line 29
-def settings(key)
-        self_settings = self.super_settings(key)
-        return self_settings if self_settings.value?
-
-        self.dmptemplate.settings(key)
-end
-
- -
- - -
- Also aliased as: super_settings -
- - - -
- - -
- -
- status() - click to toggle source -
- - -
- - - - - -
-
# File app/models/plan.rb, line 172
-def status
-        status = {
-                "num_questions" => 0,
-                "num_answers" => 0,
-                "sections" => {},
-                "questions" => {},
-                "space_used" => 0 # percentage of available space in pdf used
-
-        }
-
-        space_used = height_of_text(self.project.title, 2, 2)
-
-        sections.each do |s|
-                space_used += height_of_text(s.title, 1, 1)
-                section_questions = 0
-                section_answers = 0
-                status["sections"][s.id] = {}
-                status["sections"][s.id]["questions"] = Array.new
-                s.questions.each do |q|
-                        status["num_questions"] += 1
-                        section_questions += 1
-                        status["sections"][s.id]["questions"] << q.id
-                        status["questions"][q.id] = {}
-                        answer = answer(q.id, false)
-
-                        space_used += height_of_text(q.text) unless q.text == s.title
-                        space_used += height_of_text(answer.try(:text) || I18n.t('helpers.plan.export.pdf.question_not_answered'))
-
-                        if ! answer.nil? then
-                                status["questions"][q.id] = {
-                                        "answer_id" => answer.id,
-                                        "answer_created_at" => answer.created_at.to_i,
-                                        "answer_text" => answer.text,
-                                        "answer_option_ids" => answer.option_ids,
-                                        "answered_by" => answer.user.name
-                                }
-            q_format = q.question_format
-                                status["num_answers"] += 1 if (q_format.title == I18n.t("helpers.checkbox") || q_format.title == I18n.t("helpers.multi_select_box") ||
-                                q_format.title == I18n.t("helpers.radio_buttons") || q_format.title == I18n.t("helpers.dropdown")) || answer.text.present?
-                                section_answers += 1
-                                #TODO: include selected options in space estimate
-
-                        else
-                                status["questions"][q.id] = {
-                                        "answer_id" => nil,
-                                        "answer_created_at" => nil,
-                                        "answer_text" => nil,
-                                        "answer_option_ids" => nil,
-                                        "answered_by" => nil
-                                }
-                        end
-                        status["sections"][s.id]["num_questions"] = section_questions
-                        status["sections"][s.id]["num_answers"] = section_answers
-                end
-        end
-
-        status['space_used'] = estimate_space_used(space_used)
-        return status
-end
-
- -
- - - - -
- - -
- -
- super_settings(key) - click to toggle source -
- - -
- - - - - -
- - - - -
- Alias for: settings -
- -
- - -
- -
- title() - click to toggle source -
- - -
- - - - - -
-
# File app/models/plan.rb, line 40
-def title
-        logger.debug "Title in settings: #{self.settings(:export).title}"
-        if self.settings(:export).title == ""
-    if !self.version.nil? && !self.version.phase.nil? && !self.version.phase.title? then
-        return self.version.phase.title
-    else
-        return "DMP title"
-                end
-        else
-                return self.settings(:export).title
-        end
-end
-
- -
- - - - -
- - -
- -
- unlock_all_sections(user_id) - click to toggle source -
- - -
- - - - - -
-
# File app/models/plan.rb, line 285
-def unlock_all_sections(user_id)
-        plan_sections.where(:user_id => user_id).order("created_at DESC").each do |lock|
-                lock.delete
-        end
-end
-
- -
- - - - -
- - -
- -
- unlock_section(section_id, user_id) - click to toggle source -
- - -
- - - - - -
-
# File app/models/plan.rb, line 315
-def unlock_section(section_id, user_id)
-        plan_sections.where(:section_id => section_id, :user_id => user_id).order("created_at DESC").each do |lock|
-                lock.delete
-        end
-end
-
- -
- - - - -
- - -
- -
- warning(option_id) - click to toggle source -
- - -
- - - - - -
-
# File app/models/plan.rb, line 148
-def warning(option_id)
-        if project.organisation.nil?
-                return nil
-        else
-                return project.organisation.warning(option_id)
-        end
-end
-
- -
- - - - -
- - -
- -
-

Private Instance Methods

- - -
- -
- estimate_space_used(used_height) - click to toggle source -
- - -
- -

Based on the height of the text gathered so far and the available vertical -space of the pdf, estimate a percentage of how much space has been used. -This is highly dependent on the layout in the pdf. A more accurate approach -would be to render the pdf and check how much space had been used, but that -could be very slow. NOTE: This is only an estimate, rounded up to the -nearest 5%; it is intended for guidance when editing plan data, not to be -100% accurate.

- - - -
-
# File app/models/plan.rb, line 372
-def estimate_space_used(used_height)
-        @formatting ||= self.settings(:export).formatting
-
-        return 0 unless @formatting[:font_size] > 0
-
-        margin_height    = @formatting[:margin][:top].to_i + @formatting[:margin][:bottom].to_i
-        page_height      = A4_PAGE_HEIGHT - margin_height # 297mm for A4 portrait
-
-        available_height = page_height * self.dmptemplate.settings(:export).max_pages
-
-        percentage = (used_height / available_height) * 100
-        (percentage / ROUNDING).ceil * ROUNDING # round up to nearest five
-
-end
-
- -
- - - - -
- - -
- -
- height_of_text(text, font_size_inc = 0, vertical_margin = 0) - click to toggle source -
- - -
- -

Take a guess at the vertical height (in mm) of the given text based on the -font-size and left/right margins stored in the plan's settings. This -assumes a fixed-width for each glyph, which is obviously incorrect for the -font-face choices available; the idea is that they'll hopefully average -out to that in the long-run. Allows for hinting different font sizes -(offset from base via font_size_inc) and vertical margins (i.e. for heading -text)

- - - -
-
# File app/models/plan.rb, line 392
-def height_of_text(text, font_size_inc = 0, vertical_margin = 0)
-        @formatting     ||= self.settings(:export).formatting
-        @margin_width   ||= @formatting[:margin][:left].to_i + @formatting[:margin][:right].to_i
-        @base_font_size ||= @formatting[:font_size]
-
-        return 0 unless @base_font_size > 0
-
-        font_height = FONT_HEIGHT_CONVERSION_FACTOR * (@base_font_size + font_size_inc)
-        font_width  = font_height * FONT_WIDTH_HEIGHT_RATIO # Assume glyph width averages at 2/5s the height
-
-        leading     = font_height / 2
-
-        chars_in_line = (A4_PAGE_WIDTH - @margin_width) / font_width # 210mm for A4 portrait
-
-        num_lines = (text.length / chars_in_line).ceil
-
-        (num_lines * font_height) + vertical_margin + leading
-end
-
- -
- - - - -
- - -
- -
- -
- - - - diff --git a/html/PlanSection.html b/html/PlanSection.html deleted file mode 100644 index 563df5e..0000000 --- a/html/PlanSection.html +++ /dev/null @@ -1,279 +0,0 @@ - - - - - - -class PlanSection - DMPonline4 Documentation - - - - - - - - - - - - - - - - -
-

class PlanSection

- -
- -
- - - - -
- - - - - - - - - - -
- -
- - - - diff --git a/html/PlansController.html b/html/PlansController.html deleted file mode 100644 index 6992368..0000000 --- a/html/PlansController.html +++ /dev/null @@ -1,833 +0,0 @@ - - - - - - -class PlansController - DMPonline4 Documentation - - - - - - - - - - - - - - - - -
-

class PlansController

- -
- -
- - - - -
- - - - - - - - - - -
-

Public Instance Methods

- - -
- -
- answer() - click to toggle source -
- - -
- - - - - -
-
# File app/controllers/plans_controller.rb, line 142
-def answer
-        @plan = Plan.find(params[:id])
-        if user_signed_in? && @plan.readable_by(current_user.id) then
-                respond_to do |format|
-                        format.json { render json: @plan.answer(params[:q_id], false).to_json(:include => :options) }
-                end
-        else
-                render(:file => File.join(Rails.root, 'public/403.html'), :status => 403, :layout => false)
-        end
-end
-
- -
- - - - -
- - -
- -
- delete_recent_locks() - click to toggle source -
- - -
- - - - - -
-
# File app/controllers/plans_controller.rb, line 74
-def delete_recent_locks
-        @plan = Plan.find(params[:id])
-        if user_signed_in? && @plan.editable_by(current_user.id) then
-                respond_to do |format|
-                        if @plan.delete_recent_locks(current_user.id)
-                                format.html { render action: "edit" }
-                                format.json { head :no_content }
-                        else
-                                format.html { render action: "edit" }
-                                format.json { render json: @plan.errors, status: :unprocessable_entity }
-                        end
-                end
-        else
-                render(:file => File.join(Rails.root, 'public/403.html'), :status => 403, :layout => false)
-        end
-end
-
- -
- - - - -
- - -
- -
- edit() - click to toggle source -
- - -
- -

GET /plans/1/edit

- - - -
-
# File app/controllers/plans_controller.rb, line 6
-    def edit
-            @plan = Plan.find(params[:id])
-    
-   
-if !user_signed_in? then
-  respond_to do |format|
-                            format.html { redirect_to edit_user_registration_path }
-                    end
-            elsif !@plan.readable_by(current_user.id) then
-                    respond_to do |format|
-                            format.html { redirect_to projects_url, notice: "This account does not have access to that plan." }
-                    end
-            end
-    end
-
- -
- - - - -
- - -
- -
- export() - click to toggle source -
- - -
- - - - - -
-
# File app/controllers/plans_controller.rb, line 164
-def export
-        @plan = Plan.find(params[:id])
-
-        if user_signed_in? && @plan.readable_by(current_user.id) then
-                @exported_plan = ExportedPlan.new.tap do |ep|
-                        ep.plan = @plan
-                        ep.user = current_user
-                        ep.format = request.format.try(:symbol)
-                        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.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]'
-                                 }
-                  end
-                end
-        elsif !user_signed_in? then
-       respond_to do |format|
-                        format.html { redirect_to edit_user_registration_path }
-                end
-        elsif !@plan.editable_by(current_user.id) then
-                respond_to do |format|
-                        format.html { redirect_to projects_url, notice: "This account does not have access to that plan." }
-                end
-        end
-end
-
- -
- - - - -
- - -
- -
- lock_section() - click to toggle source -
- - -
- - - - - -
-
# File app/controllers/plans_controller.rb, line 108
-def lock_section
-        @plan = Plan.find(params[:id])
-        if user_signed_in? && @plan.editable_by(current_user.id) then
-                respond_to do |format|
-                        if @plan.lock_section(params[:section_id], current_user.id)
-                                format.html { render action: "edit" }
-                                format.json { head :no_content }
-                        else
-                                format.html { render action: "edit" }
-                                format.json { render json: @plan.errors, status: :unprocessable_entity }
-                        end
-                end
-        else
-                render(:file => File.join(Rails.root, 'public/403.html'), :status => 403, :layout => false)
-        end
-end
-
- -
- - - - -
- - -
- -
- locked() - click to toggle source -
- - -
- - - - - -
-
# File app/controllers/plans_controller.rb, line 63
-def locked
-        @plan = Plan.find(params[:id])
-        if !@plan.nil? && user_signed_in? && @plan.readable_by(current_user.id) then
-                respond_to do |format|
-                        format.json { render json: @plan.locked(params[:section_id],current_user.id) }
-                end
-        else
-                render(:file => File.join(Rails.root, 'public/403.html'), :status => 403, :layout => false)
-        end
-end
-
- -
- - - - -
- - -
- -
- section_answers() - click to toggle source -
- - -
- - - - - -
-
# File app/controllers/plans_controller.rb, line 52
-def section_answers
-        @plan = Plan.find(params[:id])
-        if user_signed_in? && @plan.readable_by(current_user.id) then
-                respond_to do |format|
-                        format.json { render json: @plan.section_answers(params[:section_id]) }
-                end
-        else
-                render(:file => File.join(Rails.root, 'public/403.html'), :status => 403, :layout => false)
-        end
-end
-
- -
- - - - -
- - -
- -
- status() - click to toggle source -
- - -
- -

GET /status/1.json

- - - -
-
# File app/controllers/plans_controller.rb, line 41
-def status
-        @plan = Plan.find(params[:id])
-        if user_signed_in? && @plan.readable_by(current_user.id) then
-                respond_to do |format|
-                        format.json { render json: @plan.status }
-                end
-        else
-                render(:file => File.join(Rails.root, 'public/403.html'), :status => 403, :layout => false)
-        end
-end
-
- -
- - - - -
- - -
- -
- unlock_all_sections() - click to toggle source -
- - -
- - - - - -
-
# File app/controllers/plans_controller.rb, line 91
-def unlock_all_sections
-        @plan = Plan.find(params[:id])
-        if user_signed_in? && @plan.editable_by(current_user.id) then
-                respond_to do |format|
-                        if @plan.unlock_all_sections(current_user.id)
-                                format.html { render action: "edit" }
-                                format.json { head :no_content }
-                        else
-                                format.html { render action: "edit" }
-                                format.json { render json: @plan.errors, status: :unprocessable_entity }
-                        end
-                end
-        else
-                render(:file => File.join(Rails.root, 'public/403.html'), :status => 403, :layout => false)
-        end
-end
-
- -
- - - - -
- - -
- -
- unlock_section() - click to toggle source -
- - -
- - - - - -
-
# File app/controllers/plans_controller.rb, line 125
-def unlock_section
-        @plan = Plan.find(params[:id])
-        if user_signed_in? && @plan.editable_by(current_user.id) then
-                respond_to do |format|
-                        if @plan.unlock_section(params[:section_id], current_user.id)
-                                format.html { render action: "edit" }
-                                format.json { head :no_content }
-                        else
-                                format.html { render action: "edit" }
-                                format.json { render json: @plan.errors, status: :unprocessable_entity }
-                        end
-                end
-        else
-                render(:file => File.join(Rails.root, 'public/403.html'), :status => 403, :layout => false)
-        end
-end
-
- -
- - - - -
- - -
- -
- update() - click to toggle source -
- - -
- -

PUT /plans/1 PUT /plans/1.json

- - - -
-
# File app/controllers/plans_controller.rb, line 23
-def update
-        @plan = Plan.find(params[:id])
-        if user_signed_in? && @plan.editable_by(current_user.id) then
-                respond_to do |format|
-                if @plan.update_attributes(params[:plan])
-                        format.html { redirect_to @plan, notice: 'Plan was successfully updated.' }
-                        format.json { head :no_content }
-                else
-                        format.html { render action: "edit" }
-                        format.json { render json: @plan.errors, status: :unprocessable_entity }
-                end
-        end
-else
-                render(:file => File.join(Rails.root, 'public/403.html'), :status => 403, :layout => false)
-end
-end
-
- -
- - - - -
- - -
- -
- warning() - click to toggle source -
- - -
- - - - - -
-
# File app/controllers/plans_controller.rb, line 153
-def warning
-        @plan = Plan.find(params[:id])
-        if user_signed_in? && @plan.readable_by(current_user.id) then
-                respond_to do |format|
-                        format.json { render json: @plan.warning(params[:option_id]) }
-                end
-        else
-                render(:file => File.join(Rails.root, 'public/403.html'), :status => 403, :layout => false)
-        end
-end
-
- -
- - - - -
- - -
- -
- -
- - - - diff --git a/html/PlansHelper.html b/html/PlansHelper.html deleted file mode 100644 index 6373cd5..0000000 --- a/html/PlansHelper.html +++ /dev/null @@ -1,427 +0,0 @@ - - - - - - -module PlansHelper - DMPonline4 Documentation - - - - - - - - - - - - - - - - -
-

module PlansHelper

- -
- -
- - - - -
- - - - - - - - - - -
-

Public Instance Methods

- - -
- -
- plan_settings_indicator(plan) - click to toggle source -
- - -
- -

Shows whether the user has default, template-default or custom settings for -the given plan.

- - - -
-
# File app/helpers/plans_helper.rb, line 45
-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
-
- -
- - - - -
- - -
- -
- project_list_body(column, project) - click to toggle source -
- - -
- - - - - -
-
# File app/helpers/plans_helper.rb, line 13
-def project_list_body(column, project)
-  klass, content = case column
-    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') + " (with #{shared_num} people) ") : t('helpers.no')
-      [ '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) || 'Unknown') ]
-    else
-      [ 'dmp_td_small', (project.try(column) || 'Unknown') ]
-  end
-
-  content_tag(:td, content, class: klass)
-end
-
- -
- - - - -
- - -
- -
- project_list_head(column) - click to toggle source -
- - -
- - - - - -
-
# File app/helpers/plans_helper.rb, line 3
-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
-
- -
- - - - -
- - -
- -
- -
- - - - diff --git a/html/Project.html b/html/Project.html deleted file mode 100644 index ca0dd35..0000000 --- a/html/Project.html +++ /dev/null @@ -1,1262 +0,0 @@ - - - - - - -class Project - DMPonline4 Documentation - - - - - - - - - - - - - - - - -
-

class Project

- -
- -
- - - - -
- - - - - - - - - - -
-

Public Class Methods

- - -
- -
- projects_for_user(user_id) - click to toggle source -
- - -
- - - - - -
-
# File app/models/project.rb, line 142
-def self.projects_for_user(user_id)
-        projects = Array.new
-        groups = ProjectGroup.where("user_id = ?", user_id)
-        unless groups.nil? then
-                groups.each do |group|
-                        unless group.project.nil? then
-                                projects << group.project
-                        end
-                end
-        end
-        return projects
-end
-
- -
- - - - -
- - -
- -
-

Public Instance Methods

- - -
- -
- administerable_by(user_id) - click to toggle source -
- - -
- - - - - -
-
# File app/models/project.rb, line 115
-def administerable_by(user_id)
-        user = project_groups.find_by_user_id(user_id)
-        if (! user.nil?) && user.project_administrator then
-                return true
-        else
-                return false
-        end
-end
-
- -
- - - - -
- - -
- -
- assign_administrator(user_id) - click to toggle source -
- - -
- - - - - -
-
# File app/models/project.rb, line 111
-def assign_administrator(user_id)
-        add_user(user_id, true, true)
-end
-
- -
- - - - -
- - -
- -
- assign_creator(user_id) - click to toggle source -
- - -
- - - - - -
-
# File app/models/project.rb, line 99
-def assign_creator(user_id)
-        add_user(user_id, true, true, true)
-end
-
- -
- - - - -
- - -
- -
- assign_editor(user_id) - click to toggle source -
- - -
- - - - - -
-
# File app/models/project.rb, line 103
-def assign_editor(user_id)
-        add_user(user_id, true)
-end
-
- -
- - - - -
- - -
- -
- assign_reader(user_id) - click to toggle source -
- - -
- - - - - -
-
# File app/models/project.rb, line 107
-def assign_reader(user_id)
-        add_user(user_id)
-end
-
- -
- - - - -
- - -
- -
- created_by(user_id) - click to toggle source -
- - -
- - - - - -
-
# File app/models/project.rb, line 155
-def created_by(user_id)
-        user = project_groups.find_by_user_id(user_id)
-        if (! user.nil?) && user.project_creator then
-                return true
-        else
-                return false
-        end
-end
-
- -
- - - - -
- - -
- -
- editable_by(user_id) - click to toggle source -
- - -
- - - - - -
-
# File app/models/project.rb, line 124
-def editable_by(user_id)
-        user = project_groups.find_by_user_id(user_id)
-        if (! user.nil?) && user.project_editor then
-                return true
-        else
-                return false
-        end
-end
-
- -
- - - - -
- - -
- -
- funder() - click to toggle source -
- - -
- - - - - -
-
# File app/models/project.rb, line 39
-def funder
-        if dmptemplate.nil? then
-                return nil
-        end
-        template_org = dmptemplate.organisation
-        if template_org.organisation_type.name == I18n.t('helpers.org_type.funder').downcase
-                return template_org
-        else
-                return nil
-        end
-end
-
- -
- - - - -
- - -
- -
- funder_id() - click to toggle source -
- - -
- - - - - -
-
# File app/models/project.rb, line 27
-def funder_id
-        if dmptemplate.nil? then
-                return nil
-        end
-        template_org = dmptemplate.organisation
-        if template_org.organisation_type.name == I18n.t('helpers.org_type.funder').downcase
-                return template_org.id
-        else
-                return nil
-        end
-end
-
- -
- - - - -
- - -
- -
- funder_id=(new_funder_id) - click to toggle source -
- - -
- - - - - -
-
# File app/models/project.rb, line 18
-def funder_id=(new_funder_id)
-        if new_funder_id != "" then
-                new_funder = Organisation.find(new_funder_id);
-                if new_funder.dmptemplates.count == 1 then
-                        dmptemplate = new_funder.dmptemplates.first
-                end
-        end
-end
-
- -
- - - - -
- - -
- -
- funder_name() - click to toggle source -
- - -
- - - - - -
-
# File app/models/project.rb, line 51
-def funder_name
-        if self.funder.nil?
-                return read_attribute(:funder_name)
-        else
-                return self.funder.name
-        end
-end
-
- -
- - - - -
- - -
- -
- funder_name=(new_funder_name) - click to toggle source -
- - -
- - - - - -
-
# File app/models/project.rb, line 59
-def funder_name=(new_funder_name)
-        write_attribute(:funder_name, new_funder_name)
-        org_table = Organisation.arel_table
-        existing_org = Organisation.where(org_table[:name].matches(new_funder_name))
-        if existing_org.nil?
-                existing_org = Organisation.where(org_table[:abbreviation].matches(new_funder_name))
-        end
-        unless existing_org.empty?
-                self.funder_id=existing_org.id
-        end
-end
-
- -
- - - - -
- - -
- -
- institution_id() - click to toggle source -
- - -
- - - - - -
-
# File app/models/project.rb, line 77
-def institution_id
-        if organisation.nil?
-                return nil
-        else
-                return organisation.root.id
-        end
-end
-
- -
- - - - -
- - -
- -
- institution_id=(new_institution_id) - click to toggle source -
- - -
- - - - - -
-
# File app/models/project.rb, line 71
-def institution_id=(new_institution_id)
-        if organisation.nil? then
-                self.organisation_id = new_institution_id
-        end
-end
-
- -
- - - - -
- - -
- -
- last_edited() - click to toggle source -
- - -
- - - - - -
-
# File app/models/project.rb, line 183
-def last_edited
-        self.latest_update.to_date
-end
-
- -
- - - - -
- - -
- -
- latest_update() - click to toggle source -
- - -
- - - - - -
-
# File app/models/project.rb, line 164
-def latest_update
-        latest_update = updated_at
-        plans.each do |plan|
-                if plan.latest_update > latest_update then
-                        latest_update = plan.latest_update
-                end
-        end
-        return latest_update
-end
-
- -
- - - - -
- - -
- -
- name() - click to toggle source -
- - -
- -

Getters to match 'My plans' columns

- - - -
-
# File app/models/project.rb, line 175
-def name
-        self.title
-end
-
- -
- - - - -
- - -
- -
- owner() - click to toggle source -
- - -
- - - - - -
-
# File app/models/project.rb, line 179
-def owner
-        self.project_groups.find_by_project_creator(true).try(:user)
-end
-
- -
- - - - -
- - -
- -
- readable_by(user_id) - click to toggle source -
- - -
- - - - - -
-
# File app/models/project.rb, line 133
-def readable_by(user_id)
-        user = project_groups.find_by_user_id(user_id)
-        if (! user.nil?) then
-                return true
-        else
-                return false
-        end
-end
-
- -
- - - - -
- - -
- -
- shared() - click to toggle source -
- - -
- - - - - -
- - - - -
- Alias for: shared? -
- -
- - -
- -
- shared?() - click to toggle source -
- - -
- - - - - -
-
# File app/models/project.rb, line 187
-def shared?
-        self.project_groups.count > 1
-end
-
- -
- - -
- Also aliased as: shared -
- - - -
- - -
- -
- template_owner() - click to toggle source -
- - -
- - - - - -
-
# File app/models/project.rb, line 193
-def template_owner
-        self.dmptemplate.try(:organisation).try(:abbreviation)
-end
-
- -
- - - - -
- - -
- -
- unit_id() - click to toggle source -
- - -
- - - - - -
-
# File app/models/project.rb, line 91
-def unit_id
-        if organisation.nil? || organisation.parent_id.nil?
-                return nil
-        else
-                return organisation_id
-        end
-end
-
- -
- - - - -
- - -
- -
- unit_id=(new_unit_id) - click to toggle source -
- - -
- - - - - -
-
# File app/models/project.rb, line 85
-def unit_id=(new_unit_id)
-        unless new_unit_id.nil? ||new_unit_id == ""
-                self.organisation_id = new_unit_id
-        end
-end
-
- -
- - - - -
- - -
- -
-

Private Instance Methods

- - -
- -
- add_user(user_id, is_editor = false, is_administrator = false, is_creator = false) - click to toggle source -
- - -
- - - - - -
-
# File app/models/project.rb, line 199
-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
-
- -
- - - - -
- - -
- -
- create_plans() - click to toggle source -
- - -
- - - - - -
-
# File app/models/project.rb, line 208
-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
-
- -
- - - - -
- - -
- -
- -
- - - - diff --git a/html/ProjectGroup.html b/html/ProjectGroup.html deleted file mode 100644 index 70c5421..0000000 --- a/html/ProjectGroup.html +++ /dev/null @@ -1,441 +0,0 @@ - - - - - - -class ProjectGroup - DMPonline4 Documentation - - - - - - - - - - - - - - - - -
-

class ProjectGroup

- -
- -
- - - - -
- - - - - - - - - - -
-

Public Instance Methods

- - -
- -
- access_level() - click to toggle source -
- - -
- - - - - -
-
# File app/models/project_group.rb, line 21
-def access_level
-        if project_administrator then
-                return 3
-        elsif project_editor then
-                return 2
-        else
-                return 1
-        end
-end
-
- -
- - - - -
- - -
- -
- access_level=(new_access_level) - click to toggle source -
- - -
- - - - - -
-
# File app/models/project_group.rb, line 31
-def access_level=(new_access_level)
-        new_access_level = new_access_level.to_i
-        if new_access_level >= 3 then
-                project_administrator = true
-        else
-                project_administrator = false
-        end
-        if new_access_level >= 2 then
-                project_editor = true
-        else
-                project_editor = false
-        end
-end
-
- -
- - - - -
- - -
- -
- email() - click to toggle source -
- - -
- - - - - -
-
# File app/models/project_group.rb, line 9
-def email
-        unless user.nil? 
-                return user.email
-        end
-end
-
- -
- - - - -
- - -
- -
- email=(new_email) - click to toggle source -
- - -
- - - - - -
-
# File app/models/project_group.rb, line 15
-def email=(new_email)
-        unless User.find_by_email(email).nil? then
-                user = User.find_by_email(email)
-        end
-end
-
- -
- - - - -
- - -
- -
- -
- - - - diff --git a/html/ProjectGroupsController.html b/html/ProjectGroupsController.html deleted file mode 100644 index 96cea38..0000000 --- a/html/ProjectGroupsController.html +++ /dev/null @@ -1,473 +0,0 @@ - - - - - - -class ProjectGroupsController - DMPonline4 Documentation - - - - - - - - - - - - - - - - -
-

class ProjectGroupsController

- -
- -
- - - - -
- - - - - - - - - - -
-

Public Instance Methods

- - -
- -
- create() - click to toggle source -
- - -
- - - - - -
-
# File app/controllers/project_groups_controller.rb, line 3
-def create
-        @project_group = ProjectGroup.new(params[:project_group])
-        access_level = params[:project_group][:access_level].to_i
-        if access_level >= 3 then
-                @project_group.project_administrator = true
-        end
-        if access_level >= 2 then
-                @project_group.project_editor = true
-        end
-        if (user_signed_in?) && @project_group.project.administerable_by(current_user.id) then
-                respond_to do |format|
-                        if params[:project_group][:email].present? && params[:project_group][:email].length > 0 then
-                                message = 'User added to project'
-                                if @project_group.save
-                                        if @project_group.user.nil? then
-                                                if User.find_by_email(params[:project_group][:email]).nil? then
-                                                        User.invite!(:email => params[:project_group][:email])
-                                                        message = 'Invitation issued successfully.'
-                                                        @project_group.user = User.find_by_email(params[:project_group][:email])
-                                                        @project_group.save
-                                                else
-                                                        @project_group.user = User.find_by_email(params[:project_group][:email])
-                                                        @project_group.save
-                                                        UserMailer.sharing_notification(@project_group).deliver
-                                                        logger.debug("Email sent from here?")
-                                                end
-                                        else
-                                                UserMailer.sharing_notification(@project_group).deliver
-                                                logger.debug("Email sent from there?")
-                                        end
-                                        flash[:notice] = message
-                                        format.html { redirect_to :controller => 'projects', :action => 'share', :id => @project_group.project.slug }
-                                        format.json { render json: @project_group, status: :created, location: @project_group }
-                                else
-                                        format.html { render action: "new" }
-                                        format.json { render json: @project_group.errors, status: :unprocessable_entity }
-                                end
-                        else
-                                flash[:notice] = "Please enter an email address"
-                                format.html { redirect_to :controller => 'projects', :action => 'share', :id => @project_group.project.slug }
-                                format.json { render json: @project_group, status: :created, location: @project_group }
-                        end
-                end                  
-        else
-                render(:file => File.join(Rails.root, 'public/403.html'), :status => 403, :layout => false)
-        end
-        
-end
-
- -
- - - - -
- - -
- -
- destroy() - click to toggle source -
- - -
- - - - - -
-
# File app/controllers/project_groups_controller.rb, line 82
-def destroy
-        @project_group = ProjectGroup.find(params[:id])
-        if (user_signed_in?) && @project_group.project.administerable_by(current_user.id) then
-                user = @project_group.user
-                project = @project_group.project
-                @project_group.destroy
-                respond_to do |format|
-                        flash[:notice] = 'Access removed'
-                        UserMailer.project_access_removed_notification(user, project).deliver
-                        format.html { redirect_to :controller => 'projects', :action => 'share', :id => @project_group.project.slug }
-                        format.json { head :no_content }
-                end
-        else
-                render(:file => File.join(Rails.root, 'public/403.html'), :status => 403, :layout => false)
-        end
-end
-
- -
- - - - -
- - -
- -
- update() - click to toggle source -
- - -
- - - - - -
-
# File app/controllers/project_groups_controller.rb, line 52
-def update
-@project_group = ProjectGroup.find(params[:id])
-access_level = params[:project_group][:access_level].to_i
-        if access_level >= 3 then
-                @project_group.project_administrator = true
-        else
-                @project_group.project_administrator = false
-        end
-        if access_level >= 2 then
-                @project_group.project_editor = true
-        else
-                @project_group.project_editor = false
-        end
-if (user_signed_in?) && @project_group.project.administerable_by(current_user.id) then
-                respond_to do |format|
-                        if @project_group.update_attributes(params[:project_group])
-                                flash[:notice] = 'Sharing details successfully updated.'
-                                UserMailer.permissions_change_notification(@project_group).deliver
-                                format.html { redirect_to :controller => 'projects', :action => 'share', :id => @project_group.project.slug }
-                                format.json { head :no_content }
-                        else
-                                format.html { render action: "edit" }
-                                format.json { render json: @project_group.errors, status: :unprocessable_entity }
-                         end
-                end
-else
-                render(:file => File.join(Rails.root, 'public/403.html'), :status => 403, :layout => false)
-        end
-end
-
- -
- - - - -
- - -
- -
- -
- - - - diff --git a/html/ProjectPartner.html b/html/ProjectPartner.html deleted file mode 100644 index 07f619b..0000000 --- a/html/ProjectPartner.html +++ /dev/null @@ -1,279 +0,0 @@ - - - - - - -class ProjectPartner - DMPonline4 Documentation - - - - - - - - - - - - - - - - -
-

class ProjectPartner

- -
- -
- - - - -
- - - - - - - - - - -
- -
- - - - diff --git a/html/ProjectsController.html b/html/ProjectsController.html deleted file mode 100644 index 3d7254b..0000000 --- a/html/ProjectsController.html +++ /dev/null @@ -1,908 +0,0 @@ - - - - - - -class ProjectsController - DMPonline4 Documentation - - - - - - - - - - - - - - - - -
-

class ProjectsController

- -
- -
- - - - -
- - - - - - - - - - -
-

Public Instance Methods

- - -
- -
- create() - click to toggle source -
- - -
- -

POST /projects POST /projects.json

- - - -
-
# File app/controllers/projects_controller.rb, line 113
-def create
-if user_signed_in? then
-                @project = Project.new(params[:project])
-                if @project.dmptemplate.nil? && params[:project][:funder_id] != "" then # this shouldn't be necessary - see setter for funder_id in project.rb
-
-                        funder = Organisation.find(params[:project][:funder_id])
-                        if funder.dmptemplates.count == 1 then
-                                @project.dmptemplate = funder.published_templates.first
-                        end
-                elsif @project.dmptemplate.nil? || params[:default_tag] == 'true' then
-                        if @project.organisation.nil?  || params[:default_tag] == 'true'  || @project.organisation.published_templates.first.nil? then
-                                @project.dmptemplate = Dmptemplate.find_by_is_default(true)
-                        else
-                                @project.dmptemplate = @project.organisation.published_templates.first
-                        end
-                end
-                @project.principal_investigator = current_user.name(false)
-                @project.title = I18n.t('helpers.project.my_project_name')+' ('+@project.dmptemplate.title+')'
-                @project.assign_creator(current_user.id)
-                respond_to do |format|
-                        if @project.save
-                                format.html { redirect_to({:action => "show", :id => @project.slug, :show_form => "yes"}, {:notice => I18n.t('helpers.project.success')}) }
-                                format.json { render json: @project, status: :created, location: @project }
-                        else
-                                format.html { render action: "new" }
-                                format.json { render json: @project.errors, status: :unprocessable_entity }
-                        end
-                end
-        else
-                render(:file => File.join(Rails.root, 'public/403.html'), :status => 403, :layout => false)
-        end
-end
-
- -
- - - - -
- - -
- -
- destroy() - click to toggle source -
- - -
- -

DELETE /projects/1 DELETE /projects/1.json

- - - -
-
# File app/controllers/projects_controller.rb, line 166
-def destroy
-        @project = Project.find(params[:id])
-        if user_signed_in? && @project.editable_by(current_user.id) then
-                @project.destroy
-
-                respond_to do |format|
-                        format.html { redirect_to projects_url }
-                        format.json { head :no_content }
-                end
-        else
-                render(:file => File.join(Rails.root, 'public/403.html'), :status => 403, :layout => false)
-        end
-end
-
- -
- - - - -
- - -
- -
- edit() - click to toggle source -
- - -
- -

GET /projects/1/edit Should this be removed?

- - - -
-
# File app/controllers/projects_controller.rb, line 71
-def edit
-        @project = Project.find(params[:id])
-        if !user_signed_in? then
-       respond_to do |format|
-                        format.html { redirect_to edit_user_registration_path }
-                end
-        elsif !@project.editable_by(current_user.id) then
-                respond_to do |format|
-                        format.html { redirect_to projects_url, notice: "This account does not have access to that plan." }
-                end
-        end
-end
-
- -
- - - - -
- - -
- -
- export() - click to toggle source -
- - -
- - - - - -
-
# File app/controllers/projects_controller.rb, line 97
-def export
-        @project = Project.find(params[:id])
-        if !user_signed_in? then
-       respond_to do |format|
-                        format.html { redirect_to edit_user_registration_path }
-                end
-        else 
-                respond_to do |format|
-                        format.html { render action: "export" }
-        
-                end
-        end
-end
-
- -
- - - - -
- - -
- -
- index() - click to toggle source -
- - -
- -

GET /projects GET /projects.json

- - - -
-
# File app/controllers/projects_controller.rb, line 6
-def index
-        if user_signed_in? then
-                if (current_user.shibboleth_id.nil? || current_user.shibboleth_id.length == 0) && !cookies[:show_shib_link].nil? && cookies[:show_shib_link] == "show_shib_link" then
-                        flash.notice = "Would you like to #{view_context.link_to 'link your DMPonline account to your institutional credentials?', user_omniauth_shibboleth_path}".html_safe
-                end
-
-                @projects = current_user.projects.filter(params[:filter])
-                @has_projects = current_user.projects.any? # unfiltered count
-
-
-                respond_to do |format|
-                        format.html # index.html.erb
-
-                        format.json { render json: @projects }
-                end
-        else
-                respond_to do |format|
-                        format.html { redirect_to edit_user_registration_path }
-                end
-        end
-end
-
- -
- - - - -
- - -
- -
- new() - click to toggle source -
- - -
- -

GET /projects/new GET /projects/new.json

- - - -
-
# File app/controllers/projects_controller.rb, line 52
-def new
-        if user_signed_in? then
-                @project = Project.new
-                @project.organisation = current_user.organisation
-                @funders = orgs_of_type(t('helpers.org_type.funder'), true)
-                @institutions = orgs_of_type(t('helpers.org_type.institution'))
-                respond_to do |format|
-                  format.html # new.html.erb
-
-                  format.json { render json: @project }
-                end
-        else
-                respond_to do |format|
-                        format.html { redirect_to edit_user_registration_path }
-                end
-        end
-end
-
- -
- - - - -
- - -
- -
- possible_guidance() - click to toggle source -
- - -
- - - - - -
-
# File app/controllers/projects_controller.rb, line 213
-def possible_guidance
-        if !params[:template].nil? && params[:template] != "" && params[:template] != "undefined" then
-                template = Dmptemplate.find(params[:template])
-        else
-                template = nil
-        end
-        if !params[:institution].nil? && params[:institution] != "" && params[:institution] != "undefined" then
-                institution = Organisation.find(params[:institution])
-        else
-                institution = nil
-        end
-        excluded_orgs = orgs_of_type(t('helpers.org_type.funder')) + orgs_of_type(t('helpers.org_type.institution')) + Organisation.orgs_with_parent_of_type(t('helpers.org_type.institution'))
-        guidance_groups = {}
-        ggs = GuidanceGroup.guidance_groups_excluding(excluded_orgs) 
-
-        ggs.each do |gg|
-                guidance_groups[gg.id] = gg.name
-        end
-
-#subset guidance that belong to the institution
-
-        unless institution.nil? then
-                optional_gg = GuidanceGroup.where("optional_subset =  ? && organisation_id = ?", true, institution.id)
-                optional_gg.each do|optional|
-                        guidance_groups[optional.id] = optional.name
-                end
-                
-                institution.children.each do |o|
-                        o.guidance_groups.each do |gg|
-                                include = false
-                                gg.guidances.each do |g|
-                                        if g.dmptemplate.nil? || g.dmptemplate_id == template.id then
-                                                include = true
-                                                break
-                                        end
-                                end
-                                if include then
-                                        guidance_groups[gg.id] = gg.name
-                                end
-                        end
-                end
-        end
-
-#If template belongs to a funder and that funder has subset guidance display then.
-
-if !template.nil? && template.organisation.organisation_type.name == t('helpers.org_type.funder') then
-    optional_gg = GuidanceGroup.where("optional_subset =  ? && organisation_id = ?", true, template.organisation_id)
-                optional_gg.each do|optional|
-                        guidance_groups[optional.id] = optional.name
-                end
-end
-
-
-        respond_to do |format|
-                format.json { render json: guidance_groups.to_json }
-        end
-end
-
- -
- - - - -
- - -
- -
- possible_templates() - click to toggle source -
- - -
- -

GET /projects/possible_templates.json

- - - -
-
# File app/controllers/projects_controller.rb, line 181
-def possible_templates
-        if !params[:funder].nil? && params[:funder] != "" && params[:funder] != "undefined" then
-                funder = Organisation.find(params[:funder])
-        else
-                funder = nil
-        end
-        if !params[:institution].nil? && params[:institution] != "" && params[:institution] != "undefined" then
-                institution = Organisation.find(params[:institution])
-        else
-                institution = nil
-        end
-        templates = {}
-        unless funder.nil? then
-                funder.published_templates.each do |t|
-                        templates[t.id] = t.title
-                end
-        end
-        if templates.count == 0 && !institution.nil? then
-                institution.published_templates.each do |t|
-                        templates[t.id] = t.title
-                end
-                institution.children.each do |o|
-                        o.published_templates.each do |t|
-                                templates[t.id] = t.title
-                        end
-                end
-        end
-        respond_to do |format|
-                format.json { render json: templates.to_json }
-        end
-end
-
- -
- - - - -
- - -
- -
- share() - click to toggle source -
- - -
- - - - - -
-
# File app/controllers/projects_controller.rb, line 84
-def share
-        @project = Project.find(params[:id])
-        if !user_signed_in? then
-       respond_to do |format|
-                        format.html { redirect_to edit_user_registration_path }
-                end
-        elsif !@project.editable_by(current_user.id) then
-                respond_to do |format|
-                        format.html { redirect_to projects_url, notice: "This account does not have access to that plan." }
-                end
-        end
-end
-
- -
- - - - -
- - -
- -
- show() - click to toggle source -
- - -
- -

GET /projects/1 GET /projects/1.json

- - - -
-
# File app/controllers/projects_controller.rb, line 28
-def show
-        @project = Project.find(params[:id])
-        @show_form = false
-        if params[:show_form] == "yes" then
-                @show_form = true
-        end
-        if user_signed_in? && @project.readable_by(current_user.id) then
-                respond_to do |format|
-                        format.html # show.html.erb
-
-                        format.json { render json: @project }
-                end
-        elsif user_signed_in? then
-                respond_to do |format|
-                        format.html { redirect_to projects_url, notice: "This account does not have access to that plan." }
-                end
-        else
-                respond_to do |format|
-                        format.html { redirect_to edit_user_registration_path }
-                end
-        end
-end
-
- -
- - - - -
- - -
- -
- update() - click to toggle source -
- - -
- -

PUT /projects/1 PUT /projects/1.json

- - - -
-
# File app/controllers/projects_controller.rb, line 147
-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: 'Project was successfully updated.' }
-                                format.json { head :no_content }
-                        else
-                                format.html { render action: "edit" }
-                                format.json { render json: @project.errors, status: :unprocessable_entity }
-                        end
-                end
-        else
-                render(:file => File.join(Rails.root, 'public/403.html'), :status => 403, :layout => false)
-        end
-end
-
- -
- - - - -
- - -
- -
-

Private Instance Methods

- - -
- -
- orgs_of_type(org_type_name, published_templates = false) - click to toggle source -
- - -
- - - - - -
-
# File app/controllers/projects_controller.rb, line 271
-def orgs_of_type(org_type_name, published_templates = false)
-        org_type = OrganisationType.find_by_name(org_type_name)
-        all_such_orgs = org_type.organisations
-        if published_templates then
-                with_published = Array.new
-                all_such_orgs.each do |o|
-                        if o.published_templates.count > 0 then
-                                with_published << o
-                        end
-                end
-                return with_published.sort_by {|o| [o.sort_name, o.name] }
-        else
-                return all_such_orgs.sort_by {|o| [o.sort_name, o.name] }
-        end
-end
-
- -
- - - - -
- - -
- -
- -
- - - - diff --git a/html/Question.html b/html/Question.html deleted file mode 100644 index a45775f..0000000 --- a/html/Question.html +++ /dev/null @@ -1,470 +0,0 @@ - - - - - - -class Question - DMPonline4 Documentation - - - - - - - - - - - - - - - - -
-

class Question

- -
- -
- - - - -
- - - - - - - - - - -
-

Public Instance Methods

- - -
- -
- get_suggested_answer(org_id) - click to toggle source -
- - -
- -

get suggested answer belonging to the currents user for this question

- - - -
-
# File app/models/question.rb, line 99
-def get_suggested_answer(org_id)
-        suggested_answer = suggested_answers.find_by_organisation_id(org_id)
-        return suggested_answer
-end
-
- -
- - - - -
- - -
- -
- guidance_for_question(question, org_admin) - click to toggle source -
- - -
- -

guidance for question in the org admin

- - - -
-
# File app/models/question.rb, line 69
-def guidance_for_question(question, org_admin)
-# pulls together guidance from various sources for question
-
-guidances = {}
-theme_ids = question.theme_ids
-
-GuidanceGroup.where("organisation_id = ?", org_admin.id).each do |group|
-    group.guidances.each do |g|
-        g.themes.where("id IN (?)", theme_ids).each do |gg|
-           guidances["#{group.name} guidance on #{gg.title}"] = g
-        end
-    end
-end
-
-       # Guidance link to directly to a question
-
-question.guidances.each do |g_by_q|
-    g_by_q.guidance_groups.each do |group|
-        if group.organisation == org_admin
-            guidances["#{group.name} guidance for this question"] = g_by_q
-        end
-    end
-       end
-
-        return guidances
-end
-
- -
- - - - -
- - -
- -
- question_themes?() - click to toggle source -
- - -
- -

def question_type?

- -
type_label = {}
-if self.is_text_field?
-  type_label = 'Text field'
-elsif self.multiple_choice?
-        type_label = 'Multiple choice'
-else
-        type_label = 'Text area'
-end
-return type_label
- -

end

- - - -
-
# File app/models/question.rb, line 51
-def question_themes?
-        themes_label = {}
-        i = 1
-        themes_quest = self.themes
-
-        themes_quest.each do |tt|
-                themes_label = tt.title
-
-                if themes_quest.count > i then
-                        themes_label +=     ','
-                        i +=1
-                end
-        end
-
-        return themes_label
-end
-
- -
- - - - -
- - -
- -
- to_s() - click to toggle source -
- - -
- - - - - -
-
# File app/models/question.rb, line 29
-    def to_s
-    "#{text}"
-end
-
- -
- - - - -
- - -
- -
- -
- - - - diff --git a/html/QuestionFormat.html b/html/QuestionFormat.html deleted file mode 100644 index 7d098d1..0000000 --- a/html/QuestionFormat.html +++ /dev/null @@ -1,325 +0,0 @@ - - - - - - -class QuestionFormat - DMPonline4 Documentation - - - - - - - - - - - - - - - - -
-

class QuestionFormat

- -
- -
- - - - -
- - - - - - - - - - -
-

Public Instance Methods

- - -
- -
- to_s() - click to toggle source -
- - -
- - - - - -
-
# File app/models/question_format.rb, line 7
- def to_s
-  "#{title}"
-end
-
- -
- - - - -
- - -
- -
- -
- - - - diff --git a/html/README_rdoc.html b/html/README_rdoc.html deleted file mode 100644 index 1100184..0000000 --- a/html/README_rdoc.html +++ /dev/null @@ -1,311 +0,0 @@ - - - - - - -README - DMPonline4 Documentation - - - - - - - - - - - - - - - - -
- -

DMPonline v4

- -

DMPonline is the DCC's data management planning tool, available at dmponline.dcc.ac.uk

- -

Development of the DMPonline by the Digital Curation Centre has been funded -by JISC. JISC inspires UK colleges and universities in the innovative use -of digital technologies, helping to maintain the UK's position as a -global leader in education. www.jisc.ac.uk

- -

This is just the application code, the accompanying question data available -at dmponline.dcc.ac.uk is not -included.

- -

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.

    -
- -

Documentation & Support

- - -

Bugs & Feature Requests

- - -

Prerequisites

- -

DMPonline is a Ruby on Rails application and you will need to have Ruby -2.0.0p247 or greater installed on your server and a MySQL server v5.0 or -greater.

- -

Further details on how to install Ruby on Rails applications are available -from the Ruby on Rails site, rubyonrails.org

- -

You may also find the following resources handy:

- - - - -

Copyright © 2013 Digital Curation Centre, University of Edinburgh.

- -

This program is free software: you can redistribute it and/or modify it -under the terms of the GNU Affero General Public License as published by -the Free Software Foundation, either version 3 of the License, or (at your -option) any later version.

- -

This program is distributed in the hope that it will be useful, but WITHOUT -ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License -for more details.

- -

You should have received a copy of the GNU Affero General Public License -along with this program. If not, see www.gnu.org/licenses.

- -
- - - - - diff --git a/html/RegistrationsController.html b/html/RegistrationsController.html deleted file mode 100644 index c12611d..0000000 --- a/html/RegistrationsController.html +++ /dev/null @@ -1,506 +0,0 @@ - - - - - - -class RegistrationsController - DMPonline4 Documentation - - - - - - - - - - - - - - - - -
-

class RegistrationsController

- -
- -

app/controllers/registrations_controller.rb

- -
- - - - -
- - - - - - - - - - -
-

Public Instance Methods

- - -
- -
- create() - click to toggle source -
- - -
- -

POST /resource

- - - -
-
# File app/controllers/registrations_controller.rb, line 6
-def create
-      if sign_up_params[:accept_terms] != "1" then
-        redirect_to after_sign_up_error_path_for(resource), alert: 'You must accept the terms and conditions to register.'
-      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
-                              @user = existing_user
-                              do_update(false, true)
-                      else
-                          redirect_to after_sign_up_error_path_for(resource), alert: 'That email address is already registered.'
-                      end
-              else
-                      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)
-                        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)
-                        end
-                      else
-                        clean_up_passwords resource
-                        redirect_to after_sign_up_error_path_for(resource), alert: 'Error processing registration. Please check that you have entered a valid email address and that your chosen password is at least 8 characters long.'
-                      end
-              end
-  end
-end
-
- -
- - - - -
- - -
- -
- update() - click to toggle source -
- - -
- - - - - -
-
# File app/controllers/registrations_controller.rb, line 39
-def update
-       if user_signed_in? then
-               @user = User.find(current_user.id)
-
-       do_update
-   else
-       render(:file => File.join(Rails.root, 'public/403.html'), :status => 403, :layout => false)
-   end
- end
-
- -
- - - - -
- - -
- -
-

Private Instance Methods

- - -
- -
- do_update(require_password = true, confirm = false) - click to toggle source -
- - -
- - - - - -
-
# File app/controllers/registrations_controller.rb, line 59
-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])
-    else
-      # remove the virtual current_password attribute update_without_password
-
-      # doesn't know how to ignore it
-
-      params[:user].delete(:current_password)
-      @user.update_without_password(params[:user])
-    end
-  else
-      @user.update_attributes(:password => params[:user][:password], :password_confirmation => params[:user][:password_confirmation])
-      successfully_updated = @user.update_without_password(params[:user])
-  end
-
-  #unlink shibboleth from user's details
-
-  if params[:unlink_flag] == 'true' then
-    @user.update_attributes(:shibboleth_id => "")
-  end
-
-  if successfully_updated
-              if confirm then
-                      @user.skip_confirmation!
-                      @user.save!
-              end
-      set_flash_message :notice, :updated
-      # Sign in the user bypassing validation in case his password changed
-
-      sign_in @user, :bypass => true
-      
-      if params[:unlink_flag] == 'true' then
-          redirect_to({:controller => "registrations", :action => "edit"}, {:notice => "Details successfully updated."})
-      else
-          redirect_to({:controller => "projects", :action => "index"}, {:notice => "Details successfully updated."})
-      end
-
-  else
-    render "edit"
-  end
-end
-
- -
- - - - -
- - -
- -
- needs_password?(user, params) - click to toggle source -
- - -
- -

check if we need password to update user data ie if password or email was -changed extend this as needed

- - - -
-
# File app/controllers/registrations_controller.rb, line 54
-def needs_password?(user, params)
-  user.email != params[:user][:email] ||
-    params[:user][:password].present?
-end
-
- -
- - - - -
- - -
- -
- -
- - - - diff --git a/html/Role.html b/html/Role.html deleted file mode 100644 index 02d87ea..0000000 --- a/html/Role.html +++ /dev/null @@ -1,279 +0,0 @@ - - - - - - -class Role - DMPonline4 Documentation - - - - - - - - - - - - - - - - -
-

class Role

- -
- -
- - - - -
- - - - - - - - - - -
- -
- - - - diff --git a/html/Section.html b/html/Section.html deleted file mode 100644 index 2ad9bcb..0000000 --- a/html/Section.html +++ /dev/null @@ -1,325 +0,0 @@ - - - - - - -class Section - DMPonline4 Documentation - - - - - - - - - - - - - - - - -
-

class Section

- -
- -
- - - - -
- - - - - - - - - - -
-

Public Instance Methods

- - -
- -
- to_s() - click to toggle source -
- - -
- - - - - -
-
# File app/models/section.rb, line 15
-def to_s
-  "#{title}"
-end
-
- -
- - - - -
- - -
- -
- -
- - - - diff --git a/html/SessionsController.html b/html/SessionsController.html deleted file mode 100644 index 163a22b..0000000 --- a/html/SessionsController.html +++ /dev/null @@ -1,375 +0,0 @@ - - - - - - -class SessionsController - DMPonline4 Documentation - - - - - - - - - - - - - - - - -
-

class SessionsController

- -
- -

app/controllers/sessions_controller.rb

- -
- - - - -
- - - - - - - - - - -
-

Public Instance Methods

- - -
- -
- create() - click to toggle source -
- - -
- - - - - -
-
# File app/controllers/sessions_controller.rb, line 4
-def create
-        existing_user = User.find_by_email(params[:user][:email])
-
-if !existing_user.nil? && existing_user.dmponline3 && (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
-
- -
- - - - -
- - -
- -
- destroy() - click to toggle source -
- - -
- - - - - -
-
# File app/controllers/sessions_controller.rb, line 19
-    def destroy
-    current_user.plan_sections.each do |lock|
-        lock.delete
-        
-    end
-    super
-end
-
- -
- - - - -
- - -
- -
- -
- - - - diff --git a/html/Settings.html b/html/Settings.html deleted file mode 100644 index 3cfcfa5..0000000 --- a/html/Settings.html +++ /dev/null @@ -1,277 +0,0 @@ - - - - - - -module Settings - DMPonline4 Documentation - - - - - - - - - - - - - - - - -
-

module Settings

- -
- -
- - - - -
- - - - - - - - - - -
- -
- - - - diff --git a/html/Settings/Dmptemplate.html b/html/Settings/Dmptemplate.html deleted file mode 100644 index ed8991b..0000000 --- a/html/Settings/Dmptemplate.html +++ /dev/null @@ -1,312 +0,0 @@ - - - - - - -class Settings::Dmptemplate - DMPonline4 Documentation - - - - - - - - - - - - - - - - -
-

class Settings::Dmptemplate

- -
- -
- - - - -
- - - - - - -
-

Constants

-
- -
DEFAULT_SETTINGS - -
- - -
VALID_ADMIN_FIELDS - -
- - -
VALID_FONT_FACES - -
- - -
VALID_FONT_SIZE_RANGE - -
- - -
VALID_MARGIN_RANGE - -
- - -
-
- - - - - - -
- -
- - - - diff --git a/html/Settings/PlanList.html b/html/Settings/PlanList.html deleted file mode 100644 index d213468..0000000 --- a/html/Settings/PlanList.html +++ /dev/null @@ -1,297 +0,0 @@ - - - - - - -class Settings::PlanList - DMPonline4 Documentation - - - - - - - - - - - - - - - - -
-

class Settings::PlanList

- -
- -
- - - - -
- - - - - - -
-

Constants

-
- -
ALL_COLUMNS - -
- - -
DEFAULT_COLUMNS - -

TODO: can these be taken from somewhere else rather than hard-coded here?

- - -
-
- - - - - - -
- -
- - - - diff --git a/html/Settings/PlansController.html b/html/Settings/PlansController.html deleted file mode 100644 index 25d458b..0000000 --- a/html/Settings/PlansController.html +++ /dev/null @@ -1,486 +0,0 @@ - - - - - - -class Settings::PlansController - DMPonline4 Documentation - - - - - - - - - - - - - - - - -
-

class Settings::PlansController

- -
- -
- - - - -
- - - - - - - - - - -
-

Public Instance Methods

- - -
- -
- show() - click to toggle source -
- - -
- - - - - -
-
# File app/controllers/settings/plans_controller.rb, line 6
-def show
-  respond_to do |format|
-    format.html
-    format.partial
-    format.json { render json: settings_json }
-  end
-end
-
- -
- - - - -
- - -
- -
- update() - click to toggle source -
- - -
- - - - - -
-
# File app/controllers/settings/plans_controller.rb, line 14
-def update
-
-  export_params = params[:export].try(:deep_symbolize_keys)
-
-  settings = plan.super_settings(:export).tap do |s|
-    if params[:commit] == 'Reset'
-      s.formatting = nil
-      s.fields = nil
-    else
-      s.formatting = export_params[:formatting]
-      s.fields = export_params[:fields]
-      s.title  = export_params[:title]
-    end
-  end
-
-  if settings.save
-    respond_to do |format|
-      format.html { redirect_to(export_project_path(plan.project)) }
-      format.json { render json: settings_json }
-    end
-  else
-    settings.formatting = nil
-    @export_settings = settings
-    render(action: :show)
-  end
-end
-
- -
- - - - -
- - -
- -
-

Private Instance Methods

- - -
- -
- get_settings() - click to toggle source -
- - -
- - - - - -
-
# File app/controllers/settings/plans_controller.rb, line 43
-def get_settings
-  @export_settings = plan.settings(:export)
-end
-
- -
- - - - -
- - -
- -
- plan() - click to toggle source -
- - -
- - - - - -
-
# File app/controllers/settings/plans_controller.rb, line 51
-def plan
-  @plan ||= Plan.find(params[:id])
-end
-
- -
- - - - -
- - -
- -
- settings_json() - click to toggle source -
- - -
- - - - - -
-
# File app/controllers/settings/plans_controller.rb, line 47
-def settings_json
-  @settings_json ||= { export: @export_settings }.to_json
-end
-
- -
- - - - -
- - -
- -
- -
- - - - diff --git a/html/Settings/ProjectsController.html b/html/Settings/ProjectsController.html deleted file mode 100644 index aa17b2f..0000000 --- a/html/Settings/ProjectsController.html +++ /dev/null @@ -1,445 +0,0 @@ - - - - - - -class Settings::ProjectsController - DMPonline4 Documentation - - - - - - - - - - - - - - - - -
-

class Settings::ProjectsController

- -
- -
- - - - -
- - - - - - - - - - -
-

Public Instance Methods

- - -
- -
- show() - click to toggle source -
- - -
- - - - - -
-
# File app/controllers/settings/projects_controller.rb, line 7
-def show
-  respond_to do |format|
-    format.html
-    format.json { render json: settings_json }
-  end
-end
-
- -
- - - - -
- - -
- -
- update() - click to toggle source -
- - -
- - - - - -
-
# File app/controllers/settings/projects_controller.rb, line 14
-def update
-  columns = (params[:columns] || {}).keys.map(&:intern)
-
-  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
-
-  end
-end
-
- -
- - - - -
- - -
- -
-

Private Instance Methods

- - -
- -
- get_settings() - click to toggle source -
- - -
- - - - - -
-
# File app/controllers/settings/projects_controller.rb, line 29
-def get_settings
-  @settings = current_user.settings(:plan_list)
-  # :name column should always be present (displayed as a disabled checkbox)
-
-  # so it's not necessary to include it in the list here
-
-  @all_columns -= [:name]
-end
-
- -
- - - - -
- - -
- -
- settings_json() - click to toggle source -
- - -
- - - - - -
-
# File app/controllers/settings/projects_controller.rb, line 36
-def settings_json
-  @settings_json ||= { selected_columns: @settings.columns, all_columns: @all_columns }.to_json
-end
-
- -
- - - - -
- - -
- -
- -
- - - - diff --git a/html/Settings/SettingsController.html b/html/Settings/SettingsController.html deleted file mode 100644 index 6273362..0000000 --- a/html/Settings/SettingsController.html +++ /dev/null @@ -1,279 +0,0 @@ - - - - - - -class Settings::SettingsController - DMPonline4 Documentation - - - - - - - - - - - - - - - - -
-

class Settings::SettingsController

- -
- -
- - - - -
- - - - - - - - - - -
- -
- - - - diff --git a/html/SplashLog.html b/html/SplashLog.html deleted file mode 100644 index 41ac7d7..0000000 --- a/html/SplashLog.html +++ /dev/null @@ -1,279 +0,0 @@ - - - - - - -class SplashLog - DMPonline4 Documentation - - - - - - - - - - - - - - - - -
-

class SplashLog

- -
- -
- - - - -
- - - - - - - - - - -
- -
- - - - diff --git a/html/SplashLogsController.html b/html/SplashLogsController.html deleted file mode 100644 index b00abb8..0000000 --- a/html/SplashLogsController.html +++ /dev/null @@ -1,337 +0,0 @@ - - - - - - -class SplashLogsController - DMPonline4 Documentation - - - - - - - - - - - - - - - - -
-

class SplashLogsController

- -
- -
- - - - -
- - - - - - - - - - -
-

Public Instance Methods

- - -
- -
- create() - click to toggle source -
- - -
- -

POST /answers POST /answers.json

- - - -
-
# File app/controllers/splash_logs_controller.rb, line 5
-def create
-        @splash_log = SplashLog.new()
-        @splash_log.destination = params[:destination]
-        respond_to do |format|
-                if @splash_log.save
-                        cookies[:dmp_splash_seen] = {
-                                value: 'splash_dialog_seen',
-                                expires: 3.hours.from_now,
-                        }
-                        format.html { redirect_to params[:destination] }
-                else
-                        format.html { redirect_to home_url }
-                end
-        end
-end
-
- -
- - - - -
- - -
- -
- -
- - - - diff --git a/html/StaticPagesController.html b/html/StaticPagesController.html deleted file mode 100644 index 65858ab..0000000 --- a/html/StaticPagesController.html +++ /dev/null @@ -1,392 +0,0 @@ - - - - - - -class StaticPagesController - DMPonline4 Documentation - - - - - - - - - - - - - - - - -
-

class StaticPagesController

- -
- -
- - - - -
- - - - - - - - - - -
-

Public Instance Methods

- - -
- -
- about_us() - click to toggle source -
- - -
- - - - - -
-
# File app/controllers/static_pages_controller.rb, line 3
-def about_us
-    dcc_news_feed_url = "http://www.dcc.ac.uk/news/dmponline-0/feed"
-      @dcc_news_feed = Feedzirra::Feed.fetch_and_parse(dcc_news_feed_url)
-      respond_to do |format|
-          format.rss { redirect_to dcc_news_feed_url }
-          format.html
-      end
-end
-
- -
- - - - -
- - -
- -
- contact_us() - click to toggle source -
- - -
- - - - - -
-
# File app/controllers/static_pages_controller.rb, line 12
-def contact_us
-end
-
- -
- - - - -
- - -
- -
- roadmap() - click to toggle source -
- - -
- - - - - -
-
# File app/controllers/static_pages_controller.rb, line 15
-def roadmap
-end
-
- -
- - - - -
- - -
- -
- -
- - - - diff --git a/html/SuggestedAnswer.html b/html/SuggestedAnswer.html deleted file mode 100644 index 707f287..0000000 --- a/html/SuggestedAnswer.html +++ /dev/null @@ -1,325 +0,0 @@ - - - - - - -class SuggestedAnswer - DMPonline4 Documentation - - - - - - - - - - - - - - - - -
-

class SuggestedAnswer

- -
- -
- - - - -
- - - - - - - - - - -
-

Public Instance Methods

- - -
- -
- to_s() - click to toggle source -
- - -
- - - - - -
-
# File app/models/suggested_answer.rb, line 11
-      def to_s
-  "#{text}"
-end
-
- -
- - - - -
- - -
- -
- -
- - - - diff --git a/html/Theme.html b/html/Theme.html deleted file mode 100644 index 5cb3a3a..0000000 --- a/html/Theme.html +++ /dev/null @@ -1,325 +0,0 @@ - - - - - - -class Theme - DMPonline4 Documentation - - - - - - - - - - - - - - - - -
-

class Theme

- -
- -
- - - - -
- - - - - - - - - - -
-

Public Instance Methods

- - -
- -
- to_s() - click to toggle source -
- - -
- - - - - -
-
# File app/models/theme.rb, line 15
-def to_s
-      title
-end
-
- -
- - - - -
- - -
- -
- -
- - - - diff --git a/html/ThemesController.html b/html/ThemesController.html deleted file mode 100644 index 425e06a..0000000 --- a/html/ThemesController.html +++ /dev/null @@ -1,561 +0,0 @@ - - - - - - -class ThemesController - DMPonline4 Documentation - - - - - - - - - - - - - - - - -
-

class ThemesController

- -
- -
- - - - -
- - - - - - - - - - -
-

Public Instance Methods

- - -
- -
- create() - click to toggle source -
- - -
- -

POST /themes POST /themes.json

- - - -
-
# File app/controllers/themes_controller.rb, line 42
-def create
-  @theme = Theme.new(params[:theme])
-
-  respond_to do |format|
-    if @theme.save
-      format.html { redirect_to @theme, notice: 'Theme was successfully created.' }
-      format.json { render json: @theme, status: :created, location: @theme }
-    else
-      format.html { render action: "new" }
-      format.json { render json: @theme.errors, status: :unprocessable_entity }
-    end
-  end
-end
-
- -
- - - - -
- - -
- -
- destroy() - click to toggle source -
- - -
- -

DELETE /themes/1 DELETE /themes/1.json

- - - -
-
# File app/controllers/themes_controller.rb, line 74
-def destroy
-  @theme = Theme.find(params[:id])
-  @theme.destroy
-
-  respond_to do |format|
-    format.html { redirect_to themes_url }
-    format.json { head :no_content }
-  end
-end
-
- -
- - - - -
- - -
- -
- edit() - click to toggle source -
- - -
- -

GET /themes/1/edit

- - - -
-
# File app/controllers/themes_controller.rb, line 36
-def edit
-  @theme = Theme.find(params[:id])
-end
-
- -
- - - - -
- - -
- -
- index() - click to toggle source -
- - -
- -

GET /themes GET /themes.json

- - - -
-
# File app/controllers/themes_controller.rb, line 4
-def index
-  @themes = Theme.all
-
-  respond_to do |format|
-    format.html # index.html.erb
-
-    format.json { render json: @themes }
-  end
-end
-
- -
- - - - -
- - -
- -
- new() - click to toggle source -
- - -
- -

GET /themes/new GET /themes/new.json

- - - -
-
# File app/controllers/themes_controller.rb, line 26
-def new
-  @theme = Theme.new
-
-  respond_to do |format|
-    format.html # new.html.erb
-
-    format.json { render json: @theme }
-  end
-end
-
- -
- - - - -
- - -
- -
- show() - click to toggle source -
- - -
- -

GET /themes/1 GET /themes/1.json

- - - -
-
# File app/controllers/themes_controller.rb, line 15
-def show
-  @theme = Theme.find(params[:id])
-
-  respond_to do |format|
-    format.html # show.html.erb
-
-    format.json { render json: @theme }
-  end
-end
-
- -
- - - - -
- - -
- -
- update() - click to toggle source -
- - -
- -

PUT /themes/1 PUT /themes/1.json

- - - -
-
# File app/controllers/themes_controller.rb, line 58
-def update
-  @theme = Theme.find(params[:id])
-
-  respond_to do |format|
-    if @theme.update_attributes(params[:theme])
-      format.html { redirect_to @theme, notice: 'Theme was successfully updated.' }
-      format.json { head :no_content }
-    else
-      format.html { render action: "edit" }
-      format.json { render json: @theme.errors, status: :unprocessable_entity }
-    end
-  end
-end
-
- -
- - - - -
- - -
- -
- -
- - - - diff --git a/html/User.html b/html/User.html deleted file mode 100644 index a2e0c45..0000000 --- a/html/User.html +++ /dev/null @@ -1,661 +0,0 @@ - - - - - - -class User - DMPonline4 Documentation - - - - - - - - - - - - - - - - -
-

class User

- -
- -
- - - - -
- - - - - - - - - - -
-

Public Instance Methods

- - -
- -
- current_organisation() - click to toggle source -
- - -
- - - - - -
-
# File app/models/user.rb, line 98
-def current_organisation
-        if self.organisations.count > 0 then
-                return self.organisations.last
-        else
-                return nil
-        end
-end
-
- -
- - - - -
- - -
- -
- filter(query) - click to toggle source -
- - -
- - - - - -
-
# File app/models/user.rb, line 19
-def filter(query)
-  return self unless query.present?
-
-  t = self.arel_table
-  q = "%#{query}%"
-
-  conditions = t[:title].matches(q)
-
-  columns = %(
-    grant_number identifier description principal_investigator data_contact
-  )
-
-  columns.each {|col| conditions = conditions.or(t[col].matches(q)) }
-
-  self.where(conditions)
-end
-
- -
- - - - -
- - -
- -
- can_super_admin?() - click to toggle source -
- - -
- - - - - -
-
# File app/models/user.rb, line 110
-def can_super_admin?
-        admin = roles.find_by_name("admin")
-        return !admin.nil?
-end
-
- -
- - - - -
- - -
- -
- can_org_admin?() - click to toggle source -
- - -
- - - - - -
-
# File app/models/user.rb, line 115
-def can_org_admin?
-        org_admin = roles.find_by_name("org_admin")
-        return !org_admin.nil?
-end
-
- -
- - - - -
- - -
- -
- name(use_email = true) - click to toggle source -
- - -
- - - - - -
-
# File app/models/user.rb, line 54
-def name(use_email = true)
-        if ((firstname.nil? && surname.nil?) || (firstname.strip == "" && surname.strip == "")) && use_email then
-                return email
-        else
-                name = "#{firstname} #{surname}"
-                return name.strip
-        end
-end
-
- -
- - - - -
- - -
- -
- org_type() - click to toggle source -
- - -
- - - - - -
-
# File app/models/user.rb, line 120
-def org_type
-    org_type = organisation.organisation_type.name
-            return org_type
-end
-
- -
- - - - -
- - -
- -
- organisation() - click to toggle source -
- - -
- - - - - -
-
# File app/models/user.rb, line 90
-def organisation
-        if self.organisations.count > 0 then
-                return self.organisations.first
-        else
-                return nil
-        end
-end
-
- -
- - - - -
- - -
- -
- organisation=(new_organisation) - click to toggle source -
- - -
- - - - - -
-
# File app/models/user.rb, line 106
-def organisation=(new_organisation)
-        organisation_id = organisation.id
-end
-
- -
- - - - -
- - -
- -
- organisation_id() - click to toggle source -
- - -
- - - - - -
-
# File app/models/user.rb, line 82
-def organisation_id
-        if self.organisations.count > 0 then
-                return self.organisations.first.id
-        else
-                return nil
-        end
-end
-
- -
- - - - -
- - -
- -
- organisation_id=(new_organisation_id) - click to toggle source -
- - -
- - - - - -
-
# File app/models/user.rb, line 63
-    def organisation_id=(new_organisation_id)
-if !self.user_org_roles.pluck(:organisation_id).include?(new_organisation_id.to_i) then
-            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("user");
-                    self.user_org_roles << new_user_org_role
-            else
-                    user_org_role = self.user_org_roles.first
-                    user_org_role.organisation_id = new_organisation_id
-        user_org_role.save
-                    org_admin_role = roles.find_by_name("org_admin")
-                    unless org_admin_role.nil? then
-                            roles.delete(org_admin_role)
-                    end
-            end
-end
-    end
-
- -
- - - - -
- - -
- -
- -
- - - - diff --git a/html/UserMailer.html b/html/UserMailer.html deleted file mode 100644 index 9a51758..0000000 --- a/html/UserMailer.html +++ /dev/null @@ -1,393 +0,0 @@ - - - - - - -class UserMailer - DMPonline4 Documentation - - - - - - - - - - - - - - - - -
-

class UserMailer

- -
- -
- - - - -
- - - - - - - - - - -
-

Public Instance Methods

- - -
- -
- permissions_change_notification(project_group) - click to toggle source -
- - -
- - - - - -
-
# File app/mailers/user_mailer.rb, line 9
-def permissions_change_notification(project_group)
-        @project_group = project_group
-        mail(to: @project_group.user.email, subject: "DMP permissions changed")
-end
-
- -
- - - - -
- - -
- -
- project_access_removed_notification(user, project) - click to toggle source -
- - -
- - - - - -
-
# File app/mailers/user_mailer.rb, line 14
-def project_access_removed_notification(user, project)
-        @user = user
-        @project = project
-        mail(to: @user.email, subject: "DMP access removed")
-end
-
- -
- - - - -
- - -
- -
- sharing_notification(project_group) - click to toggle source -
- - -
- - - - - -
-
# File app/mailers/user_mailer.rb, line 4
-def sharing_notification(project_group)
-        @project_group = project_group
-        mail(to: @project_group.user.email, subject: "You have been given access to a Data Management Plan")
-end
-
- -
- - - - -
- - -
- -
- -
- - - - diff --git a/html/UserOrgRole.html b/html/UserOrgRole.html deleted file mode 100644 index 6ec474a..0000000 --- a/html/UserOrgRole.html +++ /dev/null @@ -1,279 +0,0 @@ - - - - - - -class UserOrgRole - DMPonline4 Documentation - - - - - - - - - - - - - - - - -
-

class UserOrgRole

- -
- -
- - - - -
- - - - - - - - - - -
- -
- - - - diff --git a/html/UserOrgRolesController.html b/html/UserOrgRolesController.html deleted file mode 100644 index 6612d49..0000000 --- a/html/UserOrgRolesController.html +++ /dev/null @@ -1,561 +0,0 @@ - - - - - - -class UserOrgRolesController - DMPonline4 Documentation - - - - - - - - - - - - - - - - -
-

class UserOrgRolesController

- -
- -
- - - - -
- - - - - - - - - - -
-

Public Instance Methods

- - -
- -
- create() - click to toggle source -
- - -
- -

POST /user_org_roles POST /user_org_roles.json

- - - -
-
# File app/controllers/user_org_roles_controller.rb, line 42
-def create
-  @user_org_role = UserOrgRole.new(params[:user_org_role])
-
-  respond_to do |format|
-    if @user_org_role.save
-      format.html { redirect_to @user_org_role, notice: 'User org role was successfully created.' }
-      format.json { render json: @user_org_role, status: :created, location: @user_org_role }
-    else
-      format.html { render action: "new" }
-      format.json { render json: @user_org_role.errors, status: :unprocessable_entity }
-    end
-  end
-end
-
- -
- - - - -
- - -
- -
- destroy() - click to toggle source -
- - -
- -

DELETE /user_org_roles/1 DELETE /user_org_roles/1.json

- - - -
-
# File app/controllers/user_org_roles_controller.rb, line 74
-def destroy
-  @user_org_role = UserOrgRole.find(params[:id])
-  @user_org_role.destroy
-
-  respond_to do |format|
-    format.html { redirect_to user_org_roles_url }
-    format.json { head :no_content }
-  end
-end
-
- -
- - - - -
- - -
- -
- edit() - click to toggle source -
- - -
- -

GET /user_org_roles/1/edit

- - - -
-
# File app/controllers/user_org_roles_controller.rb, line 36
-def edit
-  @user_org_role = UserOrgRole.find(params[:id])
-end
-
- -
- - - - -
- - -
- -
- index() - click to toggle source -
- - -
- -

GET /user_org_roles GET /user_org_roles.json

- - - -
-
# File app/controllers/user_org_roles_controller.rb, line 4
-def index
-  @user_org_roles = UserOrgRole.all
-
-  respond_to do |format|
-    format.html # index.html.erb
-
-    format.json { render json: @user_org_roles }
-  end
-end
-
- -
- - - - -
- - -
- -
- new() - click to toggle source -
- - -
- -

GET /user_org_roles/new GET /user_org_roles/new.json

- - - -
-
# File app/controllers/user_org_roles_controller.rb, line 26
-def new
-  @user_org_role = UserOrgRole.new
-
-  respond_to do |format|
-    format.html # new.html.erb
-
-    format.json { render json: @user_org_role }
-  end
-end
-
- -
- - - - -
- - -
- -
- show() - click to toggle source -
- - -
- -

GET /user_org_roles/1 GET /user_org_roles/1.json

- - - -
-
# File app/controllers/user_org_roles_controller.rb, line 15
-def show
-  @user_org_role = UserOrgRole.find(params[:id])
-
-  respond_to do |format|
-    format.html # show.html.erb
-
-    format.json { render json: @user_org_role }
-  end
-end
-
- -
- - - - -
- - -
- -
- update() - click to toggle source -
- - -
- -

PUT /user_org_roles/1 PUT /user_org_roles/1.json

- - - -
-
# File app/controllers/user_org_roles_controller.rb, line 58
-def update
-  @user_org_role = UserOrgRole.find(params[:id])
-
-  respond_to do |format|
-    if @user_org_role.update_attributes(params[:user_org_role])
-      format.html { redirect_to @user_org_role, notice: 'User org role was successfully updated.' }
-      format.json { head :no_content }
-    else
-      format.html { render action: "edit" }
-      format.json { render json: @user_org_role.errors, status: :unprocessable_entity }
-    end
-  end
-end
-
- -
- - - - -
- - -
- -
- -
- - - - diff --git a/html/UserRoleType.html b/html/UserRoleType.html deleted file mode 100644 index 1808bff..0000000 --- a/html/UserRoleType.html +++ /dev/null @@ -1,279 +0,0 @@ - - - - - - -class UserRoleType - DMPonline4 Documentation - - - - - - - - - - - - - - - - -
-

class UserRoleType

- -
- -
- - - - -
- - - - - - - - - - -
- -
- - - - diff --git a/html/UserRoleTypesController.html b/html/UserRoleTypesController.html deleted file mode 100644 index 7ee343f..0000000 --- a/html/UserRoleTypesController.html +++ /dev/null @@ -1,561 +0,0 @@ - - - - - - -class UserRoleTypesController - DMPonline4 Documentation - - - - - - - - - - - - - - - - -
-

class UserRoleTypesController

- -
- -
- - - - -
- - - - - - - - - - -
-

Public Instance Methods

- - -
- -
- create() - click to toggle source -
- - -
- -

POST /user_role_types POST /user_role_types.json

- - - -
-
# File app/controllers/user_role_types_controller.rb, line 42
-def create
-  @user_role_type = UserRoleType.new(params[:user_role_type])
-
-  respond_to do |format|
-    if @user_role_type.save
-      format.html { redirect_to @user_role_type, notice: 'User role type was successfully created.' }
-      format.json { render json: @user_role_type, status: :created, location: @user_role_type }
-    else
-      format.html { render action: "new" }
-      format.json { render json: @user_role_type.errors, status: :unprocessable_entity }
-    end
-  end
-end
-
- -
- - - - -
- - -
- -
- destroy() - click to toggle source -
- - -
- -

DELETE /user_role_types/1 DELETE /user_role_types/1.json

- - - -
-
# File app/controllers/user_role_types_controller.rb, line 74
-def destroy
-  @user_role_type = UserRoleType.find(params[:id])
-  @user_role_type.destroy
-
-  respond_to do |format|
-    format.html { redirect_to user_role_types_url }
-    format.json { head :no_content }
-  end
-end
-
- -
- - - - -
- - -
- -
- edit() - click to toggle source -
- - -
- -

GET /user_role_types/1/edit

- - - -
-
# File app/controllers/user_role_types_controller.rb, line 36
-def edit
-  @user_role_type = UserRoleType.find(params[:id])
-end
-
- -
- - - - -
- - -
- -
- index() - click to toggle source -
- - -
- -

GET /user_role_types GET /user_role_types.json

- - - -
-
# File app/controllers/user_role_types_controller.rb, line 4
-def index
-  @user_role_types = UserRoleType.all
-
-  respond_to do |format|
-    format.html # index.html.erb
-
-    format.json { render json: @user_role_types }
-  end
-end
-
- -
- - - - -
- - -
- -
- new() - click to toggle source -
- - -
- -

GET /user_role_types/new GET /user_role_types/new.json

- - - -
-
# File app/controllers/user_role_types_controller.rb, line 26
-def new
-  @user_role_type = UserRoleType.new
-
-  respond_to do |format|
-    format.html # new.html.erb
-
-    format.json { render json: @user_role_type }
-  end
-end
-
- -
- - - - -
- - -
- -
- show() - click to toggle source -
- - -
- -

GET /user_role_types/1 GET /user_role_types/1.json

- - - -
-
# File app/controllers/user_role_types_controller.rb, line 15
-def show
-  @user_role_type = UserRoleType.find(params[:id])
-
-  respond_to do |format|
-    format.html # show.html.erb
-
-    format.json { render json: @user_role_type }
-  end
-end
-
- -
- - - - -
- - -
- -
- update() - click to toggle source -
- - -
- -

PUT /user_role_types/1 PUT /user_role_types/1.json

- - - -
-
# File app/controllers/user_role_types_controller.rb, line 58
-def update
-  @user_role_type = UserRoleType.find(params[:id])
-
-  respond_to do |format|
-    if @user_role_type.update_attributes(params[:user_role_type])
-      format.html { redirect_to @user_role_type, notice: 'User role type was successfully updated.' }
-      format.json { head :no_content }
-    else
-      format.html { render action: "edit" }
-      format.json { render json: @user_role_type.errors, status: :unprocessable_entity }
-    end
-  end
-end
-
- -
- - - - -
- - -
- -
- -
- - - - diff --git a/html/UserStatus.html b/html/UserStatus.html deleted file mode 100644 index ece7b89..0000000 --- a/html/UserStatus.html +++ /dev/null @@ -1,279 +0,0 @@ - - - - - - -class UserStatus - DMPonline4 Documentation - - - - - - - - - - - - - - - - -
-

class UserStatus

- -
- -
- - - - -
- - - - - - - - - - -
- -
- - - - diff --git a/html/UserStatusesController.html b/html/UserStatusesController.html deleted file mode 100644 index e74b843..0000000 --- a/html/UserStatusesController.html +++ /dev/null @@ -1,561 +0,0 @@ - - - - - - -class UserStatusesController - DMPonline4 Documentation - - - - - - - - - - - - - - - - -
-

class UserStatusesController

- -
- -
- - - - -
- - - - - - - - - - -
-

Public Instance Methods

- - -
- -
- create() - click to toggle source -
- - -
- -

POST /user_statuses POST /user_statuses.json

- - - -
-
# File app/controllers/user_statuses_controller.rb, line 42
-def create
-  @user_status = UserStatus.new(params[:user_status])
-
-  respond_to do |format|
-    if @user_status.save
-      format.html { redirect_to @user_status, notice: 'User status was successfully created.' }
-      format.json { render json: @user_status, status: :created, location: @user_status }
-    else
-      format.html { render action: "new" }
-      format.json { render json: @user_status.errors, status: :unprocessable_entity }
-    end
-  end
-end
-
- -
- - - - -
- - -
- -
- destroy() - click to toggle source -
- - -
- -

DELETE /user_statuses/1 DELETE /user_statuses/1.json

- - - -
-
# File app/controllers/user_statuses_controller.rb, line 74
-def destroy
-  @user_status = UserStatus.find(params[:id])
-  @user_status.destroy
-
-  respond_to do |format|
-    format.html { redirect_to user_statuses_url }
-    format.json { head :no_content }
-  end
-end
-
- -
- - - - -
- - -
- -
- edit() - click to toggle source -
- - -
- -

GET /user_statuses/1/edit

- - - -
-
# File app/controllers/user_statuses_controller.rb, line 36
-def edit
-  @user_status = UserStatus.find(params[:id])
-end
-
- -
- - - - -
- - -
- -
- index() - click to toggle source -
- - -
- -

GET /user_statuses GET /user_statuses.json

- - - -
-
# File app/controllers/user_statuses_controller.rb, line 4
-def index
-  @user_statuses = UserStatus.all
-
-  respond_to do |format|
-    format.html # index.html.erb
-
-    format.json { render json: @user_statuses }
-  end
-end
-
- -
- - - - -
- - -
- -
- new() - click to toggle source -
- - -
- -

GET /user_statuses/new GET /user_statuses/new.json

- - - -
-
# File app/controllers/user_statuses_controller.rb, line 26
-def new
-  @user_status = UserStatus.new
-
-  respond_to do |format|
-    format.html # new.html.erb
-
-    format.json { render json: @user_status }
-  end
-end
-
- -
- - - - -
- - -
- -
- show() - click to toggle source -
- - -
- -

GET /user_statuses/1 GET /user_statuses/1.json

- - - -
-
# File app/controllers/user_statuses_controller.rb, line 15
-def show
-  @user_status = UserStatus.find(params[:id])
-
-  respond_to do |format|
-    format.html # show.html.erb
-
-    format.json { render json: @user_status }
-  end
-end
-
- -
- - - - -
- - -
- -
- update() - click to toggle source -
- - -
- -

PUT /user_statuses/1 PUT /user_statuses/1.json

- - - -
-
# File app/controllers/user_statuses_controller.rb, line 58
-def update
-  @user_status = UserStatus.find(params[:id])
-
-  respond_to do |format|
-    if @user_status.update_attributes(params[:user_status])
-      format.html { redirect_to @user_status, notice: 'User status was successfully updated.' }
-      format.json { head :no_content }
-    else
-      format.html { render action: "edit" }
-      format.json { render json: @user_status.errors, status: :unprocessable_entity }
-    end
-  end
-end
-
- -
- - - - -
- - -
- -
- -
- - - - diff --git a/html/UserType.html b/html/UserType.html deleted file mode 100644 index f37778b..0000000 --- a/html/UserType.html +++ /dev/null @@ -1,279 +0,0 @@ - - - - - - -class UserType - DMPonline4 Documentation - - - - - - - - - - - - - - - - -
-

class UserType

- -
- -
- - - - -
- - - - - - - - - - -
- -
- - - - diff --git a/html/UserTypesController.html b/html/UserTypesController.html deleted file mode 100644 index 7a53fd5..0000000 --- a/html/UserTypesController.html +++ /dev/null @@ -1,561 +0,0 @@ - - - - - - -class UserTypesController - DMPonline4 Documentation - - - - - - - - - - - - - - - - -
-

class UserTypesController

- -
- -
- - - - -
- - - - - - - - - - -
-

Public Instance Methods

- - -
- -
- create() - click to toggle source -
- - -
- -

POST /user_types POST /user_types.json

- - - -
-
# File app/controllers/user_types_controller.rb, line 42
-def create
-  @user_type = UserType.new(params[:user_type])
-
-  respond_to do |format|
-    if @user_type.save
-      format.html { redirect_to @user_type, notice: 'User type was successfully created.' }
-      format.json { render json: @user_type, status: :created, location: @user_type }
-    else
-      format.html { render action: "new" }
-      format.json { render json: @user_type.errors, status: :unprocessable_entity }
-    end
-  end
-end
-
- -
- - - - -
- - -
- -
- destroy() - click to toggle source -
- - -
- -

DELETE /user_types/1 DELETE /user_types/1.json

- - - -
-
# File app/controllers/user_types_controller.rb, line 74
-def destroy
-  @user_type = UserType.find(params[:id])
-  @user_type.destroy
-
-  respond_to do |format|
-    format.html { redirect_to user_types_url }
-    format.json { head :no_content }
-  end
-end
-
- -
- - - - -
- - -
- -
- edit() - click to toggle source -
- - -
- -

GET /user_types/1/edit

- - - -
-
# File app/controllers/user_types_controller.rb, line 36
-def edit
-  @user_type = UserType.find(params[:id])
-end
-
- -
- - - - -
- - -
- -
- index() - click to toggle source -
- - -
- -

GET /user_types GET /user_types.json

- - - -
-
# File app/controllers/user_types_controller.rb, line 4
-def index
-  @user_types = UserType.all
-
-  respond_to do |format|
-    format.html # index.html.erb
-
-    format.json { render json: @user_types }
-  end
-end
-
- -
- - - - -
- - -
- -
- new() - click to toggle source -
- - -
- -

GET /user_types/new GET /user_types/new.json

- - - -
-
# File app/controllers/user_types_controller.rb, line 26
-def new
-  @user_type = UserType.new
-
-  respond_to do |format|
-    format.html # new.html.erb
-
-    format.json { render json: @user_type }
-  end
-end
-
- -
- - - - -
- - -
- -
- show() - click to toggle source -
- - -
- -

GET /user_types/1 GET /user_types/1.json

- - - -
-
# File app/controllers/user_types_controller.rb, line 15
-def show
-  @user_type = UserType.find(params[:id])
-
-  respond_to do |format|
-    format.html # show.html.erb
-
-    format.json { render json: @user_type }
-  end
-end
-
- -
- - - - -
- - -
- -
- update() - click to toggle source -
- - -
- -

PUT /user_types/1 PUT /user_types/1.json

- - - -
-
# File app/controllers/user_types_controller.rb, line 58
-def update
-  @user_type = UserType.find(params[:id])
-
-  respond_to do |format|
-    if @user_type.update_attributes(params[:user_type])
-      format.html { redirect_to @user_type, notice: 'User type was successfully updated.' }
-      format.json { head :no_content }
-    else
-      format.html { render action: "edit" }
-      format.json { render json: @user_type.errors, status: :unprocessable_entity }
-    end
-  end
-end
-
- -
- - - - -
- - -
- -
- -
- - - - diff --git a/html/Users.html b/html/Users.html deleted file mode 100644 index f059ad1..0000000 --- a/html/Users.html +++ /dev/null @@ -1,272 +0,0 @@ - - - - - - -module Users - DMPonline4 Documentation - - - - - - - - - - - - - - - - -
-

module Users

- -
- -
- - - - -
- - - - - - - - - - -
- -
- - - - diff --git a/html/Users/OmniauthCallbacksController.html b/html/Users/OmniauthCallbacksController.html deleted file mode 100644 index ee178a1..0000000 --- a/html/Users/OmniauthCallbacksController.html +++ /dev/null @@ -1,374 +0,0 @@ - - - - - - -class Users::OmniauthCallbacksController - DMPonline4 Documentation - - - - - - - - - - - - - - - - -
-

class Users::OmniauthCallbacksController

- -
- -
- - - - -
- - - - - - - - - - -
-

Public Instance Methods

- - -
- -
- shibboleth() - click to toggle source -
- - -
- - - - - -
-
# File app/controllers/users/omniauth_callback_controller.rb, line 3
-def shibboleth
-  if user_signed_in? && current_user.shibboleth_id.present? && current_user.shibboleth_id.length > 0 then
-    flash[:warning] = I18n.t('devise.failure.already_authenticated')
-    redirect_to root_path
-  else
-    auth = request.env['omniauth.auth'] || {}
-    eppn = auth['extra']['raw_info']['eppn']
-    uid = nil
-    if !eppn.blank? then
-      uid = eppn
-    elsif !auth['uid'].blank? then
-      uid = auth['uid']
-    elsif !auth['extra']['raw_info']['targeted-id'].blank? then
-      uid = auth['extra']['raw_info']['targeted-id']
-    end
-
-    if !uid.nil? && !uid.blank? then
-                              s_user = User.where(shibboleth_id: uid).first
-                              # Take out previous record if was not confirmed.
-
-                              if !s_user.nil? && s_user.confirmed_at.nil? then
-                                      sign_out s_user
-                                      User.delete(s_user.id)
-                                      s_user = nil
-                              end
-
-                              # Stops Shibboleth ID being blocked if email incorrectly entered.
-
-                              if !s_user.nil? && s_user.try(:persisted?) then
-                                      flash[:notice] = I18n.t('devise.omniauth_callbacks.success', :kind => 'Shibboleth')
-                                      sign_in s_user
-                  redirect_to root_path
-                              else
-                                      if user_signed_in? then
-                                              current_user.update_attribute('shibboleth_id', uid)
-                                              user_id = current_user.id
-                                              sign_out current_user
-                                              session.delete(:shibboleth_data)
-                                              s_user = User.find(user_id)
-                                              sign_in s_user
-                      redirect_to edit_user_registration_path
-                                      else
-                                              session[:shibboleth_data] = request.env['omniauth.auth']
-                                              session[:shibboleth_data][:uid] = uid
-                                              redirect_to new_user_registration_url(:nosplash => 'true')
-                                      end
-                              end
-    else
-      redirect_to root_path
-    end
-  end
-end
-
- -
- - - - -
- - -
- -
- -
- - - - diff --git a/html/Users/OmniauthShibbolethRequestController.html b/html/Users/OmniauthShibbolethRequestController.html deleted file mode 100644 index bd89987..0000000 --- a/html/Users/OmniauthShibbolethRequestController.html +++ /dev/null @@ -1,370 +0,0 @@ - - - - - - -class Users::OmniauthShibbolethRequestController - DMPonline4 Documentation - - - - - - - - - - - - - - - - -
-

class Users::OmniauthShibbolethRequestController

- -
- -
- - - - -
- - - - - - - - - - -
-

Public Instance Methods

- - -
- -
- associate() - click to toggle source -
- - -
- - - - - -
-
# File app/controllers/users/omniauth_shibboleth_request_controller.rb, line 17
-def associate
-  # This action is protected - can only be reached if user is already logged in.
-
-  # See before_filter
-
-  redirect_to user_omniauth_callback_path(:shibboleth)
-end
-
- -
- - - - -
- - -
- -
- redirect() - click to toggle source -
- - -
- - - - - -
-
# File app/controllers/users/omniauth_shibboleth_request_controller.rb, line 4
-def redirect
-      if !current_user.nil? && !current_user.organisation.nil?
-      idp = params[:idp] || current_user.organisation.wayfless_entity
-  else
-      idp = params[:idp]
-  end
-  query_params = {target: user_omniauth_callback_path(:shibboleth)}
-  unless idp.blank?
-    query_params[:entityID] = idp
-  end
-  redirect_to "#{Rails.application.config.shibboleth_login}?#{query_params.to_query}", status: 302
-end
-
- -
- - - - -
- - -
- -
- -
- - - - diff --git a/html/UsersController.html b/html/UsersController.html deleted file mode 100644 index 6ac90b1..0000000 --- a/html/UsersController.html +++ /dev/null @@ -1,523 +0,0 @@ - - - - - - -class UsersController - DMPonline4 Documentation - - - - - - - - - - - - - - - - -
-

class UsersController

- -
- -
- - - - -
- - - - - - - - - - -
-

Public Instance Methods

- - -
- -
- create() - click to toggle source -
- - -
- -

POST /users POST /users.json

- - - -
-
# File app/controllers/users_controller.rb, line 31
-def create
-  @user = User.new(params[:user])
-
-  respond_to do |format|
-    if @user.save
-      format.html { redirect_to @user, notice: 'User was successfully created.' }
-      format.json { render json: @user, status: :created, location: @user }
-    else
-      format.html { render action: "new" }
-      format.json { render json: @user.errors, status: :unprocessable_entity }
-    end
-  end
-end
-
- -
- - - - -
- - -
- -
- destroy() - click to toggle source -
- - -
- -

DELETE /users/1 DELETE /users/1.json

- - - -
-
# File app/controllers/users_controller.rb, line 66
-def destroy
-  @user = User.find(params[:id])
-  @user.destroy
-
-  respond_to do |format|
-    format.html { redirect_to users_url }
-    format.json { head :no_content }
-  end
-end
-
- -
- - - - -
- - -
- -
- edit() - click to toggle source -
- - -
- -

GET /users/1/edit

- - - -
-
# File app/controllers/users_controller.rb, line 25
-def edit
-  @user = User.find(params[:id])
-end
-
- -
- - - - -
- - -
- -
- new() - click to toggle source -
- - -
- -

GET /users/new GET /users/new.json

- - - -
-
# File app/controllers/users_controller.rb, line 15
-def new
-  @user = User.new
-
-  respond_to do |format|
-    format.html # new.html.erb
-
-    format.json { render json: @user }
-  end
-end
-
- -
- - - - -
- - -
- -
- show() - click to toggle source -
- - -
- -

GET /users/1 GET /users/1.json

- - - -
-
# File app/controllers/users_controller.rb, line 4
-def show
-  @user = User.find(params[:id])
-
-  respond_to do |format|
-    format.html # show.html.erb
-
-    format.json { render json: @user }
-  end
-end
-
- -
- - - - -
- - -
- -
- update() - click to toggle source -
- - -
- -

PUT /users/1 PUT /users/1.json

- - - -
-
# File app/controllers/users_controller.rb, line 47
-def update
-  @user = User.find(params[:id])
-
-  respond_to do |format|
-    if @user.update_attributes(params[:user])
-      format.html { redirect_to({:controller=> "projects", :action => "new"}, {:notice => 'Project was successfully created.'}) }
-                              format.json { head :no_content }
-    else
-      format.html { render action: "edit" }
-      format.json { render json: @user.errors, status: :unprocessable_entity }
-    end
-  end
-end
-
- -
- - - - -
- - -
- -
- -
- - - - diff --git a/html/Version.html b/html/Version.html deleted file mode 100644 index bfa9737..0000000 --- a/html/Version.html +++ /dev/null @@ -1,357 +0,0 @@ - - - - - - -class Version - DMPonline4 Documentation - - - - - - - - - - - - - - - - -
-

class Version

- -
- -
- - - - -
- - - - - - - - - - -
-

Public Instance Methods

- - -
- -
- global_sections() - click to toggle source -
- - -
- - - - - -
-
# File app/models/version.rb, line 22
-def global_sections
-      sections.find_all_by_organisation_id(phase.dmptemplate.organisation_id)
-end
-
- -
- - - - -
- - -
- -
- to_s() - click to toggle source -
- - -
- - - - - -
-
# File app/models/version.rb, line 16
-def to_s
-      "#{title}"
-end
-
- -
- - - - -
- - -
- -
- -
- - - - diff --git a/html/created.rid b/html/created.rid deleted file mode 100644 index 1ff390d..0000000 --- a/html/created.rid +++ /dev/null @@ -1,115 +0,0 @@ -Mon, 09 Nov 2015 14:55:18 +0000 -README.rdoc Tue, 28 Jul 2015 13:51:53 +0100 -app/admin/dashboard.rb Wed, 18 Mar 2015 14:45:56 +0000 -app/admin/dmptemplate.rb Wed, 18 Mar 2015 11:10:34 +0000 -app/admin/guidance.rb Fri, 02 Oct 2015 10:07:14 +0100 -app/admin/guidance_group.rb Mon, 09 Nov 2015 14:30:03 +0000 -app/admin/option.rb Fri, 02 Oct 2015 10:09:28 +0100 -app/admin/organisation.rb Fri, 02 Oct 2015 10:09:28 +0100 -app/admin/organisation_type.rb Fri, 02 Oct 2015 10:09:28 +0100 -app/admin/phase.rb Fri, 02 Oct 2015 10:09:28 +0100 -app/admin/project.rb Fri, 02 Oct 2015 10:09:28 +0100 -app/admin/project_group.rb Wed, 11 Mar 2015 16:23:43 +0000 -app/admin/question.rb Fri, 02 Oct 2015 10:09:28 +0100 -app/admin/question_format.rb Fri, 02 Oct 2015 10:09:28 +0100 -app/admin/role.rb Fri, 02 Oct 2015 10:09:28 +0100 -app/admin/section.rb Fri, 02 Oct 2015 10:09:28 +0100 -app/admin/suggested_answer.rb Wed, 11 Mar 2015 16:23:43 +0000 -app/admin/theme.rb Fri, 02 Oct 2015 10:09:28 +0100 -app/admin/user.rb Wed, 28 Oct 2015 11:08:46 +0000 -app/admin/user_org_role.rb Fri, 02 Oct 2015 10:09:28 +0100 -app/admin/user_role_type.rb Fri, 02 Oct 2015 10:09:28 +0100 -app/admin/user_status.rb Fri, 02 Oct 2015 10:09:28 +0100 -app/admin/user_type.rb Fri, 02 Oct 2015 10:09:28 +0100 -app/admin/version.rb Fri, 02 Oct 2015 10:09:28 +0100 -app/controllers/answers_controller.rb Thu, 16 Apr 2015 10:05:23 +0100 -app/controllers/application_controller.rb Fri, 09 Oct 2015 16:05:22 +0100 -app/controllers/comments_controller.rb Tue, 19 May 2015 16:11:58 +0100 -app/controllers/confirmations_controller.rb Wed, 09 Oct 2013 11:00:51 +0100 -app/controllers/contacts_controller.rb Mon, 27 Jul 2015 16:51:02 +0100 -app/controllers/dmptemplates_controller.rb Mon, 10 Aug 2015 12:44:35 +0100 -app/controllers/existing_users_controller.rb Tue, 26 Nov 2013 17:15:46 +0000 -app/controllers/guidance_groups_controller.rb Sun, 09 Aug 2015 14:54:18 +0100 -app/controllers/guidances_controller.rb Sun, 05 Jul 2015 22:48:47 +0100 -app/controllers/home_controller.rb Thu, 26 Sep 2013 17:04:25 +0100 -app/controllers/organisation_users_controller.rb Mon, 27 Jan 2014 15:09:50 +0000 -app/controllers/organisations_controller.rb Sun, 09 Aug 2015 14:52:46 +0100 -app/controllers/passwords_controller.rb Wed, 09 Oct 2013 11:00:51 +0100 -app/controllers/plans_controller.rb Mon, 26 Oct 2015 18:34:42 +0000 -app/controllers/project_groups_controller.rb Mon, 09 Dec 2013 10:57:33 +0000 -app/controllers/projects_controller.rb Sun, 05 Jul 2015 19:32:06 +0100 -app/controllers/registrations_controller.rb Wed, 23 Jul 2014 11:56:43 +0100 -app/controllers/sessions_controller.rb Mon, 24 Aug 2015 13:24:15 +0100 -app/controllers/settings.rb Fri, 02 Oct 2015 12:12:20 +0100 -app/controllers/settings/plans_controller.rb Wed, 09 Jul 2014 16:26:32 +0100 -app/controllers/settings/projects_controller.rb Mon, 07 Jul 2014 11:30:19 +0100 -app/controllers/splash_logs_controller.rb Wed, 27 Nov 2013 15:15:11 +0000 -app/controllers/static_pages_controller.rb Thu, 21 May 2015 16:13:16 +0100 -app/controllers/themes_controller.rb Tue, 24 Sep 2013 15:31:14 +0100 -app/controllers/user_org_roles_controller.rb Tue, 24 Sep 2013 15:31:14 +0100 -app/controllers/user_role_types_controller.rb Tue, 24 Sep 2013 15:31:14 +0100 -app/controllers/user_statuses_controller.rb Tue, 24 Sep 2013 15:31:14 +0100 -app/controllers/user_types_controller.rb Tue, 24 Sep 2013 15:31:14 +0100 -app/controllers/users/omniauth_callback_controller.rb Mon, 27 Jul 2015 12:31:00 +0100 -app/controllers/users/omniauth_shibboleth_request_controller.rb Tue, 15 Apr 2014 13:55:12 +0100 -app/controllers/users_controller.rb Tue, 12 May 2015 18:45:56 +0100 -app/helpers/application_helper.rb Mon, 10 Aug 2015 02:17:40 +0100 -app/helpers/plans_helper.rb Mon, 07 Jul 2014 11:30:19 +0100 -app/mailers/user_mailer.rb Tue, 26 Nov 2013 14:18:11 +0000 -app/models/ability.rb Tue, 06 Oct 2015 19:51:17 +0100 -app/models/answer.rb Tue, 06 Oct 2015 19:49:57 +0100 -app/models/comment.rb Tue, 06 Oct 2015 19:49:53 +0100 -app/models/dmptemplate.rb Tue, 06 Oct 2015 19:49:56 +0100 -app/models/exported_plan.rb Wed, 21 Oct 2015 14:41:40 +0100 -app/models/file_type.rb Tue, 06 Oct 2015 19:51:17 +0100 -app/models/file_upload.rb Tue, 06 Oct 2015 19:51:18 +0100 -app/models/guidance.rb Tue, 06 Oct 2015 19:49:51 +0100 -app/models/guidance_group.rb Tue, 06 Oct 2015 19:49:52 +0100 -app/models/option.rb Tue, 06 Oct 2015 19:49:56 +0100 -app/models/option_warning.rb Tue, 06 Oct 2015 19:49:57 +0100 -app/models/organisation.rb Tue, 06 Oct 2015 19:49:55 +0100 -app/models/organisation_type.rb Tue, 06 Oct 2015 19:51:18 +0100 -app/models/phase.rb Tue, 06 Oct 2015 19:49:51 +0100 -app/models/plan.rb Tue, 06 Oct 2015 19:49:56 +0100 -app/models/plan_section.rb Tue, 06 Oct 2015 19:51:19 +0100 -app/models/project.rb Tue, 06 Oct 2015 19:49:52 +0100 -app/models/project_group.rb Tue, 06 Oct 2015 19:51:19 +0100 -app/models/project_partner.rb Tue, 06 Oct 2015 19:51:16 +0100 -app/models/question.rb Tue, 06 Oct 2015 19:49:55 +0100 -app/models/question_format.rb Tue, 06 Oct 2015 19:51:20 +0100 -app/models/role.rb Tue, 06 Oct 2015 19:49:53 +0100 -app/models/section.rb Tue, 06 Oct 2015 19:51:20 +0100 -app/models/settings/dmptemplate.rb Tue, 06 Oct 2015 19:51:24 +0100 -app/models/settings/plan_list.rb Tue, 06 Oct 2015 19:51:25 +0100 -app/models/splash_log.rb Tue, 06 Oct 2015 19:51:20 +0100 -app/models/suggested_answer.rb Tue, 06 Oct 2015 19:51:21 +0100 -app/models/theme.rb Tue, 06 Oct 2015 19:51:21 +0100 -app/models/user.rb Tue, 06 Oct 2015 19:49:54 +0100 -app/models/user_org_role.rb Tue, 06 Oct 2015 19:51:22 +0100 -app/models/user_role_type.rb Tue, 06 Oct 2015 19:51:22 +0100 -app/models/user_status.rb Tue, 06 Oct 2015 19:51:23 +0100 -app/models/user_type.rb Tue, 06 Oct 2015 19:51:23 +0100 -app/models/version.rb Tue, 06 Oct 2015 19:51:24 +0100 -lib/active_admin_views_pages_base.rb Wed, 20 Nov 2013 16:27:04 +0000 -lib/custom_failure.rb Tue, 24 Sep 2013 15:31:14 +0100 -config/application.rb Tue, 06 Oct 2015 15:02:51 +0100 -config/boot.rb Tue, 24 Sep 2013 15:31:14 +0100 -config/environment.rb Tue, 24 Sep 2013 15:31:14 +0100 -config/environments/development.rb Mon, 14 Jul 2014 15:43:22 +0100 -config/environments/production.rb Mon, 14 Jul 2014 15:43:22 +0100 -config/environments/test.rb Tue, 28 Jan 2014 12:43:49 +0000 -config/initializers/active_admin.rb Mon, 12 Oct 2015 16:20:30 +0100 -config/initializers/backtrace_silencers.rb Tue, 24 Sep 2013 15:31:14 +0100 -config/initializers/contact_us.rb Mon, 14 Jul 2014 15:43:22 +0100 -config/initializers/devise.rb Fri, 02 Oct 2015 10:16:28 +0100 -config/initializers/formtastic.rb Tue, 24 Sep 2013 15:31:14 +0100 -config/initializers/inflections.rb Tue, 24 Sep 2013 15:31:14 +0100 -config/initializers/locale.rb Tue, 24 Sep 2013 15:31:14 +0100 -config/initializers/mime_types.rb Mon, 14 Jul 2014 15:43:22 +0100 -config/initializers/omniauth.rb Mon, 07 Jul 2014 11:30:12 +0100 -config/initializers/recaptcha.rb Wed, 16 Jul 2014 16:29:56 +0100 -config/initializers/rolify.rb Tue, 24 Sep 2013 15:31:14 +0100 -config/initializers/secret_token.rb Mon, 14 Jul 2014 15:43:22 +0100 -config/initializers/session_store.rb Tue, 24 Sep 2013 15:31:14 +0100 -config/initializers/wrap_parameters.rb Tue, 24 Sep 2013 15:31:14 +0100 -config/routes.rb Thu, 21 May 2015 15:42:52 +0100 diff --git a/html/images/add.png b/html/images/add.png deleted file mode 100644 index 6332fef..0000000 --- a/html/images/add.png +++ /dev/null Binary files differ diff --git a/html/images/brick.png b/html/images/brick.png deleted file mode 100644 index 7851cf3..0000000 --- a/html/images/brick.png +++ /dev/null Binary files differ diff --git a/html/images/brick_link.png b/html/images/brick_link.png deleted file mode 100644 index 9ebf013..0000000 --- a/html/images/brick_link.png +++ /dev/null Binary files differ diff --git a/html/images/bug.png b/html/images/bug.png deleted file mode 100644 index 2d5fb90..0000000 --- a/html/images/bug.png +++ /dev/null Binary files differ diff --git a/html/images/bullet_black.png b/html/images/bullet_black.png deleted file mode 100644 index 5761970..0000000 --- a/html/images/bullet_black.png +++ /dev/null Binary files differ diff --git a/html/images/bullet_toggle_minus.png b/html/images/bullet_toggle_minus.png deleted file mode 100644 index b47ce55..0000000 --- a/html/images/bullet_toggle_minus.png +++ /dev/null Binary files differ diff --git a/html/images/bullet_toggle_plus.png b/html/images/bullet_toggle_plus.png deleted file mode 100644 index 9ab4a89..0000000 --- a/html/images/bullet_toggle_plus.png +++ /dev/null Binary files differ diff --git a/html/images/date.png b/html/images/date.png deleted file mode 100644 index 783c833..0000000 --- a/html/images/date.png +++ /dev/null Binary files differ diff --git a/html/images/delete.png b/html/images/delete.png deleted file mode 100644 index 08f2493..0000000 --- a/html/images/delete.png +++ /dev/null Binary files differ diff --git a/html/images/find.png b/html/images/find.png deleted file mode 100644 index 1547479..0000000 --- a/html/images/find.png +++ /dev/null Binary files differ diff --git a/html/images/loadingAnimation.gif b/html/images/loadingAnimation.gif deleted file mode 100644 index 82290f4..0000000 --- a/html/images/loadingAnimation.gif +++ /dev/null Binary files differ diff --git a/html/images/macFFBgHack.png b/html/images/macFFBgHack.png deleted file mode 100644 index c6473b3..0000000 --- a/html/images/macFFBgHack.png +++ /dev/null Binary files differ diff --git a/html/images/package.png b/html/images/package.png deleted file mode 100644 index da3c2a2..0000000 --- a/html/images/package.png +++ /dev/null Binary files differ diff --git a/html/images/page_green.png b/html/images/page_green.png deleted file mode 100644 index de8e003..0000000 --- a/html/images/page_green.png +++ /dev/null Binary files differ diff --git a/html/images/page_white_text.png b/html/images/page_white_text.png deleted file mode 100644 index 813f712..0000000 --- a/html/images/page_white_text.png +++ /dev/null Binary files differ diff --git a/html/images/page_white_width.png b/html/images/page_white_width.png deleted file mode 100644 index 1eb8809..0000000 --- a/html/images/page_white_width.png +++ /dev/null Binary files differ diff --git a/html/images/plugin.png b/html/images/plugin.png deleted file mode 100644 index 6187b15..0000000 --- a/html/images/plugin.png +++ /dev/null Binary files differ diff --git a/html/images/ruby.png b/html/images/ruby.png deleted file mode 100644 index f763a16..0000000 --- a/html/images/ruby.png +++ /dev/null Binary files differ diff --git a/html/images/tag_blue.png b/html/images/tag_blue.png deleted file mode 100644 index 3f02b5f..0000000 --- a/html/images/tag_blue.png +++ /dev/null Binary files differ diff --git a/html/images/tag_green.png b/html/images/tag_green.png deleted file mode 100644 index 83ec984..0000000 --- a/html/images/tag_green.png +++ /dev/null Binary files differ diff --git a/html/images/transparent.png b/html/images/transparent.png deleted file mode 100644 index d665e17..0000000 --- a/html/images/transparent.png +++ /dev/null Binary files differ diff --git a/html/images/wrench.png b/html/images/wrench.png deleted file mode 100644 index 5c8213f..0000000 --- a/html/images/wrench.png +++ /dev/null Binary files differ diff --git a/html/images/wrench_orange.png b/html/images/wrench_orange.png deleted file mode 100644 index 565a933..0000000 --- a/html/images/wrench_orange.png +++ /dev/null Binary files differ diff --git a/html/images/zoom.png b/html/images/zoom.png deleted file mode 100644 index 908612e..0000000 --- a/html/images/zoom.png +++ /dev/null Binary files differ diff --git a/html/index.html b/html/index.html deleted file mode 100644 index d4524bb..0000000 --- a/html/index.html +++ /dev/null @@ -1,310 +0,0 @@ - - - - - - -DMPonline4 Documentation - - - - - - - - - - - - - - - - -
- -

DMPonline v4

- -

DMPonline is the DCC's data management planning tool, available at dmponline.dcc.ac.uk

- -

Development of the DMPonline by the Digital Curation Centre has been funded -by JISC. JISC inspires UK colleges and universities in the innovative use -of digital technologies, helping to maintain the UK's position as a -global leader in education. www.jisc.ac.uk

- -

This is just the application code, the accompanying question data available -at dmponline.dcc.ac.uk is not -included.

- -

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.

    -
- -

Documentation & Support

- - -

Bugs & Feature Requests

- - -

Prerequisites

- -

DMPonline is a Ruby on Rails application and you will need to have Ruby -2.0.0p247 or greater installed on your server and a MySQL server v5.0 or -greater.

- -

Further details on how to install Ruby on Rails applications are available -from the Ruby on Rails site, rubyonrails.org

- -

You may also find the following resources handy:

- - - - -

Copyright © 2013 Digital Curation Centre, University of Edinburgh.

- -

This program is free software: you can redistribute it and/or modify it -under the terms of the GNU Affero General Public License as published by -the Free Software Foundation, either version 3 of the License, or (at your -option) any later version.

- -

This program is distributed in the hope that it will be useful, but WITHOUT -ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License -for more details.

- -

You should have received a copy of the GNU Affero General Public License -along with this program. If not, see www.gnu.org/licenses.

- -
- - - - diff --git a/html/js/darkfish.js b/html/js/darkfish.js deleted file mode 100644 index 92d8280..0000000 --- a/html/js/darkfish.js +++ /dev/null @@ -1,155 +0,0 @@ -/** - * - * Darkfish Page Functions - * $Id: darkfish.js 53 2009-01-07 02:52:03Z deveiant $ - * - * Author: Michael Granger - * - */ - -/* Provide console simulation for firebug-less environments */ -if (!("console" in window) || !("firebug" in console)) { - var names = ["log", "debug", "info", "warn", "error", "assert", "dir", "dirxml", - "group", "groupEnd", "time", "timeEnd", "count", "trace", "profile", "profileEnd"]; - - window.console = {}; - for (var i = 0; i < names.length; ++i) - window.console[names[i]] = function() {}; -}; - - -/** - * Unwrap the first element that matches the given @expr@ from the targets and return them. - */ -$.fn.unwrap = function( expr ) { - return this.each( function() { - $(this).parents( expr ).eq( 0 ).after( this ).remove(); - }); -}; - - -function showSource( e ) { - var target = e.target; - var codeSections = $(target). - parents('.method-detail'). - find('.method-source-code'); - - $(target). - parents('.method-detail'). - find('.method-source-code'). - slideToggle(); -}; - -function hookSourceViews() { - $('.method-heading').click( showSource ); -}; - -function toggleDebuggingSection() { - $('.debugging-section').slideToggle(); -}; - -function hookDebuggingToggle() { - $('#debugging-toggle img').click( toggleDebuggingSection ); -}; - -function hookTableOfContentsToggle() { - $('.indexpage li .toc-toggle').each( function() { - $(this).click( function() { - $(this).toggleClass('open'); - }); - - var section = $(this).next(); - - $(this).click( function() { - section.slideToggle(); - }); - }); -} - -function hookSearch() { - var input = $('#search-field').eq(0); - var result = $('#search-results').eq(0); - $(result).show(); - - var search_section = $('#search-section').get(0); - $(search_section).show(); - - var search = new Search(search_data, input, result); - - search.renderItem = function(result) { - var li = document.createElement('li'); - var html = ''; - - // TODO add relative path to - - - - - - - - - - -

Table of Contents - DMPonline4 Documentation

- -

Pages

- - -

Classes/Modules

- - -

Methods

- - - - - diff --git a/public/html/Ability.html b/public/html/Ability.html new file mode 100644 index 0000000..d808822 --- /dev/null +++ b/public/html/Ability.html @@ -0,0 +1,388 @@ + + + + + + +class Ability - DMPonline4 Documentation + + + + + + + + + + + + + + + + +
+

class Ability

+ +
+ +
+ + + + +
+ + + + + + + + + + +
+

Public Class Methods

+ + +
+ +
+ new(user) + click to toggle source +
+ + +
+ + + + + +
+
# File app/models/ability.rb, line 4
+def initialize(user)
+  # Define abilities for the passed in user here. For example:
+
+  #
+
+    user ||= User.new # guest user (not logged in)
+
+    if user.has_role? :admin
+      can :manage, :all
+    else
+      can :read, :all
+    end
+
+  can :manage_settings, User do |viewed_user|
+    viewed_user.present? && user.id == viewed_user.id
+  end
+  #
+
+  # The first argument to `can` is the action you are giving the user 
+
+  # permission to do.
+
+  # If you pass :manage it will apply to every action. Other common actions
+
+  # here are :read, :create, :update and :destroy.
+
+  #
+
+  # The second argument is the resource the user can perform the action on. 
+
+  # If you pass :all it will apply to every resource. Otherwise pass a Ruby
+
+  # class of the resource.
+
+  #
+
+  # The third argument is an optional hash of conditions to further filter the
+
+  # objects.
+
+  # For example, here the user can only update published articles.
+
+  #
+
+  #   can :update, Article, :published => true
+
+  #
+
+  # See the wiki for details:
+
+  # https://github.com/ryanb/cancan/wiki/Defining-Abilities
+
+ 
+end
+
+ +
+ + + + +
+ + +
+ +
+ +
+ + + + diff --git a/public/html/ActiveAdmin.html b/public/html/ActiveAdmin.html new file mode 100644 index 0000000..aeb8dc4 --- /dev/null +++ b/public/html/ActiveAdmin.html @@ -0,0 +1,272 @@ + + + + + + +module ActiveAdmin - DMPonline4 Documentation + + + + + + + + + + + + + + + + +
+

module ActiveAdmin

+ +
+ +
+ + + + +
+ + + + + + + + + + +
+ +
+ + + + diff --git a/public/html/ActiveAdmin/Views.html b/public/html/ActiveAdmin/Views.html new file mode 100644 index 0000000..8b4e4fe --- /dev/null +++ b/public/html/ActiveAdmin/Views.html @@ -0,0 +1,272 @@ + + + + + + +module ActiveAdmin::Views - DMPonline4 Documentation + + + + + + + + + + + + + + + + +
+

module ActiveAdmin::Views

+ +
+ +
+ + + + +
+ + + + + + + + + + +
+ +
+ + + + diff --git a/public/html/ActiveAdmin/Views/Pages.html b/public/html/ActiveAdmin/Views/Pages.html new file mode 100644 index 0000000..cc0eccd --- /dev/null +++ b/public/html/ActiveAdmin/Views/Pages.html @@ -0,0 +1,272 @@ + + + + + + +module ActiveAdmin::Views::Pages - DMPonline4 Documentation + + + + + + + + + + + + + + + + +
+

module ActiveAdmin::Views::Pages

+ +
+ +
+ + + + +
+ + + + + + + + + + +
+ +
+ + + + diff --git a/public/html/ActiveAdmin/Views/Pages/Base.html b/public/html/ActiveAdmin/Views/Pages/Base.html new file mode 100644 index 0000000..0920d9a --- /dev/null +++ b/public/html/ActiveAdmin/Views/Pages/Base.html @@ -0,0 +1,331 @@ + + + + + + +class ActiveAdmin::Views::Pages::Base - DMPonline4 Documentation + + + + + + + + + + + + + + + + +
+

class ActiveAdmin::Views::Pages::Base

+ +
+ +

lib/active_admin_views_pages_base.rb

+ +
+ + + + +
+ + + + + + + + + + +
+

Private Instance Methods

+ + + + + +
+ +
+ +
+ + + + diff --git a/public/html/AdminUser.html b/public/html/AdminUser.html new file mode 100644 index 0000000..25177a0 --- /dev/null +++ b/public/html/AdminUser.html @@ -0,0 +1,279 @@ + + + + + + +class AdminUser - DMPonline4 Documentation + + + + + + + + + + + + + + + + +
+

class AdminUser

+ +
+ +
+ + + + +
+ + + + + + + + + + +
+ +
+ + + + diff --git a/public/html/Answer.html b/public/html/Answer.html new file mode 100644 index 0000000..0693ae3 --- /dev/null +++ b/public/html/Answer.html @@ -0,0 +1,279 @@ + + + + + + +class Answer - DMPonline4 Documentation + + + + + + + + + + + + + + + + +
+

class Answer

+ +
+ +
+ + + + +
+ + + + + + + + + + +
+ +
+ + + + diff --git a/public/html/AnswersController.html b/public/html/AnswersController.html new file mode 100644 index 0000000..b017bbd --- /dev/null +++ b/public/html/AnswersController.html @@ -0,0 +1,360 @@ + + + + + + +class AnswersController - DMPonline4 Documentation + + + + + + + + + + + + + + + + +
+

class AnswersController

+ +
+ +
+ + + + +
+ + + + + + + + + + +
+

Public Instance Methods

+ + +
+ +
+ create() + click to toggle source +
+ + +
+ +

POST /answers POST /answers.json

+ + + +
+
# File app/controllers/answers_controller.rb, line 5
+def create
+        @answer = Answer.new(params[:answer])
+        if (user_signed_in?) && @answer.plan.editable_by(current_user.id) then
+                old_answer = @answer.plan.answer(@answer.question_id, false)
+                proceed = false
+                @answer.text = params["answer-text-#{@answer.question_id}".to_sym]
+                if (old_answer.nil? && @answer.text != "") || ((!old_answer.nil?) && (old_answer.text != @answer.text)) then
+                        proceed = true
+                end
+    
+                if (@answer.question.question_format.title == I18n.t("helpers.checkbox") || 
+        @answer.question.question_format.title == I18n.t("helpers.multi_select_box") ||
+        @answer.question.question_format.title == I18n.t("helpers.radio_buttons") || 
+        @answer.question.question_format.title == I18n.t("helpers.dropdown")) then
+                        if (old_answer.nil? && @answer.option_ids.count > 0) || ((!old_answer.nil?) && (old_answer.option_ids - @answer.option_ids).count != 0 && (@answer.option_ids - old_answer.option_ids).count != 0) then
+                                proceed = true
+                        end
+                end
+                if proceed
+                        respond_to do |format|
+                                if @answer.save
+                                        format.html { redirect_to :back, status: :found, notice: 'Answer was successfully recorded.' }
+                                        format.json { render json: @answer, status: :created, location: @answer }
+                                else
+                                        format.html { redirect_to :back, notice: 'There was an error saving the answer.' }
+                                        format.json { render json: @answer.errors, status: :unprocessable_entity }
+                                end
+                        end
+                else
+                        respond_to do |format|
+                                format.html { redirect_to :back, notice: 'No change in answer content - not saved.' }
+                                format.json { render json: @answer.errors, status: :unprocessable_entity }
+                        end
+                end
+        else
+                render(:file => File.join(Rails.root, 'public/403.html'), :status => 403, :layout => false)
+        end
+end
+
+ +
+ + + + +
+ + +
+ +
+ +
+ + + + diff --git a/public/html/ApplicationController.html b/public/html/ApplicationController.html new file mode 100644 index 0000000..4e977fd --- /dev/null +++ b/public/html/ApplicationController.html @@ -0,0 +1,529 @@ + + + + + + +class ApplicationController - DMPonline4 Documentation + + + + + + + + + + + + + + + + +
+

class ApplicationController

+ +
+ +
+ + + + +
+ + + + + + + + + + +
+

Public Instance Methods

+ + +
+ +
+ after_sign_in_error_path_for(resource) + click to toggle source +
+ + +
+ + + + + +
+
# File app/controllers/application_controller.rb, line 32
+def after_sign_in_error_path_for(resource)
+  session[:previous_url] || root_path
+end
+
+ +
+ + + + +
+ + +
+ +
+ after_sign_in_path_for(resource) + click to toggle source +
+ + +
+ + + + + +
+
# File app/controllers/application_controller.rb, line 24
+def after_sign_in_path_for(resource)
+  session[:previous_url] || root_path
+end
+
+ +
+ + + + +
+ + +
+ +
+ after_sign_up_error_path_for(resource) + click to toggle source +
+ + +
+ + + + + +
+
# File app/controllers/application_controller.rb, line 36
+def after_sign_up_error_path_for(resource)
+  session[:previous_url] || root_path
+end
+
+ +
+ + + + +
+ + +
+ +
+ after_sign_up_path_for(resource) + click to toggle source +
+ + +
+ + + + + +
+
# File app/controllers/application_controller.rb, line 28
+def after_sign_up_path_for(resource)
+  session[:previous_url] || root_path
+end
+
+ +
+ + + + +
+ + +
+ +
+ authenticate_admin!() + click to toggle source +
+ + +
+ + + + + +
+
# File app/controllers/application_controller.rb, line 40
+def authenticate_admin!
+        redirect_to root_path unless user_signed_in? && current_user.can_super_admin?
+end
+
+ +
+ + + + +
+ + +
+ +
+ get_plan_list_columns() + click to toggle source +
+ + +
+ + + + + +
+
# File app/controllers/application_controller.rb, line 44
+def get_plan_list_columns
+        if user_signed_in?
+                @selected_columns = current_user.settings(:plan_list).columns
+                @all_columns = Settings::PlanList::ALL_COLUMNS
+        end
+end
+
+ +
+ + + + +
+ + +
+ +
+ store_location() + click to toggle source +
+ + +
+ + + + + +
+
# File app/controllers/application_controller.rb, line 13
+def store_location
+ # store last url - this is needed for post-login redirect to whatever the user last visited.
+
+        if (request.fullpath != "/users/sign_in" && \
+                request.fullpath != "/users/sign_up" && \
+                request.fullpath != "/users/password" && \
+    request.fullpath != "/users/sign_up?nosplash=true" && \
+                !request.xhr?) # don't store ajax calls
+
+          session[:previous_url] = request.fullpath 
+        end
+end
+
+ +
+ + + + +
+ + +
+ +
+ +
+ + + + diff --git a/public/html/ApplicationHelper.html b/public/html/ApplicationHelper.html new file mode 100644 index 0000000..c5ea91c --- /dev/null +++ b/public/html/ApplicationHelper.html @@ -0,0 +1,453 @@ + + + + + + +module ApplicationHelper - DMPonline4 Documentation + + + + + + + + + + + + + + + + +
+

module ApplicationHelper

+ +
+ +
+ + + + +
+ + + + + + + + + + +
+

Public Instance Methods

+ + +
+ +
+ devise_mapping() + click to toggle source +
+ + +
+ + + + + +
+
# File app/helpers/application_helper.rb, line 10
+def devise_mapping
+        @devise_mapping ||= Devise.mappings[:user]
+end
+
+ +
+ + + + +
+ + +
+ +
+ javascript(*files) + click to toggle source +
+ + +
+ + + + + +
+
# File app/helpers/application_helper.rb, line 14
+def javascript(*files)
+  content_for(:head) { javascript_include_tag(*files) }
+end
+
+ +
+ + + + +
+ + + + + +
+ +
+ resource() + click to toggle source +
+ + +
+ + + + + +
+
# File app/helpers/application_helper.rb, line 6
+def resource
+        @resource ||= User.new
+end
+
+ +
+ + + + +
+ + +
+ +
+ resource_name() + click to toggle source +
+ + +
+ + + + + +
+
# File app/helpers/application_helper.rb, line 2
+def resource_name
+        :user
+end
+
+ +
+ + + + +
+ + +
+ +
+ +
+ + + + diff --git a/public/html/Comment.html b/public/html/Comment.html new file mode 100644 index 0000000..9f7cf6b --- /dev/null +++ b/public/html/Comment.html @@ -0,0 +1,325 @@ + + + + + + +class Comment - DMPonline4 Documentation + + + + + + + + + + + + + + + + +
+

class Comment

+ +
+ +
+ + + + +
+ + + + + + + + + + +
+

Public Instance Methods

+ + +
+ +
+ to_s() + click to toggle source +
+ + +
+ + + + + +
+
# File app/models/comment.rb, line 11
+def to_s
+    "#{text}"
+end
+
+ +
+ + + + +
+ + +
+ +
+ +
+ + + + diff --git a/public/html/CommentsController.html b/public/html/CommentsController.html new file mode 100644 index 0000000..7c5267e --- /dev/null +++ b/public/html/CommentsController.html @@ -0,0 +1,538 @@ + + + + + + +class CommentsController - DMPonline4 Documentation + + + + + + + + + + + + + + + + +
+

class CommentsController

+ +
+ +
+ + + + +
+ + + + + + + + + + +
+

Public Instance Methods

+ + +
+ +
+ archive() + click to toggle source +
+ + +
+ +

ARCHIVE /comments/1 ARCHIVE /comments/1.json

+ + + +
+
# File app/controllers/comments_controller.rb, line 73
+def archive
+  @comment = Comment.find(params[:comment][:id])
+  @comment.archived = true
+  @comment.archived_by = params[:comment][:archived_by]
+  
+  @plan = Plan.find(@comment.plan_id)
+  @project = Project.find(@plan.project_id)
+
+  respond_to do |format|
+    if @comment.update_attributes(params[:comment])
+      session[:question_id_comments] = @comment.question_id
+      format.html { redirect_to edit_project_plan_path(@project, @plan), status: :found, notice: 'Comment has been removed.' }     
+    end   
+  end
+end
+
+ +
+ + + + +
+ + +
+ +
+ create() + click to toggle source +
+ + +
+ +

POST /comments POST /comments.json

+ + + +
+
# File app/controllers/comments_controller.rb, line 32
+def create
+ if user_signed_in? then
+      @comment = Comment.new(params[:new_comment])
+      @comment.text = params["#{params[:new_comment][:question_id]}new_comment_text"]
+      @comment.question_id = params[:new_comment][:question_id]
+      @comment.user_id = params[:new_comment][:user_id]
+      @comment.plan_id = params[:new_comment][:plan_id]
+      
+      @plan = Plan.find(@comment.plan_id)
+      @project = Project.find(@plan.project_id)
+      
+      respond_to do |format|
+        if @comment.save
+          session[:question_id_comments] = @comment.question_id
+          format.html { redirect_to edit_project_plan_path(@project, @plan), status: :found, notice: 'Comment was successfully created.' }
+          format.json { head :no_content  }
+        end
+      end
+  end    
+end
+
+ +
+ + + + +
+ + +
+ +
+ edit() + click to toggle source +
+ + +
+ +

GET /comments/1/edit

+ + + +
+
# File app/controllers/comments_controller.rb, line 26
+def edit
+  @comment = Comment.find(params[:id])
+end
+
+ +
+ + + + +
+ + +
+ +
+ index() + click to toggle source +
+ + +
+ +

GET /comments GET /comments.json

+ + + +
+
# File app/controllers/comments_controller.rb, line 4
+def index
+  @comments = Comment.all
+
+  respond_to do |format|
+    format.html # index.html.erb
+
+    format.json { render json: @comments }
+  end
+end
+
+ +
+ + + + +
+ + +
+ +
+ show() + click to toggle source +
+ + +
+ +

GET /comments/1 GET /comments/1.json

+ + + +
+
# File app/controllers/comments_controller.rb, line 15
+def show
+  @comment = Comment.find(params[:id])
+
+  respond_to do |format|
+    format.html # show.html.erb
+
+    format.json { render json: @comment }
+  end
+end
+
+ +
+ + + + +
+ + +
+ +
+ update() + click to toggle source +
+ + +
+ +

PUT /comments/1 PUT /comments/1.json

+ + + +
+
# File app/controllers/comments_controller.rb, line 55
+def update
+  @comment = Comment.find(params[:comment][:id])
+  @comment.text = params["#{params[:comment][:id]}_comment_text"]
+  
+  @plan = Plan.find(@comment.plan_id)
+  @project = Project.find(@plan.project_id)
+  
+  respond_to do |format|
+    if @comment.update_attributes(params[:comment])
+      session[:question_id_comments] = @comment.question_id
+      format.html { redirect_to edit_project_plan_path(@project, @plan), status: :found, notice: 'Comment was successfully updated.' }
+      format.json { head :no_content }
+    end
+  end
+end
+
+ +
+ + + + +
+ + +
+ +
+ +
+ + + + diff --git a/public/html/ConfirmationsController.html b/public/html/ConfirmationsController.html new file mode 100644 index 0000000..11e2609 --- /dev/null +++ b/public/html/ConfirmationsController.html @@ -0,0 +1,325 @@ + + + + + + +class ConfirmationsController - DMPonline4 Documentation + + + + + + + + + + + + + + + + +
+

class ConfirmationsController

+ +
+ +
+ + + + +
+ + + + + + + + + + +
+

Protected Instance Methods

+ + +
+ +
+ after_confirmation_path_for(resource_name, resource) + click to toggle source +
+ + +
+ + + + + +
+
# File app/controllers/confirmations_controller.rb, line 5
+def after_confirmation_path_for(resource_name, resource)
+  root_path
+end
+
+ +
+ + + + +
+ + +
+ +
+ +
+ + + + diff --git a/public/html/ContactsController.html b/public/html/ContactsController.html new file mode 100644 index 0000000..5cbc8c6 --- /dev/null +++ b/public/html/ContactsController.html @@ -0,0 +1,350 @@ + + + + + + +class ContactsController - DMPonline4 Documentation + + + + + + + + + + + + + + + + +
+

class ContactsController

+ +
+ +
+ + + + +
+ + + + + + + + + + +
+

Public Instance Methods

+ + +
+ +
+ create() + click to toggle source +
+ + +
+ + + + + +
+
# File app/controllers/contacts_controller.rb, line 2
+def create
+        @contact = ContactUs::Contact.new(params[:contact_us_contact])
+        if (!user_signed_in?)
+                if verify_recaptcha(:message => "You have not added the validation words correctly") && @contact.save
+                        flash[:notice] = t('contact_us.notices.success')
+                        if user_signed_in? then
+                             redirect_to :controller => 'projects', :action => 'index'
+                     else
+                             redirect_to(root_path)
+                     end
+                else
+                     flash[:alert]  = t('contact_us.notices.error')
+                     render_new_page
+                end
+        else
+                if @contact.save
+                        flash[:notice] = t('contact_us.notices.success')
+                        if user_signed_in? then
+                             redirect_to :controller => 'projects', :action => 'index'
+                     else
+                             redirect_to(root_path)
+                     end
+                else
+                     flash[:alert] = t('contact_us.notices.error')
+                     render_new_page
+                end
+        end           
+end
+
+ +
+ + + + +
+ + +
+ +
+ +
+ + + + diff --git a/public/html/CustomFailure.html b/public/html/CustomFailure.html new file mode 100644 index 0000000..00e20d5 --- /dev/null +++ b/public/html/CustomFailure.html @@ -0,0 +1,361 @@ + + + + + + +class CustomFailure - DMPonline4 Documentation + + + + + + + + + + + + + + + + +
+

class CustomFailure

+ +
+ +
+ + + + +
+ + + + + + + + + + +
+

Public Instance Methods

+ + +
+ +
+ redirect_url() + click to toggle source +
+ + +
+ + + + + +
+
# File lib/custom_failure.rb, line 2
+def redirect_url
+  root_path
+end
+
+ +
+ + + + +
+ + +
+ +
+ respond() + click to toggle source +
+ + +
+ + + + + +
+
# File lib/custom_failure.rb, line 6
+def respond
+  if http_auth?
+    http_auth
+  else
+    redirect
+  end
+end
+
+ +
+ + + + +
+ + +
+ +
+ +
+ + + + diff --git a/public/html/DMPonline4.html b/public/html/DMPonline4.html new file mode 100644 index 0000000..299d664 --- /dev/null +++ b/public/html/DMPonline4.html @@ -0,0 +1,274 @@ + + + + + + +module DMPonline4 - DMPonline4 Documentation + + + + + + + + + + + + + + + + +
+

module DMPonline4

+ +
+ +
+ + + + +
+ + + + + + + + + + +
+ +
+ + + + diff --git a/public/html/DMPonline4/Application.html b/public/html/DMPonline4/Application.html new file mode 100644 index 0000000..35ca2cd --- /dev/null +++ b/public/html/DMPonline4/Application.html @@ -0,0 +1,280 @@ + + + + + + +class DMPonline4::Application - DMPonline4 Documentation + + + + + + + + + + + + + + + + +
+

class DMPonline4::Application

+ +
+ +
+ + + + +
+ + + + + + + + + + +
+ +
+ + + + diff --git a/public/html/Dmptemplate.html b/public/html/Dmptemplate.html new file mode 100644 index 0000000..3de2e67 --- /dev/null +++ b/public/html/Dmptemplate.html @@ -0,0 +1,602 @@ + + + + + + +class Dmptemplate - DMPonline4 Documentation + + + + + + + + + + + + + + + + +
+

class Dmptemplate

+ +
+ +
+ + + + +
+ + + + + + + + + + +
+

Public Class Methods

+ + +
+ +
+ funders_and_own_templates(org_id) + click to toggle source +
+ + +
+ +

returns an array with all funders and own institutional templates

+ + + +
+
# File app/models/dmptemplate.rb, line 63
+def self.funders_and_own_templates(org_id)
+        funders_templates = self.funders_templates
+
+#verify if org type is not a funder
+
+current_org = Organisation.find(org_id)
+if current_org.organisation_type.name != I18n.t("helpers.org_type.funder") then 
+    own_institutional_templates = self.own_institutional_templates(org_id)
+        else
+    own_institutional_templates = []
+end    
+    
+        templates_list = Array.new
+        templates_list += own_institutional_templates
+        templates_list += funders_templates
+        templates_list = templates_list.sort_by { |f| f['title'].downcase }
+                        
+        return templates_list
+end
+
+ +
+ + + + +
+ + +
+ +
+ funders_templates() + click to toggle source +
+ + +
+ +

returns all funders templates

+ + + +
+
# File app/models/dmptemplate.rb, line 44
+    def self.funders_templates
+            new_org_obejcts = OrganisationType.find_by_name(I18n.t("helpers.org_type.funder")).organisations
+      org_templates = Array.new
+    
+    new_org_obejcts.each do |neworg|
+    org_templates += neworg.dmptemplates
+end
+
+return org_templates        
+    end
+
+ +
+ + + + +
+ + +
+ +
+ own_institutional_templates(org_id) + click to toggle source +
+ + +
+ +

returns all institutional templates bellowing to the current user's org

+ + + +
+
# File app/models/dmptemplate.rb, line 57
+def self.own_institutional_templates(org_id)
+        new_templates = self.where("organisation_id = ?", org_id)
+        return new_templates
+end
+
+ +
+ + + + +
+ + +
+ +
+ templates_org_type(ot) + click to toggle source +
+ + +
+ + + + + +
+
# File app/models/dmptemplate.rb, line 32
+def self.templates_org_type(ot)
+  new_org_obejcts = OrganisationType.find_by_name(ot).organisations
+  
+  org_templates = Array.new
+  new_org_obejcts.each do |neworg|
+     org_templates += neworg.dmptemplates.where("published = ?", true)
+  end
+  
+  return org_templates
+end
+
+ +
+ + + + +
+ + +
+ +
+

Public Instance Methods

+ + +
+ +
+ has_customisations?(org_id, temp) + click to toggle source +
+ + +
+ +

verify if a template has customisation by current user's org

+ + + +
+
# File app/models/dmptemplate.rb, line 88
+def has_customisations?(org_id, temp)
+        if temp.organisation_id != org_id then
+                temp.phases.each do |phase|
+                        phase.versions.each do |version|
+                                version.sections.each do |section|
+                                        return true if section.organisation_id == org_id 
+                                                                                
+                                end        
+                        end
+                        return false 
+                end
+        else
+                return false         
+        end   
+end
+
+ +
+ + + + +
+ + +
+ +
+ has_published_versions?() + click to toggle source +
+ + +
+ +

verify if there are any publish version for the template

+ + + +
+
# File app/models/dmptemplate.rb, line 106
+def has_published_versions?
+        phases.each do |phase|
+                return true if !phase.latest_published_version.nil?
+        end
+        return false 
+end
+
+ +
+ + + + +
+ + +
+ +
+ org_type() + click to toggle source +
+ + +
+ + + + + +
+
# File app/models/dmptemplate.rb, line 82
+def org_type
+        org_type = organisation.organisation_type.name
+        return org_type
+end
+
+ +
+ + + + +
+ + +
+ +
+ to_s() + click to toggle source +
+ + +
+ + + + + +
+
# File app/models/dmptemplate.rb, line 28
+def to_s
+  "#{title}"
+end
+
+ +
+ + + + +
+ + +
+ +
+ +
+ + + + diff --git a/public/html/DmptemplatesController.html b/public/html/DmptemplatesController.html new file mode 100644 index 0000000..f4c7d37 --- /dev/null +++ b/public/html/DmptemplatesController.html @@ -0,0 +1,1427 @@ + + + + + + +class DmptemplatesController - DMPonline4 Documentation + + + + + + + + + + + + + + + + +
+

class DmptemplatesController

+ +
+
Project: +
+

DMPonline v4

+
Description: +
+

This controller is responsible for all the actions in the admin interface +under templates (e.g. phases, versions, sections, questions, suggested +answer) (index; show; create; edit; delete)

+
Copyright: +
+

Digital Curation Centre

+
+ +
+ + + + +
+ + + + + + + + + + +
+

Public Instance Methods

+ + +
+ +
+ admin_addphase() + click to toggle source +
+ + +
+ +

add a new phase to a template

+ + + +
+
# File app/controllers/dmptemplates_controller.rb, line 187
+def admin_addphase
+        if user_signed_in? && current_user.can_org_admin? then
+                @dmptemplate = Dmptemplate.find(params[:id])
+                @phase = Phase.new
+                if @dmptemplate.phases.count == 0 then
+                        @phase.number = '1'
+                else
+                        @phase.number = @dmptemplate.phases.count + 1
+                end
+
+                respond_to do |format|
+      format.html
+    end
+        end
+end
+
+ +
+ + + + +
+ + +
+ +
+ admin_cloneversion() + click to toggle source +
+ + +
+ +

clone a version of a template

+ + + +
+
# File app/controllers/dmptemplates_controller.rb, line 293
+def admin_cloneversion
+        if user_signed_in? && current_user.can_org_admin? then
+@old_version = Version.find(params[:version_id])
+                @version = @old_version.amoeba_dup
+                @phase = @version.phase
+
+    respond_to do |format|
+      if @version.save
+        format.html { redirect_to admin_phase_dmptemplate_path(@phase, :version_id => @version.id, :edit => 'true'), notice: I18n.t('org_admin.templates.updated_message') }
+        format.json { head :no_content }
+      else
+        format.html { render action: "admin_phase" }
+        format.json { render json: @version.errors, status: :unprocessable_entity }
+      end
+    end
+        end
+end
+
+ +
+ + + + +
+ + +
+ +
+ admin_create() + click to toggle source +
+ + +
+ +

POST /dmptemplates POST /dmptemplates.json

+ + + +
+
# File app/controllers/dmptemplates_controller.rb, line 81
+def admin_create
+  if user_signed_in? && current_user.can_org_admin? then
+          @dmptemplate = Dmptemplate.new(params[:dmptemplate])
+          @dmptemplate.organisation_id = current_user.organisation.id
+          @dmptemplate.description = params['template-desc']
+
+          respond_to do |format|
+            if @dmptemplate.save
+              format.html { redirect_to admin_template_dmptemplate_path(@dmptemplate), notice: I18n.t('org_admin.templates.created_message') }
+              format.json { render json: @dmptemplate, status: :created, location: @dmptemplate }
+            else
+              format.html { render action: "admin_new" }
+              format.json { render json: @dmptemplate.errors, status: :unprocessable_entity }
+            end
+          end
+  else
+                      render(:file => File.join(Rails.root, 'public/403.html'), :status => 403, :layout => false)
+              end
+end
+
+ +
+ + + + +
+ + +
+ +
+ admin_createphase() + click to toggle source +
+ + +
+ +

create a phase

+ + + +
+
# File app/controllers/dmptemplates_controller.rb, line 204
+      def admin_createphase
+  if user_signed_in? && current_user.can_org_admin? then
+             @phase = Phase.new(params[:phase])
+          @phase.description = params["phase-desc"]
+          @version = @phase.versions.build
+          @version.title = "#{@phase.title} v.1"
+          @version.phase_id = @phase.id
+          @version.number = 1
+          @version.published = false
+
+          respond_to do |format|
+            if @phase.save
+              format.html { redirect_to admin_phase_dmptemplate_path(:id => @phase.id, :version_id => @version.id, :edit => 'true'), notice: I18n.t('org_admin.templates.created_message') }
+              format.json { head :no_content }
+            else
+              format.html { render action: "admin_phase" }
+              format.json { render json: @phase.errors, status: :unprocessable_entity }
+            end
+                      end
+              end
+end
+
+ +
+ + + + +
+ + +
+ +
+ admin_createquestion() + click to toggle source +
+ + +
+ +

create a question

+ + + +
+
# File app/controllers/dmptemplates_controller.rb, line 386
+      def admin_createquestion
+  if user_signed_in? && current_user.can_org_admin? then
+             @question = Question.new(params[:question])
+          @question.guidance = params["new-question-guidance"]
+          @question.default_value = params["new-question-default-value"]
+
+
+          respond_to do |format|
+            if @question.save
+              format.html { redirect_to admin_phase_dmptemplate_path(:id => @question.section.version.phase_id, :version_id => @question.section.version_id, :section_id => @question.section_id, :question_id => @question.id, :edit => 'true'), notice: I18n.t('org_admin.templates.created_message') }
+              format.json { head :no_content }
+            else
+              format.html { render action: "admin_phase" }
+              format.json { render json: @question.errors, status: :unprocessable_entity }
+            end
+                      end
+              end
+end
+
+ +
+ + + + +
+ + +
+ +
+ admin_createsection() + click to toggle source +
+ + +
+ +

create a section

+ + + +
+
# File app/controllers/dmptemplates_controller.rb, line 328
+      def admin_createsection
+  if user_signed_in? && current_user.can_org_admin? then
+             @section = Section.new(params[:section])
+          @section.description = params["section-desc"]
+
+          respond_to do |format|
+            if @section.save
+              format.html { redirect_to admin_phase_dmptemplate_path(:id => @section.version.phase_id, :version_id => @section.version_id, :section_id => @section.id, :edit => 'true'), notice: I18n.t('org_admin.templates.created_message') }
+              format.json { head :no_content }
+            else
+              format.html { render action: "admin_phase" }
+              format.json { render json: @section.errors, status: :unprocessable_entity }
+            end
+                      end
+              end
+end
+
+ +
+ + + + +
+ + +
+ +
+ admin_createsuggestedanswer() + click to toggle source +
+ + +
+ +

SUGGESTED ANSWERS create suggested answers

+ + + +
+
# File app/controllers/dmptemplates_controller.rb, line 446
+   def admin_createsuggestedanswer
+   if user_signed_in? && current_user.can_org_admin? then
+           @suggested_answer = SuggestedAnswer.new(params[:suggested_answer])
+
+       respond_to do |format|
+         if @suggested_answer.save
+           format.html { redirect_to admin_phase_dmptemplate_path(:id => @suggested_answer.question.section.version.phase_id, :version_id => @suggested_answer.question.section.version_id, :section_id => @suggested_answer.question.section_id, :question_id => @suggested_answer.question.id, :edit => 'true'), notice: I18n.t('org_admin.templates.created_message') }
+           format.json { head :no_content }
+         else
+           format.html { render action: "admin_phase" }
+           format.json { render json: @suggested_answer.errors, status: :unprocessable_entity }
+         end
+           end
+    end
+end
+
+ +
+ + + + +
+ + +
+ +
+ admin_destroy() + click to toggle source +
+ + +
+ +

DELETE /dmptemplates/1 DELETE /dmptemplates/1.json

+ + + +
+
# File app/controllers/dmptemplates_controller.rb, line 105
+def admin_destroy
+      if user_signed_in? && current_user.can_org_admin? then
+             @dmptemplate = Dmptemplate.find(params[:id])
+          @dmptemplate.destroy
+
+          respond_to do |format|
+            format.html { redirect_to admin_index_dmptemplate_path }
+            format.json { head :no_content }
+          end
+             else
+                      render(:file => File.join(Rails.root, 'public/403.html'), :status => 403, :layout => false)
+              end
+      end
+
+ +
+ + + + +
+ + +
+ +
+ admin_destroyphase() + click to toggle source +
+ + +
+ +

delete a version, sections and questions

+ + + +
+
# File app/controllers/dmptemplates_controller.rb, line 246
+def admin_destroyphase
+if user_signed_in? && current_user.can_org_admin? then
+       @phase = Phase.find(params[:phase_id])
+       @dmptemplate = @phase.dmptemplate
+    @phase.destroy
+
+    respond_to do |format|
+      format.html { redirect_to admin_template_dmptemplate_path(@dmptemplate), notice: I18n.t('org_admin.templates.destroyed_message') }
+      format.json { head :no_content }
+    end
+       end
+end
+
+ +
+ + + + +
+ + +
+ +
+ admin_destroyquestion() + click to toggle source +
+ + +
+ +

delete a version, sections and questions

+ + + +
+
# File app/controllers/dmptemplates_controller.rb, line 428
+def admin_destroyquestion
+if user_signed_in? && current_user.can_org_admin? then
+       @question = Question.find(params[:question_id])
+       @section = @question.section
+                @version = @section.version
+       @phase = @version.phase
+    @question.destroy
+
+    respond_to do |format|
+      format.html { redirect_to admin_phase_dmptemplate_path(:id => @phase.id, :version_id => @version.id, :section_id => @section.id, :edit => 'true'), notice: I18n.t('org_admin.templates.destroyed_message') }
+      format.json { head :no_content }
+    end
+       end
+end
+
+ +
+ + + + +
+ + +
+ +
+ admin_destroysection() + click to toggle source +
+ + +
+ +

delete a section and questions

+ + + +
+
# File app/controllers/dmptemplates_controller.rb, line 368
+def admin_destroysection
+if user_signed_in? && current_user.can_org_admin? then
+       @section = Section.find(params[:section_id])
+       @version = @section.version
+       @phase = @version.phase
+    @section.destroy
+
+    respond_to do |format|
+      format.html { redirect_to admin_phase_dmptemplate_path(:id => @phase.id, :version_id => @version.id,  :edit => 'true' ), notice: I18n.t('org_admin.templates.destroyed_message') }
+      format.json { head :no_content }
+    end
+       end
+end
+
+ +
+ + + + +
+ + +
+ +
+ admin_destroysuggestedanswer() + click to toggle source +
+ + +
+ +

delete a suggested answer

+ + + +
+
# File app/controllers/dmptemplates_controller.rb, line 484
+def admin_destroysuggestedanswer
+if user_signed_in? && current_user.can_org_admin? then
+       @suggested_answer = SuggestedAnswer.find(params[:suggested_answer])
+       @question = @suggested_answer.question
+       @section = @question.section
+                @version = @section.version
+       @phase = @version.phase
+    @suggested_answer.destroy
+
+    respond_to do |format|
+      format.html { redirect_to admin_phase_dmptemplate_path(:id => @phase.id, :version_id => @version.id, :section_id => @section.id, :edit => 'true'), notice: I18n.t('org_admin.templates.destroyed_message') }
+      format.json { head :no_content }
+    end
+       end
+end
+
+ +
+ + + + +
+ + +
+ +
+ admin_destroyversion() + click to toggle source +
+ + +
+ +

delete a version, sections and questions

+ + + +
+
# File app/controllers/dmptemplates_controller.rb, line 312
+def admin_destroyversion
+if user_signed_in? && current_user.can_org_admin? then
+       @version = Version.find(params[:version_id])
+       @phase = @version.phase
+    @version.destroy
+
+    respond_to do |format|
+      format.html { redirect_to admin_phase_dmptemplate_path(@phase), notice: I18n.t('org_admin.templates.destroyed_message') }
+      format.json { head :no_content }
+    end
+       end
+end
+
+ +
+ + + + +
+ + +
+ +
+ admin_index() + click to toggle source +
+ + +
+ +

GET /dmptemplates GET /dmptemplates.json

+ + + +
+
# File app/controllers/dmptemplates_controller.rb, line 9
+def admin_index
+  if user_signed_in? && current_user.can_org_admin? then
+      #institutional templates
+
+          @dmptemplates_own = Dmptemplate.own_institutional_templates(current_user.organisation_id)
+
+          #funders templates
+
+          @dmptemplates_funders = Dmptemplate.funders_templates
+
+   respond_to do |format|
+            format.html # index.html.erb
+
+         end
+  else
+                      render(:file => File.join(Rails.root, 'public/403.html'), :status => 403, :layout => false)
+              end
+end
+
+ +
+ + + + +
+ + +
+ +
+ admin_new() + click to toggle source +
+ + +
+ +

GET /dmptemplates/new GET /dmptemplates/new.json

+ + + +
+
# File app/controllers/dmptemplates_controller.rb, line 66
+def admin_new
+  if user_signed_in? && current_user.can_org_admin? then
+          @dmptemplate = Dmptemplate.new
+
+          respond_to do |format|
+            format.html # new.html.erb
+
+            format.json { render json: @dmptemplate }
+          end
+  else
+                      render(:file => File.join(Rails.root, 'public/403.html'), :status => 403, :layout => false)
+              end
+end
+
+ +
+ + + + +
+ + +
+ +
+ admin_phase() + click to toggle source +
+ + +
+ +

show and edit a phase of the template

+ + + +
+
# File app/controllers/dmptemplates_controller.rb, line 124
+def admin_phase
+        if user_signed_in? && current_user.can_org_admin? then
+
+                @phase = Phase.find(params[:id])
+
+                if !params.has_key?(:version_id) then
+                        @edit = 'false'
+                        #check for the most recent published version, if none is available then return the most recent one
+
+                        versions = @phase.versions.where('published = ?', true).order('updated_at DESC')
+                        if versions.any?() then
+                                @version = versions.first
+                        else
+                                @version = @phase.versions.order('updated_at DESC').first
+                        end
+                        # When the version_id is passed as an argument
+
+                else
+                        @edit = params[:edit]
+                        @version = Version.find(params[:version_id])
+                end
+
+                #verify if there are any sections if not create one
+
+                @sections = @version.sections
+                if !@sections.any?() || @sections.count == 0 then
+                        @section = @version.sections.build
+                        @section.title = ''
+                        @section.version_id = params[:version_id]
+                        @section.number = 1
+                        @section.organisation_id = current_user.organisation.id
+                        @section.published = true
+                        @section.save
+                end
+
+                #verify if section_id has been passed, if so then open that section
+
+                if params.has_key?(:section_id) then
+                        @open = true
+                        @section_id = params[:section_id].to_i
+                end
+
+                if params.has_key?(:question_id) then
+                        @question_id = params[:question_id].to_i
+                end
+
+                respond_to do |format|
+                        format.html
+                end
+        end
+end
+
+ +
+ + + + +
+ + +
+ +
+ admin_previewphase() + click to toggle source +
+ + +
+ +

preview a phase

+ + + +
+
# File app/controllers/dmptemplates_controller.rb, line 173
+def admin_previewphase
+        if user_signed_in? && current_user.can_org_admin? then
+                
+                @version = Version.find(params[:id])
+                
+                        
+                respond_to do |format|
+                        format.html
+                end
+        end   
+end
+
+ +
+ + + + +
+ + +
+ +
+ admin_template() + click to toggle source +
+ + +
+ +

GET /dmptemplates/1 GET /dmptemplates/1.json

+ + + +
+
# File app/controllers/dmptemplates_controller.rb, line 27
+def admin_template
+  if user_signed_in? && current_user.can_org_admin? then
+          @dmptemplate = Dmptemplate.find(params[:id])
+
+          respond_to do |format|
+            format.html # show.html.erb
+
+            format.json { render json: @dmptemplate }
+          end
+  else
+                      render(:file => File.join(Rails.root, 'public/403.html'), :status => 403, :layout => false)
+              end
+end
+
+ +
+ + + + +
+ + +
+ +
+ admin_update() + click to toggle source +
+ + +
+ +

PUT /dmptemplates/1 PUT /dmptemplates/1.json

+ + + +
+
# File app/controllers/dmptemplates_controller.rb, line 44
+def admin_update
+      if user_signed_in? && current_user.can_org_admin? then
+              @dmptemplate = Dmptemplate.find(params[:id])
+              @dmptemplate.description = params["template-desc"]
+
+                respond_to do |format|
+            if @dmptemplate.update_attributes(params[:dmptemplate])
+              format.html { redirect_to admin_template_dmptemplate_path(params[:dmptemplate]), notice: I18n.t('org_admin.templates.updated_message') }
+              format.json { head :no_content }
+            else
+              format.html { render action: "edit" }
+              format.json { render json: @dmptemplate.errors, status: :unprocessable_entity }
+            end
+             end
+      else
+                      render(:file => File.join(Rails.root, 'public/403.html'), :status => 403, :layout => false)
+      end
+end
+
+ +
+ + + + +
+ + +
+ +
+ admin_updatephase() + click to toggle source +
+ + +
+ +

update a phase of a template

+ + + +
+
# File app/controllers/dmptemplates_controller.rb, line 228
+def admin_updatephase
+        if user_signed_in? && current_user.can_org_admin? then
+        @phase = Phase.find(params[:id])
+        @phase.description = params["phase-desc"]
+
+    respond_to do |format|
+      if @phase.update_attributes(params[:phase])
+        format.html { redirect_to admin_phase_dmptemplate_path(@phase), notice: I18n.t('org_admin.templates.updated_message') }
+        format.json { head :no_content }
+      else
+        format.html { render action: "admin_phase" }
+        format.json { render json: @phase.errors, status: :unprocessable_entity }
+      end
+    end
+        end
+end
+
+ +
+ + + + +
+ + +
+ +
+ admin_updatequestion() + click to toggle source +
+ + +
+ +

update a question of a template

+ + + +
+
# File app/controllers/dmptemplates_controller.rb, line 406
+def admin_updatequestion
+        if user_signed_in? && current_user.can_org_admin? then
+               @question = Question.find(params[:id])
+                        @question.guidance = params["question-guidance-#{params[:id]}"]
+                        @question.default_value = params["question-default-value-#{params[:id]}"]
+       @section = @question.section
+                        @version = @section.version
+                        @phase = @version.phase
+
+                        respond_to do |format|
+              if @question.update_attributes(params[:question])
+                format.html { redirect_to admin_phase_dmptemplate_path(:id => @phase.id, :version_id => @version.id, :section_id => @section.id, :question_id => @question.id, :edit => 'true'), notice: I18n.t('org_admin.templates.updated_message') }
+                format.json { head :no_content }
+              else
+                format.html { render action: "admin_phase" }
+                format.json { render json: @question.errors, status: :unprocessable_entity }
+              end
+            end
+                end
+        end
+
+ +
+ + + + +
+ + +
+ +
+ admin_updatesection() + click to toggle source +
+ + +
+ +

update a section of a template

+ + + +
+
# File app/controllers/dmptemplates_controller.rb, line 347
+def admin_updatesection
+        if user_signed_in? && current_user.can_org_admin? then
+               @section = Section.find(params[:id])
+               @section.description = params["section-desc-#{params[:id]}"]
+       @version = @section.version
+                        @phase = @version.phase
+
+                        respond_to do |format|
+              if @section.update_attributes(params[:section])
+                format.html { redirect_to admin_phase_dmptemplate_path(:id => @phase.id, :version_id => @version.id, :section_id => @section.id , :edit => 'true'), notice: I18n.t('org_admin.templates.updated_message') }
+                format.json { head :no_content }
+              else
+                format.html { render action: "admin_phase" }
+                format.json { render json: @section.errors, status: :unprocessable_entity }
+              end
+            end
+                end
+end
+
+ +
+ + + + +
+ + +
+ +
+ admin_updatesuggestedanswer() + click to toggle source +
+ + +
+ +

update a suggested answer of a template

+ + + +
+
# File app/controllers/dmptemplates_controller.rb, line 463
+def admin_updatesuggestedanswer
+        if user_signed_in? && current_user.can_org_admin? then
+               @suggested_answer = SuggestedAnswer.find(params[:id])
+    @question = @suggested_answer.question
+    @section = @question.section
+    @version = @section.version
+    @phase = @version.phase
+
+                        respond_to do |format|
+              if @suggested_answer.update_attributes(params[:suggested_answer])
+                format.html { redirect_to admin_phase_dmptemplate_path(:id => @phase.id, :version_id => @version.id, :section_id => @section.id, :question_id => @question.id, :edit => 'true'), notice: I18n.t('org_admin.templates.updated_message') }
+                format.json { head :no_content }
+              else
+                format.html { render action: "admin_phase" }
+                format.json { render json: @suggested_answer.errors, status: :unprocessable_entity }
+              end
+            end
+                end
+        end
+
+ +
+ + + + +
+ + +
+ +
+ admin_updateversion() + click to toggle source +
+ + +
+ +

update a version of a template

+ + + +
+
# File app/controllers/dmptemplates_controller.rb, line 262
+def admin_updateversion
+        if user_signed_in? && current_user.can_org_admin? then
+               @version = Version.find(params[:id])
+    @version.description = params["version-desc"]
+    @phase = @version.phase
+
+    if @version.published && !@phase.dmptemplate.published then
+        @phase.dmptemplate.published = true
+    end
+    
+    @all_versions = @phase.versions.where('published = ?', true)
+    @all_versions.each do |v|
+        if v.id != @version.id && v.published == true then
+            v.published = false
+            v.save
+        end
+    end
+
+            respond_to do |format|
+              if @version.update_attributes(params[:version])
+                format.html { redirect_to admin_phase_dmptemplate_path(@phase, :version_id =>  @version.id, :edit => 'false'), notice: I18n.t('org_admin.templates.updated_message') }
+                format.json { head :no_content }
+              else
+                format.html { render action: "admin_phase" }
+                format.json { render json: @version.errors, status: :unprocessable_entity }
+              end
+            end
+                end
+        end
+
+ +
+ + + + +
+ + +
+ +
+ +
+ + + + diff --git a/public/html/ExistingUsersController.html b/public/html/ExistingUsersController.html new file mode 100644 index 0000000..a3baca4 --- /dev/null +++ b/public/html/ExistingUsersController.html @@ -0,0 +1,325 @@ + + + + + + +class ExistingUsersController - DMPonline4 Documentation + + + + + + + + + + + + + + + + +
+

class ExistingUsersController

+ +
+ +
+ + + + +
+ + + + + + + + + + +
+

Public Instance Methods

+ + +
+ +
+ index() + click to toggle source +
+ + +
+ + + + + +
+
# File app/controllers/existing_users_controller.rb, line 2
+def index
+        @email = params[:email]
+end
+
+ +
+ + + + +
+ + +
+ +
+ +
+ + + + diff --git a/public/html/ExportedPlan.html b/public/html/ExportedPlan.html new file mode 100644 index 0000000..e7911e1 --- /dev/null +++ b/public/html/ExportedPlan.html @@ -0,0 +1,846 @@ + + + + + + +class ExportedPlan - DMPonline4 Documentation + + + + + + + + + + + + + + + + +
+

class ExportedPlan

+ +
+ +
+ + + + +
+ + + + + + +
+

Constants

+
+ +
VALID_FORMATS + +
+ + +
+
+ + + + + + +
+

Public Instance Methods

+ + +
+ +
+ admin_details() + click to toggle source +
+ + +
+ + + + + +
+
# File app/models/exported_plan.rb, line 71
+def admin_details
+  @admin_details ||= self.settings(:export).fields[:admin]
+end
+
+ +
+ + + + +
+ + +
+ +
+ as_csv() + click to toggle source +
+ + +
+ +

Export formats

+ + + +
+
# File app/models/exported_plan.rb, line 77
+def as_csv
+  CSV.generate do |csv|
+    csv << ["Section","Question","Answer","Selected option(s)","Answered by","Answered at"]
+    self.sections.each do |section|
+      self.questions_for_section(section).each do |question|
+        answer = self.plan.answer(question.id)
+        options_string = answer.options.collect {|o| o.text}.join('; ')
+
+        csv << [section.title, question.text, sanitize_text(answer.text), options_string, answer.try(:user).try(:name), answer.created_at]
+      end
+    end
+  end
+end
+
+ +
+ + + + +
+ + +
+ +
+ as_txt() + click to toggle source +
+ + +
+ + + + + +
+
# File app/models/exported_plan.rb, line 91
+def as_txt
+  output = "#{self.plan.project.title}\n\n#{self.plan.version.phase.title}\n"
+
+  self.sections.each do |section|
+    output += "\n#{section.title}\n"
+
+    self.questions_for_section(section).each do |question|
+      output += "\n#{question.text}\n"
+      answer = self.plan.answer(question.id, false)
+
+      if answer.nil? || answer.text.nil? then
+        output += "Question not answered.\n"
+      else
+        output += answer.options.collect {|o| o.text}.join("\n")
+        if question.option_comment_display == true then
+          output += "\n#{sanitize_text(answer.text)}\n"
+        else
+          output += "\n"
+        end  
+      end
+    end
+  end
+
+  output
+end
+
+ +
+ + + + +
+ + +
+ +
+ funder() + click to toggle source +
+ + +
+ + + + + +
+
# File app/models/exported_plan.rb, line 46
+def funder
+  org = self.plan.project.dmptemplate.try(:organisation)
+  org.name if org.present? && org.organisation_type.try(:name) == I18n.t('helpers.org_type.funder')
+end
+
+ +
+ + + + +
+ + +
+ +
+ grant_title() + click to toggle source +
+ + +
+ + + + + +
+
# File app/models/exported_plan.rb, line 30
+def grant_title
+  self.plan.project.grant_number
+end
+
+ +
+ + + + +
+ + +
+ +
+ institution() + click to toggle source +
+ + +
+ + + + + +
+
# File app/models/exported_plan.rb, line 51
+def institution
+  plan.project.organisation.try(:name)
+end
+
+ +
+ + + + +
+ + +
+ +
+ principal_investigator() + click to toggle source +
+ + +
+ + + + + +
+
# File app/models/exported_plan.rb, line 34
+def principal_investigator
+  self.plan.project.principal_investigator
+end
+
+ +
+ + + + +
+ + +
+ +
+ project_data_contact() + click to toggle source +
+ + +
+ + + + + +
+
# File app/models/exported_plan.rb, line 38
+def project_data_contact
+  self.plan.project.data_contact
+end
+
+ +
+ + + + +
+ + +
+ +
+ project_description() + click to toggle source +
+ + +
+ + + + + +
+
# File app/models/exported_plan.rb, line 42
+def project_description
+  self.plan.project.description
+end
+
+ +
+ + + + +
+ + +
+ +
+ project_identifier() + click to toggle source +
+ + +
+ + + + + +
+
# File app/models/exported_plan.rb, line 26
+def project_identifier
+  self.plan.project.identifier
+end
+
+ +
+ + + + +
+ + +
+ +
+ project_name() + click to toggle source +
+ + +
+ +

Getters to match Settings::Dmptemplate::VALID_ADMIN_FIELDS

+ + + +
+
# File app/models/exported_plan.rb, line 20
+def project_name
+  name = self.plan.project.title
+  name += " - #{self.plan.title}" if self.plan.project.dmptemplate.phases.count > 1
+  name
+end
+
+ +
+ + + + +
+ + +
+ +
+ questions_for_section(section_id) + click to toggle source +
+ + +
+ + + + + +
+
# File app/models/exported_plan.rb, line 67
+def questions_for_section(section_id)
+  questions.where(section_id: section_id)
+end
+
+ +
+ + + + +
+ + +
+ +
+ sections() + click to toggle source +
+ + +
+ +

sections taken from fields settings

+ + + +
+
# File app/models/exported_plan.rb, line 56
+def sections
+  sections = self.plan.sections
+
+  return [] if questions.empty?
+
+  section_ids = questions.pluck(:section_id).uniq
+  sections = sections.select {|section| section_ids.member?(section.id) }
+
+  sections.sort_by(&:number)
+end
+
+ +
+ + + + +
+ + +
+ +
+

Private Instance Methods

+ + +
+ +
+ questions() + click to toggle source +
+ + +
+ + + + + +
+
# File app/models/exported_plan.rb, line 119
+def questions
+  @questions ||= begin
+    question_settings = self.settings(:export).fields[:questions]
+
+    return [] if question_settings.is_a?(Array) && question_settings.empty?
+
+    questions = if question_settings.present? && question_settings != :all
+      Question.where(id: question_settings)
+    else
+      Question.where(section_id: self.plan.sections.collect {|s| s.id })
+    end
+
+    questions.order(:number)
+  end
+end
+
+ +
+ + + + +
+ + +
+ +
+ sanitize_text(text) + click to toggle source +
+ + +
+ + + + + +
+
# File app/models/exported_plan.rb, line 135
+def sanitize_text(text)
+  if (!text.nil?) then ActionView::Base.full_sanitizer.sanitize(text.gsub(/&nbsp;/,"")) end
+end
+
+ +
+ + + + +
+ + +
+ +
+ +
+ + + + diff --git a/public/html/FileType.html b/public/html/FileType.html new file mode 100644 index 0000000..749a3b5 --- /dev/null +++ b/public/html/FileType.html @@ -0,0 +1,279 @@ + + + + + + +class FileType - DMPonline4 Documentation + + + + + + + + + + + + + + + + +
+

class FileType

+ +
+ +
+ + + + +
+ + + + + + + + + + +
+ +
+ + + + diff --git a/public/html/FileUpload.html b/public/html/FileUpload.html new file mode 100644 index 0000000..a91679c --- /dev/null +++ b/public/html/FileUpload.html @@ -0,0 +1,279 @@ + + + + + + +class FileUpload - DMPonline4 Documentation + + + + + + + + + + + + + + + + +
+

class FileUpload

+ +
+ +
+ + + + +
+ + + + + + + + + + +
+ +
+ + + + diff --git a/public/html/Guidance.html b/public/html/Guidance.html new file mode 100644 index 0000000..f65c3d8 --- /dev/null +++ b/public/html/Guidance.html @@ -0,0 +1,426 @@ + + + + + + +class Guidance - DMPonline4 Documentation + + + + + + + + + + + + + + + + +
+

class Guidance

+ +
+
Project: +
+

DMPonline v4

+
Description: +
+

This class keeps the information organisations enter to support users when +answering questions. It always belongs to a guidance group class and it +can be linked directly to a question or through one or more themes

+
Created: +
+

07/07/2014

+
Copyright: +
+

Digital Curation Centre

+
+ +
+ + + + +
+ + + + + + + + + + +
+

Public Class Methods

+ + +
+ +
+ by_organisation(org_id) + click to toggle source +
+ + +
+ +

all guidance that belong to an organisation

+ + + +
+
# File app/models/guidance.rb, line 40
+def self.by_organisation(org_id)
+        all_guidance = Guidance.all
+        org_guidance = Array.new
+    
+        all_guidance.each do |guidance|
+           if guidance.in_group_belonging_to?(org_id) then
+                        org_guidance << guidance
+           end
+        end
+        
+        return org_guidance
+        
+end
+
+ +
+ + + + +
+ + +
+ +
+

Public Instance Methods

+ + +
+ +
+ get_guidance_group_templates?(guidance_group) + click to toggle source +
+ + +
+ + + + + +
+
# File app/models/guidance.rb, line 55
+def get_guidance_group_templates? (guidance_group)
+                templates = guidancegroups.where("guidance_group_id (?)", guidance_group.id).template 
+                return templates
+        end
+
+ +
+ + + + +
+ + +
+ +
+ in_group_belonging_to?(organisation_id) + click to toggle source +
+ + +
+ +

verifies if one guidance belongs to a org

+ + + +
+
# File app/models/guidance.rb, line 29
+def in_group_belonging_to?(organisation_id)
+        guidance_groups.each do |guidance_group|
+                if guidance_group.organisation_id == organisation_id then
+                        return true
+                end
+        end
+        return false
+end
+
+ +
+ + + + +
+ + +
+ +
+ +
+ + + + diff --git a/public/html/GuidanceGroup.html b/public/html/GuidanceGroup.html new file mode 100644 index 0000000..0907393 --- /dev/null +++ b/public/html/GuidanceGroup.html @@ -0,0 +1,404 @@ + + + + + + +class GuidanceGroup - DMPonline4 Documentation + + + + + + + + + + + + + + + + +
+

class GuidanceGroup

+ +
+ +
+ + + + +
+ + + + + + + + + + +
+

Public Class Methods

+ + +
+ +
+ guidance_groups_excluding(excluded_orgs) + click to toggle source +
+ + +
+ + + + + +
+
# File app/models/guidance_group.rb, line 28
+def self.guidance_groups_excluding(excluded_orgs)
+        excluded_org_ids = Array.new
+        excluded_orgs.each do |org|
+                excluded_org_ids << org.id
+        end
+        return_orgs =  GuidanceGroup.where("organisation_id NOT IN (?)", excluded_org_ids)
+        return return_orgs
+end
+
+ +
+ + + + +
+ + +
+ +
+

Public Instance Methods

+ + +
+ +
+ display_name() + click to toggle source +
+ + +
+ + + + + +
+
# File app/models/guidance_group.rb, line 20
+def display_name
+        if organisation.guidance_groups.count > 1
+                return "#{organisation.name}: #{name}"
+        else
+                return organisation.name
+        end
+end
+
+ +
+ + + + +
+ + +
+ +
+ to_s() + click to toggle source +
+ + +
+ + + + + +
+
# File app/models/guidance_group.rb, line 16
+def to_s
+        "#{display_name}"
+end
+
+ +
+ + + + +
+ + +
+ +
+ +
+ + + + diff --git a/public/html/GuidanceGroupsController.html b/public/html/GuidanceGroupsController.html new file mode 100644 index 0000000..7283e1a --- /dev/null +++ b/public/html/GuidanceGroupsController.html @@ -0,0 +1,547 @@ + + + + + + +class GuidanceGroupsController - DMPonline4 Documentation + + + + + + + + + + + + + + + + +
+

class GuidanceGroupsController

+ +
+ +
+ + + + +
+ + + + + + + + + + +
+

Public Instance Methods

+ + +
+ +
+ admin_create() + click to toggle source +
+ + +
+ +

POST /guidance_groups POST /guidance_groups.json

+ + + +
+
# File app/controllers/guidance_groups_controller.rb, line 34
+def admin_create
+  if user_signed_in? && current_user.can_org_admin? then
+          @guidance_group = GuidanceGroup.new(params[:guidance_group])
+          @guidance_group.organisation_id = current_user.organisation_id
+      
+          respond_to do |format|
+            if @guidance_group.save
+              format.html { redirect_to admin_index_guidance_path, notice: I18n.t('org_admin.guidance_group.created_message') }
+              format.json { render json: @guidance_group, status: :created, location: @guidance_group }
+            else
+              format.html { render action: "new" }
+              format.json { render json: @guidance_group.errors, status: :unprocessable_entity }
+            end
+          end
+  else
+                      render(:file => File.join(Rails.root, 'public/403.html'), :status => 403, :layout => false)
+              end 
+end
+
+ +
+ + + + +
+ + +
+ +
+ admin_destroy() + click to toggle source +
+ + +
+ +

DELETE /guidance_groups/1 DELETE /guidance_groups/1.json

+ + + +
+
# File app/controllers/guidance_groups_controller.rb, line 87
+def admin_destroy
+      if user_signed_in? && current_user.can_org_admin? then
+             @guidance_group = GuidanceGroup.find(params[:id])
+          @guidance_group.destroy
+      
+          respond_to do |format|
+            format.html { redirect_to admin_index_guidance_path, notice: I18n.t('org_admin.guidance_group.destroyed_message') }
+            format.json { head :no_content }
+          end
+             else
+                      render(:file => File.join(Rails.root, 'public/403.html'), :status => 403, :layout => false)
+              end 
+      
+      end
+
+ +
+ + + + +
+ + +
+ +
+ admin_edit() + click to toggle source +
+ + +
+ +

GET /guidance_groups/1/edit

+ + + +
+
# File app/controllers/guidance_groups_controller.rb, line 55
+def admin_edit
+      if user_signed_in? && current_user.can_org_admin? then
+    @guidance_group = GuidanceGroup.find(params[:id])
+  else
+                      render(:file => File.join(Rails.root, 'public/403.html'), :status => 403, :layout => false)
+              end 
+end
+
+ +
+ + + + +
+ + +
+ +
+ admin_new() + click to toggle source +
+ + +
+ +

GET add new guidance groups

+ + + +
+
# File app/controllers/guidance_groups_controller.rb, line 21
+    def admin_new
+if user_signed_in? && current_user.can_org_admin? then
+        @guidance_group = GuidanceGroup.new
+           
+        respond_to do |format|
+          format.html # new.html.erb
+
+          format.json { render json: @guidance }
+        end
+    end
+    end
+
+ +
+ + + + +
+ + +
+ +
+ admin_show() + click to toggle source +
+ + +
+ +

GET /guidance_groups/1 GET /guidance_groups/1.json

+ + + +
+
# File app/controllers/guidance_groups_controller.rb, line 6
+def admin_show
+  if user_signed_in? && current_user.can_org_admin? then
+          @guidance_group = GuidanceGroup.find(params[:id])
+      
+          respond_to do |format|
+            format.html 
+            format.json { render json: @guidance_group }
+          end
+  else
+                      render(:file => File.join(Rails.root, 'public/403.html'), :status => 403, :layout => false)
+              end 
+end
+
+ +
+ + + + +
+ + +
+ +
+ admin_update() + click to toggle source +
+ + +
+ +

PUT /guidance_groups/1 PUT /guidance_groups/1.json

+ + + +
+
# File app/controllers/guidance_groups_controller.rb, line 65
+def admin_update
+              if user_signed_in? && current_user.can_org_admin? then
+              @guidance_group = GuidanceGroup.find(params[:id])
+          @guidance_group.organisation_id = current_user.organisation_id
+
+          respond_to do |format|
+            if @guidance_group.update_attributes(params[:guidance_group])
+              format.html { redirect_to admin_index_guidance_path(params[:guidance_group]), notice: I18n.t('org_admin.guidance_group.updated_message') }
+              format.json { head :no_content }
+            else
+              format.html { render action: "edit" }
+              format.json { render json: @guidance_group.errors, status: :unprocessable_entity }
+            end
+          end
+  else
+                      render(:file => File.join(Rails.root, 'public/403.html'), :status => 403, :layout => false)
+              end 
+end
+
+ +
+ + + + +
+ + +
+ +
+ +
+ + + + diff --git a/public/html/GuidancesController.html b/public/html/GuidancesController.html new file mode 100644 index 0000000..7e036ea --- /dev/null +++ b/public/html/GuidancesController.html @@ -0,0 +1,810 @@ + + + + + + +class GuidancesController - DMPonline4 Documentation + + + + + + + + + + + + + + + + +
+

class GuidancesController

+ +
+ +
+ + + + +
+ + + + + + + + + + +
+

Public Instance Methods

+ + +
+ +
+ admin_create() + click to toggle source +
+ + +
+ +

POST /guidances POST /guidances.json

+ + + +
+
# File app/controllers/guidances_controller.rb, line 155
+def admin_create
+  if user_signed_in? && current_user.can_org_admin? then
+          @guidance = Guidance.new(params[:guidance])
+          @guidance.text = params["guidance-text"]
+          @guidance.question_id = params["question_id"]
+
+          respond_to do |format|
+            if @guidance.save
+              format.html { redirect_to admin_show_guidance_path(@guidance), notice: I18n.t('org_admin.guidance.created_message') }
+              format.json { render json: @guidance, status: :created, location: @guidance }
+            else
+              format.html { render action: "new" }
+              format.json { render json: @guidance.errors, status: :unprocessable_entity }
+            end
+          end
+  else
+                      render(:file => File.join(Rails.root, 'public/403.html'), :status => 403, :layout => false)
+              end
+end
+
+ +
+ + + + +
+ + +
+ +
+ admin_destroy() + click to toggle source +
+ + +
+ +

DELETE /guidances/1 DELETE /guidances/1.json

+ + + +
+
# File app/controllers/guidances_controller.rb, line 202
+def admin_destroy
+      if user_signed_in? && current_user.can_org_admin? then
+             @guidance = Guidance.find(params[:id])
+          @guidance.destroy
+
+          respond_to do |format|
+            format.html { redirect_to admin_index_guidance_path }
+            format.json { head :no_content }
+          end
+             else
+                      render(:file => File.join(Rails.root, 'public/403.html'), :status => 403, :layout => false)
+              end
+
+      end
+
+ +
+ + + + +
+ + +
+ +
+ admin_edit() + click to toggle source +
+ + +
+ +

GET /guidances/1/edit

+ + + +
+
# File app/controllers/guidances_controller.rb, line 112
+def admin_edit
+      if user_signed_in? && current_user.can_org_admin? then
+    @guidance = Guidance.find(params[:id])
+    @dmptemplates = Dmptemplate.funders_and_own_templates(current_user.organisation_id)
+                      @phases = nil
+                      @dmptemplates.each do |template|
+                              if @phases.nil? then
+                                      @phases = template.phases.find(:all,:order => 'number ASC')
+                              else
+                                      @phases = @phases + template.phases.find(:all,:order => 'number ASC')
+                              end
+                      end
+                      @versions = nil
+                      @phases.each do |phase|
+                              if @versions.nil? then
+                                      @versions = phase.versions.find(:all,:order => 'title ASC')
+                              else
+                                      @versions = @versions + phase.versions.find(:all,:order => 'title ASC')
+                              end
+                      end
+                      @sections = nil
+                      @versions.each do |version|
+                              if @sections.nil? then
+                                      @sections = version.sections.find(:all,:order => 'number ASC')
+                              else
+                                      @sections = @sections + version.sections.find(:all,:order => 'number ASC')
+                              end
+                      end
+                      @questions = nil
+                      @sections.each do |section|
+                              if @questions.nil? then
+                                      @questions = section.questions.find(:all,:order => 'number ASC')
+                              else
+                                      @questions = @questions + section.questions.find(:all,:order => 'number ASC')
+                              end
+                      end
+  else
+                      render(:file => File.join(Rails.root, 'public/403.html'), :status => 403, :layout => false)
+              end
+end
+
+ +
+ + + + +
+ + +
+ +
+ admin_index() + click to toggle source +
+ + +
+ +

GET /guidances GET /guidances.json

+ + + +
+
# File app/controllers/guidances_controller.rb, line 5
+def admin_index
+  if user_signed_in? && current_user.can_org_admin? then
+          @guidances = Guidance.by_organisation(current_user.organisation_id)
+          @guidance_groups = GuidanceGroup.where('organisation_id = ?', current_user.organisation_id )
+
+
+          respond_to do |format|
+            format.html # index.html.erb
+
+            format.json { render json: @guidances }
+          end
+  else
+                      render(:file => File.join(Rails.root, 'public/403.html'), :status => 403, :layout => false)
+              end
+end
+
+ +
+ + + + +
+ + +
+ +
+ admin_new() + click to toggle source +
+ + +
+ + + + + +
+
# File app/controllers/guidances_controller.rb, line 33
+def admin_new
+  if user_signed_in? && current_user.can_org_admin? then
+          @guidance = Guidance.new
+                      @dmptemplates = Dmptemplate.funders_and_own_templates(current_user.organisation_id)
+                      @phases = nil
+                      @dmptemplates.each do |template|
+                              if @phases.nil? then
+                                      @phases = template.phases.find(:all,:order => 'number ASC')
+                              else
+                                      @phases = @phases + template.phases.find(:all,:order => 'number ASC')
+                              end
+                      end
+                      @versions = nil
+                      @phases.each do |phase|
+                              if @versions.nil? then
+                                      @versions = phase.versions.find(:all,:order => 'title ASC')
+                              else
+                                      @versions = @versions + phase.versions.find(:all,:order => 'title ASC')
+                              end
+                      end
+                      @sections = nil
+                      @versions.each do |version|
+                              if @sections.nil? then
+                                      @sections = version.sections.find(:all,:order => 'number ASC')
+                              else
+                                      @sections = @sections + version.sections.find(:all,:order => 'number ASC')
+                              end
+                      end
+                      @questions = nil
+                      @sections.each do |section|
+                              if @questions.nil? then
+                                      @questions = section.questions.find(:all,:order => 'number ASC')
+                              else
+                                      @questions = @questions + section.questions.find(:all,:order => 'number ASC')
+                              end
+                      end
+          respond_to do |format|
+            format.html
+          end
+      end
+      end
+
+ +
+ + + + +
+ + +
+ +
+ admin_show() + click to toggle source +
+ + +
+ +

GET /guidances/1 GET /guidances/1.json

+ + + +
+
# File app/controllers/guidances_controller.rb, line 22
+def admin_show
+  if user_signed_in? && current_user.can_org_admin? then
+          @guidance = Guidance.find(params[:id])
+
+          respond_to do |format|
+            format.html # show.html.erb
+
+            format.json { render json: @guidance }
+          end
+ end
+end
+
+ +
+ + + + +
+ + +
+ +
+ admin_update() + click to toggle source +
+ + +
+ +

PUT /guidances/1 PUT /guidances/1.json

+ + + +
+
# File app/controllers/guidances_controller.rb, line 177
+def admin_update
+              if user_signed_in? && current_user.can_org_admin? then
+              @guidance = Guidance.find(params[:id])
+
+                      @guidance.text = params["guidance-text"]
+
+                      @guidance.question_id = params["question_id"]
+
+          respond_to do |format|
+            if @guidance.update_attributes(params[:guidance])
+              format.html { redirect_to admin_show_guidance_path(params[:guidance]), notice: I18n.t('org_admin.guidance.updated_message') }
+              format.json { head :no_content }
+            else
+              format.html { render action: "edit" }
+              format.json { render json: @guidance.errors, status: :unprocessable_entity }
+            end
+          end
+  else
+                      render(:file => File.join(Rails.root, 'public/403.html'), :status => 403, :layout => false)
+              end
+end
+
+ +
+ + + + +
+ + +
+ +
+ update_phases() + click to toggle source +
+ + +
+ +

setup variables for use in the dynamic updating

+ + + +
+
# File app/controllers/guidances_controller.rb, line 76
+      def update_phases
+  # updates phases, versions, sections and questions based on template selected
+
+  dmptemplate = Dmptemplate.find(params[:dmptemplate_id])
+  # map to title and id for use in our options_for_select
+
+  @phases = dmptemplate.phases.map{|a| [a.title, a.id]}.insert(0, "Select a phase")
+  @versions = dmptemplate.versions.map{|s| [s.title, s.id]}.insert(0, "Select a version")
+  @sections = dmptemplate.sections.map{|s| [s.title, s.id]}.insert(0, "Select a section")
+  @questions = dmptemplate.questions.map{|s| [s.text, s.id]}.insert(0, "Select a question")
+
+end
+
+ +
+ + + + +
+ + +
+ +
+ update_questions() + click to toggle source +
+ + +
+ + + + + +
+
# File app/controllers/guidances_controller.rb, line 104
+def update_questions
+  # updates songs based on artist selected
+
+  section = Section.find(params[:section_id])
+  @questions = section.questions.map{|s| [s.text, s.id]}.insert(0, "Select a question")
+end
+
+ +
+ + + + +
+ + +
+ +
+ update_sections() + click to toggle source +
+ + +
+ + + + + +
+
# File app/controllers/guidances_controller.rb, line 96
+def update_sections
+  # updates sections and questions based on version selected
+
+  version = Version.find(params[:version_id])
+  # map to name and id for use in our options_for_select
+
+  @sections = version.sections.map{|s| [s.title, s.id]}.insert(0, "Select a section")
+  @questions = version.questions.map{|s| [s.text, s.id]}.insert(0, "Select a question")
+end
+
+ +
+ + + + +
+ + +
+ +
+ update_versions() + click to toggle source +
+ + +
+ + + + + +
+
# File app/controllers/guidances_controller.rb, line 87
+def update_versions
+   # updates versions, sections and questions based on phase selected
+
+   phase = Phase.find(params[:phase_id])
+   # map to name and id for use in our options_for_select
+
+   @versions = phase.versions.map{|s| [s.title, s.id]}.insert(0, "Select a version")
+   @sections = phase.sections.map{|s| [s.title, s.id]}.insert(0, "Select a section")
+   @questions = phase.questions.map{|s| [s.text, s.id]}.insert(0, "Select a question")
+ end
+
+ +
+ + + + +
+ + +
+ +
+ +
+ + + + diff --git a/public/html/HomeController.html b/public/html/HomeController.html new file mode 100644 index 0000000..dcc676f --- /dev/null +++ b/public/html/HomeController.html @@ -0,0 +1,363 @@ + + + + + + +class HomeController - DMPonline4 Documentation + + + + + + + + + + + + + + + + +
+

class HomeController

+ +
+ +
+ + + + +
+ + + + + + + + + + +
+

Public Instance Methods

+ + +
+ +
+ about_us() + click to toggle source +
+ + +
+ + + + + +
+
# File app/controllers/home_controller.rb, line 13
+def about_us
+end
+
+ +
+ + + + +
+ + +
+ +
+ index() + click to toggle source +
+ + +
+ + + + + +
+
# File app/controllers/home_controller.rb, line 2
+def index
+      if user_signed_in?
+              name = current_user.name(false)
+              if name.nil? || name == "" then
+                      redirect_to edit_user_registration_path
+              else
+                      redirect_to projects_url
+              end
+      end
+end
+
+ +
+ + + + +
+ + +
+ +
+ +
+ + + + diff --git a/public/html/Object.html b/public/html/Object.html new file mode 100644 index 0000000..e231136 --- /dev/null +++ b/public/html/Object.html @@ -0,0 +1,326 @@ + + + + + + +class Object - DMPonline4 Documentation + + + + + + + + + + + + + + + + +
+

class Object

+ +
+ +
+ + + + +
+ + + + + + + + + + +
+

Public Instance Methods

+ + +
+ +
+ scoped_collection() + click to toggle source +
+ + +
+ + + + + +
+
# File app/admin/user.rb, line 118
+def scoped_collection
+  resource_class.includes(:organisations) # prevents N+1 queries to your database
+
+end
+
+ +
+ + + + +
+ + +
+ +
+ +
+ + + + diff --git a/public/html/Option.html b/public/html/Option.html new file mode 100644 index 0000000..1798432 --- /dev/null +++ b/public/html/Option.html @@ -0,0 +1,325 @@ + + + + + + +class Option - DMPonline4 Documentation + + + + + + + + + + + + + + + + +
+

class Option

+ +
+ +
+ + + + +
+ + + + + + + + + + +
+

Public Instance Methods

+ + +
+ +
+ to_s() + click to toggle source +
+ + +
+ + + + + +
+
# File app/models/option.rb, line 12
+def to_s
+        "#{text}"
+end
+
+ +
+ + + + +
+ + +
+ +
+ +
+ + + + diff --git a/public/html/OptionWarning.html b/public/html/OptionWarning.html new file mode 100644 index 0000000..921cfe8 --- /dev/null +++ b/public/html/OptionWarning.html @@ -0,0 +1,325 @@ + + + + + + +class OptionWarning - DMPonline4 Documentation + + + + + + + + + + + + + + + + +
+

class OptionWarning

+ +
+ +
+ + + + +
+ + + + + + + + + + +
+

Public Instance Methods

+ + +
+ +
+ to_s() + click to toggle source +
+ + +
+ + + + + +
+
# File app/models/option_warning.rb, line 9
+def to_s
+        "#{text}"
+end
+
+ +
+ + + + +
+ + +
+ +
+ +
+ + + + diff --git a/public/html/Organisation.html b/public/html/Organisation.html new file mode 100644 index 0000000..d71187f --- /dev/null +++ b/public/html/Organisation.html @@ -0,0 +1,626 @@ + + + + + + +class Organisation - DMPonline4 Documentation + + + + + + + + + + + + + + + + +
+

class Organisation

+ +
+ +
+ + + + +
+ + + + + + + + + + +
+

Public Class Methods

+ + +
+ +
+ orgs_with_parent_of_type(org_type) + click to toggle source +
+ + +
+ +

retrieves info off a child org

+ + + +
+
# File app/models/organisation.rb, line 35
+def self.orgs_with_parent_of_type(org_type)
+        parents = OrganisationType.find_by_name(org_type).organisations
+        children = Array.new
+        parents.each do |parent|
+              children += parent.children
+        end
+        return children
+end
+
+ +
+ + + + +
+ + +
+ +
+ other_organisations() + click to toggle source +
+ + +
+ + + + + +
+
# File app/models/organisation.rb, line 45
+def self.other_organisations
+        org_types = [I18n.t('helpers.org_type.organisation')]
+        organisations_list = []
+        org_types.each do |ot|
+                new_org_obejct = OrganisationType.find_by_name(ot)
+
+                org_with_guidance = GuidanceGroup.joins(new_org_obejct.organisations)
+
+                organisations_list = organisations_list + org_with_guidance
+        end
+        return organisations_list
+end
+
+ +
+ + + + +
+ + +
+ +
+

Public Instance Methods

+ + +
+ +
+ all_guidance_groups() + click to toggle source +
+ + +
+ + + + + +
+
# File app/models/organisation.rb, line 70
+def all_guidance_groups
+        ggs = guidance_groups
+        children.each do |c|
+                ggs = ggs + c.all_guidance_groups
+        end
+        return ggs
+end
+
+ +
+ + + + +
+ + +
+ +
+ all_sections(version_id) + click to toggle source +
+ + +
+ + + + + +
+
# File app/models/organisation.rb, line 58
+def all_sections(version_id)
+        if parent.nil?
+                secs = sections.where("version_id = ?", version_id)
+                if secs.nil? then
+                        secs = Array.new
+                end
+                return secs
+        else
+                return sections.find_all_by_version_id(version_id) + parent.all_sections(version_id)
+        end
+end
+
+ +
+ + + + +
+ + +
+ +
+ published_templates() + click to toggle source +
+ + +
+ + + + + +
+
# File app/models/organisation.rb, line 95
+def published_templates
+        return dmptemplates.find_all_by_published(1)
+end
+
+ +
+ + + + +
+ + +
+ +
+ root() + click to toggle source +
+ + +
+ + + + + +
+
# File app/models/organisation.rb, line 78
+def root
+        if parent.nil?
+                return self
+        else
+                return parent.root
+        end
+end
+
+ +
+ + + + +
+ + +
+ +
+ short_name() + click to toggle source +
+ + +
+ + + + + +
+
# File app/models/organisation.rb, line 26
+def short_name
+        if abbreviation.nil? then
+                return name
+        else
+                return abbreviation
+        end
+end
+
+ +
+ + + + +
+ + +
+ +
+ to_s() + click to toggle source +
+ + +
+ + + + + +
+
# File app/models/organisation.rb, line 22
+def to_s
+        name
+end
+
+ +
+ + + + +
+ + +
+ +
+ warning(option_id) + click to toggle source +
+ + +
+ + + + + +
+
# File app/models/organisation.rb, line 86
+def warning(option_id)
+        warning = option_warnings.find_by_option_id(option_id)
+        if warning.nil? && !parent.nil? then
+                return parent.warning(option_id)
+        else
+                return warning
+        end
+end
+
+ +
+ + + + +
+ + +
+ +
+ +
+ + + + diff --git a/public/html/OrganisationType.html b/public/html/OrganisationType.html new file mode 100644 index 0000000..1448f7c --- /dev/null +++ b/public/html/OrganisationType.html @@ -0,0 +1,279 @@ + + + + + + +class OrganisationType - DMPonline4 Documentation + + + + + + + + + + + + + + + + +
+

class OrganisationType

+ +
+ +
+ + + + +
+ + + + + + + + + + +
+ +
+ + + + diff --git a/public/html/OrganisationUsersController.html b/public/html/OrganisationUsersController.html new file mode 100644 index 0000000..cd53ddb --- /dev/null +++ b/public/html/OrganisationUsersController.html @@ -0,0 +1,334 @@ + + + + + + +class OrganisationUsersController - DMPonline4 Documentation + + + + + + + + + + + + + + + + +
+

class OrganisationUsersController

+ +
+ +
+ + + + +
+ + + + + + + + + + +
+

Public Instance Methods

+ + +
+ +
+ admin_index() + click to toggle source +
+ + +
+ + + + + +
+
# File app/controllers/organisation_users_controller.rb, line 3
+def admin_index
+        if user_signed_in? && current_user.can_org_admin? then
+                
+                respond_to do |format|
+                        format.html # index.html.erb
+
+                        format.json { render json: @organisation_users }
+                end
+        else
+                render(:file => File.join(Rails.root, 'public/403.html'), :status => 403, :layout => false)
+        end 
+end
+
+ +
+ + + + +
+ + +
+ +
+ +
+ + + + diff --git a/public/html/OrganisationsController.html b/public/html/OrganisationsController.html new file mode 100644 index 0000000..91d1f12 --- /dev/null +++ b/public/html/OrganisationsController.html @@ -0,0 +1,707 @@ + + + + + + +class OrganisationsController - DMPonline4 Documentation + + + + + + + + + + + + + + + + +
+

class OrganisationsController

+ +
+ +
+ + + + +
+ + + + + + + + + + +
+

Public Instance Methods

+ + +
+ +
+ admin_edit() + click to toggle source +
+ + +
+ +

GET /organisations/1/edit

+ + + +
+
# File app/controllers/organisations_controller.rb, line 58
+def admin_edit
+      if user_signed_in? && current_user.can_org_admin? then
+      @organisation = Organisation.find(params[:id])
+  
+  else
+              render(:file => File.join(Rails.root, 'public/403.html'), :status => 403, :layout => false)
+      end 
+end
+
+ +
+ + + + +
+ + +
+ +
+ admin_show() + click to toggle source +
+ + +
+ +

GET /organisations/1 GET /organisations/1.json

+ + + +
+
# File app/controllers/organisations_controller.rb, line 43
+def admin_show
+      if user_signed_in? && current_user.can_org_admin? then
+          @organisation = Organisation.find(params[:id])
+      
+          respond_to do |format|
+            format.html # show.html.erb
+
+            format.json { render json: @organisation }
+          end
+  else
+                      render(:file => File.join(Rails.root, 'public/403.html'), :status => 403, :layout => false)
+              end 
+              
+end
+
+ +
+ + + + +
+ + +
+ +
+ admin_update() + click to toggle source +
+ + +
+ +

PUT /organisations/1 PUT /organisations/1.json

+ + + +
+
# File app/controllers/organisations_controller.rb, line 70
+def admin_update
+  if user_signed_in? && current_user.can_org_admin? then
+      @organisation = Organisation.find(params[:id])
+      @organisation.banner_text = params["org_banner_text"]
+              
+              
+          respond_to do |format|
+            if @organisation.update_attributes(params[:organisation])
+              format.html { redirect_to admin_show_organisation_path(params[:id]), notice: I18n.t("admin.org_updated_message")  }
+              format.json { head :no_content }
+            else
+              format.html { render action: "edit" }
+              format.json { render json: @organisation.errors, status: :unprocessable_entity }
+            end
+          end
+      else
+        render(:file => File.join(Rails.root, 'public/403.html'), :status => 403, :layout => false)
+  end         
+end
+
+ +
+ + + + +
+ + +
+ +
+ children() + click to toggle source +
+ + +
+ + + + + +
+
# File app/controllers/organisations_controller.rb, line 108
+        def children
+                @organisation = Organisation.find(params[:id])
+                #if user_signed_in? then
+
+                children = {}
+                @organisation.children.each do |child|
+                        children[child.id] = child.name
+                end
+                respond_to do |format|
+                        format.json { render json: children.to_json }
+                end
+#               else
+
+#                       render(:file => File.join(Rails.root, 'public/403.html'), :status => 403, :layout => false)
+
+#               end
+
+        end
+
+ +
+ + + + +
+ + +
+ +
+ create() + click to toggle source +
+ + +
+ +

POST /organisations POST /organisations.json

+ + + +
+
# File app/controllers/organisations_controller.rb, line 26
+def create
+  @organisation = Organisation.new(params[:organisation])
+
+  respond_to do |format|
+    if @organisation.save
+      format.html { redirect_to @organisation, notice: I18n.t("admin.org_created_message") }
+      format.json { render json: @organisation, status: :created, location: @organisation }
+    else
+      format.html { render action: "new" }
+      format.json { render json: @organisation.errors, status: :unprocessable_entity }
+    end
+  end
+end
+
+ +
+ + + + +
+ + +
+ +
+ destroy() + click to toggle source +
+ + +
+ +

DELETE /organisations/1 DELETE /organisations/1.json

+ + + +
+
# File app/controllers/organisations_controller.rb, line 92
+def destroy
+  @organisation = Organisation.find(params[:id])
+  @organisation.destroy
+
+  respond_to do |format|
+    format.html { redirect_to organisations_url }
+    format.json { head :no_content }
+  end
+end
+
+ +
+ + + + +
+ + +
+ +
+ index() + click to toggle source +
+ + +
+ +

GET /organisations GET /organisations.json

+ + + +
+
# File app/controllers/organisations_controller.rb, line 4
+def index
+  @organisations = Organisation.all
+
+  respond_to do |format|
+    format.html # index.html.erb
+
+    format.json { render json: @organisations }
+  end
+end
+
+ +
+ + + + +
+ + +
+ +
+ new() + click to toggle source +
+ + +
+ +

GET /organisations/new GET /organisations/new.json

+ + + +
+
# File app/controllers/organisations_controller.rb, line 15
+def new
+  @organisation = Organisation.new
+
+  respond_to do |format|
+    format.html # new.html.erb
+
+    format.json { render json: @organisation }
+  end
+end
+
+ +
+ + + + +
+ + +
+ +
+ parent() + click to toggle source +
+ + +
+ + + + + +
+
# File app/controllers/organisations_controller.rb, line 102
+def parent
+      @organisation = Organisation.find(params[:id])
+      parent_org = @organisation.find_by {|o| o.parent_id }
+      return parent_org
+end
+
+ +
+ + + + +
+ + +
+ +
+ templates() + click to toggle source +
+ + +
+ + + + + +
+
# File app/controllers/organisations_controller.rb, line 123
+        def templates
+                @organisation = Organisation.find(params[:id])
+                #if user_signed_in? then
+
+                templates = {}
+                @organisation.dmptemplates.each do |template|
+                        if template.is_published? then
+                                templates[template.id] = template.title
+                        end
+                end
+                respond_to do |format|
+                        format.json { render json: templates.to_json }
+                end
+#               else
+
+#                       render(:file => File.join(Rails.root, 'public/403.html'), :status => 403, :layout => false)
+
+#               end
+
+        end
+
+ +
+ + + + +
+ + +
+ +
+ +
+ + + + diff --git a/public/html/Page.html b/public/html/Page.html new file mode 100644 index 0000000..a4a8cea --- /dev/null +++ b/public/html/Page.html @@ -0,0 +1,279 @@ + + + + + + +class Page - DMPonline4 Documentation + + + + + + + + + + + + + + + + +
+

class Page

+ +
+ +
+ + + + +
+ + + + + + + + + + +
+ +
+ + + + diff --git a/public/html/PagesController.html b/public/html/PagesController.html new file mode 100644 index 0000000..b067c7c --- /dev/null +++ b/public/html/PagesController.html @@ -0,0 +1,561 @@ + + + + + + +class PagesController - DMPonline4 Documentation + + + + + + + + + + + + + + + + +
+

class PagesController

+ +
+ +
+ + + + +
+ + + + + + + + + + +
+

Public Instance Methods

+ + +
+ +
+ create() + click to toggle source +
+ + +
+ +

POST /pages POST /pages.json

+ + + +
+
# File app/controllers/pages_controller.rb, line 42
+def create
+  @page = Page.new(params[:page])
+
+  respond_to do |format|
+    if @page.save
+      format.html { redirect_to @page, notice: 'Page was successfully created.' }
+      format.json { render json: @page, status: :created, location: @page }
+    else
+      format.html { render action: "new" }
+      format.json { render json: @page.errors, status: :unprocessable_entity }
+    end
+  end
+end
+
+ +
+ + + + +
+ + +
+ +
+ destroy() + click to toggle source +
+ + +
+ +

DELETE /pages/1 DELETE /pages/1.json

+ + + +
+
# File app/controllers/pages_controller.rb, line 74
+def destroy
+  @page = Page.find(params[:id])
+  @page.destroy
+
+  respond_to do |format|
+    format.html { redirect_to pages_url }
+    format.json { head :no_content }
+  end
+end
+
+ +
+ + + + +
+ + +
+ +
+ edit() + click to toggle source +
+ + +
+ +

GET /pages/1/edit

+ + + +
+
# File app/controllers/pages_controller.rb, line 36
+def edit
+  @page = Page.find(params[:id])
+end
+
+ +
+ + + + +
+ + +
+ +
+ index() + click to toggle source +
+ + +
+ +

GET /pages GET /pages.json

+ + + +
+
# File app/controllers/pages_controller.rb, line 4
+def index
+  @pages = Page.all
+
+  respond_to do |format|
+    format.html # index.html.erb
+
+    format.json { render json: @pages }
+  end
+end
+
+ +
+ + + + +
+ + +
+ +
+ new() + click to toggle source +
+ + +
+ +

GET /pages/new GET /pages/new.json

+ + + +
+
# File app/controllers/pages_controller.rb, line 26
+def new
+  @page = Page.new
+
+  respond_to do |format|
+    format.html # new.html.erb
+
+    format.json { render json: @page }
+  end
+end
+
+ +
+ + + + +
+ + +
+ +
+ show() + click to toggle source +
+ + +
+ +

GET /pages/1 GET /pages/1.json

+ + + +
+
# File app/controllers/pages_controller.rb, line 15
+def show
+  @page = Page.find(params[:id])
+
+  respond_to do |format|
+    format.html # show.html.erb
+
+    format.json { render json: @page }
+  end
+end
+
+ +
+ + + + +
+ + +
+ +
+ update() + click to toggle source +
+ + +
+ +

PUT /pages/1 PUT /pages/1.json

+ + + +
+
# File app/controllers/pages_controller.rb, line 58
+def update
+  @page = Page.find(params[:id])
+
+  respond_to do |format|
+    if @page.update_attributes(params[:page])
+      format.html { redirect_to @page, notice: 'Page was successfully updated.' }
+      format.json { head :no_content }
+    else
+      format.html { render action: "edit" }
+      format.json { render json: @page.errors, status: :unprocessable_entity }
+    end
+  end
+end
+
+ +
+ + + + +
+ + +
+ +
+ +
+ + + + diff --git a/public/html/PasswordsController.html b/public/html/PasswordsController.html new file mode 100644 index 0000000..3364f85 --- /dev/null +++ b/public/html/PasswordsController.html @@ -0,0 +1,325 @@ + + + + + + +class PasswordsController - DMPonline4 Documentation + + + + + + + + + + + + + + + + +
+

class PasswordsController

+ +
+ +
+ + + + +
+ + + + + + + + + + +
+

Protected Instance Methods

+ + +
+ +
+ after_resetting_password_path_for(resource) + click to toggle source +
+ + +
+ + + + + +
+
# File app/controllers/passwords_controller.rb, line 5
+    def after_resetting_password_path_for(resource)
+    root_path
+end
+
+ +
+ + + + +
+ + +
+ +
+ +
+ + + + diff --git a/public/html/Phase.html b/public/html/Phase.html new file mode 100644 index 0000000..c5491a9 --- /dev/null +++ b/public/html/Phase.html @@ -0,0 +1,457 @@ + + + + + + +class Phase - DMPonline4 Documentation + + + + + + + + + + + + + + + + +
+

class Phase

+ +
+
Project: +
+

DMPonline v4

+
Description: +
+

This model describes informmation about the phase of a plan, it's +title, order of display and which template it belongs to.

+
Created: +
+

03/09/2014

+
Copyright: +
+

Digital Curation Centre

+
+ +
+ + + + +
+ + + + + + + + + + +
+

Public Instance Methods

+ + +
+ +
+ has_sections() + click to toggle source +
+ + +
+ +

verify if a phase has a published version or a version with one or more +sections

+ + + +
+
# File app/models/phase.rb, line 44
+def has_sections
+        versions = self.versions.where('published = ?', true).order('updated_at DESC')
+        if versions.any? then
+                version = versions.first
+                if !version.sections.empty? then
+                        has_section = true
+                else
+                        has_section = false
+                end  
+        else
+                version = self.versions.order('updated_at DESC').first 
+                if !version.sections.empty? then
+                        has_section = true
+                else
+                        has_section = false
+                end  
+        end
+        return has_section
+end
+
+ +
+ + + + +
+ + +
+ +
+ latest_published_version() + click to toggle source +
+ + +
+ +

Verify if this phase has any published versions

+ + + +
+
# File app/models/phase.rb, line 34
+def latest_published_version
+        versions.order("number DESC").each do |version|
+                if version.published then
+                        return version
+                end
+        end
+        return nil
+end
+
+ +
+ + + + +
+ + +
+ +
+ latest_version() + click to toggle source +
+ + +
+ + + + + +
+
# File app/models/phase.rb, line 29
+def latest_version
+        return versions.order("number DESC").last
+end
+
+ +
+ + + + +
+ + +
+ +
+ to_s() + click to toggle source +
+ + +
+ + + + + +
+
# File app/models/phase.rb, line 25
+def to_s
+        "#{title}"
+end
+
+ +
+ + + + +
+ + +
+ +
+ +
+ + + + diff --git a/public/html/Plan.html b/public/html/Plan.html new file mode 100644 index 0000000..9f0b894 --- /dev/null +++ b/public/html/Plan.html @@ -0,0 +1,1393 @@ + + + + + + +class Plan - DMPonline4 Documentation + + + + + + + + + + + + + + + + +
+

class Plan

+ +
+ +
+ + + + +
+ + + + + + +
+

Constants

+
+ +
A4_PAGE_HEIGHT + +
+ + +
A4_PAGE_WIDTH + +
+ + +
FONT_HEIGHT_CONVERSION_FACTOR + +
+ + +
FONT_WIDTH_HEIGHT_RATIO + +
+ + +
ROUNDING + +
+ + +
+
+ + + + + + +
+

Public Instance Methods

+ + +
+ +
+ add_guidance_to_array(guidance_array, guidance_group, theme, guidance) + click to toggle source +
+ + +
+ + + + + +
+
# File app/models/plan.rb, line 119
+def add_guidance_to_array(guidance_array, guidance_group, theme, guidance)
+        
+        if guidance_array[guidance_group].nil? then
+                guidance_array[guidance_group] = {}
+        end
+        if theme.nil? then
+                if guidance_array[guidance_group]["no_theme"].nil? then
+                        guidance_array[guidance_group]["no_theme"] = []
+                end
+                if !guidance_array[guidance_group]["no_theme"].include?(guidance) then
+                        guidance_array[guidance_group]["no_theme"].push(guidance)
+                end
+        else
+                if guidance_array[guidance_group][theme].nil? then
+                        guidance_array[guidance_group][theme] = []
+                end
+                if !guidance_array[guidance_group][theme].include?(guidance) then
+                        guidance_array[guidance_group][theme].push(guidance)
+                end
+        end
+        
+return guidance_array
+end
+
+ +
+ + + + +
+ + +
+ +
+ administerable_by(user_id) + click to toggle source +
+ + +
+ + + + + +
+
# File app/models/plan.rb, line 168
+def administerable_by(user_id)
+        return project.readable_by(user_id)
+end
+
+ +
+ + + + +
+ + +
+ +
+ answer(qid, create_if_missing = true) + click to toggle source +
+ + +
+ + + + + +
+
# File app/models/plan.rb, line 53
+def answer(qid, create_if_missing = true)
+        answer = answers.where(:question_id => qid).order("created_at DESC").first
+        question = Question.find(qid)
+        if answer.nil? && create_if_missing then
+                answer = Answer.new
+                answer.plan_id = id
+                answer.question_id = qid
+                answer.text = question.default_value
+                default_options = Array.new
+                question.options.each do |option|
+                        if option.is_default
+                                default_options << option
+                        end
+                end
+                answer.options = default_options
+        end
+        return answer
+end
+
+ +
+ + + + +
+ + +
+ +
+ delete_recent_locks(user_id) + click to toggle source +
+ + +
+ + + + + +
+
# File app/models/plan.rb, line 291
+def delete_recent_locks(user_id)
+        plan_sections.where(:user_id => user_id).each do |lock|
+                lock.delete
+        end
+end
+
+ +
+ + + + +
+ + +
+ +
+ details() + click to toggle source +
+ + +
+ + + + + +
+
# File app/models/plan.rb, line 230
+def details
+        details = {
+                "project_title" => project.title,
+                "phase_title" => version.phase.title,
+                "sections" => {}
+        }
+        sections.sort_by(&:"number").each do |s|
+                details["sections"][s.number] = {}
+                details["sections"][s.number]["title"] = s.title
+                details["sections"][s.number]["questions"] = {}
+                s.questions.order("number").each do |q|
+                        details["sections"][s.number]["questions"][q.number] = {}
+                        details["sections"][s.number]["questions"][q.number]["question_text"] = q.text
+                        answer = answer(q.id, false)
+                        if ! answer.nil? then
+            q_format = q.question_format
+                                if (q_format.title == t("helpers.checkbox") || q_format.title == t("helpers.multi_select_box") ||
+                                q_format.title == t("helpers.radio_buttons") || q_format.title == t("helpers.dropdown")) then
+                                        details["sections"][s.number]["questions"][q.number]["selections"] = {}
+                                        answer.options.each do |o|
+                                                details["sections"][s.number]["questions"][q.number]["selections"][o.number] = o.text
+                                        end
+                                end
+                                details["sections"][s.number]["questions"][q.number]["answer_text"] = answer.text
+                        end
+                end
+        end
+        return details
+end
+
+ +
+ + + + +
+ + +
+ +
+ dmptemplate() + click to toggle source +
+ + +
+ + + + + +
+
# File app/models/plan.rb, line 36
+def dmptemplate
+        self.project.try(:dmptemplate) || Dmptemplate.new
+end
+
+ +
+ + + + +
+ + +
+ +
+ editable_by(user_id) + click to toggle source +
+ + +
+ + + + + +
+
# File app/models/plan.rb, line 156
+def editable_by(user_id)
+        return project.editable_by(user_id)
+end
+
+ +
+ + + + +
+ + +
+ +
+ guidance_for_question(question) + click to toggle source +
+ + +
+ + + + + +
+
# File app/models/plan.rb, line 81
+def guidance_for_question(question)
+        guidances = {}
+        # If project org isn't nil, get guidance by theme from any "non-subset" groups belonging to project org
+
+        unless project.organisation.nil? then
+                project.organisation.guidance_groups.each do |group|
+                        if !group.optional_subset && (group.dmptemplates.pluck(:id).include?(project.dmptemplate_id) || group.dmptemplates.count == 0) then
+                                group.guidances.each do |guidance|
+                                        guidance.themes.where("id IN (?)", question.theme_ids).each do |theme|
+                                                guidances = self.add_guidance_to_array(guidances, group, theme, guidance)
+                                        end
+                                end
+                        end
+                end
+        end
+
+        # Get guidance by theme from any guidance groups selected on creation
+
+        project.guidance_groups.each do |group|
+                if group.dmptemplates.pluck(:id).include?(project.dmptemplate_id) || group.dmptemplates.count == 0 then
+                        group.guidances.each do |guidance|
+                                guidance.themes.where("id IN (?)", question.theme_ids).each do |theme|
+                                        guidances = self.add_guidance_to_array(guidances, group, theme, guidance)
+                                end
+                        end
+                end 
+end
+        
+        # Get guidance by question where guidance group was selected on creation or if group is organisation default
+
+        question.guidances.each do |guidance|
+                guidance.guidance_groups.each do |group|
+                        if (group.organisation == project.organisation && !group.optional_subset) || project.guidance_groups.include?(group) then
+                                guidances = self.add_guidance_to_array(guidances, group, nil, guidance)
+                        end
+    end
+        end
+
+        return guidances
+end
+
+ +
+ + + + +
+ + +
+ +
+ latest_update() + click to toggle source +
+ + +
+ + + + + +
+
# File app/models/plan.rb, line 321
+def latest_update
+        if answers.any? then
+                last_answered = answers.order("updated_at DESC").first.updated_at
+                if last_answered > updated_at then
+                        return last_answered
+                else
+                        return updated_at
+                end
+        else
+                return updated_at
+        end
+end
+
+ +
+ + + + +
+ + +
+ +
+ lock_all_sections(user_id) + click to toggle source +
+ + +
+ + + + + +
+
# File app/models/plan.rb, line 279
+def lock_all_sections(user_id)
+        sections.each do |s|
+                lock_section(s.id, user_id, 1800)
+        end
+end
+
+ +
+ + + + +
+ + +
+ +
+ lock_section(section_id, user_id, release_time = 60) + click to toggle source +
+ + +
+ + + + + +
+
# File app/models/plan.rb, line 297
+def lock_section(section_id, user_id, release_time = 60)
+        status = locked(section_id, user_id)
+        if ! status["locked"] then
+                plan_section = PlanSection.new
+                plan_section.plan_id = id
+                plan_section.section_id = section_id
+                plan_section.release_time = Time.now + release_time.seconds
+                plan_section.user_id = user_id
+                plan_section.save
+        elsif status["current_user"] then
+                plan_section = PlanSection.find(status["id"])
+                plan_section.release_time = Time.now + release_time.seconds
+                plan_section.save
+        else
+                return false
+        end
+end
+
+ +
+ + + + +
+ + +
+ +
+ locked(section_id, user_id) + click to toggle source +
+ + +
+ + + + + +
+
# File app/models/plan.rb, line 260
+def locked(section_id, user_id)
+        plan_section = plan_sections.where("section_id = ? AND user_id != ? AND release_time > ?", section_id, user_id, Time.now).last
+        if plan_section.nil? then
+                status = {
+                        "locked" => false,
+                        "locked_by" => nil,
+                        "timestamp" => nil,
+                        "id" => nil
+                }
+        else
+                status = {
+                        "locked" => true,
+                        "locked_by" => plan_section.user.name,
+                        "timestamp" => plan_section.updated_at,
+                        "id" => plan_section.id
+                }
+        end
+end
+
+ +
+ + + + +
+ + +
+ +
+ readable_by(user_id) + click to toggle source +
+ + +
+ + + + + +
+
# File app/models/plan.rb, line 160
+def readable_by(user_id)
+        if project.nil?
+                return false
+        else
+                return project.readable_by(user_id)
+        end
+end
+
+ +
+ + + + +
+ + +
+ +
+ section_answers(section_id) + click to toggle source +
+ + +
+ + + + + +
+
# File app/models/plan.rb, line 334
+def section_answers(section_id)
+        section = Section.find(section_id)
+        section_questions = Array.new
+        counter = 0
+        section.questions.each do |q|
+                section_questions[counter] = {}
+                section_questions[counter]["id"] = q.id
+                #section_questions[counter]["multiple_choice"] = q.multiple_choice
+
+                q_answer = answer(q.id, false)
+                if q_answer.nil? then
+                        section_questions[counter]["answer_id"] = nil
+                        if q.suggested_answers.find_by_organisation_id(project.organisation_id).nil? then
+                                section_questions[counter]["answer_text"] = ""
+                        else
+                                section_questions[counter]["answer_text"] = q.default_value
+                        end
+                        section_questions[counter]["answer_timestamp"] = nil
+                        section_questions[counter]["answer_options"] = Array.new
+                else
+                        section_questions[counter]["answer_id"] = q_answer.id
+                        section_questions[counter]["answer_text"] = q_answer.text
+                        section_questions[counter]["answer_timestamp"] = q_answer.created_at
+                        section_questions[counter]["answer_options"] = q_answer.options.pluck(:id)
+                end
+                counter = counter + 1
+        end
+        return section_questions
+end
+
+ +
+ + + + +
+ + +
+ +
+ sections() + click to toggle source +
+ + +
+ + + + + +
+
# File app/models/plan.rb, line 72
+def sections
+        unless project.organisation.nil? then
+                sections = version.global_sections + project.organisation.all_sections(version_id)
+        else
+                sections = version.global_sections
+        end
+        return sections.uniq.sort_by &:number
+end
+
+ +
+ + + + +
+ + +
+ +
+ settings(key) + click to toggle source +
+ + +
+ +

Proxy through to the template settings (or defaults if this plan +doesn't have an associated template) if there are no settings stored +for this plan. `key` is required by rails-settings, so it's required +here, too.

+ + + +
+
# File app/models/plan.rb, line 29
+def settings(key)
+        self_settings = self.super_settings(key)
+        return self_settings if self_settings.value?
+
+        self.dmptemplate.settings(key)
+end
+
+ +
+ + +
+ Also aliased as: super_settings +
+ + + +
+ + +
+ +
+ status() + click to toggle source +
+ + +
+ + + + + +
+
# File app/models/plan.rb, line 172
+def status
+        status = {
+                "num_questions" => 0,
+                "num_answers" => 0,
+                "sections" => {},
+                "questions" => {},
+                "space_used" => 0 # percentage of available space in pdf used
+
+        }
+
+        space_used = height_of_text(self.project.title, 2, 2)
+
+        sections.each do |s|
+                space_used += height_of_text(s.title, 1, 1)
+                section_questions = 0
+                section_answers = 0
+                status["sections"][s.id] = {}
+                status["sections"][s.id]["questions"] = Array.new
+                s.questions.each do |q|
+                        status["num_questions"] += 1
+                        section_questions += 1
+                        status["sections"][s.id]["questions"] << q.id
+                        status["questions"][q.id] = {}
+                        answer = answer(q.id, false)
+
+                        space_used += height_of_text(q.text) unless q.text == s.title
+                        space_used += height_of_text(answer.try(:text) || I18n.t('helpers.plan.export.pdf.question_not_answered'))
+
+                        if ! answer.nil? then
+                                status["questions"][q.id] = {
+                                        "answer_id" => answer.id,
+                                        "answer_created_at" => answer.created_at.to_i,
+                                        "answer_text" => answer.text,
+                                        "answer_option_ids" => answer.option_ids,
+                                        "answered_by" => answer.user.name
+                                }
+            q_format = q.question_format
+                                status["num_answers"] += 1 if (q_format.title == I18n.t("helpers.checkbox") || q_format.title == I18n.t("helpers.multi_select_box") ||
+                                q_format.title == I18n.t("helpers.radio_buttons") || q_format.title == I18n.t("helpers.dropdown")) || answer.text.present?
+                                section_answers += 1
+                                #TODO: include selected options in space estimate
+
+                        else
+                                status["questions"][q.id] = {
+                                        "answer_id" => nil,
+                                        "answer_created_at" => nil,
+                                        "answer_text" => nil,
+                                        "answer_option_ids" => nil,
+                                        "answered_by" => nil
+                                }
+                        end
+                        status["sections"][s.id]["num_questions"] = section_questions
+                        status["sections"][s.id]["num_answers"] = section_answers
+                end
+        end
+
+        status['space_used'] = estimate_space_used(space_used)
+        return status
+end
+
+ +
+ + + + +
+ + +
+ +
+ super_settings(key) + click to toggle source +
+ + +
+ + + + + +
+ + + + +
+ Alias for: settings +
+ +
+ + +
+ +
+ title() + click to toggle source +
+ + +
+ + + + + +
+
# File app/models/plan.rb, line 40
+def title
+        logger.debug "Title in settings: #{self.settings(:export).title}"
+        if self.settings(:export).title == ""
+    if !self.version.nil? && !self.version.phase.nil? && !self.version.phase.title? then
+        return self.version.phase.title
+    else
+        return "DMP title"
+                end
+        else
+                return self.settings(:export).title
+        end
+end
+
+ +
+ + + + +
+ + +
+ +
+ unlock_all_sections(user_id) + click to toggle source +
+ + +
+ + + + + +
+
# File app/models/plan.rb, line 285
+def unlock_all_sections(user_id)
+        plan_sections.where(:user_id => user_id).order("created_at DESC").each do |lock|
+                lock.delete
+        end
+end
+
+ +
+ + + + +
+ + +
+ +
+ unlock_section(section_id, user_id) + click to toggle source +
+ + +
+ + + + + +
+
# File app/models/plan.rb, line 315
+def unlock_section(section_id, user_id)
+        plan_sections.where(:section_id => section_id, :user_id => user_id).order("created_at DESC").each do |lock|
+                lock.delete
+        end
+end
+
+ +
+ + + + +
+ + +
+ +
+ warning(option_id) + click to toggle source +
+ + +
+ + + + + +
+
# File app/models/plan.rb, line 148
+def warning(option_id)
+        if project.organisation.nil?
+                return nil
+        else
+                return project.organisation.warning(option_id)
+        end
+end
+
+ +
+ + + + +
+ + +
+ +
+

Private Instance Methods

+ + +
+ +
+ estimate_space_used(used_height) + click to toggle source +
+ + +
+ +

Based on the height of the text gathered so far and the available vertical +space of the pdf, estimate a percentage of how much space has been used. +This is highly dependent on the layout in the pdf. A more accurate approach +would be to render the pdf and check how much space had been used, but that +could be very slow. NOTE: This is only an estimate, rounded up to the +nearest 5%; it is intended for guidance when editing plan data, not to be +100% accurate.

+ + + +
+
# File app/models/plan.rb, line 372
+def estimate_space_used(used_height)
+        @formatting ||= self.settings(:export).formatting
+
+        return 0 unless @formatting[:font_size] > 0
+
+        margin_height    = @formatting[:margin][:top].to_i + @formatting[:margin][:bottom].to_i
+        page_height      = A4_PAGE_HEIGHT - margin_height # 297mm for A4 portrait
+
+        available_height = page_height * self.dmptemplate.settings(:export).max_pages
+
+        percentage = (used_height / available_height) * 100
+        (percentage / ROUNDING).ceil * ROUNDING # round up to nearest five
+
+end
+
+ +
+ + + + +
+ + +
+ +
+ height_of_text(text, font_size_inc = 0, vertical_margin = 0) + click to toggle source +
+ + +
+ +

Take a guess at the vertical height (in mm) of the given text based on the +font-size and left/right margins stored in the plan's settings. This +assumes a fixed-width for each glyph, which is obviously incorrect for the +font-face choices available; the idea is that they'll hopefully average +out to that in the long-run. Allows for hinting different font sizes +(offset from base via font_size_inc) and vertical margins (i.e. for heading +text)

+ + + +
+
# File app/models/plan.rb, line 392
+def height_of_text(text, font_size_inc = 0, vertical_margin = 0)
+        @formatting     ||= self.settings(:export).formatting
+        @margin_width   ||= @formatting[:margin][:left].to_i + @formatting[:margin][:right].to_i
+        @base_font_size ||= @formatting[:font_size]
+
+        return 0 unless @base_font_size > 0
+
+        font_height = FONT_HEIGHT_CONVERSION_FACTOR * (@base_font_size + font_size_inc)
+        font_width  = font_height * FONT_WIDTH_HEIGHT_RATIO # Assume glyph width averages at 2/5s the height
+
+        leading     = font_height / 2
+
+        chars_in_line = (A4_PAGE_WIDTH - @margin_width) / font_width # 210mm for A4 portrait
+
+        num_lines = (text.length / chars_in_line).ceil
+
+        (num_lines * font_height) + vertical_margin + leading
+end
+
+ +
+ + + + +
+ + +
+ +
+ +
+ + + + diff --git a/public/html/PlanSection.html b/public/html/PlanSection.html new file mode 100644 index 0000000..563df5e --- /dev/null +++ b/public/html/PlanSection.html @@ -0,0 +1,279 @@ + + + + + + +class PlanSection - DMPonline4 Documentation + + + + + + + + + + + + + + + + +
+

class PlanSection

+ +
+ +
+ + + + +
+ + + + + + + + + + +
+ +
+ + + + diff --git a/public/html/PlansController.html b/public/html/PlansController.html new file mode 100644 index 0000000..6992368 --- /dev/null +++ b/public/html/PlansController.html @@ -0,0 +1,833 @@ + + + + + + +class PlansController - DMPonline4 Documentation + + + + + + + + + + + + + + + + +
+

class PlansController

+ +
+ +
+ + + + +
+ + + + + + + + + + +
+

Public Instance Methods

+ + +
+ +
+ answer() + click to toggle source +
+ + +
+ + + + + +
+
# File app/controllers/plans_controller.rb, line 142
+def answer
+        @plan = Plan.find(params[:id])
+        if user_signed_in? && @plan.readable_by(current_user.id) then
+                respond_to do |format|
+                        format.json { render json: @plan.answer(params[:q_id], false).to_json(:include => :options) }
+                end
+        else
+                render(:file => File.join(Rails.root, 'public/403.html'), :status => 403, :layout => false)
+        end
+end
+
+ +
+ + + + +
+ + +
+ +
+ delete_recent_locks() + click to toggle source +
+ + +
+ + + + + +
+
# File app/controllers/plans_controller.rb, line 74
+def delete_recent_locks
+        @plan = Plan.find(params[:id])
+        if user_signed_in? && @plan.editable_by(current_user.id) then
+                respond_to do |format|
+                        if @plan.delete_recent_locks(current_user.id)
+                                format.html { render action: "edit" }
+                                format.json { head :no_content }
+                        else
+                                format.html { render action: "edit" }
+                                format.json { render json: @plan.errors, status: :unprocessable_entity }
+                        end
+                end
+        else
+                render(:file => File.join(Rails.root, 'public/403.html'), :status => 403, :layout => false)
+        end
+end
+
+ +
+ + + + +
+ + +
+ +
+ edit() + click to toggle source +
+ + +
+ +

GET /plans/1/edit

+ + + +
+
# File app/controllers/plans_controller.rb, line 6
+    def edit
+            @plan = Plan.find(params[:id])
+    
+   
+if !user_signed_in? then
+  respond_to do |format|
+                            format.html { redirect_to edit_user_registration_path }
+                    end
+            elsif !@plan.readable_by(current_user.id) then
+                    respond_to do |format|
+                            format.html { redirect_to projects_url, notice: "This account does not have access to that plan." }
+                    end
+            end
+    end
+
+ +
+ + + + +
+ + +
+ +
+ export() + click to toggle source +
+ + +
+ + + + + +
+
# File app/controllers/plans_controller.rb, line 164
+def export
+        @plan = Plan.find(params[:id])
+
+        if user_signed_in? && @plan.readable_by(current_user.id) then
+                @exported_plan = ExportedPlan.new.tap do |ep|
+                        ep.plan = @plan
+                        ep.user = current_user
+                        ep.format = request.format.try(:symbol)
+                        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.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]'
+                                 }
+                  end
+                end
+        elsif !user_signed_in? then
+       respond_to do |format|
+                        format.html { redirect_to edit_user_registration_path }
+                end
+        elsif !@plan.editable_by(current_user.id) then
+                respond_to do |format|
+                        format.html { redirect_to projects_url, notice: "This account does not have access to that plan." }
+                end
+        end
+end
+
+ +
+ + + + +
+ + +
+ +
+ lock_section() + click to toggle source +
+ + +
+ + + + + +
+
# File app/controllers/plans_controller.rb, line 108
+def lock_section
+        @plan = Plan.find(params[:id])
+        if user_signed_in? && @plan.editable_by(current_user.id) then
+                respond_to do |format|
+                        if @plan.lock_section(params[:section_id], current_user.id)
+                                format.html { render action: "edit" }
+                                format.json { head :no_content }
+                        else
+                                format.html { render action: "edit" }
+                                format.json { render json: @plan.errors, status: :unprocessable_entity }
+                        end
+                end
+        else
+                render(:file => File.join(Rails.root, 'public/403.html'), :status => 403, :layout => false)
+        end
+end
+
+ +
+ + + + +
+ + +
+ +
+ locked() + click to toggle source +
+ + +
+ + + + + +
+
# File app/controllers/plans_controller.rb, line 63
+def locked
+        @plan = Plan.find(params[:id])
+        if !@plan.nil? && user_signed_in? && @plan.readable_by(current_user.id) then
+                respond_to do |format|
+                        format.json { render json: @plan.locked(params[:section_id],current_user.id) }
+                end
+        else
+                render(:file => File.join(Rails.root, 'public/403.html'), :status => 403, :layout => false)
+        end
+end
+
+ +
+ + + + +
+ + +
+ +
+ section_answers() + click to toggle source +
+ + +
+ + + + + +
+
# File app/controllers/plans_controller.rb, line 52
+def section_answers
+        @plan = Plan.find(params[:id])
+        if user_signed_in? && @plan.readable_by(current_user.id) then
+                respond_to do |format|
+                        format.json { render json: @plan.section_answers(params[:section_id]) }
+                end
+        else
+                render(:file => File.join(Rails.root, 'public/403.html'), :status => 403, :layout => false)
+        end
+end
+
+ +
+ + + + +
+ + +
+ +
+ status() + click to toggle source +
+ + +
+ +

GET /status/1.json

+ + + +
+
# File app/controllers/plans_controller.rb, line 41
+def status
+        @plan = Plan.find(params[:id])
+        if user_signed_in? && @plan.readable_by(current_user.id) then
+                respond_to do |format|
+                        format.json { render json: @plan.status }
+                end
+        else
+                render(:file => File.join(Rails.root, 'public/403.html'), :status => 403, :layout => false)
+        end
+end
+
+ +
+ + + + +
+ + +
+ +
+ unlock_all_sections() + click to toggle source +
+ + +
+ + + + + +
+
# File app/controllers/plans_controller.rb, line 91
+def unlock_all_sections
+        @plan = Plan.find(params[:id])
+        if user_signed_in? && @plan.editable_by(current_user.id) then
+                respond_to do |format|
+                        if @plan.unlock_all_sections(current_user.id)
+                                format.html { render action: "edit" }
+                                format.json { head :no_content }
+                        else
+                                format.html { render action: "edit" }
+                                format.json { render json: @plan.errors, status: :unprocessable_entity }
+                        end
+                end
+        else
+                render(:file => File.join(Rails.root, 'public/403.html'), :status => 403, :layout => false)
+        end
+end
+
+ +
+ + + + +
+ + +
+ +
+ unlock_section() + click to toggle source +
+ + +
+ + + + + +
+
# File app/controllers/plans_controller.rb, line 125
+def unlock_section
+        @plan = Plan.find(params[:id])
+        if user_signed_in? && @plan.editable_by(current_user.id) then
+                respond_to do |format|
+                        if @plan.unlock_section(params[:section_id], current_user.id)
+                                format.html { render action: "edit" }
+                                format.json { head :no_content }
+                        else
+                                format.html { render action: "edit" }
+                                format.json { render json: @plan.errors, status: :unprocessable_entity }
+                        end
+                end
+        else
+                render(:file => File.join(Rails.root, 'public/403.html'), :status => 403, :layout => false)
+        end
+end
+
+ +
+ + + + +
+ + +
+ +
+ update() + click to toggle source +
+ + +
+ +

PUT /plans/1 PUT /plans/1.json

+ + + +
+
# File app/controllers/plans_controller.rb, line 23
+def update
+        @plan = Plan.find(params[:id])
+        if user_signed_in? && @plan.editable_by(current_user.id) then
+                respond_to do |format|
+                if @plan.update_attributes(params[:plan])
+                        format.html { redirect_to @plan, notice: 'Plan was successfully updated.' }
+                        format.json { head :no_content }
+                else
+                        format.html { render action: "edit" }
+                        format.json { render json: @plan.errors, status: :unprocessable_entity }
+                end
+        end
+else
+                render(:file => File.join(Rails.root, 'public/403.html'), :status => 403, :layout => false)
+end
+end
+
+ +
+ + + + +
+ + +
+ +
+ warning() + click to toggle source +
+ + +
+ + + + + +
+
# File app/controllers/plans_controller.rb, line 153
+def warning
+        @plan = Plan.find(params[:id])
+        if user_signed_in? && @plan.readable_by(current_user.id) then
+                respond_to do |format|
+                        format.json { render json: @plan.warning(params[:option_id]) }
+                end
+        else
+                render(:file => File.join(Rails.root, 'public/403.html'), :status => 403, :layout => false)
+        end
+end
+
+ +
+ + + + +
+ + +
+ +
+ +
+ + + + diff --git a/public/html/PlansHelper.html b/public/html/PlansHelper.html new file mode 100644 index 0000000..6373cd5 --- /dev/null +++ b/public/html/PlansHelper.html @@ -0,0 +1,427 @@ + + + + + + +module PlansHelper - DMPonline4 Documentation + + + + + + + + + + + + + + + + +
+

module PlansHelper

+ +
+ +
+ + + + +
+ + + + + + + + + + +
+

Public Instance Methods

+ + +
+ +
+ plan_settings_indicator(plan) + click to toggle source +
+ + +
+ +

Shows whether the user has default, template-default or custom settings for +the given plan.

+ + + +
+
# File app/helpers/plans_helper.rb, line 45
+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
+
+ +
+ + + + +
+ + +
+ +
+ project_list_body(column, project) + click to toggle source +
+ + +
+ + + + + +
+
# File app/helpers/plans_helper.rb, line 13
+def project_list_body(column, project)
+  klass, content = case column
+    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') + " (with #{shared_num} people) ") : t('helpers.no')
+      [ '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) || 'Unknown') ]
+    else
+      [ 'dmp_td_small', (project.try(column) || 'Unknown') ]
+  end
+
+  content_tag(:td, content, class: klass)
+end
+
+ +
+ + + + +
+ + +
+ +
+ project_list_head(column) + click to toggle source +
+ + +
+ + + + + +
+
# File app/helpers/plans_helper.rb, line 3
+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
+
+ +
+ + + + +
+ + +
+ +
+ +
+ + + + diff --git a/public/html/Project.html b/public/html/Project.html new file mode 100644 index 0000000..ca0dd35 --- /dev/null +++ b/public/html/Project.html @@ -0,0 +1,1262 @@ + + + + + + +class Project - DMPonline4 Documentation + + + + + + + + + + + + + + + + +
+

class Project

+ +
+ +
+ + + + +
+ + + + + + + + + + +
+

Public Class Methods

+ + +
+ +
+ projects_for_user(user_id) + click to toggle source +
+ + +
+ + + + + +
+
# File app/models/project.rb, line 142
+def self.projects_for_user(user_id)
+        projects = Array.new
+        groups = ProjectGroup.where("user_id = ?", user_id)
+        unless groups.nil? then
+                groups.each do |group|
+                        unless group.project.nil? then
+                                projects << group.project
+                        end
+                end
+        end
+        return projects
+end
+
+ +
+ + + + +
+ + +
+ +
+

Public Instance Methods

+ + +
+ +
+ administerable_by(user_id) + click to toggle source +
+ + +
+ + + + + +
+
# File app/models/project.rb, line 115
+def administerable_by(user_id)
+        user = project_groups.find_by_user_id(user_id)
+        if (! user.nil?) && user.project_administrator then
+                return true
+        else
+                return false
+        end
+end
+
+ +
+ + + + +
+ + +
+ +
+ assign_administrator(user_id) + click to toggle source +
+ + +
+ + + + + +
+
# File app/models/project.rb, line 111
+def assign_administrator(user_id)
+        add_user(user_id, true, true)
+end
+
+ +
+ + + + +
+ + +
+ +
+ assign_creator(user_id) + click to toggle source +
+ + +
+ + + + + +
+
# File app/models/project.rb, line 99
+def assign_creator(user_id)
+        add_user(user_id, true, true, true)
+end
+
+ +
+ + + + +
+ + +
+ +
+ assign_editor(user_id) + click to toggle source +
+ + +
+ + + + + +
+
# File app/models/project.rb, line 103
+def assign_editor(user_id)
+        add_user(user_id, true)
+end
+
+ +
+ + + + +
+ + +
+ +
+ assign_reader(user_id) + click to toggle source +
+ + +
+ + + + + +
+
# File app/models/project.rb, line 107
+def assign_reader(user_id)
+        add_user(user_id)
+end
+
+ +
+ + + + +
+ + +
+ +
+ created_by(user_id) + click to toggle source +
+ + +
+ + + + + +
+
# File app/models/project.rb, line 155
+def created_by(user_id)
+        user = project_groups.find_by_user_id(user_id)
+        if (! user.nil?) && user.project_creator then
+                return true
+        else
+                return false
+        end
+end
+
+ +
+ + + + +
+ + +
+ +
+ editable_by(user_id) + click to toggle source +
+ + +
+ + + + + +
+
# File app/models/project.rb, line 124
+def editable_by(user_id)
+        user = project_groups.find_by_user_id(user_id)
+        if (! user.nil?) && user.project_editor then
+                return true
+        else
+                return false
+        end
+end
+
+ +
+ + + + +
+ + +
+ +
+ funder() + click to toggle source +
+ + +
+ + + + + +
+
# File app/models/project.rb, line 39
+def funder
+        if dmptemplate.nil? then
+                return nil
+        end
+        template_org = dmptemplate.organisation
+        if template_org.organisation_type.name == I18n.t('helpers.org_type.funder').downcase
+                return template_org
+        else
+                return nil
+        end
+end
+
+ +
+ + + + +
+ + +
+ +
+ funder_id() + click to toggle source +
+ + +
+ + + + + +
+
# File app/models/project.rb, line 27
+def funder_id
+        if dmptemplate.nil? then
+                return nil
+        end
+        template_org = dmptemplate.organisation
+        if template_org.organisation_type.name == I18n.t('helpers.org_type.funder').downcase
+                return template_org.id
+        else
+                return nil
+        end
+end
+
+ +
+ + + + +
+ + +
+ +
+ funder_id=(new_funder_id) + click to toggle source +
+ + +
+ + + + + +
+
# File app/models/project.rb, line 18
+def funder_id=(new_funder_id)
+        if new_funder_id != "" then
+                new_funder = Organisation.find(new_funder_id);
+                if new_funder.dmptemplates.count == 1 then
+                        dmptemplate = new_funder.dmptemplates.first
+                end
+        end
+end
+
+ +
+ + + + +
+ + +
+ +
+ funder_name() + click to toggle source +
+ + +
+ + + + + +
+
# File app/models/project.rb, line 51
+def funder_name
+        if self.funder.nil?
+                return read_attribute(:funder_name)
+        else
+                return self.funder.name
+        end
+end
+
+ +
+ + + + +
+ + +
+ +
+ funder_name=(new_funder_name) + click to toggle source +
+ + +
+ + + + + +
+
# File app/models/project.rb, line 59
+def funder_name=(new_funder_name)
+        write_attribute(:funder_name, new_funder_name)
+        org_table = Organisation.arel_table
+        existing_org = Organisation.where(org_table[:name].matches(new_funder_name))
+        if existing_org.nil?
+                existing_org = Organisation.where(org_table[:abbreviation].matches(new_funder_name))
+        end
+        unless existing_org.empty?
+                self.funder_id=existing_org.id
+        end
+end
+
+ +
+ + + + +
+ + +
+ +
+ institution_id() + click to toggle source +
+ + +
+ + + + + +
+
# File app/models/project.rb, line 77
+def institution_id
+        if organisation.nil?
+                return nil
+        else
+                return organisation.root.id
+        end
+end
+
+ +
+ + + + +
+ + +
+ +
+ institution_id=(new_institution_id) + click to toggle source +
+ + +
+ + + + + +
+
# File app/models/project.rb, line 71
+def institution_id=(new_institution_id)
+        if organisation.nil? then
+                self.organisation_id = new_institution_id
+        end
+end
+
+ +
+ + + + +
+ + +
+ +
+ last_edited() + click to toggle source +
+ + +
+ + + + + +
+
# File app/models/project.rb, line 183
+def last_edited
+        self.latest_update.to_date
+end
+
+ +
+ + + + +
+ + +
+ +
+ latest_update() + click to toggle source +
+ + +
+ + + + + +
+
# File app/models/project.rb, line 164
+def latest_update
+        latest_update = updated_at
+        plans.each do |plan|
+                if plan.latest_update > latest_update then
+                        latest_update = plan.latest_update
+                end
+        end
+        return latest_update
+end
+
+ +
+ + + + +
+ + +
+ +
+ name() + click to toggle source +
+ + +
+ +

Getters to match 'My plans' columns

+ + + +
+
# File app/models/project.rb, line 175
+def name
+        self.title
+end
+
+ +
+ + + + +
+ + +
+ +
+ owner() + click to toggle source +
+ + +
+ + + + + +
+
# File app/models/project.rb, line 179
+def owner
+        self.project_groups.find_by_project_creator(true).try(:user)
+end
+
+ +
+ + + + +
+ + +
+ +
+ readable_by(user_id) + click to toggle source +
+ + +
+ + + + + +
+
# File app/models/project.rb, line 133
+def readable_by(user_id)
+        user = project_groups.find_by_user_id(user_id)
+        if (! user.nil?) then
+                return true
+        else
+                return false
+        end
+end
+
+ +
+ + + + +
+ + +
+ +
+ shared() + click to toggle source +
+ + +
+ + + + + +
+ + + + +
+ Alias for: shared? +
+ +
+ + +
+ +
+ shared?() + click to toggle source +
+ + +
+ + + + + +
+
# File app/models/project.rb, line 187
+def shared?
+        self.project_groups.count > 1
+end
+
+ +
+ + +
+ Also aliased as: shared +
+ + + +
+ + +
+ +
+ template_owner() + click to toggle source +
+ + +
+ + + + + +
+
# File app/models/project.rb, line 193
+def template_owner
+        self.dmptemplate.try(:organisation).try(:abbreviation)
+end
+
+ +
+ + + + +
+ + +
+ +
+ unit_id() + click to toggle source +
+ + +
+ + + + + +
+
# File app/models/project.rb, line 91
+def unit_id
+        if organisation.nil? || organisation.parent_id.nil?
+                return nil
+        else
+                return organisation_id
+        end
+end
+
+ +
+ + + + +
+ + +
+ +
+ unit_id=(new_unit_id) + click to toggle source +
+ + +
+ + + + + +
+
# File app/models/project.rb, line 85
+def unit_id=(new_unit_id)
+        unless new_unit_id.nil? ||new_unit_id == ""
+                self.organisation_id = new_unit_id
+        end
+end
+
+ +
+ + + + +
+ + +
+ +
+

Private Instance Methods

+ + +
+ +
+ add_user(user_id, is_editor = false, is_administrator = false, is_creator = false) + click to toggle source +
+ + +
+ + + + + +
+
# File app/models/project.rb, line 199
+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
+
+ +
+ + + + +
+ + +
+ +
+ create_plans() + click to toggle source +
+ + +
+ + + + + +
+
# File app/models/project.rb, line 208
+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
+
+ +
+ + + + +
+ + +
+ +
+ +
+ + + + diff --git a/public/html/ProjectGroup.html b/public/html/ProjectGroup.html new file mode 100644 index 0000000..70c5421 --- /dev/null +++ b/public/html/ProjectGroup.html @@ -0,0 +1,441 @@ + + + + + + +class ProjectGroup - DMPonline4 Documentation + + + + + + + + + + + + + + + + +
+

class ProjectGroup

+ +
+ +
+ + + + +
+ + + + + + + + + + +
+

Public Instance Methods

+ + +
+ +
+ access_level() + click to toggle source +
+ + +
+ + + + + +
+
# File app/models/project_group.rb, line 21
+def access_level
+        if project_administrator then
+                return 3
+        elsif project_editor then
+                return 2
+        else
+                return 1
+        end
+end
+
+ +
+ + + + +
+ + +
+ +
+ access_level=(new_access_level) + click to toggle source +
+ + +
+ + + + + +
+
# File app/models/project_group.rb, line 31
+def access_level=(new_access_level)
+        new_access_level = new_access_level.to_i
+        if new_access_level >= 3 then
+                project_administrator = true
+        else
+                project_administrator = false
+        end
+        if new_access_level >= 2 then
+                project_editor = true
+        else
+                project_editor = false
+        end
+end
+
+ +
+ + + + +
+ + +
+ +
+ email() + click to toggle source +
+ + +
+ + + + + +
+
# File app/models/project_group.rb, line 9
+def email
+        unless user.nil? 
+                return user.email
+        end
+end
+
+ +
+ + + + +
+ + +
+ +
+ email=(new_email) + click to toggle source +
+ + +
+ + + + + +
+
# File app/models/project_group.rb, line 15
+def email=(new_email)
+        unless User.find_by_email(email).nil? then
+                user = User.find_by_email(email)
+        end
+end
+
+ +
+ + + + +
+ + +
+ +
+ +
+ + + + diff --git a/public/html/ProjectGroupsController.html b/public/html/ProjectGroupsController.html new file mode 100644 index 0000000..96cea38 --- /dev/null +++ b/public/html/ProjectGroupsController.html @@ -0,0 +1,473 @@ + + + + + + +class ProjectGroupsController - DMPonline4 Documentation + + + + + + + + + + + + + + + + +
+

class ProjectGroupsController

+ +
+ +
+ + + + +
+ + + + + + + + + + +
+

Public Instance Methods

+ + +
+ +
+ create() + click to toggle source +
+ + +
+ + + + + +
+
# File app/controllers/project_groups_controller.rb, line 3
+def create
+        @project_group = ProjectGroup.new(params[:project_group])
+        access_level = params[:project_group][:access_level].to_i
+        if access_level >= 3 then
+                @project_group.project_administrator = true
+        end
+        if access_level >= 2 then
+                @project_group.project_editor = true
+        end
+        if (user_signed_in?) && @project_group.project.administerable_by(current_user.id) then
+                respond_to do |format|
+                        if params[:project_group][:email].present? && params[:project_group][:email].length > 0 then
+                                message = 'User added to project'
+                                if @project_group.save
+                                        if @project_group.user.nil? then
+                                                if User.find_by_email(params[:project_group][:email]).nil? then
+                                                        User.invite!(:email => params[:project_group][:email])
+                                                        message = 'Invitation issued successfully.'
+                                                        @project_group.user = User.find_by_email(params[:project_group][:email])
+                                                        @project_group.save
+                                                else
+                                                        @project_group.user = User.find_by_email(params[:project_group][:email])
+                                                        @project_group.save
+                                                        UserMailer.sharing_notification(@project_group).deliver
+                                                        logger.debug("Email sent from here?")
+                                                end
+                                        else
+                                                UserMailer.sharing_notification(@project_group).deliver
+                                                logger.debug("Email sent from there?")
+                                        end
+                                        flash[:notice] = message
+                                        format.html { redirect_to :controller => 'projects', :action => 'share', :id => @project_group.project.slug }
+                                        format.json { render json: @project_group, status: :created, location: @project_group }
+                                else
+                                        format.html { render action: "new" }
+                                        format.json { render json: @project_group.errors, status: :unprocessable_entity }
+                                end
+                        else
+                                flash[:notice] = "Please enter an email address"
+                                format.html { redirect_to :controller => 'projects', :action => 'share', :id => @project_group.project.slug }
+                                format.json { render json: @project_group, status: :created, location: @project_group }
+                        end
+                end                  
+        else
+                render(:file => File.join(Rails.root, 'public/403.html'), :status => 403, :layout => false)
+        end
+        
+end
+
+ +
+ + + + +
+ + +
+ +
+ destroy() + click to toggle source +
+ + +
+ + + + + +
+
# File app/controllers/project_groups_controller.rb, line 82
+def destroy
+        @project_group = ProjectGroup.find(params[:id])
+        if (user_signed_in?) && @project_group.project.administerable_by(current_user.id) then
+                user = @project_group.user
+                project = @project_group.project
+                @project_group.destroy
+                respond_to do |format|
+                        flash[:notice] = 'Access removed'
+                        UserMailer.project_access_removed_notification(user, project).deliver
+                        format.html { redirect_to :controller => 'projects', :action => 'share', :id => @project_group.project.slug }
+                        format.json { head :no_content }
+                end
+        else
+                render(:file => File.join(Rails.root, 'public/403.html'), :status => 403, :layout => false)
+        end
+end
+
+ +
+ + + + +
+ + +
+ +
+ update() + click to toggle source +
+ + +
+ + + + + +
+
# File app/controllers/project_groups_controller.rb, line 52
+def update
+@project_group = ProjectGroup.find(params[:id])
+access_level = params[:project_group][:access_level].to_i
+        if access_level >= 3 then
+                @project_group.project_administrator = true
+        else
+                @project_group.project_administrator = false
+        end
+        if access_level >= 2 then
+                @project_group.project_editor = true
+        else
+                @project_group.project_editor = false
+        end
+if (user_signed_in?) && @project_group.project.administerable_by(current_user.id) then
+                respond_to do |format|
+                        if @project_group.update_attributes(params[:project_group])
+                                flash[:notice] = 'Sharing details successfully updated.'
+                                UserMailer.permissions_change_notification(@project_group).deliver
+                                format.html { redirect_to :controller => 'projects', :action => 'share', :id => @project_group.project.slug }
+                                format.json { head :no_content }
+                        else
+                                format.html { render action: "edit" }
+                                format.json { render json: @project_group.errors, status: :unprocessable_entity }
+                         end
+                end
+else
+                render(:file => File.join(Rails.root, 'public/403.html'), :status => 403, :layout => false)
+        end
+end
+
+ +
+ + + + +
+ + +
+ +
+ +
+ + + + diff --git a/public/html/ProjectPartner.html b/public/html/ProjectPartner.html new file mode 100644 index 0000000..07f619b --- /dev/null +++ b/public/html/ProjectPartner.html @@ -0,0 +1,279 @@ + + + + + + +class ProjectPartner - DMPonline4 Documentation + + + + + + + + + + + + + + + + +
+

class ProjectPartner

+ +
+ +
+ + + + +
+ + + + + + + + + + +
+ +
+ + + + diff --git a/public/html/ProjectsController.html b/public/html/ProjectsController.html new file mode 100644 index 0000000..3d7254b --- /dev/null +++ b/public/html/ProjectsController.html @@ -0,0 +1,908 @@ + + + + + + +class ProjectsController - DMPonline4 Documentation + + + + + + + + + + + + + + + + +
+

class ProjectsController

+ +
+ +
+ + + + +
+ + + + + + + + + + +
+

Public Instance Methods

+ + +
+ +
+ create() + click to toggle source +
+ + +
+ +

POST /projects POST /projects.json

+ + + +
+
# File app/controllers/projects_controller.rb, line 113
+def create
+if user_signed_in? then
+                @project = Project.new(params[:project])
+                if @project.dmptemplate.nil? && params[:project][:funder_id] != "" then # this shouldn't be necessary - see setter for funder_id in project.rb
+
+                        funder = Organisation.find(params[:project][:funder_id])
+                        if funder.dmptemplates.count == 1 then
+                                @project.dmptemplate = funder.published_templates.first
+                        end
+                elsif @project.dmptemplate.nil? || params[:default_tag] == 'true' then
+                        if @project.organisation.nil?  || params[:default_tag] == 'true'  || @project.organisation.published_templates.first.nil? then
+                                @project.dmptemplate = Dmptemplate.find_by_is_default(true)
+                        else
+                                @project.dmptemplate = @project.organisation.published_templates.first
+                        end
+                end
+                @project.principal_investigator = current_user.name(false)
+                @project.title = I18n.t('helpers.project.my_project_name')+' ('+@project.dmptemplate.title+')'
+                @project.assign_creator(current_user.id)
+                respond_to do |format|
+                        if @project.save
+                                format.html { redirect_to({:action => "show", :id => @project.slug, :show_form => "yes"}, {:notice => I18n.t('helpers.project.success')}) }
+                                format.json { render json: @project, status: :created, location: @project }
+                        else
+                                format.html { render action: "new" }
+                                format.json { render json: @project.errors, status: :unprocessable_entity }
+                        end
+                end
+        else
+                render(:file => File.join(Rails.root, 'public/403.html'), :status => 403, :layout => false)
+        end
+end
+
+ +
+ + + + +
+ + +
+ +
+ destroy() + click to toggle source +
+ + +
+ +

DELETE /projects/1 DELETE /projects/1.json

+ + + +
+
# File app/controllers/projects_controller.rb, line 166
+def destroy
+        @project = Project.find(params[:id])
+        if user_signed_in? && @project.editable_by(current_user.id) then
+                @project.destroy
+
+                respond_to do |format|
+                        format.html { redirect_to projects_url }
+                        format.json { head :no_content }
+                end
+        else
+                render(:file => File.join(Rails.root, 'public/403.html'), :status => 403, :layout => false)
+        end
+end
+
+ +
+ + + + +
+ + +
+ +
+ edit() + click to toggle source +
+ + +
+ +

GET /projects/1/edit Should this be removed?

+ + + +
+
# File app/controllers/projects_controller.rb, line 71
+def edit
+        @project = Project.find(params[:id])
+        if !user_signed_in? then
+       respond_to do |format|
+                        format.html { redirect_to edit_user_registration_path }
+                end
+        elsif !@project.editable_by(current_user.id) then
+                respond_to do |format|
+                        format.html { redirect_to projects_url, notice: "This account does not have access to that plan." }
+                end
+        end
+end
+
+ +
+ + + + +
+ + +
+ +
+ export() + click to toggle source +
+ + +
+ + + + + +
+
# File app/controllers/projects_controller.rb, line 97
+def export
+        @project = Project.find(params[:id])
+        if !user_signed_in? then
+       respond_to do |format|
+                        format.html { redirect_to edit_user_registration_path }
+                end
+        else 
+                respond_to do |format|
+                        format.html { render action: "export" }
+        
+                end
+        end
+end
+
+ +
+ + + + +
+ + +
+ +
+ index() + click to toggle source +
+ + +
+ +

GET /projects GET /projects.json

+ + + +
+
# File app/controllers/projects_controller.rb, line 6
+def index
+        if user_signed_in? then
+                if (current_user.shibboleth_id.nil? || current_user.shibboleth_id.length == 0) && !cookies[:show_shib_link].nil? && cookies[:show_shib_link] == "show_shib_link" then
+                        flash.notice = "Would you like to #{view_context.link_to 'link your DMPonline account to your institutional credentials?', user_omniauth_shibboleth_path}".html_safe
+                end
+
+                @projects = current_user.projects.filter(params[:filter])
+                @has_projects = current_user.projects.any? # unfiltered count
+
+
+                respond_to do |format|
+                        format.html # index.html.erb
+
+                        format.json { render json: @projects }
+                end
+        else
+                respond_to do |format|
+                        format.html { redirect_to edit_user_registration_path }
+                end
+        end
+end
+
+ +
+ + + + +
+ + +
+ +
+ new() + click to toggle source +
+ + +
+ +

GET /projects/new GET /projects/new.json

+ + + +
+
# File app/controllers/projects_controller.rb, line 52
+def new
+        if user_signed_in? then
+                @project = Project.new
+                @project.organisation = current_user.organisation
+                @funders = orgs_of_type(t('helpers.org_type.funder'), true)
+                @institutions = orgs_of_type(t('helpers.org_type.institution'))
+                respond_to do |format|
+                  format.html # new.html.erb
+
+                  format.json { render json: @project }
+                end
+        else
+                respond_to do |format|
+                        format.html { redirect_to edit_user_registration_path }
+                end
+        end
+end
+
+ +
+ + + + +
+ + +
+ +
+ possible_guidance() + click to toggle source +
+ + +
+ + + + + +
+
# File app/controllers/projects_controller.rb, line 213
+def possible_guidance
+        if !params[:template].nil? && params[:template] != "" && params[:template] != "undefined" then
+                template = Dmptemplate.find(params[:template])
+        else
+                template = nil
+        end
+        if !params[:institution].nil? && params[:institution] != "" && params[:institution] != "undefined" then
+                institution = Organisation.find(params[:institution])
+        else
+                institution = nil
+        end
+        excluded_orgs = orgs_of_type(t('helpers.org_type.funder')) + orgs_of_type(t('helpers.org_type.institution')) + Organisation.orgs_with_parent_of_type(t('helpers.org_type.institution'))
+        guidance_groups = {}
+        ggs = GuidanceGroup.guidance_groups_excluding(excluded_orgs) 
+
+        ggs.each do |gg|
+                guidance_groups[gg.id] = gg.name
+        end
+
+#subset guidance that belong to the institution
+
+        unless institution.nil? then
+                optional_gg = GuidanceGroup.where("optional_subset =  ? && organisation_id = ?", true, institution.id)
+                optional_gg.each do|optional|
+                        guidance_groups[optional.id] = optional.name
+                end
+                
+                institution.children.each do |o|
+                        o.guidance_groups.each do |gg|
+                                include = false
+                                gg.guidances.each do |g|
+                                        if g.dmptemplate.nil? || g.dmptemplate_id == template.id then
+                                                include = true
+                                                break
+                                        end
+                                end
+                                if include then
+                                        guidance_groups[gg.id] = gg.name
+                                end
+                        end
+                end
+        end
+
+#If template belongs to a funder and that funder has subset guidance display then.
+
+if !template.nil? && template.organisation.organisation_type.name == t('helpers.org_type.funder') then
+    optional_gg = GuidanceGroup.where("optional_subset =  ? && organisation_id = ?", true, template.organisation_id)
+                optional_gg.each do|optional|
+                        guidance_groups[optional.id] = optional.name
+                end
+end
+
+
+        respond_to do |format|
+                format.json { render json: guidance_groups.to_json }
+        end
+end
+
+ +
+ + + + +
+ + +
+ +
+ possible_templates() + click to toggle source +
+ + +
+ +

GET /projects/possible_templates.json

+ + + +
+
# File app/controllers/projects_controller.rb, line 181
+def possible_templates
+        if !params[:funder].nil? && params[:funder] != "" && params[:funder] != "undefined" then
+                funder = Organisation.find(params[:funder])
+        else
+                funder = nil
+        end
+        if !params[:institution].nil? && params[:institution] != "" && params[:institution] != "undefined" then
+                institution = Organisation.find(params[:institution])
+        else
+                institution = nil
+        end
+        templates = {}
+        unless funder.nil? then
+                funder.published_templates.each do |t|
+                        templates[t.id] = t.title
+                end
+        end
+        if templates.count == 0 && !institution.nil? then
+                institution.published_templates.each do |t|
+                        templates[t.id] = t.title
+                end
+                institution.children.each do |o|
+                        o.published_templates.each do |t|
+                                templates[t.id] = t.title
+                        end
+                end
+        end
+        respond_to do |format|
+                format.json { render json: templates.to_json }
+        end
+end
+
+ +
+ + + + +
+ + +
+ +
+ share() + click to toggle source +
+ + +
+ + + + + +
+
# File app/controllers/projects_controller.rb, line 84
+def share
+        @project = Project.find(params[:id])
+        if !user_signed_in? then
+       respond_to do |format|
+                        format.html { redirect_to edit_user_registration_path }
+                end
+        elsif !@project.editable_by(current_user.id) then
+                respond_to do |format|
+                        format.html { redirect_to projects_url, notice: "This account does not have access to that plan." }
+                end
+        end
+end
+
+ +
+ + + + +
+ + +
+ +
+ show() + click to toggle source +
+ + +
+ +

GET /projects/1 GET /projects/1.json

+ + + +
+
# File app/controllers/projects_controller.rb, line 28
+def show
+        @project = Project.find(params[:id])
+        @show_form = false
+        if params[:show_form] == "yes" then
+                @show_form = true
+        end
+        if user_signed_in? && @project.readable_by(current_user.id) then
+                respond_to do |format|
+                        format.html # show.html.erb
+
+                        format.json { render json: @project }
+                end
+        elsif user_signed_in? then
+                respond_to do |format|
+                        format.html { redirect_to projects_url, notice: "This account does not have access to that plan." }
+                end
+        else
+                respond_to do |format|
+                        format.html { redirect_to edit_user_registration_path }
+                end
+        end
+end
+
+ +
+ + + + +
+ + +
+ +
+ update() + click to toggle source +
+ + +
+ +

PUT /projects/1 PUT /projects/1.json

+ + + +
+
# File app/controllers/projects_controller.rb, line 147
+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: 'Project was successfully updated.' }
+                                format.json { head :no_content }
+                        else
+                                format.html { render action: "edit" }
+                                format.json { render json: @project.errors, status: :unprocessable_entity }
+                        end
+                end
+        else
+                render(:file => File.join(Rails.root, 'public/403.html'), :status => 403, :layout => false)
+        end
+end
+
+ +
+ + + + +
+ + +
+ +
+

Private Instance Methods

+ + +
+ +
+ orgs_of_type(org_type_name, published_templates = false) + click to toggle source +
+ + +
+ + + + + +
+
# File app/controllers/projects_controller.rb, line 271
+def orgs_of_type(org_type_name, published_templates = false)
+        org_type = OrganisationType.find_by_name(org_type_name)
+        all_such_orgs = org_type.organisations
+        if published_templates then
+                with_published = Array.new
+                all_such_orgs.each do |o|
+                        if o.published_templates.count > 0 then
+                                with_published << o
+                        end
+                end
+                return with_published.sort_by {|o| [o.sort_name, o.name] }
+        else
+                return all_such_orgs.sort_by {|o| [o.sort_name, o.name] }
+        end
+end
+
+ +
+ + + + +
+ + +
+ +
+ +
+ + + + diff --git a/public/html/Question.html b/public/html/Question.html new file mode 100644 index 0000000..a45775f --- /dev/null +++ b/public/html/Question.html @@ -0,0 +1,470 @@ + + + + + + +class Question - DMPonline4 Documentation + + + + + + + + + + + + + + + + +
+

class Question

+ +
+ +
+ + + + +
+ + + + + + + + + + +
+

Public Instance Methods

+ + +
+ +
+ get_suggested_answer(org_id) + click to toggle source +
+ + +
+ +

get suggested answer belonging to the currents user for this question

+ + + +
+
# File app/models/question.rb, line 99
+def get_suggested_answer(org_id)
+        suggested_answer = suggested_answers.find_by_organisation_id(org_id)
+        return suggested_answer
+end
+
+ +
+ + + + +
+ + +
+ +
+ guidance_for_question(question, org_admin) + click to toggle source +
+ + +
+ +

guidance for question in the org admin

+ + + +
+
# File app/models/question.rb, line 69
+def guidance_for_question(question, org_admin)
+# pulls together guidance from various sources for question
+
+guidances = {}
+theme_ids = question.theme_ids
+
+GuidanceGroup.where("organisation_id = ?", org_admin.id).each do |group|
+    group.guidances.each do |g|
+        g.themes.where("id IN (?)", theme_ids).each do |gg|
+           guidances["#{group.name} guidance on #{gg.title}"] = g
+        end
+    end
+end
+
+       # Guidance link to directly to a question
+
+question.guidances.each do |g_by_q|
+    g_by_q.guidance_groups.each do |group|
+        if group.organisation == org_admin
+            guidances["#{group.name} guidance for this question"] = g_by_q
+        end
+    end
+       end
+
+        return guidances
+end
+
+ +
+ + + + +
+ + +
+ +
+ question_themes?() + click to toggle source +
+ + +
+ +

def question_type?

+ +
type_label = {}
+if self.is_text_field?
+  type_label = 'Text field'
+elsif self.multiple_choice?
+        type_label = 'Multiple choice'
+else
+        type_label = 'Text area'
+end
+return type_label
+ +

end

+ + + +
+
# File app/models/question.rb, line 51
+def question_themes?
+        themes_label = {}
+        i = 1
+        themes_quest = self.themes
+
+        themes_quest.each do |tt|
+                themes_label = tt.title
+
+                if themes_quest.count > i then
+                        themes_label +=     ','
+                        i +=1
+                end
+        end
+
+        return themes_label
+end
+
+ +
+ + + + +
+ + +
+ +
+ to_s() + click to toggle source +
+ + +
+ + + + + +
+
# File app/models/question.rb, line 29
+    def to_s
+    "#{text}"
+end
+
+ +
+ + + + +
+ + +
+ +
+ +
+ + + + diff --git a/public/html/QuestionFormat.html b/public/html/QuestionFormat.html new file mode 100644 index 0000000..7d098d1 --- /dev/null +++ b/public/html/QuestionFormat.html @@ -0,0 +1,325 @@ + + + + + + +class QuestionFormat - DMPonline4 Documentation + + + + + + + + + + + + + + + + +
+

class QuestionFormat

+ +
+ +
+ + + + +
+ + + + + + + + + + +
+

Public Instance Methods

+ + +
+ +
+ to_s() + click to toggle source +
+ + +
+ + + + + +
+
# File app/models/question_format.rb, line 7
+ def to_s
+  "#{title}"
+end
+
+ +
+ + + + +
+ + +
+ +
+ +
+ + + + diff --git a/public/html/README_rdoc.html b/public/html/README_rdoc.html new file mode 100644 index 0000000..1100184 --- /dev/null +++ b/public/html/README_rdoc.html @@ -0,0 +1,311 @@ + + + + + + +README - DMPonline4 Documentation + + + + + + + + + + + + + + + + +
+ +

DMPonline v4

+ +

DMPonline is the DCC's data management planning tool, available at dmponline.dcc.ac.uk

+ +

Development of the DMPonline by the Digital Curation Centre has been funded +by JISC. JISC inspires UK colleges and universities in the innovative use +of digital technologies, helping to maintain the UK's position as a +global leader in education. www.jisc.ac.uk

+ +

This is just the application code, the accompanying question data available +at dmponline.dcc.ac.uk is not +included.

+ +

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.

    +
+ +

Documentation & Support

+ + +

Bugs & Feature Requests

+ + +

Prerequisites

+ +

DMPonline is a Ruby on Rails application and you will need to have Ruby +2.0.0p247 or greater installed on your server and a MySQL server v5.0 or +greater.

+ +

Further details on how to install Ruby on Rails applications are available +from the Ruby on Rails site, rubyonrails.org

+ +

You may also find the following resources handy:

+ + + + +

Copyright © 2013 Digital Curation Centre, University of Edinburgh.

+ +

This program is free software: you can redistribute it and/or modify it +under the terms of the GNU Affero General Public License as published by +the Free Software Foundation, either version 3 of the License, or (at your +option) any later version.

+ +

This program is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License +for more details.

+ +

You should have received a copy of the GNU Affero General Public License +along with this program. If not, see www.gnu.org/licenses.

+ +
+ + + + + diff --git a/public/html/RegistrationsController.html b/public/html/RegistrationsController.html new file mode 100644 index 0000000..c12611d --- /dev/null +++ b/public/html/RegistrationsController.html @@ -0,0 +1,506 @@ + + + + + + +class RegistrationsController - DMPonline4 Documentation + + + + + + + + + + + + + + + + +
+

class RegistrationsController

+ +
+ +

app/controllers/registrations_controller.rb

+ +
+ + + + +
+ + + + + + + + + + +
+

Public Instance Methods

+ + +
+ +
+ create() + click to toggle source +
+ + +
+ +

POST /resource

+ + + +
+
# File app/controllers/registrations_controller.rb, line 6
+def create
+      if sign_up_params[:accept_terms] != "1" then
+        redirect_to after_sign_up_error_path_for(resource), alert: 'You must accept the terms and conditions to register.'
+      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
+                              @user = existing_user
+                              do_update(false, true)
+                      else
+                          redirect_to after_sign_up_error_path_for(resource), alert: 'That email address is already registered.'
+                      end
+              else
+                      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)
+                        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)
+                        end
+                      else
+                        clean_up_passwords resource
+                        redirect_to after_sign_up_error_path_for(resource), alert: 'Error processing registration. Please check that you have entered a valid email address and that your chosen password is at least 8 characters long.'
+                      end
+              end
+  end
+end
+
+ +
+ + + + +
+ + +
+ +
+ update() + click to toggle source +
+ + +
+ + + + + +
+
# File app/controllers/registrations_controller.rb, line 39
+def update
+       if user_signed_in? then
+               @user = User.find(current_user.id)
+
+       do_update
+   else
+       render(:file => File.join(Rails.root, 'public/403.html'), :status => 403, :layout => false)
+   end
+ end
+
+ +
+ + + + +
+ + +
+ +
+

Private Instance Methods

+ + +
+ +
+ do_update(require_password = true, confirm = false) + click to toggle source +
+ + +
+ + + + + +
+
# File app/controllers/registrations_controller.rb, line 59
+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])
+    else
+      # remove the virtual current_password attribute update_without_password
+
+      # doesn't know how to ignore it
+
+      params[:user].delete(:current_password)
+      @user.update_without_password(params[:user])
+    end
+  else
+      @user.update_attributes(:password => params[:user][:password], :password_confirmation => params[:user][:password_confirmation])
+      successfully_updated = @user.update_without_password(params[:user])
+  end
+
+  #unlink shibboleth from user's details
+
+  if params[:unlink_flag] == 'true' then
+    @user.update_attributes(:shibboleth_id => "")
+  end
+
+  if successfully_updated
+              if confirm then
+                      @user.skip_confirmation!
+                      @user.save!
+              end
+      set_flash_message :notice, :updated
+      # Sign in the user bypassing validation in case his password changed
+
+      sign_in @user, :bypass => true
+      
+      if params[:unlink_flag] == 'true' then
+          redirect_to({:controller => "registrations", :action => "edit"}, {:notice => "Details successfully updated."})
+      else
+          redirect_to({:controller => "projects", :action => "index"}, {:notice => "Details successfully updated."})
+      end
+
+  else
+    render "edit"
+  end
+end
+
+ +
+ + + + +
+ + +
+ +
+ needs_password?(user, params) + click to toggle source +
+ + +
+ +

check if we need password to update user data ie if password or email was +changed extend this as needed

+ + + +
+
# File app/controllers/registrations_controller.rb, line 54
+def needs_password?(user, params)
+  user.email != params[:user][:email] ||
+    params[:user][:password].present?
+end
+
+ +
+ + + + +
+ + +
+ +
+ +
+ + + + diff --git a/public/html/Role.html b/public/html/Role.html new file mode 100644 index 0000000..02d87ea --- /dev/null +++ b/public/html/Role.html @@ -0,0 +1,279 @@ + + + + + + +class Role - DMPonline4 Documentation + + + + + + + + + + + + + + + + +
+

class Role

+ +
+ +
+ + + + +
+ + + + + + + + + + +
+ +
+ + + + diff --git a/public/html/Section.html b/public/html/Section.html new file mode 100644 index 0000000..2ad9bcb --- /dev/null +++ b/public/html/Section.html @@ -0,0 +1,325 @@ + + + + + + +class Section - DMPonline4 Documentation + + + + + + + + + + + + + + + + +
+

class Section

+ +
+ +
+ + + + +
+ + + + + + + + + + +
+

Public Instance Methods

+ + +
+ +
+ to_s() + click to toggle source +
+ + +
+ + + + + +
+
# File app/models/section.rb, line 15
+def to_s
+  "#{title}"
+end
+
+ +
+ + + + +
+ + +
+ +
+ +
+ + + + diff --git a/public/html/SessionsController.html b/public/html/SessionsController.html new file mode 100644 index 0000000..163a22b --- /dev/null +++ b/public/html/SessionsController.html @@ -0,0 +1,375 @@ + + + + + + +class SessionsController - DMPonline4 Documentation + + + + + + + + + + + + + + + + +
+

class SessionsController

+ +
+ +

app/controllers/sessions_controller.rb

+ +
+ + + + +
+ + + + + + + + + + +
+

Public Instance Methods

+ + +
+ +
+ create() + click to toggle source +
+ + +
+ + + + + +
+
# File app/controllers/sessions_controller.rb, line 4
+def create
+        existing_user = User.find_by_email(params[:user][:email])
+
+if !existing_user.nil? && existing_user.dmponline3 && (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
+
+ +
+ + + + +
+ + +
+ +
+ destroy() + click to toggle source +
+ + +
+ + + + + +
+
# File app/controllers/sessions_controller.rb, line 19
+    def destroy
+    current_user.plan_sections.each do |lock|
+        lock.delete
+        
+    end
+    super
+end
+
+ +
+ + + + +
+ + +
+ +
+ +
+ + + + diff --git a/public/html/Settings.html b/public/html/Settings.html new file mode 100644 index 0000000..3cfcfa5 --- /dev/null +++ b/public/html/Settings.html @@ -0,0 +1,277 @@ + + + + + + +module Settings - DMPonline4 Documentation + + + + + + + + + + + + + + + + +
+

module Settings

+ +
+ +
+ + + + +
+ + + + + + + + + + +
+ +
+ + + + diff --git a/public/html/Settings/Dmptemplate.html b/public/html/Settings/Dmptemplate.html new file mode 100644 index 0000000..ed8991b --- /dev/null +++ b/public/html/Settings/Dmptemplate.html @@ -0,0 +1,312 @@ + + + + + + +class Settings::Dmptemplate - DMPonline4 Documentation + + + + + + + + + + + + + + + + +
+

class Settings::Dmptemplate

+ +
+ +
+ + + + +
+ + + + + + +
+

Constants

+
+ +
DEFAULT_SETTINGS + +
+ + +
VALID_ADMIN_FIELDS + +
+ + +
VALID_FONT_FACES + +
+ + +
VALID_FONT_SIZE_RANGE + +
+ + +
VALID_MARGIN_RANGE + +
+ + +
+
+ + + + + + +
+ +
+ + + + diff --git a/public/html/Settings/PlanList.html b/public/html/Settings/PlanList.html new file mode 100644 index 0000000..d213468 --- /dev/null +++ b/public/html/Settings/PlanList.html @@ -0,0 +1,297 @@ + + + + + + +class Settings::PlanList - DMPonline4 Documentation + + + + + + + + + + + + + + + + +
+

class Settings::PlanList

+ +
+ +
+ + + + +
+ + + + + + +
+

Constants

+
+ +
ALL_COLUMNS + +
+ + +
DEFAULT_COLUMNS + +

TODO: can these be taken from somewhere else rather than hard-coded here?

+ + +
+
+ + + + + + +
+ +
+ + + + diff --git a/public/html/Settings/PlansController.html b/public/html/Settings/PlansController.html new file mode 100644 index 0000000..25d458b --- /dev/null +++ b/public/html/Settings/PlansController.html @@ -0,0 +1,486 @@ + + + + + + +class Settings::PlansController - DMPonline4 Documentation + + + + + + + + + + + + + + + + +
+

class Settings::PlansController

+ +
+ +
+ + + + +
+ + + + + + + + + + +
+

Public Instance Methods

+ + +
+ +
+ show() + click to toggle source +
+ + +
+ + + + + +
+
# File app/controllers/settings/plans_controller.rb, line 6
+def show
+  respond_to do |format|
+    format.html
+    format.partial
+    format.json { render json: settings_json }
+  end
+end
+
+ +
+ + + + +
+ + +
+ +
+ update() + click to toggle source +
+ + +
+ + + + + +
+
# File app/controllers/settings/plans_controller.rb, line 14
+def update
+
+  export_params = params[:export].try(:deep_symbolize_keys)
+
+  settings = plan.super_settings(:export).tap do |s|
+    if params[:commit] == 'Reset'
+      s.formatting = nil
+      s.fields = nil
+    else
+      s.formatting = export_params[:formatting]
+      s.fields = export_params[:fields]
+      s.title  = export_params[:title]
+    end
+  end
+
+  if settings.save
+    respond_to do |format|
+      format.html { redirect_to(export_project_path(plan.project)) }
+      format.json { render json: settings_json }
+    end
+  else
+    settings.formatting = nil
+    @export_settings = settings
+    render(action: :show)
+  end
+end
+
+ +
+ + + + +
+ + +
+ +
+

Private Instance Methods

+ + +
+ +
+ get_settings() + click to toggle source +
+ + +
+ + + + + +
+
# File app/controllers/settings/plans_controller.rb, line 43
+def get_settings
+  @export_settings = plan.settings(:export)
+end
+
+ +
+ + + + +
+ + +
+ +
+ plan() + click to toggle source +
+ + +
+ + + + + +
+
# File app/controllers/settings/plans_controller.rb, line 51
+def plan
+  @plan ||= Plan.find(params[:id])
+end
+
+ +
+ + + + +
+ + +
+ +
+ settings_json() + click to toggle source +
+ + +
+ + + + + +
+
# File app/controllers/settings/plans_controller.rb, line 47
+def settings_json
+  @settings_json ||= { export: @export_settings }.to_json
+end
+
+ +
+ + + + +
+ + +
+ +
+ +
+ + + + diff --git a/public/html/Settings/ProjectsController.html b/public/html/Settings/ProjectsController.html new file mode 100644 index 0000000..aa17b2f --- /dev/null +++ b/public/html/Settings/ProjectsController.html @@ -0,0 +1,445 @@ + + + + + + +class Settings::ProjectsController - DMPonline4 Documentation + + + + + + + + + + + + + + + + +
+

class Settings::ProjectsController

+ +
+ +
+ + + + +
+ + + + + + + + + + +
+

Public Instance Methods

+ + +
+ +
+ show() + click to toggle source +
+ + +
+ + + + + +
+
# File app/controllers/settings/projects_controller.rb, line 7
+def show
+  respond_to do |format|
+    format.html
+    format.json { render json: settings_json }
+  end
+end
+
+ +
+ + + + +
+ + +
+ +
+ update() + click to toggle source +
+ + +
+ + + + + +
+
# File app/controllers/settings/projects_controller.rb, line 14
+def update
+  columns = (params[:columns] || {}).keys.map(&:intern)
+
+  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
+
+  end
+end
+
+ +
+ + + + +
+ + +
+ +
+

Private Instance Methods

+ + +
+ +
+ get_settings() + click to toggle source +
+ + +
+ + + + + +
+
# File app/controllers/settings/projects_controller.rb, line 29
+def get_settings
+  @settings = current_user.settings(:plan_list)
+  # :name column should always be present (displayed as a disabled checkbox)
+
+  # so it's not necessary to include it in the list here
+
+  @all_columns -= [:name]
+end
+
+ +
+ + + + +
+ + +
+ +
+ settings_json() + click to toggle source +
+ + +
+ + + + + +
+
# File app/controllers/settings/projects_controller.rb, line 36
+def settings_json
+  @settings_json ||= { selected_columns: @settings.columns, all_columns: @all_columns }.to_json
+end
+
+ +
+ + + + +
+ + +
+ +
+ +
+ + + + diff --git a/public/html/Settings/SettingsController.html b/public/html/Settings/SettingsController.html new file mode 100644 index 0000000..6273362 --- /dev/null +++ b/public/html/Settings/SettingsController.html @@ -0,0 +1,279 @@ + + + + + + +class Settings::SettingsController - DMPonline4 Documentation + + + + + + + + + + + + + + + + +
+

class Settings::SettingsController

+ +
+ +
+ + + + +
+ + + + + + + + + + +
+ +
+ + + + diff --git a/public/html/SplashLog.html b/public/html/SplashLog.html new file mode 100644 index 0000000..41ac7d7 --- /dev/null +++ b/public/html/SplashLog.html @@ -0,0 +1,279 @@ + + + + + + +class SplashLog - DMPonline4 Documentation + + + + + + + + + + + + + + + + +
+

class SplashLog

+ +
+ +
+ + + + +
+ + + + + + + + + + +
+ +
+ + + + diff --git a/public/html/SplashLogsController.html b/public/html/SplashLogsController.html new file mode 100644 index 0000000..b00abb8 --- /dev/null +++ b/public/html/SplashLogsController.html @@ -0,0 +1,337 @@ + + + + + + +class SplashLogsController - DMPonline4 Documentation + + + + + + + + + + + + + + + + +
+

class SplashLogsController

+ +
+ +
+ + + + +
+ + + + + + + + + + +
+

Public Instance Methods

+ + +
+ +
+ create() + click to toggle source +
+ + +
+ +

POST /answers POST /answers.json

+ + + +
+
# File app/controllers/splash_logs_controller.rb, line 5
+def create
+        @splash_log = SplashLog.new()
+        @splash_log.destination = params[:destination]
+        respond_to do |format|
+                if @splash_log.save
+                        cookies[:dmp_splash_seen] = {
+                                value: 'splash_dialog_seen',
+                                expires: 3.hours.from_now,
+                        }
+                        format.html { redirect_to params[:destination] }
+                else
+                        format.html { redirect_to home_url }
+                end
+        end
+end
+
+ +
+ + + + +
+ + +
+ +
+ +
+ + + + diff --git a/public/html/StaticPagesController.html b/public/html/StaticPagesController.html new file mode 100644 index 0000000..65858ab --- /dev/null +++ b/public/html/StaticPagesController.html @@ -0,0 +1,392 @@ + + + + + + +class StaticPagesController - DMPonline4 Documentation + + + + + + + + + + + + + + + + +
+

class StaticPagesController

+ +
+ +
+ + + + +
+ + + + + + + + + + +
+

Public Instance Methods

+ + +
+ +
+ about_us() + click to toggle source +
+ + +
+ + + + + +
+
# File app/controllers/static_pages_controller.rb, line 3
+def about_us
+    dcc_news_feed_url = "http://www.dcc.ac.uk/news/dmponline-0/feed"
+      @dcc_news_feed = Feedzirra::Feed.fetch_and_parse(dcc_news_feed_url)
+      respond_to do |format|
+          format.rss { redirect_to dcc_news_feed_url }
+          format.html
+      end
+end
+
+ +
+ + + + +
+ + +
+ +
+ contact_us() + click to toggle source +
+ + +
+ + + + + +
+
# File app/controllers/static_pages_controller.rb, line 12
+def contact_us
+end
+
+ +
+ + + + +
+ + +
+ +
+ roadmap() + click to toggle source +
+ + +
+ + + + + +
+
# File app/controllers/static_pages_controller.rb, line 15
+def roadmap
+end
+
+ +
+ + + + +
+ + +
+ +
+ +
+ + + + diff --git a/public/html/SuggestedAnswer.html b/public/html/SuggestedAnswer.html new file mode 100644 index 0000000..707f287 --- /dev/null +++ b/public/html/SuggestedAnswer.html @@ -0,0 +1,325 @@ + + + + + + +class SuggestedAnswer - DMPonline4 Documentation + + + + + + + + + + + + + + + + +
+

class SuggestedAnswer

+ +
+ +
+ + + + +
+ + + + + + + + + + +
+

Public Instance Methods

+ + +
+ +
+ to_s() + click to toggle source +
+ + +
+ + + + + +
+
# File app/models/suggested_answer.rb, line 11
+      def to_s
+  "#{text}"
+end
+
+ +
+ + + + +
+ + +
+ +
+ +
+ + + + diff --git a/public/html/Theme.html b/public/html/Theme.html new file mode 100644 index 0000000..5cb3a3a --- /dev/null +++ b/public/html/Theme.html @@ -0,0 +1,325 @@ + + + + + + +class Theme - DMPonline4 Documentation + + + + + + + + + + + + + + + + +
+

class Theme

+ +
+ +
+ + + + +
+ + + + + + + + + + +
+

Public Instance Methods

+ + +
+ +
+ to_s() + click to toggle source +
+ + +
+ + + + + +
+
# File app/models/theme.rb, line 15
+def to_s
+      title
+end
+
+ +
+ + + + +
+ + +
+ +
+ +
+ + + + diff --git a/public/html/ThemesController.html b/public/html/ThemesController.html new file mode 100644 index 0000000..425e06a --- /dev/null +++ b/public/html/ThemesController.html @@ -0,0 +1,561 @@ + + + + + + +class ThemesController - DMPonline4 Documentation + + + + + + + + + + + + + + + + +
+

class ThemesController

+ +
+ +
+ + + + +
+ + + + + + + + + + +
+

Public Instance Methods

+ + +
+ +
+ create() + click to toggle source +
+ + +
+ +

POST /themes POST /themes.json

+ + + +
+
# File app/controllers/themes_controller.rb, line 42
+def create
+  @theme = Theme.new(params[:theme])
+
+  respond_to do |format|
+    if @theme.save
+      format.html { redirect_to @theme, notice: 'Theme was successfully created.' }
+      format.json { render json: @theme, status: :created, location: @theme }
+    else
+      format.html { render action: "new" }
+      format.json { render json: @theme.errors, status: :unprocessable_entity }
+    end
+  end
+end
+
+ +
+ + + + +
+ + +
+ +
+ destroy() + click to toggle source +
+ + +
+ +

DELETE /themes/1 DELETE /themes/1.json

+ + + +
+
# File app/controllers/themes_controller.rb, line 74
+def destroy
+  @theme = Theme.find(params[:id])
+  @theme.destroy
+
+  respond_to do |format|
+    format.html { redirect_to themes_url }
+    format.json { head :no_content }
+  end
+end
+
+ +
+ + + + +
+ + +
+ +
+ edit() + click to toggle source +
+ + +
+ +

GET /themes/1/edit

+ + + +
+
# File app/controllers/themes_controller.rb, line 36
+def edit
+  @theme = Theme.find(params[:id])
+end
+
+ +
+ + + + +
+ + +
+ +
+ index() + click to toggle source +
+ + +
+ +

GET /themes GET /themes.json

+ + + +
+
# File app/controllers/themes_controller.rb, line 4
+def index
+  @themes = Theme.all
+
+  respond_to do |format|
+    format.html # index.html.erb
+
+    format.json { render json: @themes }
+  end
+end
+
+ +
+ + + + +
+ + +
+ +
+ new() + click to toggle source +
+ + +
+ +

GET /themes/new GET /themes/new.json

+ + + +
+
# File app/controllers/themes_controller.rb, line 26
+def new
+  @theme = Theme.new
+
+  respond_to do |format|
+    format.html # new.html.erb
+
+    format.json { render json: @theme }
+  end
+end
+
+ +
+ + + + +
+ + +
+ +
+ show() + click to toggle source +
+ + +
+ +

GET /themes/1 GET /themes/1.json

+ + + +
+
# File app/controllers/themes_controller.rb, line 15
+def show
+  @theme = Theme.find(params[:id])
+
+  respond_to do |format|
+    format.html # show.html.erb
+
+    format.json { render json: @theme }
+  end
+end
+
+ +
+ + + + +
+ + +
+ +
+ update() + click to toggle source +
+ + +
+ +

PUT /themes/1 PUT /themes/1.json

+ + + +
+
# File app/controllers/themes_controller.rb, line 58
+def update
+  @theme = Theme.find(params[:id])
+
+  respond_to do |format|
+    if @theme.update_attributes(params[:theme])
+      format.html { redirect_to @theme, notice: 'Theme was successfully updated.' }
+      format.json { head :no_content }
+    else
+      format.html { render action: "edit" }
+      format.json { render json: @theme.errors, status: :unprocessable_entity }
+    end
+  end
+end
+
+ +
+ + + + +
+ + +
+ +
+ +
+ + + + diff --git a/public/html/User.html b/public/html/User.html new file mode 100644 index 0000000..a2e0c45 --- /dev/null +++ b/public/html/User.html @@ -0,0 +1,661 @@ + + + + + + +class User - DMPonline4 Documentation + + + + + + + + + + + + + + + + +
+

class User

+ +
+ +
+ + + + +
+ + + + + + + + + + +
+

Public Instance Methods

+ + +
+ +
+ current_organisation() + click to toggle source +
+ + +
+ + + + + +
+
# File app/models/user.rb, line 98
+def current_organisation
+        if self.organisations.count > 0 then
+                return self.organisations.last
+        else
+                return nil
+        end
+end
+
+ +
+ + + + +
+ + +
+ +
+ filter(query) + click to toggle source +
+ + +
+ + + + + +
+
# File app/models/user.rb, line 19
+def filter(query)
+  return self unless query.present?
+
+  t = self.arel_table
+  q = "%#{query}%"
+
+  conditions = t[:title].matches(q)
+
+  columns = %(
+    grant_number identifier description principal_investigator data_contact
+  )
+
+  columns.each {|col| conditions = conditions.or(t[col].matches(q)) }
+
+  self.where(conditions)
+end
+
+ +
+ + + + +
+ + +
+ +
+ can_super_admin?() + click to toggle source +
+ + +
+ + + + + +
+
# File app/models/user.rb, line 110
+def can_super_admin?
+        admin = roles.find_by_name("admin")
+        return !admin.nil?
+end
+
+ +
+ + + + +
+ + +
+ +
+ can_org_admin?() + click to toggle source +
+ + +
+ + + + + +
+
# File app/models/user.rb, line 115
+def can_org_admin?
+        org_admin = roles.find_by_name("org_admin")
+        return !org_admin.nil?
+end
+
+ +
+ + + + +
+ + +
+ +
+ name(use_email = true) + click to toggle source +
+ + +
+ + + + + +
+
# File app/models/user.rb, line 54
+def name(use_email = true)
+        if ((firstname.nil? && surname.nil?) || (firstname.strip == "" && surname.strip == "")) && use_email then
+                return email
+        else
+                name = "#{firstname} #{surname}"
+                return name.strip
+        end
+end
+
+ +
+ + + + +
+ + +
+ +
+ org_type() + click to toggle source +
+ + +
+ + + + + +
+
# File app/models/user.rb, line 120
+def org_type
+    org_type = organisation.organisation_type.name
+            return org_type
+end
+
+ +
+ + + + +
+ + +
+ +
+ organisation() + click to toggle source +
+ + +
+ + + + + +
+
# File app/models/user.rb, line 90
+def organisation
+        if self.organisations.count > 0 then
+                return self.organisations.first
+        else
+                return nil
+        end
+end
+
+ +
+ + + + +
+ + +
+ +
+ organisation=(new_organisation) + click to toggle source +
+ + +
+ + + + + +
+
# File app/models/user.rb, line 106
+def organisation=(new_organisation)
+        organisation_id = organisation.id
+end
+
+ +
+ + + + +
+ + +
+ +
+ organisation_id() + click to toggle source +
+ + +
+ + + + + +
+
# File app/models/user.rb, line 82
+def organisation_id
+        if self.organisations.count > 0 then
+                return self.organisations.first.id
+        else
+                return nil
+        end
+end
+
+ +
+ + + + +
+ + +
+ +
+ organisation_id=(new_organisation_id) + click to toggle source +
+ + +
+ + + + + +
+
# File app/models/user.rb, line 63
+    def organisation_id=(new_organisation_id)
+if !self.user_org_roles.pluck(:organisation_id).include?(new_organisation_id.to_i) then
+            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("user");
+                    self.user_org_roles << new_user_org_role
+            else
+                    user_org_role = self.user_org_roles.first
+                    user_org_role.organisation_id = new_organisation_id
+        user_org_role.save
+                    org_admin_role = roles.find_by_name("org_admin")
+                    unless org_admin_role.nil? then
+                            roles.delete(org_admin_role)
+                    end
+            end
+end
+    end
+
+ +
+ + + + +
+ + +
+ +
+ +
+ + + + diff --git a/public/html/UserMailer.html b/public/html/UserMailer.html new file mode 100644 index 0000000..9a51758 --- /dev/null +++ b/public/html/UserMailer.html @@ -0,0 +1,393 @@ + + + + + + +class UserMailer - DMPonline4 Documentation + + + + + + + + + + + + + + + + +
+

class UserMailer

+ +
+ +
+ + + + +
+ + + + + + + + + + +
+

Public Instance Methods

+ + +
+ +
+ permissions_change_notification(project_group) + click to toggle source +
+ + +
+ + + + + +
+
# File app/mailers/user_mailer.rb, line 9
+def permissions_change_notification(project_group)
+        @project_group = project_group
+        mail(to: @project_group.user.email, subject: "DMP permissions changed")
+end
+
+ +
+ + + + +
+ + +
+ +
+ project_access_removed_notification(user, project) + click to toggle source +
+ + +
+ + + + + +
+
# File app/mailers/user_mailer.rb, line 14
+def project_access_removed_notification(user, project)
+        @user = user
+        @project = project
+        mail(to: @user.email, subject: "DMP access removed")
+end
+
+ +
+ + + + +
+ + +
+ +
+ sharing_notification(project_group) + click to toggle source +
+ + +
+ + + + + +
+
# File app/mailers/user_mailer.rb, line 4
+def sharing_notification(project_group)
+        @project_group = project_group
+        mail(to: @project_group.user.email, subject: "You have been given access to a Data Management Plan")
+end
+
+ +
+ + + + +
+ + +
+ +
+ +
+ + + + diff --git a/public/html/UserOrgRole.html b/public/html/UserOrgRole.html new file mode 100644 index 0000000..6ec474a --- /dev/null +++ b/public/html/UserOrgRole.html @@ -0,0 +1,279 @@ + + + + + + +class UserOrgRole - DMPonline4 Documentation + + + + + + + + + + + + + + + + +
+

class UserOrgRole

+ +
+ +
+ + + + +
+ + + + + + + + + + +
+ +
+ + + + diff --git a/public/html/UserOrgRolesController.html b/public/html/UserOrgRolesController.html new file mode 100644 index 0000000..6612d49 --- /dev/null +++ b/public/html/UserOrgRolesController.html @@ -0,0 +1,561 @@ + + + + + + +class UserOrgRolesController - DMPonline4 Documentation + + + + + + + + + + + + + + + + +
+

class UserOrgRolesController

+ +
+ +
+ + + + +
+ + + + + + + + + + +
+

Public Instance Methods

+ + +
+ +
+ create() + click to toggle source +
+ + +
+ +

POST /user_org_roles POST /user_org_roles.json

+ + + +
+
# File app/controllers/user_org_roles_controller.rb, line 42
+def create
+  @user_org_role = UserOrgRole.new(params[:user_org_role])
+
+  respond_to do |format|
+    if @user_org_role.save
+      format.html { redirect_to @user_org_role, notice: 'User org role was successfully created.' }
+      format.json { render json: @user_org_role, status: :created, location: @user_org_role }
+    else
+      format.html { render action: "new" }
+      format.json { render json: @user_org_role.errors, status: :unprocessable_entity }
+    end
+  end
+end
+
+ +
+ + + + +
+ + +
+ +
+ destroy() + click to toggle source +
+ + +
+ +

DELETE /user_org_roles/1 DELETE /user_org_roles/1.json

+ + + +
+
# File app/controllers/user_org_roles_controller.rb, line 74
+def destroy
+  @user_org_role = UserOrgRole.find(params[:id])
+  @user_org_role.destroy
+
+  respond_to do |format|
+    format.html { redirect_to user_org_roles_url }
+    format.json { head :no_content }
+  end
+end
+
+ +
+ + + + +
+ + +
+ +
+ edit() + click to toggle source +
+ + +
+ +

GET /user_org_roles/1/edit

+ + + +
+
# File app/controllers/user_org_roles_controller.rb, line 36
+def edit
+  @user_org_role = UserOrgRole.find(params[:id])
+end
+
+ +
+ + + + +
+ + +
+ +
+ index() + click to toggle source +
+ + +
+ +

GET /user_org_roles GET /user_org_roles.json

+ + + +
+
# File app/controllers/user_org_roles_controller.rb, line 4
+def index
+  @user_org_roles = UserOrgRole.all
+
+  respond_to do |format|
+    format.html # index.html.erb
+
+    format.json { render json: @user_org_roles }
+  end
+end
+
+ +
+ + + + +
+ + +
+ +
+ new() + click to toggle source +
+ + +
+ +

GET /user_org_roles/new GET /user_org_roles/new.json

+ + + +
+
# File app/controllers/user_org_roles_controller.rb, line 26
+def new
+  @user_org_role = UserOrgRole.new
+
+  respond_to do |format|
+    format.html # new.html.erb
+
+    format.json { render json: @user_org_role }
+  end
+end
+
+ +
+ + + + +
+ + +
+ +
+ show() + click to toggle source +
+ + +
+ +

GET /user_org_roles/1 GET /user_org_roles/1.json

+ + + +
+
# File app/controllers/user_org_roles_controller.rb, line 15
+def show
+  @user_org_role = UserOrgRole.find(params[:id])
+
+  respond_to do |format|
+    format.html # show.html.erb
+
+    format.json { render json: @user_org_role }
+  end
+end
+
+ +
+ + + + +
+ + +
+ +
+ update() + click to toggle source +
+ + +
+ +

PUT /user_org_roles/1 PUT /user_org_roles/1.json

+ + + +
+
# File app/controllers/user_org_roles_controller.rb, line 58
+def update
+  @user_org_role = UserOrgRole.find(params[:id])
+
+  respond_to do |format|
+    if @user_org_role.update_attributes(params[:user_org_role])
+      format.html { redirect_to @user_org_role, notice: 'User org role was successfully updated.' }
+      format.json { head :no_content }
+    else
+      format.html { render action: "edit" }
+      format.json { render json: @user_org_role.errors, status: :unprocessable_entity }
+    end
+  end
+end
+
+ +
+ + + + +
+ + +
+ +
+ +
+ + + + diff --git a/public/html/UserRoleType.html b/public/html/UserRoleType.html new file mode 100644 index 0000000..1808bff --- /dev/null +++ b/public/html/UserRoleType.html @@ -0,0 +1,279 @@ + + + + + + +class UserRoleType - DMPonline4 Documentation + + + + + + + + + + + + + + + + +
+

class UserRoleType

+ +
+ +
+ + + + +
+ + + + + + + + + + +
+ +
+ + + + diff --git a/public/html/UserRoleTypesController.html b/public/html/UserRoleTypesController.html new file mode 100644 index 0000000..7ee343f --- /dev/null +++ b/public/html/UserRoleTypesController.html @@ -0,0 +1,561 @@ + + + + + + +class UserRoleTypesController - DMPonline4 Documentation + + + + + + + + + + + + + + + + +
+

class UserRoleTypesController

+ +
+ +
+ + + + +
+ + + + + + + + + + +
+

Public Instance Methods

+ + +
+ +
+ create() + click to toggle source +
+ + +
+ +

POST /user_role_types POST /user_role_types.json

+ + + +
+
# File app/controllers/user_role_types_controller.rb, line 42
+def create
+  @user_role_type = UserRoleType.new(params[:user_role_type])
+
+  respond_to do |format|
+    if @user_role_type.save
+      format.html { redirect_to @user_role_type, notice: 'User role type was successfully created.' }
+      format.json { render json: @user_role_type, status: :created, location: @user_role_type }
+    else
+      format.html { render action: "new" }
+      format.json { render json: @user_role_type.errors, status: :unprocessable_entity }
+    end
+  end
+end
+
+ +
+ + + + +
+ + +
+ +
+ destroy() + click to toggle source +
+ + +
+ +

DELETE /user_role_types/1 DELETE /user_role_types/1.json

+ + + +
+
# File app/controllers/user_role_types_controller.rb, line 74
+def destroy
+  @user_role_type = UserRoleType.find(params[:id])
+  @user_role_type.destroy
+
+  respond_to do |format|
+    format.html { redirect_to user_role_types_url }
+    format.json { head :no_content }
+  end
+end
+
+ +
+ + + + +
+ + +
+ +
+ edit() + click to toggle source +
+ + +
+ +

GET /user_role_types/1/edit

+ + + +
+
# File app/controllers/user_role_types_controller.rb, line 36
+def edit
+  @user_role_type = UserRoleType.find(params[:id])
+end
+
+ +
+ + + + +
+ + +
+ +
+ index() + click to toggle source +
+ + +
+ +

GET /user_role_types GET /user_role_types.json

+ + + +
+
# File app/controllers/user_role_types_controller.rb, line 4
+def index
+  @user_role_types = UserRoleType.all
+
+  respond_to do |format|
+    format.html # index.html.erb
+
+    format.json { render json: @user_role_types }
+  end
+end
+
+ +
+ + + + +
+ + +
+ +
+ new() + click to toggle source +
+ + +
+ +

GET /user_role_types/new GET /user_role_types/new.json

+ + + +
+
# File app/controllers/user_role_types_controller.rb, line 26
+def new
+  @user_role_type = UserRoleType.new
+
+  respond_to do |format|
+    format.html # new.html.erb
+
+    format.json { render json: @user_role_type }
+  end
+end
+
+ +
+ + + + +
+ + +
+ +
+ show() + click to toggle source +
+ + +
+ +

GET /user_role_types/1 GET /user_role_types/1.json

+ + + +
+
# File app/controllers/user_role_types_controller.rb, line 15
+def show
+  @user_role_type = UserRoleType.find(params[:id])
+
+  respond_to do |format|
+    format.html # show.html.erb
+
+    format.json { render json: @user_role_type }
+  end
+end
+
+ +
+ + + + +
+ + +
+ +
+ update() + click to toggle source +
+ + +
+ +

PUT /user_role_types/1 PUT /user_role_types/1.json

+ + + +
+
# File app/controllers/user_role_types_controller.rb, line 58
+def update
+  @user_role_type = UserRoleType.find(params[:id])
+
+  respond_to do |format|
+    if @user_role_type.update_attributes(params[:user_role_type])
+      format.html { redirect_to @user_role_type, notice: 'User role type was successfully updated.' }
+      format.json { head :no_content }
+    else
+      format.html { render action: "edit" }
+      format.json { render json: @user_role_type.errors, status: :unprocessable_entity }
+    end
+  end
+end
+
+ +
+ + + + +
+ + +
+ +
+ +
+ + + + diff --git a/public/html/UserStatus.html b/public/html/UserStatus.html new file mode 100644 index 0000000..ece7b89 --- /dev/null +++ b/public/html/UserStatus.html @@ -0,0 +1,279 @@ + + + + + + +class UserStatus - DMPonline4 Documentation + + + + + + + + + + + + + + + + +
+

class UserStatus

+ +
+ +
+ + + + +
+ + + + + + + + + + +
+ +
+ + + + diff --git a/public/html/UserStatusesController.html b/public/html/UserStatusesController.html new file mode 100644 index 0000000..e74b843 --- /dev/null +++ b/public/html/UserStatusesController.html @@ -0,0 +1,561 @@ + + + + + + +class UserStatusesController - DMPonline4 Documentation + + + + + + + + + + + + + + + + +
+

class UserStatusesController

+ +
+ +
+ + + + +
+ + + + + + + + + + +
+

Public Instance Methods

+ + +
+ +
+ create() + click to toggle source +
+ + +
+ +

POST /user_statuses POST /user_statuses.json

+ + + +
+
# File app/controllers/user_statuses_controller.rb, line 42
+def create
+  @user_status = UserStatus.new(params[:user_status])
+
+  respond_to do |format|
+    if @user_status.save
+      format.html { redirect_to @user_status, notice: 'User status was successfully created.' }
+      format.json { render json: @user_status, status: :created, location: @user_status }
+    else
+      format.html { render action: "new" }
+      format.json { render json: @user_status.errors, status: :unprocessable_entity }
+    end
+  end
+end
+
+ +
+ + + + +
+ + +
+ +
+ destroy() + click to toggle source +
+ + +
+ +

DELETE /user_statuses/1 DELETE /user_statuses/1.json

+ + + +
+
# File app/controllers/user_statuses_controller.rb, line 74
+def destroy
+  @user_status = UserStatus.find(params[:id])
+  @user_status.destroy
+
+  respond_to do |format|
+    format.html { redirect_to user_statuses_url }
+    format.json { head :no_content }
+  end
+end
+
+ +
+ + + + +
+ + +
+ +
+ edit() + click to toggle source +
+ + +
+ +

GET /user_statuses/1/edit

+ + + +
+
# File app/controllers/user_statuses_controller.rb, line 36
+def edit
+  @user_status = UserStatus.find(params[:id])
+end
+
+ +
+ + + + +
+ + +
+ +
+ index() + click to toggle source +
+ + +
+ +

GET /user_statuses GET /user_statuses.json

+ + + +
+
# File app/controllers/user_statuses_controller.rb, line 4
+def index
+  @user_statuses = UserStatus.all
+
+  respond_to do |format|
+    format.html # index.html.erb
+
+    format.json { render json: @user_statuses }
+  end
+end
+
+ +
+ + + + +
+ + +
+ +
+ new() + click to toggle source +
+ + +
+ +

GET /user_statuses/new GET /user_statuses/new.json

+ + + +
+
# File app/controllers/user_statuses_controller.rb, line 26
+def new
+  @user_status = UserStatus.new
+
+  respond_to do |format|
+    format.html # new.html.erb
+
+    format.json { render json: @user_status }
+  end
+end
+
+ +
+ + + + +
+ + +
+ +
+ show() + click to toggle source +
+ + +
+ +

GET /user_statuses/1 GET /user_statuses/1.json

+ + + +
+
# File app/controllers/user_statuses_controller.rb, line 15
+def show
+  @user_status = UserStatus.find(params[:id])
+
+  respond_to do |format|
+    format.html # show.html.erb
+
+    format.json { render json: @user_status }
+  end
+end
+
+ +
+ + + + +
+ + +
+ +
+ update() + click to toggle source +
+ + +
+ +

PUT /user_statuses/1 PUT /user_statuses/1.json

+ + + +
+
# File app/controllers/user_statuses_controller.rb, line 58
+def update
+  @user_status = UserStatus.find(params[:id])
+
+  respond_to do |format|
+    if @user_status.update_attributes(params[:user_status])
+      format.html { redirect_to @user_status, notice: 'User status was successfully updated.' }
+      format.json { head :no_content }
+    else
+      format.html { render action: "edit" }
+      format.json { render json: @user_status.errors, status: :unprocessable_entity }
+    end
+  end
+end
+
+ +
+ + + + +
+ + +
+ +
+ +
+ + + + diff --git a/public/html/UserType.html b/public/html/UserType.html new file mode 100644 index 0000000..f37778b --- /dev/null +++ b/public/html/UserType.html @@ -0,0 +1,279 @@ + + + + + + +class UserType - DMPonline4 Documentation + + + + + + + + + + + + + + + + +
+

class UserType

+ +
+ +
+ + + + +
+ + + + + + + + + + +
+ +
+ + + + diff --git a/public/html/UserTypesController.html b/public/html/UserTypesController.html new file mode 100644 index 0000000..7a53fd5 --- /dev/null +++ b/public/html/UserTypesController.html @@ -0,0 +1,561 @@ + + + + + + +class UserTypesController - DMPonline4 Documentation + + + + + + + + + + + + + + + + +
+

class UserTypesController

+ +
+ +
+ + + + +
+ + + + + + + + + + +
+

Public Instance Methods

+ + +
+ +
+ create() + click to toggle source +
+ + +
+ +

POST /user_types POST /user_types.json

+ + + +
+
# File app/controllers/user_types_controller.rb, line 42
+def create
+  @user_type = UserType.new(params[:user_type])
+
+  respond_to do |format|
+    if @user_type.save
+      format.html { redirect_to @user_type, notice: 'User type was successfully created.' }
+      format.json { render json: @user_type, status: :created, location: @user_type }
+    else
+      format.html { render action: "new" }
+      format.json { render json: @user_type.errors, status: :unprocessable_entity }
+    end
+  end
+end
+
+ +
+ + + + +
+ + +
+ +
+ destroy() + click to toggle source +
+ + +
+ +

DELETE /user_types/1 DELETE /user_types/1.json

+ + + +
+
# File app/controllers/user_types_controller.rb, line 74
+def destroy
+  @user_type = UserType.find(params[:id])
+  @user_type.destroy
+
+  respond_to do |format|
+    format.html { redirect_to user_types_url }
+    format.json { head :no_content }
+  end
+end
+
+ +
+ + + + +
+ + +
+ +
+ edit() + click to toggle source +
+ + +
+ +

GET /user_types/1/edit

+ + + +
+
# File app/controllers/user_types_controller.rb, line 36
+def edit
+  @user_type = UserType.find(params[:id])
+end
+
+ +
+ + + + +
+ + +
+ +
+ index() + click to toggle source +
+ + +
+ +

GET /user_types GET /user_types.json

+ + + +
+
# File app/controllers/user_types_controller.rb, line 4
+def index
+  @user_types = UserType.all
+
+  respond_to do |format|
+    format.html # index.html.erb
+
+    format.json { render json: @user_types }
+  end
+end
+
+ +
+ + + + +
+ + +
+ +
+ new() + click to toggle source +
+ + +
+ +

GET /user_types/new GET /user_types/new.json

+ + + +
+
# File app/controllers/user_types_controller.rb, line 26
+def new
+  @user_type = UserType.new
+
+  respond_to do |format|
+    format.html # new.html.erb
+
+    format.json { render json: @user_type }
+  end
+end
+
+ +
+ + + + +
+ + +
+ +
+ show() + click to toggle source +
+ + +
+ +

GET /user_types/1 GET /user_types/1.json

+ + + +
+
# File app/controllers/user_types_controller.rb, line 15
+def show
+  @user_type = UserType.find(params[:id])
+
+  respond_to do |format|
+    format.html # show.html.erb
+
+    format.json { render json: @user_type }
+  end
+end
+
+ +
+ + + + +
+ + +
+ +
+ update() + click to toggle source +
+ + +
+ +

PUT /user_types/1 PUT /user_types/1.json

+ + + +
+
# File app/controllers/user_types_controller.rb, line 58
+def update
+  @user_type = UserType.find(params[:id])
+
+  respond_to do |format|
+    if @user_type.update_attributes(params[:user_type])
+      format.html { redirect_to @user_type, notice: 'User type was successfully updated.' }
+      format.json { head :no_content }
+    else
+      format.html { render action: "edit" }
+      format.json { render json: @user_type.errors, status: :unprocessable_entity }
+    end
+  end
+end
+
+ +
+ + + + +
+ + +
+ +
+ +
+ + + + diff --git a/public/html/Users.html b/public/html/Users.html new file mode 100644 index 0000000..f059ad1 --- /dev/null +++ b/public/html/Users.html @@ -0,0 +1,272 @@ + + + + + + +module Users - DMPonline4 Documentation + + + + + + + + + + + + + + + + +
+

module Users

+ +
+ +
+ + + + +
+ + + + + + + + + + +
+ +
+ + + + diff --git a/public/html/Users/OmniauthCallbacksController.html b/public/html/Users/OmniauthCallbacksController.html new file mode 100644 index 0000000..ee178a1 --- /dev/null +++ b/public/html/Users/OmniauthCallbacksController.html @@ -0,0 +1,374 @@ + + + + + + +class Users::OmniauthCallbacksController - DMPonline4 Documentation + + + + + + + + + + + + + + + + +
+

class Users::OmniauthCallbacksController

+ +
+ +
+ + + + +
+ + + + + + + + + + +
+

Public Instance Methods

+ + +
+ +
+ shibboleth() + click to toggle source +
+ + +
+ + + + + +
+
# File app/controllers/users/omniauth_callback_controller.rb, line 3
+def shibboleth
+  if user_signed_in? && current_user.shibboleth_id.present? && current_user.shibboleth_id.length > 0 then
+    flash[:warning] = I18n.t('devise.failure.already_authenticated')
+    redirect_to root_path
+  else
+    auth = request.env['omniauth.auth'] || {}
+    eppn = auth['extra']['raw_info']['eppn']
+    uid = nil
+    if !eppn.blank? then
+      uid = eppn
+    elsif !auth['uid'].blank? then
+      uid = auth['uid']
+    elsif !auth['extra']['raw_info']['targeted-id'].blank? then
+      uid = auth['extra']['raw_info']['targeted-id']
+    end
+
+    if !uid.nil? && !uid.blank? then
+                              s_user = User.where(shibboleth_id: uid).first
+                              # Take out previous record if was not confirmed.
+
+                              if !s_user.nil? && s_user.confirmed_at.nil? then
+                                      sign_out s_user
+                                      User.delete(s_user.id)
+                                      s_user = nil
+                              end
+
+                              # Stops Shibboleth ID being blocked if email incorrectly entered.
+
+                              if !s_user.nil? && s_user.try(:persisted?) then
+                                      flash[:notice] = I18n.t('devise.omniauth_callbacks.success', :kind => 'Shibboleth')
+                                      sign_in s_user
+                  redirect_to root_path
+                              else
+                                      if user_signed_in? then
+                                              current_user.update_attribute('shibboleth_id', uid)
+                                              user_id = current_user.id
+                                              sign_out current_user
+                                              session.delete(:shibboleth_data)
+                                              s_user = User.find(user_id)
+                                              sign_in s_user
+                      redirect_to edit_user_registration_path
+                                      else
+                                              session[:shibboleth_data] = request.env['omniauth.auth']
+                                              session[:shibboleth_data][:uid] = uid
+                                              redirect_to new_user_registration_url(:nosplash => 'true')
+                                      end
+                              end
+    else
+      redirect_to root_path
+    end
+  end
+end
+
+ +
+ + + + +
+ + +
+ +
+ +
+ + + + diff --git a/public/html/Users/OmniauthShibbolethRequestController.html b/public/html/Users/OmniauthShibbolethRequestController.html new file mode 100644 index 0000000..bd89987 --- /dev/null +++ b/public/html/Users/OmniauthShibbolethRequestController.html @@ -0,0 +1,370 @@ + + + + + + +class Users::OmniauthShibbolethRequestController - DMPonline4 Documentation + + + + + + + + + + + + + + + + +
+

class Users::OmniauthShibbolethRequestController

+ +
+ +
+ + + + +
+ + + + + + + + + + +
+

Public Instance Methods

+ + +
+ +
+ associate() + click to toggle source +
+ + +
+ + + + + +
+
# File app/controllers/users/omniauth_shibboleth_request_controller.rb, line 17
+def associate
+  # This action is protected - can only be reached if user is already logged in.
+
+  # See before_filter
+
+  redirect_to user_omniauth_callback_path(:shibboleth)
+end
+
+ +
+ + + + +
+ + +
+ +
+ redirect() + click to toggle source +
+ + +
+ + + + + +
+
# File app/controllers/users/omniauth_shibboleth_request_controller.rb, line 4
+def redirect
+      if !current_user.nil? && !current_user.organisation.nil?
+      idp = params[:idp] || current_user.organisation.wayfless_entity
+  else
+      idp = params[:idp]
+  end
+  query_params = {target: user_omniauth_callback_path(:shibboleth)}
+  unless idp.blank?
+    query_params[:entityID] = idp
+  end
+  redirect_to "#{Rails.application.config.shibboleth_login}?#{query_params.to_query}", status: 302
+end
+
+ +
+ + + + +
+ + +
+ +
+ +
+ + + + diff --git a/public/html/UsersController.html b/public/html/UsersController.html new file mode 100644 index 0000000..6ac90b1 --- /dev/null +++ b/public/html/UsersController.html @@ -0,0 +1,523 @@ + + + + + + +class UsersController - DMPonline4 Documentation + + + + + + + + + + + + + + + + +
+

class UsersController

+ +
+ +
+ + + + +
+ + + + + + + + + + +
+

Public Instance Methods

+ + +
+ +
+ create() + click to toggle source +
+ + +
+ +

POST /users POST /users.json

+ + + +
+
# File app/controllers/users_controller.rb, line 31
+def create
+  @user = User.new(params[:user])
+
+  respond_to do |format|
+    if @user.save
+      format.html { redirect_to @user, notice: 'User was successfully created.' }
+      format.json { render json: @user, status: :created, location: @user }
+    else
+      format.html { render action: "new" }
+      format.json { render json: @user.errors, status: :unprocessable_entity }
+    end
+  end
+end
+
+ +
+ + + + +
+ + +
+ +
+ destroy() + click to toggle source +
+ + +
+ +

DELETE /users/1 DELETE /users/1.json

+ + + +
+
# File app/controllers/users_controller.rb, line 66
+def destroy
+  @user = User.find(params[:id])
+  @user.destroy
+
+  respond_to do |format|
+    format.html { redirect_to users_url }
+    format.json { head :no_content }
+  end
+end
+
+ +
+ + + + +
+ + +
+ +
+ edit() + click to toggle source +
+ + +
+ +

GET /users/1/edit

+ + + +
+
# File app/controllers/users_controller.rb, line 25
+def edit
+  @user = User.find(params[:id])
+end
+
+ +
+ + + + +
+ + +
+ +
+ new() + click to toggle source +
+ + +
+ +

GET /users/new GET /users/new.json

+ + + +
+
# File app/controllers/users_controller.rb, line 15
+def new
+  @user = User.new
+
+  respond_to do |format|
+    format.html # new.html.erb
+
+    format.json { render json: @user }
+  end
+end
+
+ +
+ + + + +
+ + +
+ +
+ show() + click to toggle source +
+ + +
+ +

GET /users/1 GET /users/1.json

+ + + +
+
# File app/controllers/users_controller.rb, line 4
+def show
+  @user = User.find(params[:id])
+
+  respond_to do |format|
+    format.html # show.html.erb
+
+    format.json { render json: @user }
+  end
+end
+
+ +
+ + + + +
+ + +
+ +
+ update() + click to toggle source +
+ + +
+ +

PUT /users/1 PUT /users/1.json

+ + + +
+
# File app/controllers/users_controller.rb, line 47
+def update
+  @user = User.find(params[:id])
+
+  respond_to do |format|
+    if @user.update_attributes(params[:user])
+      format.html { redirect_to({:controller=> "projects", :action => "new"}, {:notice => 'Project was successfully created.'}) }
+                              format.json { head :no_content }
+    else
+      format.html { render action: "edit" }
+      format.json { render json: @user.errors, status: :unprocessable_entity }
+    end
+  end
+end
+
+ +
+ + + + +
+ + +
+ +
+ +
+ + + + diff --git a/public/html/Version.html b/public/html/Version.html new file mode 100644 index 0000000..bfa9737 --- /dev/null +++ b/public/html/Version.html @@ -0,0 +1,357 @@ + + + + + + +class Version - DMPonline4 Documentation + + + + + + + + + + + + + + + + +
+

class Version

+ +
+ +
+ + + + +
+ + + + + + + + + + +
+

Public Instance Methods

+ + +
+ +
+ global_sections() + click to toggle source +
+ + +
+ + + + + +
+
# File app/models/version.rb, line 22
+def global_sections
+      sections.find_all_by_organisation_id(phase.dmptemplate.organisation_id)
+end
+
+ +
+ + + + +
+ + +
+ +
+ to_s() + click to toggle source +
+ + +
+ + + + + +
+
# File app/models/version.rb, line 16
+def to_s
+      "#{title}"
+end
+
+ +
+ + + + +
+ + +
+ +
+ +
+ + + + diff --git a/public/html/created.rid b/public/html/created.rid new file mode 100644 index 0000000..1ff390d --- /dev/null +++ b/public/html/created.rid @@ -0,0 +1,115 @@ +Mon, 09 Nov 2015 14:55:18 +0000 +README.rdoc Tue, 28 Jul 2015 13:51:53 +0100 +app/admin/dashboard.rb Wed, 18 Mar 2015 14:45:56 +0000 +app/admin/dmptemplate.rb Wed, 18 Mar 2015 11:10:34 +0000 +app/admin/guidance.rb Fri, 02 Oct 2015 10:07:14 +0100 +app/admin/guidance_group.rb Mon, 09 Nov 2015 14:30:03 +0000 +app/admin/option.rb Fri, 02 Oct 2015 10:09:28 +0100 +app/admin/organisation.rb Fri, 02 Oct 2015 10:09:28 +0100 +app/admin/organisation_type.rb Fri, 02 Oct 2015 10:09:28 +0100 +app/admin/phase.rb Fri, 02 Oct 2015 10:09:28 +0100 +app/admin/project.rb Fri, 02 Oct 2015 10:09:28 +0100 +app/admin/project_group.rb Wed, 11 Mar 2015 16:23:43 +0000 +app/admin/question.rb Fri, 02 Oct 2015 10:09:28 +0100 +app/admin/question_format.rb Fri, 02 Oct 2015 10:09:28 +0100 +app/admin/role.rb Fri, 02 Oct 2015 10:09:28 +0100 +app/admin/section.rb Fri, 02 Oct 2015 10:09:28 +0100 +app/admin/suggested_answer.rb Wed, 11 Mar 2015 16:23:43 +0000 +app/admin/theme.rb Fri, 02 Oct 2015 10:09:28 +0100 +app/admin/user.rb Wed, 28 Oct 2015 11:08:46 +0000 +app/admin/user_org_role.rb Fri, 02 Oct 2015 10:09:28 +0100 +app/admin/user_role_type.rb Fri, 02 Oct 2015 10:09:28 +0100 +app/admin/user_status.rb Fri, 02 Oct 2015 10:09:28 +0100 +app/admin/user_type.rb Fri, 02 Oct 2015 10:09:28 +0100 +app/admin/version.rb Fri, 02 Oct 2015 10:09:28 +0100 +app/controllers/answers_controller.rb Thu, 16 Apr 2015 10:05:23 +0100 +app/controllers/application_controller.rb Fri, 09 Oct 2015 16:05:22 +0100 +app/controllers/comments_controller.rb Tue, 19 May 2015 16:11:58 +0100 +app/controllers/confirmations_controller.rb Wed, 09 Oct 2013 11:00:51 +0100 +app/controllers/contacts_controller.rb Mon, 27 Jul 2015 16:51:02 +0100 +app/controllers/dmptemplates_controller.rb Mon, 10 Aug 2015 12:44:35 +0100 +app/controllers/existing_users_controller.rb Tue, 26 Nov 2013 17:15:46 +0000 +app/controllers/guidance_groups_controller.rb Sun, 09 Aug 2015 14:54:18 +0100 +app/controllers/guidances_controller.rb Sun, 05 Jul 2015 22:48:47 +0100 +app/controllers/home_controller.rb Thu, 26 Sep 2013 17:04:25 +0100 +app/controllers/organisation_users_controller.rb Mon, 27 Jan 2014 15:09:50 +0000 +app/controllers/organisations_controller.rb Sun, 09 Aug 2015 14:52:46 +0100 +app/controllers/passwords_controller.rb Wed, 09 Oct 2013 11:00:51 +0100 +app/controllers/plans_controller.rb Mon, 26 Oct 2015 18:34:42 +0000 +app/controllers/project_groups_controller.rb Mon, 09 Dec 2013 10:57:33 +0000 +app/controllers/projects_controller.rb Sun, 05 Jul 2015 19:32:06 +0100 +app/controllers/registrations_controller.rb Wed, 23 Jul 2014 11:56:43 +0100 +app/controllers/sessions_controller.rb Mon, 24 Aug 2015 13:24:15 +0100 +app/controllers/settings.rb Fri, 02 Oct 2015 12:12:20 +0100 +app/controllers/settings/plans_controller.rb Wed, 09 Jul 2014 16:26:32 +0100 +app/controllers/settings/projects_controller.rb Mon, 07 Jul 2014 11:30:19 +0100 +app/controllers/splash_logs_controller.rb Wed, 27 Nov 2013 15:15:11 +0000 +app/controllers/static_pages_controller.rb Thu, 21 May 2015 16:13:16 +0100 +app/controllers/themes_controller.rb Tue, 24 Sep 2013 15:31:14 +0100 +app/controllers/user_org_roles_controller.rb Tue, 24 Sep 2013 15:31:14 +0100 +app/controllers/user_role_types_controller.rb Tue, 24 Sep 2013 15:31:14 +0100 +app/controllers/user_statuses_controller.rb Tue, 24 Sep 2013 15:31:14 +0100 +app/controllers/user_types_controller.rb Tue, 24 Sep 2013 15:31:14 +0100 +app/controllers/users/omniauth_callback_controller.rb Mon, 27 Jul 2015 12:31:00 +0100 +app/controllers/users/omniauth_shibboleth_request_controller.rb Tue, 15 Apr 2014 13:55:12 +0100 +app/controllers/users_controller.rb Tue, 12 May 2015 18:45:56 +0100 +app/helpers/application_helper.rb Mon, 10 Aug 2015 02:17:40 +0100 +app/helpers/plans_helper.rb Mon, 07 Jul 2014 11:30:19 +0100 +app/mailers/user_mailer.rb Tue, 26 Nov 2013 14:18:11 +0000 +app/models/ability.rb Tue, 06 Oct 2015 19:51:17 +0100 +app/models/answer.rb Tue, 06 Oct 2015 19:49:57 +0100 +app/models/comment.rb Tue, 06 Oct 2015 19:49:53 +0100 +app/models/dmptemplate.rb Tue, 06 Oct 2015 19:49:56 +0100 +app/models/exported_plan.rb Wed, 21 Oct 2015 14:41:40 +0100 +app/models/file_type.rb Tue, 06 Oct 2015 19:51:17 +0100 +app/models/file_upload.rb Tue, 06 Oct 2015 19:51:18 +0100 +app/models/guidance.rb Tue, 06 Oct 2015 19:49:51 +0100 +app/models/guidance_group.rb Tue, 06 Oct 2015 19:49:52 +0100 +app/models/option.rb Tue, 06 Oct 2015 19:49:56 +0100 +app/models/option_warning.rb Tue, 06 Oct 2015 19:49:57 +0100 +app/models/organisation.rb Tue, 06 Oct 2015 19:49:55 +0100 +app/models/organisation_type.rb Tue, 06 Oct 2015 19:51:18 +0100 +app/models/phase.rb Tue, 06 Oct 2015 19:49:51 +0100 +app/models/plan.rb Tue, 06 Oct 2015 19:49:56 +0100 +app/models/plan_section.rb Tue, 06 Oct 2015 19:51:19 +0100 +app/models/project.rb Tue, 06 Oct 2015 19:49:52 +0100 +app/models/project_group.rb Tue, 06 Oct 2015 19:51:19 +0100 +app/models/project_partner.rb Tue, 06 Oct 2015 19:51:16 +0100 +app/models/question.rb Tue, 06 Oct 2015 19:49:55 +0100 +app/models/question_format.rb Tue, 06 Oct 2015 19:51:20 +0100 +app/models/role.rb Tue, 06 Oct 2015 19:49:53 +0100 +app/models/section.rb Tue, 06 Oct 2015 19:51:20 +0100 +app/models/settings/dmptemplate.rb Tue, 06 Oct 2015 19:51:24 +0100 +app/models/settings/plan_list.rb Tue, 06 Oct 2015 19:51:25 +0100 +app/models/splash_log.rb Tue, 06 Oct 2015 19:51:20 +0100 +app/models/suggested_answer.rb Tue, 06 Oct 2015 19:51:21 +0100 +app/models/theme.rb Tue, 06 Oct 2015 19:51:21 +0100 +app/models/user.rb Tue, 06 Oct 2015 19:49:54 +0100 +app/models/user_org_role.rb Tue, 06 Oct 2015 19:51:22 +0100 +app/models/user_role_type.rb Tue, 06 Oct 2015 19:51:22 +0100 +app/models/user_status.rb Tue, 06 Oct 2015 19:51:23 +0100 +app/models/user_type.rb Tue, 06 Oct 2015 19:51:23 +0100 +app/models/version.rb Tue, 06 Oct 2015 19:51:24 +0100 +lib/active_admin_views_pages_base.rb Wed, 20 Nov 2013 16:27:04 +0000 +lib/custom_failure.rb Tue, 24 Sep 2013 15:31:14 +0100 +config/application.rb Tue, 06 Oct 2015 15:02:51 +0100 +config/boot.rb Tue, 24 Sep 2013 15:31:14 +0100 +config/environment.rb Tue, 24 Sep 2013 15:31:14 +0100 +config/environments/development.rb Mon, 14 Jul 2014 15:43:22 +0100 +config/environments/production.rb Mon, 14 Jul 2014 15:43:22 +0100 +config/environments/test.rb Tue, 28 Jan 2014 12:43:49 +0000 +config/initializers/active_admin.rb Mon, 12 Oct 2015 16:20:30 +0100 +config/initializers/backtrace_silencers.rb Tue, 24 Sep 2013 15:31:14 +0100 +config/initializers/contact_us.rb Mon, 14 Jul 2014 15:43:22 +0100 +config/initializers/devise.rb Fri, 02 Oct 2015 10:16:28 +0100 +config/initializers/formtastic.rb Tue, 24 Sep 2013 15:31:14 +0100 +config/initializers/inflections.rb Tue, 24 Sep 2013 15:31:14 +0100 +config/initializers/locale.rb Tue, 24 Sep 2013 15:31:14 +0100 +config/initializers/mime_types.rb Mon, 14 Jul 2014 15:43:22 +0100 +config/initializers/omniauth.rb Mon, 07 Jul 2014 11:30:12 +0100 +config/initializers/recaptcha.rb Wed, 16 Jul 2014 16:29:56 +0100 +config/initializers/rolify.rb Tue, 24 Sep 2013 15:31:14 +0100 +config/initializers/secret_token.rb Mon, 14 Jul 2014 15:43:22 +0100 +config/initializers/session_store.rb Tue, 24 Sep 2013 15:31:14 +0100 +config/initializers/wrap_parameters.rb Tue, 24 Sep 2013 15:31:14 +0100 +config/routes.rb Thu, 21 May 2015 15:42:52 +0100 diff --git a/public/html/images/add.png b/public/html/images/add.png new file mode 100644 index 0000000..6332fef --- /dev/null +++ b/public/html/images/add.png Binary files differ diff --git a/public/html/images/brick.png b/public/html/images/brick.png new file mode 100644 index 0000000..7851cf3 --- /dev/null +++ b/public/html/images/brick.png Binary files differ diff --git a/public/html/images/brick_link.png b/public/html/images/brick_link.png new file mode 100644 index 0000000..9ebf013 --- /dev/null +++ b/public/html/images/brick_link.png Binary files differ diff --git a/public/html/images/bug.png b/public/html/images/bug.png new file mode 100644 index 0000000..2d5fb90 --- /dev/null +++ b/public/html/images/bug.png Binary files differ diff --git a/public/html/images/bullet_black.png b/public/html/images/bullet_black.png new file mode 100644 index 0000000..5761970 --- /dev/null +++ b/public/html/images/bullet_black.png Binary files differ diff --git a/public/html/images/bullet_toggle_minus.png b/public/html/images/bullet_toggle_minus.png new file mode 100644 index 0000000..b47ce55 --- /dev/null +++ b/public/html/images/bullet_toggle_minus.png Binary files differ diff --git a/public/html/images/bullet_toggle_plus.png b/public/html/images/bullet_toggle_plus.png new file mode 100644 index 0000000..9ab4a89 --- /dev/null +++ b/public/html/images/bullet_toggle_plus.png Binary files differ diff --git a/public/html/images/date.png b/public/html/images/date.png new file mode 100644 index 0000000..783c833 --- /dev/null +++ b/public/html/images/date.png Binary files differ diff --git a/public/html/images/delete.png b/public/html/images/delete.png new file mode 100644 index 0000000..08f2493 --- /dev/null +++ b/public/html/images/delete.png Binary files differ diff --git a/public/html/images/find.png b/public/html/images/find.png new file mode 100644 index 0000000..1547479 --- /dev/null +++ b/public/html/images/find.png Binary files differ diff --git a/public/html/images/loadingAnimation.gif b/public/html/images/loadingAnimation.gif new file mode 100644 index 0000000..82290f4 --- /dev/null +++ b/public/html/images/loadingAnimation.gif Binary files differ diff --git a/public/html/images/macFFBgHack.png b/public/html/images/macFFBgHack.png new file mode 100644 index 0000000..c6473b3 --- /dev/null +++ b/public/html/images/macFFBgHack.png Binary files differ diff --git a/public/html/images/package.png b/public/html/images/package.png new file mode 100644 index 0000000..da3c2a2 --- /dev/null +++ b/public/html/images/package.png Binary files differ diff --git a/public/html/images/page_green.png b/public/html/images/page_green.png new file mode 100644 index 0000000..de8e003 --- /dev/null +++ b/public/html/images/page_green.png Binary files differ diff --git a/public/html/images/page_white_text.png b/public/html/images/page_white_text.png new file mode 100644 index 0000000..813f712 --- /dev/null +++ b/public/html/images/page_white_text.png Binary files differ diff --git a/public/html/images/page_white_width.png b/public/html/images/page_white_width.png new file mode 100644 index 0000000..1eb8809 --- /dev/null +++ b/public/html/images/page_white_width.png Binary files differ diff --git a/public/html/images/plugin.png b/public/html/images/plugin.png new file mode 100644 index 0000000..6187b15 --- /dev/null +++ b/public/html/images/plugin.png Binary files differ diff --git a/public/html/images/ruby.png b/public/html/images/ruby.png new file mode 100644 index 0000000..f763a16 --- /dev/null +++ b/public/html/images/ruby.png Binary files differ diff --git a/public/html/images/tag_blue.png b/public/html/images/tag_blue.png new file mode 100644 index 0000000..3f02b5f --- /dev/null +++ b/public/html/images/tag_blue.png Binary files differ diff --git a/public/html/images/tag_green.png b/public/html/images/tag_green.png new file mode 100644 index 0000000..83ec984 --- /dev/null +++ b/public/html/images/tag_green.png Binary files differ diff --git a/public/html/images/transparent.png b/public/html/images/transparent.png new file mode 100644 index 0000000..d665e17 --- /dev/null +++ b/public/html/images/transparent.png Binary files differ diff --git a/public/html/images/wrench.png b/public/html/images/wrench.png new file mode 100644 index 0000000..5c8213f --- /dev/null +++ b/public/html/images/wrench.png Binary files differ diff --git a/public/html/images/wrench_orange.png b/public/html/images/wrench_orange.png new file mode 100644 index 0000000..565a933 --- /dev/null +++ b/public/html/images/wrench_orange.png Binary files differ diff --git a/public/html/images/zoom.png b/public/html/images/zoom.png new file mode 100644 index 0000000..908612e --- /dev/null +++ b/public/html/images/zoom.png Binary files differ diff --git a/public/html/index.html b/public/html/index.html new file mode 100644 index 0000000..d4524bb --- /dev/null +++ b/public/html/index.html @@ -0,0 +1,310 @@ + + + + + + +DMPonline4 Documentation + + + + + + + + + + + + + + + + +
+ +

DMPonline v4

+ +

DMPonline is the DCC's data management planning tool, available at dmponline.dcc.ac.uk

+ +

Development of the DMPonline by the Digital Curation Centre has been funded +by JISC. JISC inspires UK colleges and universities in the innovative use +of digital technologies, helping to maintain the UK's position as a +global leader in education. www.jisc.ac.uk

+ +

This is just the application code, the accompanying question data available +at dmponline.dcc.ac.uk is not +included.

+ +

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.

    +
+ +

Documentation & Support

+ + +

Bugs & Feature Requests

+ + +

Prerequisites

+ +

DMPonline is a Ruby on Rails application and you will need to have Ruby +2.0.0p247 or greater installed on your server and a MySQL server v5.0 or +greater.

+ +

Further details on how to install Ruby on Rails applications are available +from the Ruby on Rails site, rubyonrails.org

+ +

You may also find the following resources handy:

+ + + + +

Copyright © 2013 Digital Curation Centre, University of Edinburgh.

+ +

This program is free software: you can redistribute it and/or modify it +under the terms of the GNU Affero General Public License as published by +the Free Software Foundation, either version 3 of the License, or (at your +option) any later version.

+ +

This program is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License +for more details.

+ +

You should have received a copy of the GNU Affero General Public License +along with this program. If not, see www.gnu.org/licenses.

+ +
+ + + + diff --git a/public/html/js/darkfish.js b/public/html/js/darkfish.js new file mode 100644 index 0000000..92d8280 --- /dev/null +++ b/public/html/js/darkfish.js @@ -0,0 +1,155 @@ +/** + * + * Darkfish Page Functions + * $Id: darkfish.js 53 2009-01-07 02:52:03Z deveiant $ + * + * Author: Michael Granger + * + */ + +/* Provide console simulation for firebug-less environments */ +if (!("console" in window) || !("firebug" in console)) { + var names = ["log", "debug", "info", "warn", "error", "assert", "dir", "dirxml", + "group", "groupEnd", "time", "timeEnd", "count", "trace", "profile", "profileEnd"]; + + window.console = {}; + for (var i = 0; i < names.length; ++i) + window.console[names[i]] = function() {}; +}; + + +/** + * Unwrap the first element that matches the given @expr@ from the targets and return them. + */ +$.fn.unwrap = function( expr ) { + return this.each( function() { + $(this).parents( expr ).eq( 0 ).after( this ).remove(); + }); +}; + + +function showSource( e ) { + var target = e.target; + var codeSections = $(target). + parents('.method-detail'). + find('.method-source-code'); + + $(target). + parents('.method-detail'). + find('.method-source-code'). + slideToggle(); +}; + +function hookSourceViews() { + $('.method-heading').click( showSource ); +}; + +function toggleDebuggingSection() { + $('.debugging-section').slideToggle(); +}; + +function hookDebuggingToggle() { + $('#debugging-toggle img').click( toggleDebuggingSection ); +}; + +function hookTableOfContentsToggle() { + $('.indexpage li .toc-toggle').each( function() { + $(this).click( function() { + $(this).toggleClass('open'); + }); + + var section = $(this).next(); + + $(this).click( function() { + section.slideToggle(); + }); + }); +} + +function hookSearch() { + var input = $('#search-field').eq(0); + var result = $('#search-results').eq(0); + $(result).show(); + + var search_section = $('#search-section').get(0); + $(search_section).show(); + + var search = new Search(search_data, input, result); + + search.renderItem = function(result) { + var li = document.createElement('li'); + var html = ''; + + // TODO add relative path to + + + + + + + + + + +

Table of Contents - DMPonline4 Documentation

+ +

Pages

+ + +

Classes/Modules

+ + +

Methods

+ + + + + diff --git a/public/i18n.js b/public/i18n.js new file mode 100644 index 0000000..9797f5b --- /dev/null +++ b/public/i18n.js @@ -0,0 +1,934 @@ +// I18n.js +// ======= +// +// This small library provides the Rails I18n API on the Javascript. +// You don't actually have to use Rails (or even Ruby) to use I18n.js. +// Just make sure you export all translations in an object like this: +// +// I18n.translations.en = { +// hello: "Hello World" +// }; +// +// See tests for specific formatting like numbers and dates. +// + +;(function(factory) { + if (typeof module !== 'undefined' && module.exports) { + // Node/CommonJS + module.exports = factory(this); + } else if (typeof define === 'function' && define.amd) { + // AMD + var global=this; + define('i18n', function(){ return factory(global);}); + } else { + // Browser globals + this.I18n = factory(this); + } +}(function(global) { + "use strict"; + + // Use previously defined object if exists in current scope + var I18n = global && global.I18n || {}; + + // Just cache the Array#slice function. + var slice = Array.prototype.slice; + + // Apply number padding. + var padding = function(number) { + return ("0" + number.toString()).substr(-2); + }; + + // Improved toFixed number rounding function with support for unprecise floating points + // JavaScript's standard toFixed function does not round certain numbers correctly (for example 0.105 with precision 2). + var toFixed = function(number, precision) { + return decimalAdjust('round', number, -precision).toFixed(precision); + }; + + // Is a given variable an object? + // Borrowed from Underscore.js + var isObject = function(obj) { + var type = typeof obj; + return type === 'function' || type === 'object' && !!obj; + }; + + // Is a given value an array? + // Borrowed from Underscore.js + var isArray = function(obj) { + if (Array.isArray) { + return Array.isArray(obj); + }; + return Object.prototype.toString.call(obj) === '[object Array]'; + }; + + var decimalAdjust = function(type, value, exp) { + // If the exp is undefined or zero... + if (typeof exp === 'undefined' || +exp === 0) { + return Math[type](value); + } + value = +value; + exp = +exp; + // If the value is not a number or the exp is not an integer... + if (isNaN(value) || !(typeof exp === 'number' && exp % 1 === 0)) { + return NaN; + } + // Shift + value = value.toString().split('e'); + value = Math[type](+(value[0] + 'e' + (value[1] ? (+value[1] - exp) : -exp))); + // Shift back + value = value.toString().split('e'); + return +(value[0] + 'e' + (value[1] ? (+value[1] + exp) : exp)); + } + + // Set default days/months translations. + var DATE = { + day_names: ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"] + , abbr_day_names: ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"] + , month_names: [null, "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"] + , abbr_month_names: [null, "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"] + , meridian: ["AM", "PM"] + }; + + // Set default number format. + var NUMBER_FORMAT = { + precision: 3 + , separator: "." + , delimiter: "," + , strip_insignificant_zeros: false + }; + + // Set default currency format. + var CURRENCY_FORMAT = { + unit: "$" + , precision: 2 + , format: "%u%n" + , sign_first: true + , delimiter: "," + , separator: "." + }; + + // Set default percentage format. + var PERCENTAGE_FORMAT = { + unit: "%" + , precision: 3 + , format: "%n%u" + , separator: "." + , delimiter: "" + }; + + // Set default size units. + var SIZE_UNITS = [null, "kb", "mb", "gb", "tb"]; + + // Other default options + var DEFAULT_OPTIONS = { + // Set default locale. This locale will be used when fallback is enabled and + // the translation doesn't exist in a particular locale. + defaultLocale: "en" + // Set the current locale to `en`. + , locale: "en" + // Set the translation key separator. + , defaultSeparator: "." + // Set the placeholder format. Accepts `{{placeholder}}` and `%{placeholder}`. + , placeholder: /(?:\{\{|%\{)(.*?)(?:\}\}?)/gm + // Set if engine should fallback to the default locale when a translation + // is missing. + , fallbacks: false + // Set the default translation object. + , translations: {} + // Set missing translation behavior. 'message' will display a message + // that the translation is missing, 'guess' will try to guess the string + , missingBehaviour: 'message' + // if you use missingBehaviour with 'message', but want to know that the + // string is actually missing for testing purposes, you can prefix the + // guessed string by setting the value here. By default, no prefix! + , missingTranslationPrefix: '' + }; + + I18n.reset = function() { + // Set default locale. This locale will be used when fallback is enabled and + // the translation doesn't exist in a particular locale. + this.defaultLocale = DEFAULT_OPTIONS.defaultLocale; + + // Set the current locale to `en`. + this.locale = DEFAULT_OPTIONS.locale; + + // Set the translation key separator. + this.defaultSeparator = DEFAULT_OPTIONS.defaultSeparator; + + // Set the placeholder format. Accepts `{{placeholder}}` and `%{placeholder}`. + this.placeholder = DEFAULT_OPTIONS.placeholder; + + // Set if engine should fallback to the default locale when a translation + // is missing. + this.fallbacks = DEFAULT_OPTIONS.fallbacks; + + // Set the default translation object. + this.translations = DEFAULT_OPTIONS.translations; + + // Set the default missing behaviour + this.missingBehaviour = DEFAULT_OPTIONS.missingBehaviour; + + // Set the default missing string prefix for guess behaviour + this.missingTranslationPrefix = DEFAULT_OPTIONS.missingTranslationPrefix; + + }; + + // Much like `reset`, but only assign options if not already assigned + I18n.initializeOptions = function() { + if (typeof(this.defaultLocale) === "undefined" && this.defaultLocale !== null) + this.defaultLocale = DEFAULT_OPTIONS.defaultLocale; + + if (typeof(this.locale) === "undefined" && this.locale !== null) + this.locale = DEFAULT_OPTIONS.locale; + + if (typeof(this.defaultSeparator) === "undefined" && this.defaultSeparator !== null) + this.defaultSeparator = DEFAULT_OPTIONS.defaultSeparator; + + if (typeof(this.placeholder) === "undefined" && this.placeholder !== null) + this.placeholder = DEFAULT_OPTIONS.placeholder; + + if (typeof(this.fallbacks) === "undefined" && this.fallbacks !== null) + this.fallbacks = DEFAULT_OPTIONS.fallbacks; + + if (typeof(this.translations) === "undefined" && this.translations !== null) + this.translations = DEFAULT_OPTIONS.translations; + }; + I18n.initializeOptions(); + + // Return a list of all locales that must be tried before returning the + // missing translation message. By default, this will consider the inline option, + // current locale and fallback locale. + // + // I18n.locales.get("de-DE"); + // // ["de-DE", "de", "en"] + // + // You can define custom rules for any locale. Just make sure you return a array + // containing all locales. + // + // // Default the Wookie locale to English. + // I18n.locales["wk"] = function(locale) { + // return ["en"]; + // }; + // + I18n.locales = {}; + + // Retrieve locales based on inline locale, current locale or default to + // I18n's detection. + I18n.locales.get = function(locale) { + var result = this[locale] || this[I18n.locale] || this["default"]; + + if (typeof(result) === "function") { + result = result(locale); + } + + if (isArray(result) === false) { + result = [result]; + } + + return result; + }; + + // The default locale list. + I18n.locales["default"] = function(locale) { + var locales = [] + , list = [] + , countryCode + , count + ; + + // Handle the inline locale option that can be provided to + // the `I18n.t` options. + if (locale) { + locales.push(locale); + } + + // Add the current locale to the list. + if (!locale && I18n.locale) { + locales.push(I18n.locale); + } + + // Add the default locale if fallback strategy is enabled. + if (I18n.fallbacks && I18n.defaultLocale) { + locales.push(I18n.defaultLocale); + } + + // Compute each locale with its country code. + // So this will return an array containing both + // `de-DE` and `de` locales. + locales.forEach(function(locale){ + countryCode = locale.split("-")[0]; + + if (!~list.indexOf(locale)) { + list.push(locale); + } + + if (I18n.fallbacks && countryCode && countryCode !== locale && !~list.indexOf(countryCode)) { + list.push(countryCode); + } + }); + + // No locales set? English it is. + if (!locales.length) { + locales.push("en"); + } + + return list; + }; + + // Hold pluralization rules. + I18n.pluralization = {}; + + // Return the pluralizer for a specific locale. + // If no specify locale is found, then I18n's default will be used. + I18n.pluralization.get = function(locale) { + return this[locale] || this[I18n.locale] || this["default"]; + }; + + // The default pluralizer rule. + // It detects the `zero`, `one`, and `other` scopes. + I18n.pluralization["default"] = function(count) { + switch (count) { + case 0: return ["zero", "other"]; + case 1: return ["one"]; + default: return ["other"]; + } + }; + + // Return current locale. If no locale has been set, then + // the current locale will be the default locale. + I18n.currentLocale = function() { + return this.locale || this.defaultLocale; + }; + + // Check if value is different than undefined and null; + I18n.isSet = function(value) { + return value !== undefined && value !== null; + }; + + // Find and process the translation using the provided scope and options. + // This is used internally by some functions and should not be used as an + // public API. + I18n.lookup = function(scope, options) { + options = this.prepareOptions(options); + + var locales = this.locales.get(options.locale).slice() + , requestedLocale = locales[0] + , locale + , scopes + , translations + ; + + scope = this.getFullScope(scope, options); + + while (locales.length) { + locale = locales.shift(); + scopes = scope.split(this.defaultSeparator); + translations = this.translations[locale]; + + if (!translations) { + continue; + } + + while (scopes.length) { + translations = translations[scopes.shift()]; + + if (translations === undefined || translations === null) { + break; + } + } + + if (translations !== undefined && translations !== null) { + return translations; + } + } + + if (this.isSet(options.defaultValue)) { + return options.defaultValue; + } + }; + + // Rails changed the way the meridian is stored. + // It started with `date.meridian` returning an array, + // then it switched to `time.am` and `time.pm`. + // This function abstracts this difference and returns + // the correct meridian or the default value when none is provided. + I18n.meridian = function() { + var time = this.lookup("time"); + var date = this.lookup("date"); + + if (time && time.am && time.pm) { + return [time.am, time.pm]; + } else if (date && date.meridian) { + return date.meridian; + } else { + return DATE.meridian; + } + }; + + // Merge serveral hash options, checking if value is set before + // overwriting any value. The precedence is from left to right. + // + // I18n.prepareOptions({name: "John Doe"}, {name: "Mary Doe", role: "user"}); + // #=> {name: "John Doe", role: "user"} + // + I18n.prepareOptions = function() { + var args = slice.call(arguments) + , options = {} + , subject + ; + + while (args.length) { + subject = args.shift(); + + if (typeof(subject) != "object") { + continue; + } + + for (var attr in subject) { + if (!subject.hasOwnProperty(attr)) { + continue; + } + + if (this.isSet(options[attr])) { + continue; + } + + options[attr] = subject[attr]; + } + } + + return options; + }; + + // Generate a list of translation options for default fallbacks. + // `defaultValue` is also deleted from options as it is returned as part of + // the translationOptions array. + I18n.createTranslationOptions = function(scope, options) { + var translationOptions = [{scope: scope}]; + + // Defaults should be an array of hashes containing either + // fallback scopes or messages + if (this.isSet(options.defaults)) { + translationOptions = translationOptions.concat(options.defaults); + } + + // Maintain support for defaultValue. Since it is always a message + // insert it in to the translation options as such. + if (this.isSet(options.defaultValue)) { + translationOptions.push({ message: options.defaultValue }); + delete options.defaultValue; + } + + return translationOptions; + }; + + // Translate the given scope with the provided options. + I18n.translate = function(scope, options) { + options = this.prepareOptions(options); + + var translationOptions = this.createTranslationOptions(scope, options); + + var translation; + // Iterate through the translation options until a translation + // or message is found. + var translationFound = + translationOptions.some(function(translationOption) { + if (this.isSet(translationOption.scope)) { + translation = this.lookup(translationOption.scope, options); + } else if (this.isSet(translationOption.message)) { + translation = translationOption.message; + } + + if (translation !== undefined && translation !== null) { + return true; + } + }, this); + + if (!translationFound) { + return this.missingTranslation(scope, options); + } + + if (typeof(translation) === "string") { + translation = this.interpolate(translation, options); + } else if (isObject(translation) && this.isSet(options.count)) { + translation = this.pluralize(options.count, translation, options); + } + + return translation; + }; + + // This function interpolates the all variables in the given message. + I18n.interpolate = function(message, options) { + options = this.prepareOptions(options); + var matches = message.match(this.placeholder) + , placeholder + , value + , name + , regex + ; + + if (!matches) { + return message; + } + + var value; + + while (matches.length) { + placeholder = matches.shift(); + name = placeholder.replace(this.placeholder, "$1"); + + if (this.isSet(options[name])) { + value = options[name].toString().replace(/\$/gm, "_#$#_"); + } else if (name in options) { + value = this.nullPlaceholder(placeholder, message, options); + } else { + value = this.missingPlaceholder(placeholder, message, options); + } + + regex = new RegExp(placeholder.replace(/\{/gm, "\\{").replace(/\}/gm, "\\}")); + message = message.replace(regex, value); + } + + return message.replace(/_#\$#_/g, "$"); + }; + + // Pluralize the given scope using the `count` value. + // The pluralized translation may have other placeholders, + // which will be retrieved from `options`. + I18n.pluralize = function(count, scope, options) { + options = this.prepareOptions(options); + var translations, pluralizer, keys, key, message; + + if (isObject(scope)) { + translations = scope; + } else { + translations = this.lookup(scope, options); + } + + if (!translations) { + return this.missingTranslation(scope, options); + } + + pluralizer = this.pluralization.get(options.locale); + keys = pluralizer(count); + + while (keys.length) { + key = keys.shift(); + + if (this.isSet(translations[key])) { + message = translations[key]; + break; + } + } + + options.count = String(count); + return this.interpolate(message, options); + }; + + // Return a missing translation message for the given parameters. + I18n.missingTranslation = function(scope, options) { + //guess intended string + if(this.missingBehaviour == 'guess'){ + //get only the last portion of the scope + var s = scope.split('.').slice(-1)[0]; + //replace underscore with space && camelcase with space and lowercase letter + return (this.missingTranslationPrefix.length > 0 ? this.missingTranslationPrefix : '') + + s.replace('_',' ').replace(/([a-z])([A-Z])/g, + function(match, p1, p2) {return p1 + ' ' + p2.toLowerCase()} ); + } + + var fullScope = this.getFullScope(scope, options); + var fullScopeWithLocale = [this.currentLocale(), fullScope].join(this.defaultSeparator); + + return '[missing "' + fullScopeWithLocale + '" translation]'; + }; + + // Return a missing placeholder message for given parameters + I18n.missingPlaceholder = function(placeholder, message, options) { + return "[missing " + placeholder + " value]"; + }; + + I18n.nullPlaceholder = function() { + return I18n.missingPlaceholder.apply(I18n, arguments); + }; + + // Format number using localization rules. + // The options will be retrieved from the `number.format` scope. + // If this isn't present, then the following options will be used: + // + // - `precision`: `3` + // - `separator`: `"."` + // - `delimiter`: `","` + // - `strip_insignificant_zeros`: `false` + // + // You can also override these options by providing the `options` argument. + // + I18n.toNumber = function(number, options) { + options = this.prepareOptions( + options + , this.lookup("number.format") + , NUMBER_FORMAT + ); + + var negative = number < 0 + , string = toFixed(Math.abs(number), options.precision).toString() + , parts = string.split(".") + , precision + , buffer = [] + , formattedNumber + , format = options.format || "%n" + , sign = negative ? "-" : "" + ; + + number = parts[0]; + precision = parts[1]; + + while (number.length > 0) { + buffer.unshift(number.substr(Math.max(0, number.length - 3), 3)); + number = number.substr(0, number.length -3); + } + + formattedNumber = buffer.join(options.delimiter); + + if (options.strip_insignificant_zeros && precision) { + precision = precision.replace(/0+$/, ""); + } + + if (options.precision > 0 && precision) { + formattedNumber += options.separator + precision; + } + + if (options.sign_first) { + format = "%s" + format; + } + else { + format = format.replace("%n", "%s%n"); + } + + formattedNumber = format + .replace("%u", options.unit) + .replace("%n", formattedNumber) + .replace("%s", sign) + ; + + return formattedNumber; + }; + + // Format currency with localization rules. + // The options will be retrieved from the `number.currency.format` and + // `number.format` scopes, in that order. + // + // Any missing option will be retrieved from the `I18n.toNumber` defaults and + // the following options: + // + // - `unit`: `"$"` + // - `precision`: `2` + // - `format`: `"%u%n"` + // - `delimiter`: `","` + // - `separator`: `"."` + // + // You can also override these options by providing the `options` argument. + // + I18n.toCurrency = function(number, options) { + options = this.prepareOptions( + options + , this.lookup("number.currency.format") + , this.lookup("number.format") + , CURRENCY_FORMAT + ); + + return this.toNumber(number, options); + }; + + // Localize several values. + // You can provide the following scopes: `currency`, `number`, or `percentage`. + // If you provide a scope that matches the `/^(date|time)/` regular expression + // then the `value` will be converted by using the `I18n.toTime` function. + // + // It will default to the value's `toString` function. + // + I18n.localize = function(scope, value, options) { + options || (options = {}); + + switch (scope) { + case "currency": + return this.toCurrency(value); + case "number": + scope = this.lookup("number.format"); + return this.toNumber(value, scope); + case "percentage": + return this.toPercentage(value); + default: + var localizedValue; + + if (scope.match(/^(date|time)/)) { + localizedValue = this.toTime(scope, value); + } else { + localizedValue = value.toString(); + } + + return this.interpolate(localizedValue, options); + } + }; + + // Parse a given `date` string into a JavaScript Date object. + // This function is time zone aware. + // + // The following string formats are recognized: + // + // yyyy-mm-dd + // yyyy-mm-dd[ T]hh:mm::ss + // yyyy-mm-dd[ T]hh:mm::ss + // yyyy-mm-dd[ T]hh:mm::ssZ + // yyyy-mm-dd[ T]hh:mm::ss+0000 + // yyyy-mm-dd[ T]hh:mm::ss+00:00 + // yyyy-mm-dd[ T]hh:mm::ss.123Z + // + I18n.parseDate = function(date) { + var matches, convertedDate, fraction; + // we have a date, so just return it. + if (typeof(date) == "object") { + return date; + }; + + matches = date.toString().match(/(\d{4})-(\d{2})-(\d{2})(?:[ T](\d{2}):(\d{2}):(\d{2})([\.,]\d{1,3})?)?(Z|\+00:?00)?/); + + if (matches) { + for (var i = 1; i <= 6; i++) { + matches[i] = parseInt(matches[i], 10) || 0; + } + + // month starts on 0 + matches[2] -= 1; + + fraction = matches[7] ? 1000 * ("0" + matches[7]) : null; + + if (matches[8]) { + convertedDate = new Date(Date.UTC(matches[1], matches[2], matches[3], matches[4], matches[5], matches[6], fraction)); + } else { + convertedDate = new Date(matches[1], matches[2], matches[3], matches[4], matches[5], matches[6], fraction); + } + } else if (typeof(date) == "number") { + // UNIX timestamp + convertedDate = new Date(); + convertedDate.setTime(date); + } else if (date.match(/([A-Z][a-z]{2}) ([A-Z][a-z]{2}) (\d+) (\d+:\d+:\d+) ([+-]\d+) (\d+)/)) { + // This format `Wed Jul 20 13:03:39 +0000 2011` is parsed by + // webkit/firefox, but not by IE, so we must parse it manually. + convertedDate = new Date(); + convertedDate.setTime(Date.parse([ + RegExp.$1, RegExp.$2, RegExp.$3, RegExp.$6, RegExp.$4, RegExp.$5 + ].join(" "))); + } else if (date.match(/\d+ \d+:\d+:\d+ [+-]\d+ \d+/)) { + // a valid javascript format with timezone info + convertedDate = new Date(); + convertedDate.setTime(Date.parse(date)); + } else { + // an arbitrary javascript string + convertedDate = new Date(); + convertedDate.setTime(Date.parse(date)); + } + + return convertedDate; + }; + + // Formats time according to the directives in the given format string. + // The directives begins with a percent (%) character. Any text not listed as a + // directive will be passed through to the output string. + // + // The accepted formats are: + // + // %a - The abbreviated weekday name (Sun) + // %A - The full weekday name (Sunday) + // %b - The abbreviated month name (Jan) + // %B - The full month name (January) + // %c - The preferred local date and time representation + // %d - Day of the month (01..31) + // %-d - Day of the month (1..31) + // %H - Hour of the day, 24-hour clock (00..23) + // %-H - Hour of the day, 24-hour clock (0..23) + // %I - Hour of the day, 12-hour clock (01..12) + // %-I - Hour of the day, 12-hour clock (1..12) + // %m - Month of the year (01..12) + // %-m - Month of the year (1..12) + // %M - Minute of the hour (00..59) + // %-M - Minute of the hour (0..59) + // %p - Meridian indicator (AM or PM) + // %S - Second of the minute (00..60) + // %-S - Second of the minute (0..60) + // %w - Day of the week (Sunday is 0, 0..6) + // %y - Year without a century (00..99) + // %-y - Year without a century (0..99) + // %Y - Year with century + // %z - Timezone offset (+0545) + // + I18n.strftime = function(date, format) { + var options = this.lookup("date") + , meridianOptions = I18n.meridian() + ; + + if (!options) { + options = {}; + } + + options = this.prepareOptions(options, DATE); + + var weekDay = date.getDay() + , day = date.getDate() + , year = date.getFullYear() + , month = date.getMonth() + 1 + , hour = date.getHours() + , hour12 = hour + , meridian = hour > 11 ? 1 : 0 + , secs = date.getSeconds() + , mins = date.getMinutes() + , offset = date.getTimezoneOffset() + , absOffsetHours = Math.floor(Math.abs(offset / 60)) + , absOffsetMinutes = Math.abs(offset) - (absOffsetHours * 60) + , timezoneoffset = (offset > 0 ? "-" : "+") + + (absOffsetHours.toString().length < 2 ? "0" + absOffsetHours : absOffsetHours) + + (absOffsetMinutes.toString().length < 2 ? "0" + absOffsetMinutes : absOffsetMinutes) + ; + + if (hour12 > 12) { + hour12 = hour12 - 12; + } else if (hour12 === 0) { + hour12 = 12; + } + + format = format.replace("%a", options.abbr_day_names[weekDay]); + format = format.replace("%A", options.day_names[weekDay]); + format = format.replace("%b", options.abbr_month_names[month]); + format = format.replace("%B", options.month_names[month]); + format = format.replace("%d", padding(day)); + format = format.replace("%e", day); + format = format.replace("%-d", day); + format = format.replace("%H", padding(hour)); + format = format.replace("%-H", hour); + format = format.replace("%I", padding(hour12)); + format = format.replace("%-I", hour12); + format = format.replace("%m", padding(month)); + format = format.replace("%-m", month); + format = format.replace("%M", padding(mins)); + format = format.replace("%-M", mins); + format = format.replace("%p", meridianOptions[meridian]); + format = format.replace("%S", padding(secs)); + format = format.replace("%-S", secs); + format = format.replace("%w", weekDay); + format = format.replace("%y", padding(year)); + format = format.replace("%-y", padding(year).replace(/^0+/, "")); + format = format.replace("%Y", year); + format = format.replace("%z", timezoneoffset); + + return format; + }; + + // Convert the given dateString into a formatted date. + I18n.toTime = function(scope, dateString) { + var date = this.parseDate(dateString) + , format = this.lookup(scope) + ; + + if (date.toString().match(/invalid/i)) { + return date.toString(); + } + + if (!format) { + return date.toString(); + } + + return this.strftime(date, format); + }; + + // Convert a number into a formatted percentage value. + I18n.toPercentage = function(number, options) { + options = this.prepareOptions( + options + , this.lookup("number.percentage.format") + , this.lookup("number.format") + , PERCENTAGE_FORMAT + ); + + return this.toNumber(number, options); + }; + + // Convert a number into a readable size representation. + I18n.toHumanSize = function(number, options) { + var kb = 1024 + , size = number + , iterations = 0 + , unit + , precision + ; + + while (size >= kb && iterations < 4) { + size = size / kb; + iterations += 1; + } + + if (iterations === 0) { + unit = this.t("number.human.storage_units.units.byte", {count: size}); + precision = 0; + } else { + unit = this.t("number.human.storage_units.units." + SIZE_UNITS[iterations]); + precision = (size - Math.floor(size) === 0) ? 0 : 1; + } + + options = this.prepareOptions( + options + , {unit: unit, precision: precision, format: "%n%u", delimiter: ""} + ); + + return this.toNumber(size, options); + }; + + I18n.getFullScope = function(scope, options) { + options = this.prepareOptions(options); + + // Deal with the scope as an array. + if (scope.constructor === Array) { + scope = scope.join(this.defaultSeparator); + } + + // Deal with the scope option provided through the second argument. + // + // I18n.t('hello', {scope: 'greetings'}); + // + if (options.scope) { + scope = [options.scope, scope].join(this.defaultSeparator); + } + + return scope; + }; + /** + * Merge obj1 with obj2 (shallow merge), without modifying inputs + * @param {Object} obj1 + * @param {Object} obj2 + * @returns {Object} Merged values of obj1 and obj2 + * + * In order to support ES3, `Object.prototype.hasOwnProperty.call` is used + * Idea is from: + * https://stackoverflow.com/questions/8157700/object-has-no-hasownproperty-method-i-e-its-undefined-ie8 + */ + I18n.extend = function ( obj1, obj2 ) { + var extended = {}; + var prop; + for (prop in obj1) { + if (Object.prototype.hasOwnProperty.call(obj1, prop)) { + extended[prop] = obj1[prop]; + } + } + for (prop in obj2) { + if (Object.prototype.hasOwnProperty.call(obj2, prop)) { + extended[prop] = obj2[prop]; + } + } + return extended; + }; + + // Set aliases, so we can save some typing. + I18n.t = I18n.translate; + I18n.l = I18n.localize; + I18n.p = I18n.pluralize; + + return I18n; +})); diff --git a/public/javascripts/i18n.js b/public/javascripts/i18n.js deleted file mode 100644 index 9797f5b..0000000 --- a/public/javascripts/i18n.js +++ /dev/null @@ -1,934 +0,0 @@ -// I18n.js -// ======= -// -// This small library provides the Rails I18n API on the Javascript. -// You don't actually have to use Rails (or even Ruby) to use I18n.js. -// Just make sure you export all translations in an object like this: -// -// I18n.translations.en = { -// hello: "Hello World" -// }; -// -// See tests for specific formatting like numbers and dates. -// - -;(function(factory) { - if (typeof module !== 'undefined' && module.exports) { - // Node/CommonJS - module.exports = factory(this); - } else if (typeof define === 'function' && define.amd) { - // AMD - var global=this; - define('i18n', function(){ return factory(global);}); - } else { - // Browser globals - this.I18n = factory(this); - } -}(function(global) { - "use strict"; - - // Use previously defined object if exists in current scope - var I18n = global && global.I18n || {}; - - // Just cache the Array#slice function. - var slice = Array.prototype.slice; - - // Apply number padding. - var padding = function(number) { - return ("0" + number.toString()).substr(-2); - }; - - // Improved toFixed number rounding function with support for unprecise floating points - // JavaScript's standard toFixed function does not round certain numbers correctly (for example 0.105 with precision 2). - var toFixed = function(number, precision) { - return decimalAdjust('round', number, -precision).toFixed(precision); - }; - - // Is a given variable an object? - // Borrowed from Underscore.js - var isObject = function(obj) { - var type = typeof obj; - return type === 'function' || type === 'object' && !!obj; - }; - - // Is a given value an array? - // Borrowed from Underscore.js - var isArray = function(obj) { - if (Array.isArray) { - return Array.isArray(obj); - }; - return Object.prototype.toString.call(obj) === '[object Array]'; - }; - - var decimalAdjust = function(type, value, exp) { - // If the exp is undefined or zero... - if (typeof exp === 'undefined' || +exp === 0) { - return Math[type](value); - } - value = +value; - exp = +exp; - // If the value is not a number or the exp is not an integer... - if (isNaN(value) || !(typeof exp === 'number' && exp % 1 === 0)) { - return NaN; - } - // Shift - value = value.toString().split('e'); - value = Math[type](+(value[0] + 'e' + (value[1] ? (+value[1] - exp) : -exp))); - // Shift back - value = value.toString().split('e'); - return +(value[0] + 'e' + (value[1] ? (+value[1] + exp) : exp)); - } - - // Set default days/months translations. - var DATE = { - day_names: ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"] - , abbr_day_names: ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"] - , month_names: [null, "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"] - , abbr_month_names: [null, "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"] - , meridian: ["AM", "PM"] - }; - - // Set default number format. - var NUMBER_FORMAT = { - precision: 3 - , separator: "." - , delimiter: "," - , strip_insignificant_zeros: false - }; - - // Set default currency format. - var CURRENCY_FORMAT = { - unit: "$" - , precision: 2 - , format: "%u%n" - , sign_first: true - , delimiter: "," - , separator: "." - }; - - // Set default percentage format. - var PERCENTAGE_FORMAT = { - unit: "%" - , precision: 3 - , format: "%n%u" - , separator: "." - , delimiter: "" - }; - - // Set default size units. - var SIZE_UNITS = [null, "kb", "mb", "gb", "tb"]; - - // Other default options - var DEFAULT_OPTIONS = { - // Set default locale. This locale will be used when fallback is enabled and - // the translation doesn't exist in a particular locale. - defaultLocale: "en" - // Set the current locale to `en`. - , locale: "en" - // Set the translation key separator. - , defaultSeparator: "." - // Set the placeholder format. Accepts `{{placeholder}}` and `%{placeholder}`. - , placeholder: /(?:\{\{|%\{)(.*?)(?:\}\}?)/gm - // Set if engine should fallback to the default locale when a translation - // is missing. - , fallbacks: false - // Set the default translation object. - , translations: {} - // Set missing translation behavior. 'message' will display a message - // that the translation is missing, 'guess' will try to guess the string - , missingBehaviour: 'message' - // if you use missingBehaviour with 'message', but want to know that the - // string is actually missing for testing purposes, you can prefix the - // guessed string by setting the value here. By default, no prefix! - , missingTranslationPrefix: '' - }; - - I18n.reset = function() { - // Set default locale. This locale will be used when fallback is enabled and - // the translation doesn't exist in a particular locale. - this.defaultLocale = DEFAULT_OPTIONS.defaultLocale; - - // Set the current locale to `en`. - this.locale = DEFAULT_OPTIONS.locale; - - // Set the translation key separator. - this.defaultSeparator = DEFAULT_OPTIONS.defaultSeparator; - - // Set the placeholder format. Accepts `{{placeholder}}` and `%{placeholder}`. - this.placeholder = DEFAULT_OPTIONS.placeholder; - - // Set if engine should fallback to the default locale when a translation - // is missing. - this.fallbacks = DEFAULT_OPTIONS.fallbacks; - - // Set the default translation object. - this.translations = DEFAULT_OPTIONS.translations; - - // Set the default missing behaviour - this.missingBehaviour = DEFAULT_OPTIONS.missingBehaviour; - - // Set the default missing string prefix for guess behaviour - this.missingTranslationPrefix = DEFAULT_OPTIONS.missingTranslationPrefix; - - }; - - // Much like `reset`, but only assign options if not already assigned - I18n.initializeOptions = function() { - if (typeof(this.defaultLocale) === "undefined" && this.defaultLocale !== null) - this.defaultLocale = DEFAULT_OPTIONS.defaultLocale; - - if (typeof(this.locale) === "undefined" && this.locale !== null) - this.locale = DEFAULT_OPTIONS.locale; - - if (typeof(this.defaultSeparator) === "undefined" && this.defaultSeparator !== null) - this.defaultSeparator = DEFAULT_OPTIONS.defaultSeparator; - - if (typeof(this.placeholder) === "undefined" && this.placeholder !== null) - this.placeholder = DEFAULT_OPTIONS.placeholder; - - if (typeof(this.fallbacks) === "undefined" && this.fallbacks !== null) - this.fallbacks = DEFAULT_OPTIONS.fallbacks; - - if (typeof(this.translations) === "undefined" && this.translations !== null) - this.translations = DEFAULT_OPTIONS.translations; - }; - I18n.initializeOptions(); - - // Return a list of all locales that must be tried before returning the - // missing translation message. By default, this will consider the inline option, - // current locale and fallback locale. - // - // I18n.locales.get("de-DE"); - // // ["de-DE", "de", "en"] - // - // You can define custom rules for any locale. Just make sure you return a array - // containing all locales. - // - // // Default the Wookie locale to English. - // I18n.locales["wk"] = function(locale) { - // return ["en"]; - // }; - // - I18n.locales = {}; - - // Retrieve locales based on inline locale, current locale or default to - // I18n's detection. - I18n.locales.get = function(locale) { - var result = this[locale] || this[I18n.locale] || this["default"]; - - if (typeof(result) === "function") { - result = result(locale); - } - - if (isArray(result) === false) { - result = [result]; - } - - return result; - }; - - // The default locale list. - I18n.locales["default"] = function(locale) { - var locales = [] - , list = [] - , countryCode - , count - ; - - // Handle the inline locale option that can be provided to - // the `I18n.t` options. - if (locale) { - locales.push(locale); - } - - // Add the current locale to the list. - if (!locale && I18n.locale) { - locales.push(I18n.locale); - } - - // Add the default locale if fallback strategy is enabled. - if (I18n.fallbacks && I18n.defaultLocale) { - locales.push(I18n.defaultLocale); - } - - // Compute each locale with its country code. - // So this will return an array containing both - // `de-DE` and `de` locales. - locales.forEach(function(locale){ - countryCode = locale.split("-")[0]; - - if (!~list.indexOf(locale)) { - list.push(locale); - } - - if (I18n.fallbacks && countryCode && countryCode !== locale && !~list.indexOf(countryCode)) { - list.push(countryCode); - } - }); - - // No locales set? English it is. - if (!locales.length) { - locales.push("en"); - } - - return list; - }; - - // Hold pluralization rules. - I18n.pluralization = {}; - - // Return the pluralizer for a specific locale. - // If no specify locale is found, then I18n's default will be used. - I18n.pluralization.get = function(locale) { - return this[locale] || this[I18n.locale] || this["default"]; - }; - - // The default pluralizer rule. - // It detects the `zero`, `one`, and `other` scopes. - I18n.pluralization["default"] = function(count) { - switch (count) { - case 0: return ["zero", "other"]; - case 1: return ["one"]; - default: return ["other"]; - } - }; - - // Return current locale. If no locale has been set, then - // the current locale will be the default locale. - I18n.currentLocale = function() { - return this.locale || this.defaultLocale; - }; - - // Check if value is different than undefined and null; - I18n.isSet = function(value) { - return value !== undefined && value !== null; - }; - - // Find and process the translation using the provided scope and options. - // This is used internally by some functions and should not be used as an - // public API. - I18n.lookup = function(scope, options) { - options = this.prepareOptions(options); - - var locales = this.locales.get(options.locale).slice() - , requestedLocale = locales[0] - , locale - , scopes - , translations - ; - - scope = this.getFullScope(scope, options); - - while (locales.length) { - locale = locales.shift(); - scopes = scope.split(this.defaultSeparator); - translations = this.translations[locale]; - - if (!translations) { - continue; - } - - while (scopes.length) { - translations = translations[scopes.shift()]; - - if (translations === undefined || translations === null) { - break; - } - } - - if (translations !== undefined && translations !== null) { - return translations; - } - } - - if (this.isSet(options.defaultValue)) { - return options.defaultValue; - } - }; - - // Rails changed the way the meridian is stored. - // It started with `date.meridian` returning an array, - // then it switched to `time.am` and `time.pm`. - // This function abstracts this difference and returns - // the correct meridian or the default value when none is provided. - I18n.meridian = function() { - var time = this.lookup("time"); - var date = this.lookup("date"); - - if (time && time.am && time.pm) { - return [time.am, time.pm]; - } else if (date && date.meridian) { - return date.meridian; - } else { - return DATE.meridian; - } - }; - - // Merge serveral hash options, checking if value is set before - // overwriting any value. The precedence is from left to right. - // - // I18n.prepareOptions({name: "John Doe"}, {name: "Mary Doe", role: "user"}); - // #=> {name: "John Doe", role: "user"} - // - I18n.prepareOptions = function() { - var args = slice.call(arguments) - , options = {} - , subject - ; - - while (args.length) { - subject = args.shift(); - - if (typeof(subject) != "object") { - continue; - } - - for (var attr in subject) { - if (!subject.hasOwnProperty(attr)) { - continue; - } - - if (this.isSet(options[attr])) { - continue; - } - - options[attr] = subject[attr]; - } - } - - return options; - }; - - // Generate a list of translation options for default fallbacks. - // `defaultValue` is also deleted from options as it is returned as part of - // the translationOptions array. - I18n.createTranslationOptions = function(scope, options) { - var translationOptions = [{scope: scope}]; - - // Defaults should be an array of hashes containing either - // fallback scopes or messages - if (this.isSet(options.defaults)) { - translationOptions = translationOptions.concat(options.defaults); - } - - // Maintain support for defaultValue. Since it is always a message - // insert it in to the translation options as such. - if (this.isSet(options.defaultValue)) { - translationOptions.push({ message: options.defaultValue }); - delete options.defaultValue; - } - - return translationOptions; - }; - - // Translate the given scope with the provided options. - I18n.translate = function(scope, options) { - options = this.prepareOptions(options); - - var translationOptions = this.createTranslationOptions(scope, options); - - var translation; - // Iterate through the translation options until a translation - // or message is found. - var translationFound = - translationOptions.some(function(translationOption) { - if (this.isSet(translationOption.scope)) { - translation = this.lookup(translationOption.scope, options); - } else if (this.isSet(translationOption.message)) { - translation = translationOption.message; - } - - if (translation !== undefined && translation !== null) { - return true; - } - }, this); - - if (!translationFound) { - return this.missingTranslation(scope, options); - } - - if (typeof(translation) === "string") { - translation = this.interpolate(translation, options); - } else if (isObject(translation) && this.isSet(options.count)) { - translation = this.pluralize(options.count, translation, options); - } - - return translation; - }; - - // This function interpolates the all variables in the given message. - I18n.interpolate = function(message, options) { - options = this.prepareOptions(options); - var matches = message.match(this.placeholder) - , placeholder - , value - , name - , regex - ; - - if (!matches) { - return message; - } - - var value; - - while (matches.length) { - placeholder = matches.shift(); - name = placeholder.replace(this.placeholder, "$1"); - - if (this.isSet(options[name])) { - value = options[name].toString().replace(/\$/gm, "_#$#_"); - } else if (name in options) { - value = this.nullPlaceholder(placeholder, message, options); - } else { - value = this.missingPlaceholder(placeholder, message, options); - } - - regex = new RegExp(placeholder.replace(/\{/gm, "\\{").replace(/\}/gm, "\\}")); - message = message.replace(regex, value); - } - - return message.replace(/_#\$#_/g, "$"); - }; - - // Pluralize the given scope using the `count` value. - // The pluralized translation may have other placeholders, - // which will be retrieved from `options`. - I18n.pluralize = function(count, scope, options) { - options = this.prepareOptions(options); - var translations, pluralizer, keys, key, message; - - if (isObject(scope)) { - translations = scope; - } else { - translations = this.lookup(scope, options); - } - - if (!translations) { - return this.missingTranslation(scope, options); - } - - pluralizer = this.pluralization.get(options.locale); - keys = pluralizer(count); - - while (keys.length) { - key = keys.shift(); - - if (this.isSet(translations[key])) { - message = translations[key]; - break; - } - } - - options.count = String(count); - return this.interpolate(message, options); - }; - - // Return a missing translation message for the given parameters. - I18n.missingTranslation = function(scope, options) { - //guess intended string - if(this.missingBehaviour == 'guess'){ - //get only the last portion of the scope - var s = scope.split('.').slice(-1)[0]; - //replace underscore with space && camelcase with space and lowercase letter - return (this.missingTranslationPrefix.length > 0 ? this.missingTranslationPrefix : '') + - s.replace('_',' ').replace(/([a-z])([A-Z])/g, - function(match, p1, p2) {return p1 + ' ' + p2.toLowerCase()} ); - } - - var fullScope = this.getFullScope(scope, options); - var fullScopeWithLocale = [this.currentLocale(), fullScope].join(this.defaultSeparator); - - return '[missing "' + fullScopeWithLocale + '" translation]'; - }; - - // Return a missing placeholder message for given parameters - I18n.missingPlaceholder = function(placeholder, message, options) { - return "[missing " + placeholder + " value]"; - }; - - I18n.nullPlaceholder = function() { - return I18n.missingPlaceholder.apply(I18n, arguments); - }; - - // Format number using localization rules. - // The options will be retrieved from the `number.format` scope. - // If this isn't present, then the following options will be used: - // - // - `precision`: `3` - // - `separator`: `"."` - // - `delimiter`: `","` - // - `strip_insignificant_zeros`: `false` - // - // You can also override these options by providing the `options` argument. - // - I18n.toNumber = function(number, options) { - options = this.prepareOptions( - options - , this.lookup("number.format") - , NUMBER_FORMAT - ); - - var negative = number < 0 - , string = toFixed(Math.abs(number), options.precision).toString() - , parts = string.split(".") - , precision - , buffer = [] - , formattedNumber - , format = options.format || "%n" - , sign = negative ? "-" : "" - ; - - number = parts[0]; - precision = parts[1]; - - while (number.length > 0) { - buffer.unshift(number.substr(Math.max(0, number.length - 3), 3)); - number = number.substr(0, number.length -3); - } - - formattedNumber = buffer.join(options.delimiter); - - if (options.strip_insignificant_zeros && precision) { - precision = precision.replace(/0+$/, ""); - } - - if (options.precision > 0 && precision) { - formattedNumber += options.separator + precision; - } - - if (options.sign_first) { - format = "%s" + format; - } - else { - format = format.replace("%n", "%s%n"); - } - - formattedNumber = format - .replace("%u", options.unit) - .replace("%n", formattedNumber) - .replace("%s", sign) - ; - - return formattedNumber; - }; - - // Format currency with localization rules. - // The options will be retrieved from the `number.currency.format` and - // `number.format` scopes, in that order. - // - // Any missing option will be retrieved from the `I18n.toNumber` defaults and - // the following options: - // - // - `unit`: `"$"` - // - `precision`: `2` - // - `format`: `"%u%n"` - // - `delimiter`: `","` - // - `separator`: `"."` - // - // You can also override these options by providing the `options` argument. - // - I18n.toCurrency = function(number, options) { - options = this.prepareOptions( - options - , this.lookup("number.currency.format") - , this.lookup("number.format") - , CURRENCY_FORMAT - ); - - return this.toNumber(number, options); - }; - - // Localize several values. - // You can provide the following scopes: `currency`, `number`, or `percentage`. - // If you provide a scope that matches the `/^(date|time)/` regular expression - // then the `value` will be converted by using the `I18n.toTime` function. - // - // It will default to the value's `toString` function. - // - I18n.localize = function(scope, value, options) { - options || (options = {}); - - switch (scope) { - case "currency": - return this.toCurrency(value); - case "number": - scope = this.lookup("number.format"); - return this.toNumber(value, scope); - case "percentage": - return this.toPercentage(value); - default: - var localizedValue; - - if (scope.match(/^(date|time)/)) { - localizedValue = this.toTime(scope, value); - } else { - localizedValue = value.toString(); - } - - return this.interpolate(localizedValue, options); - } - }; - - // Parse a given `date` string into a JavaScript Date object. - // This function is time zone aware. - // - // The following string formats are recognized: - // - // yyyy-mm-dd - // yyyy-mm-dd[ T]hh:mm::ss - // yyyy-mm-dd[ T]hh:mm::ss - // yyyy-mm-dd[ T]hh:mm::ssZ - // yyyy-mm-dd[ T]hh:mm::ss+0000 - // yyyy-mm-dd[ T]hh:mm::ss+00:00 - // yyyy-mm-dd[ T]hh:mm::ss.123Z - // - I18n.parseDate = function(date) { - var matches, convertedDate, fraction; - // we have a date, so just return it. - if (typeof(date) == "object") { - return date; - }; - - matches = date.toString().match(/(\d{4})-(\d{2})-(\d{2})(?:[ T](\d{2}):(\d{2}):(\d{2})([\.,]\d{1,3})?)?(Z|\+00:?00)?/); - - if (matches) { - for (var i = 1; i <= 6; i++) { - matches[i] = parseInt(matches[i], 10) || 0; - } - - // month starts on 0 - matches[2] -= 1; - - fraction = matches[7] ? 1000 * ("0" + matches[7]) : null; - - if (matches[8]) { - convertedDate = new Date(Date.UTC(matches[1], matches[2], matches[3], matches[4], matches[5], matches[6], fraction)); - } else { - convertedDate = new Date(matches[1], matches[2], matches[3], matches[4], matches[5], matches[6], fraction); - } - } else if (typeof(date) == "number") { - // UNIX timestamp - convertedDate = new Date(); - convertedDate.setTime(date); - } else if (date.match(/([A-Z][a-z]{2}) ([A-Z][a-z]{2}) (\d+) (\d+:\d+:\d+) ([+-]\d+) (\d+)/)) { - // This format `Wed Jul 20 13:03:39 +0000 2011` is parsed by - // webkit/firefox, but not by IE, so we must parse it manually. - convertedDate = new Date(); - convertedDate.setTime(Date.parse([ - RegExp.$1, RegExp.$2, RegExp.$3, RegExp.$6, RegExp.$4, RegExp.$5 - ].join(" "))); - } else if (date.match(/\d+ \d+:\d+:\d+ [+-]\d+ \d+/)) { - // a valid javascript format with timezone info - convertedDate = new Date(); - convertedDate.setTime(Date.parse(date)); - } else { - // an arbitrary javascript string - convertedDate = new Date(); - convertedDate.setTime(Date.parse(date)); - } - - return convertedDate; - }; - - // Formats time according to the directives in the given format string. - // The directives begins with a percent (%) character. Any text not listed as a - // directive will be passed through to the output string. - // - // The accepted formats are: - // - // %a - The abbreviated weekday name (Sun) - // %A - The full weekday name (Sunday) - // %b - The abbreviated month name (Jan) - // %B - The full month name (January) - // %c - The preferred local date and time representation - // %d - Day of the month (01..31) - // %-d - Day of the month (1..31) - // %H - Hour of the day, 24-hour clock (00..23) - // %-H - Hour of the day, 24-hour clock (0..23) - // %I - Hour of the day, 12-hour clock (01..12) - // %-I - Hour of the day, 12-hour clock (1..12) - // %m - Month of the year (01..12) - // %-m - Month of the year (1..12) - // %M - Minute of the hour (00..59) - // %-M - Minute of the hour (0..59) - // %p - Meridian indicator (AM or PM) - // %S - Second of the minute (00..60) - // %-S - Second of the minute (0..60) - // %w - Day of the week (Sunday is 0, 0..6) - // %y - Year without a century (00..99) - // %-y - Year without a century (0..99) - // %Y - Year with century - // %z - Timezone offset (+0545) - // - I18n.strftime = function(date, format) { - var options = this.lookup("date") - , meridianOptions = I18n.meridian() - ; - - if (!options) { - options = {}; - } - - options = this.prepareOptions(options, DATE); - - var weekDay = date.getDay() - , day = date.getDate() - , year = date.getFullYear() - , month = date.getMonth() + 1 - , hour = date.getHours() - , hour12 = hour - , meridian = hour > 11 ? 1 : 0 - , secs = date.getSeconds() - , mins = date.getMinutes() - , offset = date.getTimezoneOffset() - , absOffsetHours = Math.floor(Math.abs(offset / 60)) - , absOffsetMinutes = Math.abs(offset) - (absOffsetHours * 60) - , timezoneoffset = (offset > 0 ? "-" : "+") + - (absOffsetHours.toString().length < 2 ? "0" + absOffsetHours : absOffsetHours) + - (absOffsetMinutes.toString().length < 2 ? "0" + absOffsetMinutes : absOffsetMinutes) - ; - - if (hour12 > 12) { - hour12 = hour12 - 12; - } else if (hour12 === 0) { - hour12 = 12; - } - - format = format.replace("%a", options.abbr_day_names[weekDay]); - format = format.replace("%A", options.day_names[weekDay]); - format = format.replace("%b", options.abbr_month_names[month]); - format = format.replace("%B", options.month_names[month]); - format = format.replace("%d", padding(day)); - format = format.replace("%e", day); - format = format.replace("%-d", day); - format = format.replace("%H", padding(hour)); - format = format.replace("%-H", hour); - format = format.replace("%I", padding(hour12)); - format = format.replace("%-I", hour12); - format = format.replace("%m", padding(month)); - format = format.replace("%-m", month); - format = format.replace("%M", padding(mins)); - format = format.replace("%-M", mins); - format = format.replace("%p", meridianOptions[meridian]); - format = format.replace("%S", padding(secs)); - format = format.replace("%-S", secs); - format = format.replace("%w", weekDay); - format = format.replace("%y", padding(year)); - format = format.replace("%-y", padding(year).replace(/^0+/, "")); - format = format.replace("%Y", year); - format = format.replace("%z", timezoneoffset); - - return format; - }; - - // Convert the given dateString into a formatted date. - I18n.toTime = function(scope, dateString) { - var date = this.parseDate(dateString) - , format = this.lookup(scope) - ; - - if (date.toString().match(/invalid/i)) { - return date.toString(); - } - - if (!format) { - return date.toString(); - } - - return this.strftime(date, format); - }; - - // Convert a number into a formatted percentage value. - I18n.toPercentage = function(number, options) { - options = this.prepareOptions( - options - , this.lookup("number.percentage.format") - , this.lookup("number.format") - , PERCENTAGE_FORMAT - ); - - return this.toNumber(number, options); - }; - - // Convert a number into a readable size representation. - I18n.toHumanSize = function(number, options) { - var kb = 1024 - , size = number - , iterations = 0 - , unit - , precision - ; - - while (size >= kb && iterations < 4) { - size = size / kb; - iterations += 1; - } - - if (iterations === 0) { - unit = this.t("number.human.storage_units.units.byte", {count: size}); - precision = 0; - } else { - unit = this.t("number.human.storage_units.units." + SIZE_UNITS[iterations]); - precision = (size - Math.floor(size) === 0) ? 0 : 1; - } - - options = this.prepareOptions( - options - , {unit: unit, precision: precision, format: "%n%u", delimiter: ""} - ); - - return this.toNumber(size, options); - }; - - I18n.getFullScope = function(scope, options) { - options = this.prepareOptions(options); - - // Deal with the scope as an array. - if (scope.constructor === Array) { - scope = scope.join(this.defaultSeparator); - } - - // Deal with the scope option provided through the second argument. - // - // I18n.t('hello', {scope: 'greetings'}); - // - if (options.scope) { - scope = [options.scope, scope].join(this.defaultSeparator); - } - - return scope; - }; - /** - * Merge obj1 with obj2 (shallow merge), without modifying inputs - * @param {Object} obj1 - * @param {Object} obj2 - * @returns {Object} Merged values of obj1 and obj2 - * - * In order to support ES3, `Object.prototype.hasOwnProperty.call` is used - * Idea is from: - * https://stackoverflow.com/questions/8157700/object-has-no-hasownproperty-method-i-e-its-undefined-ie8 - */ - I18n.extend = function ( obj1, obj2 ) { - var extended = {}; - var prop; - for (prop in obj1) { - if (Object.prototype.hasOwnProperty.call(obj1, prop)) { - extended[prop] = obj1[prop]; - } - } - for (prop in obj2) { - if (Object.prototype.hasOwnProperty.call(obj2, prop)) { - extended[prop] = obj2[prop]; - } - } - return extended; - }; - - // Set aliases, so we can save some typing. - I18n.t = I18n.translate; - I18n.l = I18n.localize; - I18n.p = I18n.pluralize; - - return I18n; -}));