forked from bofh/fetsite
AutoCommit Mon Aug 10 13:03:04 CEST 2015
This commit is contained in:
@@ -33,6 +33,7 @@ class Survey::QuestionsController < ApplicationController
|
|||||||
@template = Survey::Question.find(params[:id])
|
@template = Survey::Question.find(params[:id])
|
||||||
parent= params[:parent_type].constantize.find(params[:parent_id])
|
parent= params[:parent_type].constantize.find(params[:parent_id])
|
||||||
@survey_question = @template.copy_from_template_for(parent)
|
@survey_question = @template.copy_from_template_for(parent)
|
||||||
|
@survey_question.user=current_user
|
||||||
render action: :show
|
render action: :show
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -64,7 +65,7 @@ class Survey::QuestionsController < ApplicationController
|
|||||||
# POST /survey/questions.json
|
# POST /survey/questions.json
|
||||||
def create
|
def create
|
||||||
@survey_question = Survey::Question.new(params[:survey_question])
|
@survey_question = Survey::Question.new(params[:survey_question])
|
||||||
|
@survey_question.user=current_user
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
if @survey_question.save
|
if @survey_question.save
|
||||||
format.html { redirect_to @survey_question, notice: 'Question was successfully created.' }
|
format.html { redirect_to @survey_question, notice: 'Question was successfully created.' }
|
||||||
@@ -78,7 +79,8 @@ class Survey::QuestionsController < ApplicationController
|
|||||||
# PUT /survey/questions/1.json
|
# PUT /survey/questions/1.json
|
||||||
def update
|
def update
|
||||||
@survey_question = Survey::Question.find(params[:id])
|
@survey_question = Survey::Question.find(params[:id])
|
||||||
|
@survey_question.user=current_user
|
||||||
|
@survey_question.save
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
if @survey_question.update_attributes(params[:survey_question])
|
if @survey_question.update_attributes(params[:survey_question])
|
||||||
format.html { redirect_to @survey_question, notice: 'Question was successfully updated.' }
|
format.html { redirect_to @survey_question, notice: 'Question was successfully updated.' }
|
||||||
|
|||||||
@@ -11,10 +11,17 @@ class Ability
|
|||||||
end
|
end
|
||||||
user ||= User.new # guest user (not logged in)
|
user ||= User.new # guest user (not logged in)
|
||||||
|
|
||||||
can :manage, Survey::Question
|
if( user.has_role?("fetuser") || user.has_role?("fetadmin"))
|
||||||
can :manage, Survey::Choice
|
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
|
can :manage, Survey::Answer
|
||||||
|
end
|
||||||
|
if user.has_role?("fetadmin")
|
||||||
|
can [:delete,:flag_template], Survey::Question
|
||||||
|
end
|
||||||
#---------------------------------------------------
|
#---------------------------------------------------
|
||||||
|
|
||||||
can [:index,:hide], Comment
|
can [:index,:hide], Comment
|
||||||
|
|||||||
@@ -5,11 +5,11 @@ class Survey::Question < ActiveRecord::Base
|
|||||||
has_many :choices, dependent: :destroy, class_name: "Survey::Choice"
|
has_many :choices, dependent: :destroy, class_name: "Survey::Choice"
|
||||||
has_many :answers, through: :choices
|
has_many :answers, through: :choices
|
||||||
include IsCommentable
|
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?"}
|
FLAG_CONFIRM={"delete"=> "Sicher loeschen?"}
|
||||||
scope :templates, ->{ where(flag_template: true)}
|
scope :templates, ->{ where(flag_template: true)}
|
||||||
acts_as_flagable
|
acts_as_flagable
|
||||||
|
belongs_to :user
|
||||||
def copy_from_template_for(parent)
|
def copy_from_template_for(parent)
|
||||||
unless self.flag_template
|
unless self.flag_template
|
||||||
return nil
|
return nil
|
||||||
|
|||||||
@@ -1,10 +1,12 @@
|
|||||||
<%= content_for :header do %>
|
<%= content_for :header do %>
|
||||||
<title>Fetsite - <%= @lva.full_name %></title>
|
<title>Fetsite - <%= @lva.full_name %></title>
|
||||||
<% set_meta_tags :og => {
|
<% set_meta_tags :og => {
|
||||||
:url=>lva_path(:theme=>nil) }
|
:url=>lva_path(:theme=>nil)
|
||||||
%>
|
}
|
||||||
<%= display_meta_tags %>
|
%>
|
||||||
|
<%= display_meta_tags %>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
<div itemscope itemtype="schema.org/Article" >
|
<div itemscope itemtype="schema.org/Article" >
|
||||||
<div class="container-fluid">
|
<div class="container-fluid">
|
||||||
<%= render 'studien/tabs'%>
|
<%= render 'studien/tabs'%>
|
||||||
@@ -15,7 +17,6 @@
|
|||||||
<%= render 'layouts/pretty_toolbar' %>
|
<%= render 'layouts/pretty_toolbar' %>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="row-fluid">
|
<div class="row-fluid">
|
||||||
<div class="span8">
|
<div class="span8">
|
||||||
<h1 itemprop="name"><%= @lva.full_name %></h1>
|
<h1 itemprop="name"><%= @lva.full_name %></h1>
|
||||||
@@ -58,12 +59,10 @@
|
|||||||
<li><b><%= link_to modul.name , modul_path(modul)%></b>
|
<li><b><%= link_to modul.name , modul_path(modul)%></b>
|
||||||
<ul>
|
<ul>
|
||||||
<% modul.modulgruppen.each do |g| %>
|
<% modul.modulgruppen.each do |g| %>
|
||||||
|
|
||||||
<li><%= link_to g.studium.title_context , studium_path(g.studium)%> (<%=link_to g.name, modulgruppe_path(g)%>)</li>
|
<li><%= link_to g.studium.title_context , studium_path(g.studium)%> (<%=link_to g.name, modulgruppe_path(g)%>)</li>
|
||||||
<% end %>
|
<% end %>
|
||||||
</ul>
|
</ul>
|
||||||
</li>
|
</li>
|
||||||
|
|
||||||
<% end %>
|
<% end %>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
@@ -71,13 +70,10 @@
|
|||||||
<h2> <%= I18n.t "lecturers.lecturers" %> </h2>
|
<h2> <%= I18n.t "lecturers.lecturers" %> </h2>
|
||||||
<% @lva.lecturers.each do |lec| %>
|
<% @lva.lecturers.each do |lec| %>
|
||||||
<%= render :partial=>'lecturers/lec_lva', :object=>lec %>
|
<%= render :partial=>'lecturers/lec_lva', :object=>lec %>
|
||||||
|
|
||||||
<% end %>
|
<% end %>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
<div class="row-fluid">
|
<div class="row-fluid">
|
||||||
<div class="span12">
|
<div class="span12">
|
||||||
|
|
||||||
@@ -86,7 +82,7 @@
|
|||||||
</p>
|
</p>
|
||||||
<%= link_to t("beispiel.zip") , beispiel_sammlung_lva_path(@lva), class: :linkbox %>
|
<%= link_to t("beispiel.zip") , beispiel_sammlung_lva_path(@lva), class: :linkbox %>
|
||||||
<% @beispiele_all.each do |b| %>
|
<% @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 %>
|
<% 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%>
|
<%= render b%>
|
||||||
<% end %>
|
<% end %>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
<%= div_tag_for(choice) do %>
|
<%= div_tag_for(choice) do %>
|
||||||
|
|
||||||
<%
|
<%
|
||||||
if current_user.nil?
|
unless can?(:answer,choice.question)
|
||||||
t=choice.text
|
t=choice.text
|
||||||
else
|
else
|
||||||
value=(current_user.id.nil?)? false : choice.answers.where(user_id: current_user.id).count>0
|
value=(current_user.id.nil?)? false : choice.answers.where(user_id: current_user.id).count>0
|
||||||
@@ -13,7 +13,7 @@ end
|
|||||||
%>
|
%>
|
||||||
|
|
||||||
|
|
||||||
<%= t %> <%= link_to fa_icon("pencil"), edit_survey_choice_path(choice) , class: "btn btn-link navbar-btn" , remote: true
|
<%= t %> <%= link_to fa_icon("pencil"), edit_survey_choice_path(choice) , class: "btn btn-link navbar-btn" , remote: true if can? :edit, choice
|
||||||
%>
|
%>
|
||||||
<%= link_to fa_icon("trash"), survey_choice_path(choice) , class: "btn btn-link navbar-btn" , remote: true , method: :delete, data: { confirm: 'Are you sure?' } %>
|
<%= link_to fa_icon("trash"), survey_choice_path(choice) , class: "btn btn-link navbar-btn" , remote: true , method: :delete, data: { confirm: 'Are you sure?' } if can? :delete,choice %>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
<% if current_user.nil? %>
|
<% unless can?(:answer,question) %>
|
||||||
<%= div_tag_for(question) do%>
|
<%= div_tag_for(question) do%>
|
||||||
<%= render partial: "survey/questions/answeredquestion", object: question unless question.flag_delete%>
|
<%= render partial: "survey/questions/answeredquestion", object: question unless question.flag_delete%>
|
||||||
<% end %>
|
<% end %>
|
||||||
@@ -7,16 +7,19 @@
|
|||||||
<div >
|
<div >
|
||||||
<b><%= question.title%></b>
|
<b><%= question.title%></b>
|
||||||
<%= question.text %>
|
<%= question.text %>
|
||||||
<%= link_to fa_icon("pencil"), edit_survey_question_path(question) , class: "btn btn-link navbar-btn" , remote: true %>
|
<%= link_to fa_icon("pencil"), edit_survey_question_path(question) , class: "btn btn-link navbar-btn" , remote: true if can? :edit, question %>
|
||||||
<%= flag_link(question, "delete")%>
|
|
||||||
<%= flag_link(question, "template")%>
|
<%= flag_link(question, "locked") %>
|
||||||
|
|
||||||
|
<%= flag_link(question, "template") %>
|
||||||
|
<%= flag_link(question, "delete") %>
|
||||||
<% unless question.flag_delete %>
|
<% unless question.flag_delete %>
|
||||||
<ul class="choice-list">
|
<ul class="choice-list">
|
||||||
<% question.choices.each do |c| %>
|
<% question.choices.each do |c| %>
|
||||||
<li><%= render c %></li>
|
<li><%= render c %></li>
|
||||||
<% end %>
|
<% end %>
|
||||||
</ul>
|
</ul>
|
||||||
<%= link_to "+" , new_survey_choice_path(params:{question_id: question.id}), remote: true%>
|
<%= link_to "+" , new_survey_choice_path(params:{question_id: question.id}), remote: true if can? :edit, question %>
|
||||||
<% end %>
|
<% end %>
|
||||||
</div>
|
</div>
|
||||||
<%= render partial: "survey/questions/answeredquestion", object: question if question.answers.where(user_id: current_user.id).count>0 unless question.flag_delete %>
|
<%= render partial: "survey/questions/answeredquestion", object: question if question.answers.where(user_id: current_user.id).count>0 unless question.flag_delete %>
|
||||||
|
|||||||
Reference in New Issue
Block a user