AutoCommit Mon Aug 10 20:03:02 CEST 2015

This commit is contained in:
Andreas Stephanides
2015-08-10 20:03:02 +02:00
parent d628d6cee8
commit 2ef0dc7fb8
7 changed files with 26 additions and 28 deletions

View File

@@ -51,7 +51,7 @@ end
authorize! :comment, c authorize! :comment, c
@comment = Comment.build_for(c, current_user,"", params_new) @comment = Comment.build_for(c, current_user,"", params_new)
@commentable=c
if @comment.parent_object.class==Comment if @comment.parent_object.class==Comment
@comments= @comment.parent_object.children @comments= @comment.parent_object.children
else else

View File

@@ -16,16 +16,11 @@ class LvasController < ApplicationController
end end
def beispiel_sammlung def beispiel_sammlung
@lva = Lva.find_by_id(params[:id]) @lva = Lva.find_by_id(params[:id])
#Attachment name
filename = 'beispiel_sammlung_' + @lva.lvanr.to_s + '_' + l(Date.today).to_s + '.zip' filename = 'beispiel_sammlung_' + @lva.lvanr.to_s + '_' + l(Date.today).to_s + '.zip'
temp_file = Tempfile.new(filename) temp_file = Tempfile.new(filename)
begin begin
#This is the tricky part
#Initialize the temp file as a zip file
Zip::OutputStream.open(temp_file) { |zos| } 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| Zip::File.open(temp_file.path, Zip::File::CREATE) do |zip|
#Put files in here
i=1 i=1
@lva.beispiele.each do |bsp| @lva.beispiele.each do |bsp|
zip.add(i.to_s + '_' + File.basename(bsp.beispieldatei.current_path), bsp.beispieldatei.current_path) 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) @beispiele_deleted = @lva.beispiele.flag_delete.order(:datum).accessible_by(current_ability, :show)
@toolbar_elements =[] @toolbar_elements =[]
@toolbar_elements<<{:hicon=>'icon-pencil', :icon=>:pencil,:text =>I18n.t('common.manage'),:path => verwalten_lva_path(@lva)} if can? :verwalten, @lva @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 end
def verwalten def verwalten
@lva = Lva.find_by_id(params[:id]) @lva = Lva.find_by_id(params[:id])
@beispiel=Beispiel.new @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 = @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_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) @beispiele_deleted = @lva.beispiele.flag_delete.order(:datum).accessible_by(current_ability, :show)
render :show render :show
end end
# GET /lvas/new
# GET /lvas/new.json
def new def new
@lva = Lva.new @lva = Lva.new
modul=Modul.find_by_id(params[:modul_id]) modul=Modul.find_by_id(params[:modul_id])
@lva.modul<<modul unless modul.nil? # @lva.modul<<modul unless modul.nil? #
end end
# GET /lvas/1/edit
def edit def edit
@lva = Lva.find(params[:id]) @lva = Lva.find(params[:id])
@semester = @lva.modul.map(&:modulgruppen).flatten.map(&:studium).map(&:semester).flatten.uniq @semester = @lva.modul.map(&:modulgruppen).flatten.map(&:studium).map(&:semester).flatten.uniq
@@ -126,7 +118,6 @@ class LvasController < ApplicationController
def destroy def destroy
@lva = Lva.find(params[:id]) @lva = Lva.find(params[:id])
@lva.destroy @lva.destroy
respond_to do |format| respond_to do |format|
format.html { redirect_to lvas_url } format.html { redirect_to lvas_url }
end end
@@ -139,10 +130,6 @@ private
@toolbar_elements<<{:hicon=>'icon-pencil', :icon=>:pencil,:text =>I18n.t('common.edit'),:path => edit_lva_path(@lva)} if can? :edit, @lva @toolbar_elements<<{:hicon=>'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=>"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 @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
end end

View File

@@ -48,6 +48,8 @@ class Lva < ActiveRecord::Base
has_and_belongs_to_many :lecturers has_and_belongs_to_many :lecturers
has_many :nlinks, as: :link has_many :nlinks, as: :link
has_many :crawlobjects, :as=>:something 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}%")} # 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 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

