diff --git a/app/controllers/survey/questions_controller.rb b/app/controllers/survey/questions_controller.rb index b7cbad3..e6a96ce 100644 --- a/app/controllers/survey/questions_controller.rb +++ b/app/controllers/survey/questions_controller.rb @@ -33,6 +33,7 @@ class Survey::QuestionsController < ApplicationController @template = Survey::Question.find(params[:id]) parent= params[:parent_type].constantize.find(params[:parent_id]) @survey_question = @template.copy_from_template_for(parent) + @survey_question.user=current_user render action: :show end @@ -64,7 +65,7 @@ class Survey::QuestionsController < ApplicationController # POST /survey/questions.json def create @survey_question = Survey::Question.new(params[:survey_question]) - + @survey_question.user=current_user respond_to do |format| if @survey_question.save format.html { redirect_to @survey_question, notice: 'Question was successfully created.' } @@ -78,7 +79,8 @@ class Survey::QuestionsController < ApplicationController # PUT /survey/questions/1.json def update @survey_question = Survey::Question.find(params[:id]) - + @survey_question.user=current_user + @survey_question.save respond_to do |format| if @survey_question.update_attributes(params[:survey_question]) format.html { redirect_to @survey_question, notice: 'Question was successfully updated.' } diff --git a/app/models/ability.rb b/app/models/ability.rb index 324c256..6dfe69d 100755 --- a/app/models/ability.rb +++ b/app/models/ability.rb @@ -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 diff --git a/app/models/survey/question.rb b/app/models/survey/question.rb index 26ad1b3..9500d05 100644 --- a/app/models/survey/question.rb +++ b/app/models/survey/question.rb @@ -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 diff --git a/app/views/lvas/show.html.erb b/app/views/lvas/show.html.erb index ce4a8e8..d4cb37f 100755 --- a/app/views/lvas/show.html.erb +++ b/app/views/lvas/show.html.erb @@ -1,10 +1,12 @@ <%= content_for :header do %> -
<%= I18n.t("lva.ratebsp")%> <%= link_to ffi1_icon("facebook1") + I18n.t('home.fblogin'), user_omniauth_authorize_path(:facebook) ,class: :linkbox %> -
- <%= link_to t("beispiel.zip") , beispiel_sammlung_lva_path(@lva), class: :linkbox %> - <% @beispiele_all.each do |b| %> - <% cache("beispiel_" +I18n.locale.to_s+b.id.to_s+can?(:delete,b).to_s+"_"+can?(:edit,b).to_s + "_" + can?(:flag, b).to_s + "_" + can?(:like, b).to_s + "_" + b.updated_at.try(:utc).try(:to_s) + get_theme_help(current_user).to_s) do %> - <%= render b%> - <% end %> - <% end %> +<%= I18n.t("lva.ratebsp")%> <%= link_to ffi1_icon("facebook1") + I18n.t('home.fblogin'), user_omniauth_authorize_path(:facebook) ,class: :linkbox %> +
+ <%= link_to t("beispiel.zip") , beispiel_sammlung_lva_path(@lva), class: :linkbox %> + <% @beispiele_all.each do |b| %> + <% cache("beispiel_" +I18n.locale.to_s+b.id.to_s+can?(:delete,b).to_s+"_"+can?(:edit,b).to_s + "_" + can?(:flag, b).to_s+ can?(:comment, b).to_s + "_" + can?(:like, b).to_s + "_" + b.updated_at.try(:utc).try(:to_s) + get_theme_help(current_user).to_s) do %> + <%= render b%> + <% end %> + <% end %>