diff --git a/public/html/Ability.html b/public/html/Ability.html deleted file mode 100644 index d808822..0000000 --- a/public/html/Ability.html +++ /dev/null @@ -1,388 +0,0 @@ - - - -
- - -# 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-
Arbre::HTML::Document - -
lib/active_admin_views_pages_base.rb
- -ActiveRecord::Base - -
ActiveRecord::Base - -
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-
ActionController::Base - -
# File app/controllers/application_controller.rb, line 32 -def after_sign_in_error_path_for(resource) - session[:previous_url] || root_path -end-
# File app/controllers/application_controller.rb, line 24 -def after_sign_in_path_for(resource) - session[:previous_url] || root_path -end-
# File app/controllers/application_controller.rb, line 36 -def after_sign_up_error_path_for(resource) - session[:previous_url] || root_path -end-
# File app/controllers/application_controller.rb, line 28 -def after_sign_up_path_for(resource) - session[:previous_url] || root_path -end-
# 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-
# 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-
# 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-
# File app/helpers/application_helper.rb, line 10 -def devise_mapping - @devise_mapping ||= Devise.mappings[:user] -end-
# File app/helpers/application_helper.rb, line 14 -def javascript(*files) - content_for(:head) { javascript_include_tag(*files) } -end-
# File app/helpers/application_helper.rb, line 19 - def link_to_add_object(name, f, association, css_class, i) - new_object = f.object.class.reflect_on_association(association).klass.new - fields = f.fields_for(association, new_object, :child_index => "new_#{association}") do |builder| - j = i + 1 - new_object.number = j - render(association.to_s.singularize + "_fields", :f => builder) - end - link_to_function(name, "add_object(this, \"#{association}\", \"#{escape_javascript(fields)}\")", :class => css_class) -end-
# File app/helpers/application_helper.rb, line 6 -def resource - @resource ||= User.new -end-
# File app/helpers/application_helper.rb, line 2 -def resource_name - :user -end-
ActiveRecord::Base - -
# File app/models/comment.rb, line 11 -def to_s - "#{text}" -end-
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-
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-
GET /comments/1/edit
- - - -# File app/controllers/comments_controller.rb, line 26 -def edit - @comment = Comment.find(params[:id]) -end-
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-
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-
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-
Devise::ConfirmationsController - -
# File app/controllers/confirmations_controller.rb, line 5 -def after_confirmation_path_for(resource_name, resource) - root_path -end-
ContactUs::ContactsController - -
# 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-
Devise::FailureApp - -
# File lib/custom_failure.rb, line 2 -def redirect_url - root_path -end-
# File lib/custom_failure.rb, line 6 -def respond - if http_auth? - http_auth - else - redirect - end -end-
Rails::Application - -
ActiveRecord::Base - -
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-
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-
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-
# 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-
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-
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-
# File app/models/dmptemplate.rb, line 82 -def org_type - org_type = organisation.organisation_type.name - return org_type -end-
# File app/models/dmptemplate.rb, line 28 -def to_s - "#{title}" -end-
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
-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-
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-
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-
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-
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-
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-
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-
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-
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-
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-
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-
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-
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-
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-
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-
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-
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-
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-
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-
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-
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-
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-
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-
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-
# File app/controllers/existing_users_controller.rb, line 2 -def index - @email = params[:email] -end-
ActiveRecord::Base - -
# File app/models/exported_plan.rb, line 71 -def admin_details - @admin_details ||= self.settings(:export).fields[:admin] -end-
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-
# 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-
# 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-
# File app/models/exported_plan.rb, line 30 -def grant_title - self.plan.project.grant_number -end-
# File app/models/exported_plan.rb, line 51 -def institution - plan.project.organisation.try(:name) -end-
# File app/models/exported_plan.rb, line 34 -def principal_investigator - self.plan.project.principal_investigator -end-
# File app/models/exported_plan.rb, line 38 -def project_data_contact - self.plan.project.data_contact -end-
# File app/models/exported_plan.rb, line 42 -def project_description - self.plan.project.description -end-
# File app/models/exported_plan.rb, line 26 -def project_identifier - self.plan.project.identifier -end-
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-
# File app/models/exported_plan.rb, line 67 -def questions_for_section(section_id) - questions.where(section_id: section_id) -end-
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-
# 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-
# File app/models/exported_plan.rb, line 135 -def sanitize_text(text) - if (!text.nil?) then ActionView::Base.full_sanitizer.sanitize(text.gsub(/ /,"")) end -end-
ActiveRecord::Base - -
ActiveRecord::Base - -
ActiveRecord::Base - -
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
-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-
# 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-
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-
ActiveRecord::Base - -
# 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-
# 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-
# File app/models/guidance_group.rb, line 16 -def to_s - "#{display_name}" -end-
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-
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-
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-
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-
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-
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-
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-
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-
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-
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-
# 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-
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-
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-
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-
# 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-
# 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-
# 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-
# File app/controllers/home_controller.rb, line 13 -def about_us -end-
# 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-
BasicObject - -
# File app/admin/user.rb, line 118 -def scoped_collection - resource_class.includes(:organisations) # prevents N+1 queries to your database - -end-
ActiveRecord::Base - -
# File app/models/option.rb, line 12 -def to_s - "#{text}" -end-
ActiveRecord::Base - -
# File app/models/option_warning.rb, line 9 -def to_s - "#{text}" -end-
ActiveRecord::Base - -
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-
# 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-
# 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-
# 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-
# File app/models/organisation.rb, line 95 -def published_templates - return dmptemplates.find_all_by_published(1) -end-
# File app/models/organisation.rb, line 78 -def root - if parent.nil? - return self - else - return parent.root - end -end-
# File app/models/organisation.rb, line 26 -def short_name - if abbreviation.nil? then - return name - else - return abbreviation - end -end-
# File app/models/organisation.rb, line 22 -def to_s - name -end-
# 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-
ActiveRecord::Base - -
# 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-
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-
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-
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-
# 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-
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-
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-
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-
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-
# 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-
# 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-
ActiveRecord::Base - -
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-
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-
GET /pages/1/edit
- - - -# File app/controllers/pages_controller.rb, line 36 -def edit - @page = Page.find(params[:id]) -end-
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-
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-
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-
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-
Devise::PasswordsController - -
# File app/controllers/passwords_controller.rb, line 5 - def after_resetting_password_path_for(resource) - root_path -end-
ActiveRecord::Base - -
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
-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-
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-
# File app/models/phase.rb, line 29 -def latest_version - return versions.order("number DESC").last -end-
# File app/models/phase.rb, line 25 -def to_s - "#{title}" -end-
ActiveRecord::Base - -
# 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-
# File app/models/plan.rb, line 168 -def administerable_by(user_id) - return project.readable_by(user_id) -end-
# 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-
# 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-
# 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-
# File app/models/plan.rb, line 36 -def dmptemplate - self.project.try(:dmptemplate) || Dmptemplate.new -end-
# File app/models/plan.rb, line 156 -def editable_by(user_id) - return project.editable_by(user_id) -end-
# 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-
# 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-
# 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-
# 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-
# 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-
# 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-
# 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-
# 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-
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-
# 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-
# 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-
# 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-
# 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-
# 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-
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-
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-
ActiveRecord::Base - -
# 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-
# 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-
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-
# 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-
# 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-
# 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-
# 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-
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-
# 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-
# 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-
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-
# 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-
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-
# 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-
# 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-
ActiveRecord::Base - -
# 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-
# 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-
# File app/models/project.rb, line 111 -def assign_administrator(user_id) - add_user(user_id, true, true) -end-
# File app/models/project.rb, line 99 -def assign_creator(user_id) - add_user(user_id, true, true, true) -end-
# File app/models/project.rb, line 103 -def assign_editor(user_id) - add_user(user_id, true) -end-
# File app/models/project.rb, line 107 -def assign_reader(user_id) - add_user(user_id) -end-
# 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-
# 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-
# 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-
# 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-
# 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-
# 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-
# 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-
# File app/models/project.rb, line 77 -def institution_id - if organisation.nil? - return nil - else - return organisation.root.id - end -end-
# 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-
# File app/models/project.rb, line 183 -def last_edited - self.latest_update.to_date -end-
# 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-
Getters to match 'My plans' columns
- - - -# File app/models/project.rb, line 175 -def name - self.title -end-
# File app/models/project.rb, line 179 -def owner - self.project_groups.find_by_project_creator(true).try(:user) -end-
# 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-
# File app/models/project.rb, line 193 -def template_owner - self.dmptemplate.try(:organisation).try(:abbreviation) -end-
# 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-
# 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-
# 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-
# 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-
ActiveRecord::Base - -
# 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-
# 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-
# File app/models/project_group.rb, line 9 -def email - unless user.nil? - return user.email - end -end-
# 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-
# 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-
# 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-
# 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-
ActiveRecord::Base - -
ActiveRecord::Base - -
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 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-
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-
# File app/models/question.rb, line 29 - def to_s - "#{text}" -end-
ActiveRecord::Base - -
# File app/models/question_format.rb, line 7 - def to_s - "#{title}" -end-
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
-To help create and maintain different versions of Data Management Plans;
-To provide useful guidance on data management issues and how to meet -research funders' requirements;
-To export attractive and useful plans in a variety of formats;
-To allow collaborative work when creating Data Management Plans.
-You can contact us by email, dmponline@dcc.ac.uk, but we can only provide -limited support for your installation
-Bug Reports & Feature Requests: github.com/DigitalCurationCentre/DMPonline_v4/issues
-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:
-The Getting Started Guide: guides.rubyonrails.org/getting_started.html
-Ruby on Rails Tutorial Book: www.railstutorial.org/
-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.
- -Devise::RegistrationsController - -
app/controllers/registrations_controller.rb
- -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-
# 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-
# 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-
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-
ActiveRecord::Base - -
ActiveRecord::Base - -
# File app/models/section.rb, line 15 -def to_s - "#{title}" -end-
Devise::SessionsController - -
app/controllers/sessions_controller.rb
- -# 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-
# File app/controllers/sessions_controller.rb, line 19 - def destroy - current_user.plan_sections.each do |lock| - lock.delete - - end - super -end-
RailsSettings::SettingObject - -
RailsSettings::SettingObject - -
TODO: can these be taken from somewhere else rather than hard-coded here?
- - -# 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-
# 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-
# File app/controllers/settings/plans_controller.rb, line 43 -def get_settings - @export_settings = plan.settings(:export) -end-
# File app/controllers/settings/plans_controller.rb, line 51 -def plan - @plan ||= Plan.find(params[:id]) -end-
# File app/controllers/settings/plans_controller.rb, line 47 -def settings_json - @settings_json ||= { export: @export_settings }.to_json -end-
# 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-
# 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-
# 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-
# 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-
ActiveRecord::Base - -
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-
# 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-
# File app/controllers/static_pages_controller.rb, line 12 -def contact_us -end-
# File app/controllers/static_pages_controller.rb, line 15 -def roadmap -end-
ActiveRecord::Base - -
# File app/models/suggested_answer.rb, line 11 - def to_s - "#{text}" -end-
ActiveRecord::Base - -
# File app/models/theme.rb, line 15 -def to_s - title -end-
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-
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-
GET /themes/1/edit
- - - -# File app/controllers/themes_controller.rb, line 36 -def edit - @theme = Theme.find(params[:id]) -end-
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-
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-
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-
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-
ActiveRecord::Base - -
# 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-
# 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-
# File app/models/user.rb, line 110 -def can_super_admin? - admin = roles.find_by_name("admin") - return !admin.nil? -end-
# File app/models/user.rb, line 115 -def can_org_admin? - org_admin = roles.find_by_name("org_admin") - return !org_admin.nil? -end-
# 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-
# File app/models/user.rb, line 120 -def org_type - org_type = organisation.organisation_type.name - return org_type -end-
# File app/models/user.rb, line 90 -def organisation - if self.organisations.count > 0 then - return self.organisations.first - else - return nil - end -end-
# File app/models/user.rb, line 106 -def organisation=(new_organisation) - organisation_id = organisation.id -end-
# 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-
# 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-
ActionMailer::Base - -
# 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-
# 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-
# 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-
ActiveRecord::Base - -
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-
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-
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-
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-
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-
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-
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-
ActiveRecord::Base - -
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-
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-
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-
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-
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-
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-
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-
ActiveRecord::Base - -
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-
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-
GET /user_statuses/1/edit
- - - -# File app/controllers/user_statuses_controller.rb, line 36 -def edit - @user_status = UserStatus.find(params[:id]) -end-
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-
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-
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-
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-
ActiveRecord::Base - -
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-
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-
GET /user_types/1/edit
- - - -# File app/controllers/user_types_controller.rb, line 36 -def edit - @user_type = UserType.find(params[:id]) -end-
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-
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-
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-
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-
Devise::OmniauthCallbacksController - -
# 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-
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-
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-
GET /users/1/edit
- - - -# File app/controllers/users_controller.rb, line 25 -def edit - @user = User.find(params[:id]) -end-
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-
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-
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-
ActiveRecord::Base - -
# File app/models/version.rb, line 22 -def global_sections - sections.find_all_by_organisation_id(phase.dmptemplate.organisation_id) -end-
# File app/models/version.rb, line 16 -def to_s - "#{title}" -end-
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
-To help create and maintain different versions of Data Management Plans;
-To provide useful guidance on data management issues and how to meet -research funders' requirements;
-To export attractive and useful plans in a variety of formats;
-To allow collaborative work when creating Data Management Plans.
-You can contact us by email, dmponline@dcc.ac.uk, but we can only provide -limited support for your installation
-Bug Reports & Feature Requests: github.com/DigitalCurationCentre/DMPonline_v4/issues
-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:
-The Getting Started Guide: guides.rubyonrails.org/getting_started.html
-Ruby on Rails Tutorial Book: www.railstutorial.org/
-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.
- -
-
-