View File

@@ -38,7 +38,7 @@
</p> </p>
<%= render partial: "neuigkeit_view", object: @neuigkeit %> <%= render partial: "neuigkeit_view", object: @neuigkeit %>
<%= new_question_for(@neuigkeit) if can? :new, Survey::Question %>
<% @questions.each do |q| %> <% @questions.each do |q| %>
<%= render q if can? :show, q %> <%= render q if can? :show, q %>
<% end %> <% end %>

View File

@@ -1,6 +1,8 @@
<div id="container_question_<%= answeredquestion.id %>" style="min-width: 310px; max-width: 800px; height: <%= (100+answeredquestion.choices.count * 90).to_s %>px; margin: 0 auto" class="contentbox"> <div id="container_question_<%= answeredquestion.id %>" style="min-width: 310px; max-width: 800px; height: <%= (100+answeredquestion.choices.count * 90).to_s %>px; margin: 0 auto" class="contentbox">
<div style="background:red"> <div style="background:red">
<b><%= answeredquestion.title%></b> <b>
<%= answeredquestion.title%>
</b>
<ul> <ul>
<% answeredquestion.choices.each do |c| %> <% answeredquestion.choices.each do |c| %>
<li> <li>

View File

@@ -4,13 +4,13 @@
<span class="caret"></span> <span class="caret"></span>
</button> </button>
<ul class="dropdown-menu" aria-labelledby="dropdownMenu1"> <ul class="dropdown-menu" aria-labelledby="dropdownMenu1">
<li><%= link_to "Neue FRage", new_survey_question_path(params: {parent_type: parent.class.to_s, parent_id: parent.id.to_s}) %></li> <li>
<% question_templates.each do |q| %> <%= link_to "Neue FRage", new_survey_question_path(params: {parent_type: parent.class.to_s, parent_id: parent.id.to_s}) %>
</li>
<li><%= link_to q.title, create_from_template_survey_question_path(q, params: {parent_type: parent.class.to_s, parent_id: parent.id.to_s}) %> <% question_templates.each do |q| %>
</li> <li>
<% end %> <%= link_to q.title, create_from_template_survey_question_path(q, params: {parent_type: parent.class.to_s, parent_id: parent.id.to_s}) %>
</li>
<% end %>
</ul> </ul>
</div> </div>

View File

@@ -44,6 +44,7 @@
<%= @lva.desc.to_s.html_safe %> <%= @lva.desc.to_s.html_safe %>
</div> </div>
</div> </div>
</div> </div>
<div class="span4"> <div class="span4">
<div class="contentbox"> <div class="contentbox">
@@ -80,6 +81,10 @@
<div class="row-fluid"> <div class="row-fluid">
<div class="span12"> <div class="span12">
<%= new_question_for(@lva) %>
<% @questions.each do |q| %>
<%= render q if can? :show, q %>
<% end %>
<h2><%= I18n.t("lva.bspe") %></h2> <h2><%= I18n.t("lva.bspe") %></h2>
<p> <p>
@@ -115,6 +120,7 @@
<div class="row-fluid"> <div class="row-fluid">
<div class="span12"> <div class="span12">
<% unless @lva.nlinks.empty? %> <% unless @lva.nlinks.empty? %>
<h2><%= I18n.t("rubrik.title") %></h2> <h2><%= I18n.t("rubrik.title") %></h2>
<% @lva.nlinks.each do |l| %> <% @lva.nlinks.each do |l| %>
@@ -132,6 +138,7 @@
</div> </div>
<% end %> <% end %>
<% unless @crawlobjects.nil? %> <% unless @crawlobjects.nil? %>
<div class="row-fluid"> <div class="row-fluid">
<div class="span12"> <div class="span12">