From 88877ccab03dee4467b8249d807602eac1b92df9 Mon Sep 17 00:00:00 2001
From: Andreas Stephanides
Date: Thu, 25 Jun 2015 16:03:20 +0200
Subject: [PATCH 1/2] AutoCommit Don Jun 25 16:03:19 CEST 2015
---
app/controllers/beispiele_controller.rb | 16 ++++++++++++++++
app/models/beispiel.rb | 3 ++-
app/views/beispiele/_form.html.erb | 2 +-
config/routes.rb | 1 +
4 files changed, 20 insertions(+), 2 deletions(-)
diff --git a/app/controllers/beispiele_controller.rb b/app/controllers/beispiele_controller.rb
index 7c75fa5..1bfd478 100755
--- a/app/controllers/beispiele_controller.rb
+++ b/app/controllers/beispiele_controller.rb
@@ -36,6 +36,22 @@ class BeispieleController < ApplicationController
end
end
+ def set_lecturer
+ @beispiel = Beispiel.find(params[:id])
+ @beispiel.lecturer = Lecturer.find(params[:beispiel][:lecturer_id])
+ @beispiel.save
+ if @beispiel.save
+ format.html { redirect_to @backlink, notice: 'Beispiel was successfully updated.' }
+ format.js {render text: "alert(\"updated\");"}
+ format.json { head :no_content }
+ else
+ format.html { render action: "edit" }
+ format.js
+ format.json { render json: @beispiel.errors, status: :unprocessable_entity }
+ end
+
+
+ end
# GET /beispiele/1/edit
def edit
@beispiel = Beispiel.find(params[:id])
diff --git a/app/models/beispiel.rb b/app/models/beispiel.rb
index 24a0f7b..4725133 100755
--- a/app/models/beispiel.rb
+++ b/app/models/beispiel.rb
@@ -13,10 +13,11 @@
class Beispiel < ActiveRecord::Base
has_paper_trail
- attr_accessible :desc, :name, :lva_id, :beispieldatei, :beispieldatei_cache, :datum
+ attr_accessible :desc, :name, :lva_id, :beispieldatei, :beispieldatei_cache, :datum, :lecturer_id
acts_as_votable
acts_as_flagable
belongs_to :lva
+ belongs_to :lecturer
FLAG_ICONS = {"badquality"=>"fa fa-flag","goodquality"=>"fa fa-flag", "delete"=>"fa fa-trash"}
scope :not_flag_badquality, ->{where("flag_badquality IS NULL OR flag_badquality=?",false)}
scope :flag_badquality, ->{where("flag_badquality=?",true)}
diff --git a/app/views/beispiele/_form.html.erb b/app/views/beispiele/_form.html.erb
index 4526e7c..ef9f727 100755
--- a/app/views/beispiele/_form.html.erb
+++ b/app/views/beispiele/_form.html.erb
@@ -24,7 +24,7 @@
<%= f.input :desc %>
- <%= f.input :lva, :as=>:radio, :collection => Lva.all %>
+ <%= f.input :lecturer, :as=>:select, :collection => @beispiel.lva.lecturers %>
<%= f.hidden_field :beispieldatei_cache %>
<%= f.actions do %>
diff --git a/config/routes.rb b/config/routes.rb
index dd339d5..892b23f 100755
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -74,6 +74,7 @@
get 'like'
get 'dislike'
get 'flag'
+ get 'set_lecturer'
end
end
resources :lvas do
From 133a882cf851bf18aa47ba1026d05e51a5636035 Mon Sep 17 00:00:00 2001
From: Andreas Stephanides
Date: Thu, 25 Jun 2015 17:04:04 +0200
Subject: [PATCH 2/2] AutoCommit Don Jun 25 17:04:03 CEST 2015
---
app/views/themes/blue2/lvas/show.html.erb | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/app/views/themes/blue2/lvas/show.html.erb b/app/views/themes/blue2/lvas/show.html.erb
index 253114a..2ca1903 100755
--- a/app/views/themes/blue2/lvas/show.html.erb
+++ b/app/views/themes/blue2/lvas/show.html.erb
@@ -88,14 +88,14 @@
<%= link_to t("beispiel.zip") , beispiel_sammlung_lva_path(@lva), class: :linkbox %>
<% @beispiele.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.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?(:like, b).to_s + "_" + b.updated_at.try(:utc).try(:to_s) + get_theme_help(current_user).to_s) do %>
<%= render b%>
<% end %>
<% end %>
<% if @beispiele_badQ.count > 0 %>
Bad Quality or Outdated
<% @beispiele_badQ.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.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?(:like, b).to_s + "_" + b.updated_at.try(:utc).try(:to_s) + get_theme_help(current_user).to_s) do %>
<%= render b%>
<% end %>
<% end %>
@@ -103,7 +103,7 @@
<% if @beispiele_deleted.count > 0 %>
Trash
<% @beispiele_deleted.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.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?(:like, b).to_s + "_" + b.updated_at.try(:utc).try(:to_s) + get_theme_help(current_user).to_s) do %>
<%= render b%>
<% end %>
<% end %>