AutoCommit Mon Aug 10 13:03:04 CEST 2015

This commit is contained in:
Andreas Stephanides
2015-08-10 13:03:04 +02:00
parent cb73bbfa43
commit 3835c0e773
6 changed files with 115 additions and 107 deletions

View File

@@ -11,10 +11,17 @@ class Ability
end
user ||= User.new # guest user (not logged in)
can :manage, Survey::Question
can :manage, Survey::Choice
can :manage, Survey::Answer
if( user.has_role?("fetuser") || user.has_role?("fetadmin"))
can [:show,:answer, :create,:new, :create_from_template, :flag], Survey::Question
can [:edit, :update, :flag_delete], Survey::Question, :flag_locked=>false
can :flag_locked, Survey::Question, :user_id=>user.id
can [:show,:new], Survey::Choice
can [:edit,:update, :delete,:create], Survey::Choice, :question=>{:flag_locked=>false}
can :manage, Survey::Answer
end
if user.has_role?("fetadmin")
can [:delete,:flag_template], Survey::Question
end
#---------------------------------------------------
can [:index,:hide], Comment

View File

@@ -5,11 +5,11 @@ class Survey::Question < ActiveRecord::Base
has_many :choices, dependent: :destroy, class_name: "Survey::Choice"
has_many :answers, through: :choices
include IsCommentable
FLAG_ICONS={"delete" => "fa fa-trash", "template"=> "ffi1-cleaning1"}
FLAG_ICONS={"delete" => "fa fa-trash", "template"=> "ffi1-cleaning1","locked"=>"fa fa-key"}
FLAG_CONFIRM={"delete"=> "Sicher loeschen?"}
scope :templates, ->{ where(flag_template: true)}
acts_as_flagable
belongs_to :user
def copy_from_template_for(parent)
unless self.flag_template
return nil