diff --git a/app/controllers/comments_controller.rb b/app/controllers/comments_controller.rb index c3b6a2c..fb3a87c 100644 --- a/app/controllers/comments_controller.rb +++ b/app/controllers/comments_controller.rb @@ -51,7 +51,7 @@ end authorize! :comment, c @comment = Comment.build_for(c, current_user,"", params_new) - + @commentable=c if @comment.parent_object.class==Comment @comments= @comment.parent_object.children else diff --git a/app/controllers/lvas_controller.rb b/app/controllers/lvas_controller.rb index 234cf3a..137bc89 100755 --- a/app/controllers/lvas_controller.rb +++ b/app/controllers/lvas_controller.rb @@ -16,16 +16,11 @@ class LvasController < ApplicationController end def beispiel_sammlung @lva = Lva.find_by_id(params[:id]) - #Attachment name filename = 'beispiel_sammlung_' + @lva.lvanr.to_s + '_' + l(Date.today).to_s + '.zip' temp_file = Tempfile.new(filename) begin - #This is the tricky part - #Initialize the temp file as a zip file Zip::OutputStream.open(temp_file) { |zos| } - #Add files to the zip file as usual Zip::File.open(temp_file.path, Zip::File::CREATE) do |zip| - #Put files in here i=1 @lva.beispiele.each do |bsp| zip.add(i.to_s + '_' + File.basename(bsp.beispieldatei.current_path), bsp.beispieldatei.current_path) @@ -53,29 +48,26 @@ class LvasController < ApplicationController @beispiele_deleted = @lva.beispiele.flag_delete.order(:datum).accessible_by(current_ability, :show) @toolbar_elements =[] @toolbar_elements<<{:hicon=>'icon-pencil', :icon=>:pencil,:text =>I18n.t('common.manage'),:path => verwalten_lva_path(@lva)} if can? :verwalten, @lva - @crawlobjects = @lva.crawlobjects.roots.accessible_by(current_ability) + @crawlobjects = @lva.crawlobjects.roots.accessible_by(current_ability) + @questions=@lva.questions.accessible_by(current_ability,:show) end + def verwalten @lva = Lva.find_by_id(params[:id]) @beispiel=Beispiel.new - @beispiele_all=@lva.beispiele.order(:datum).accessible_by(current_ability, :show) + @beispiele_all=@lva.beispiele.order(:datum).accessible_by(current_ability, :show) @beispiele = @lva.beispiele.not_flag_badquality.not_flag_delete.order(:lecturer_id,:datum).accessible_by(current_ability, :show) @beispiele_badQ = @lva.beispiele.flag_badquality.not_flag_delete.order(:datum).accessible_by(current_ability, :show) @beispiele_deleted = @lva.beispiele.flag_delete.order(:datum).accessible_by(current_ability, :show) - render :show end - # GET /lvas/new - # GET /lvas/new.json def new @lva = Lva.new modul=Modul.find_by_id(params[:modul_id]) @lva.modul<'icon-pencil', :icon=>:pencil,:text =>I18n.t('common.edit'),:path => edit_lva_path(@lva)} if can? :edit, @lva @toolbar_elements << {:hicon=>'icon-remove-circle', :text=>"Tissvergleichladen", :path=> compare_tiss_lva_path(@lva)} if can? :compare_tiss, @lva @toolbar_elements << {:hicon=>'icon-remove-circle', :text=>I18n.t('lva.delete'), :path=> lva_path(@lva), :method=>:delete, :confirm=>t('lva.deletesure') } if can? :delete, @lva - - - - end end diff --git a/app/models/lva.rb b/app/models/lva.rb index c6e95be..f9e76b1 100755 --- a/app/models/lva.rb +++ b/app/models/lva.rb @@ -48,6 +48,8 @@ class Lva < ActiveRecord::Base has_and_belongs_to_many :lecturers has_many :nlinks, as: :link has_many :crawlobjects, :as=>:something + has_many :questions, :class_name=>"Survey::Question", as: :parent + # scope :search, ->(query) {where("name like ? or lvas.desc like ?", "%#{query}%", "%#{query}%")} validates :lvanr,:format=>{ :with => /^[0-9][0-9][0-9]\.[0-9A][0-9][0-9]$/}, :presence=>true, :uniqueness=>true # , :uniqueness=>true # LVA-Nummer muss das Format 000.000 besitzen (uniqueness?) oder 000 für nicht diff --git a/app/views/neuigkeiten/show.html.erb b/app/views/neuigkeiten/show.html.erb index f1a740d..d63d433 100755 --- a/app/views/neuigkeiten/show.html.erb +++ b/app/views/neuigkeiten/show.html.erb @@ -38,7 +38,7 @@

<%= render partial: "neuigkeit_view", object: @neuigkeit %> - +<%= new_question_for(@neuigkeit) if can? :new, Survey::Question %> <% @questions.each do |q| %> <%= render q if can? :show, q %> <% end %> diff --git a/app/views/survey/questions/_answeredquestion.html.erb b/app/views/survey/questions/_answeredquestion.html.erb index 4060bfa..f663bc6 100644 --- a/app/views/survey/questions/_answeredquestion.html.erb +++ b/app/views/survey/questions/_answeredquestion.html.erb @@ -1,6 +1,8 @@
- <%= answeredquestion.title%> + + <%= answeredquestion.title%> +
    <% answeredquestion.choices.each do |c| %>
  • diff --git a/app/views/survey/questions/_new_question.html.erb b/app/views/survey/questions/_new_question.html.erb index 9d5d65f..8094fa6 100644 --- a/app/views/survey/questions/_new_question.html.erb +++ b/app/views/survey/questions/_new_question.html.erb @@ -4,13 +4,13 @@
diff --git a/app/views/themes/blue2/lvas/show.html.erb b/app/views/themes/blue2/lvas/show.html.erb index 2ca1903..d134c54 100755 --- a/app/views/themes/blue2/lvas/show.html.erb +++ b/app/views/themes/blue2/lvas/show.html.erb @@ -44,6 +44,7 @@ <%= @lva.desc.to_s.html_safe %>
+
@@ -80,6 +81,10 @@
+ <%= new_question_for(@lva) %> + <% @questions.each do |q| %> + <%= render q if can? :show, q %> + <% end %>

<%= I18n.t("lva.bspe") %>

@@ -115,6 +120,7 @@

+ <% unless @lva.nlinks.empty? %>

<%= I18n.t("rubrik.title") %>

<% @lva.nlinks.each do |l| %> @@ -132,6 +138,7 @@
<% end %> + <% unless @crawlobjects.nil? %>