diff --git a/app/controllers/beispiele_controller.rb b/app/controllers/beispiele_controller.rb index 2a58b0d..de2fd70 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 69add16..7f6df24 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/app/views/themes/blue2/lvas/show.html.erb b/app/views/themes/blue2/lvas/show.html.erb index 63ae063..f4e3596 100755 --- a/app/views/themes/blue2/lvas/show.html.erb +++ b/app/views/themes/blue2/lvas/show.html.erb @@ -95,7 +95,7 @@ <% 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_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?(: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,8 @@ <% 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_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?(:like, b).to_s + "_" + b.updated_at.try(:utc).try(:to_s) + get_theme_help(current_user).to_s) do %> <%= render b%> <% end %> <% end %> 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