diff --git a/app/controllers/neuigkeiten_controller.rb b/app/controllers/neuigkeiten_controller.rb index 9943b29..a1d357f 100755 --- a/app/controllers/neuigkeiten_controller.rb +++ b/app/controllers/neuigkeiten_controller.rb @@ -8,27 +8,34 @@ class NeuigkeitenController < ApplicationController def show @neuigkeit = Neuigkeit.find(params[:id]) - if can? :edit, @neuigkeit - @toolbar_elements << {:text=>I18n.t('common.edit'),:path=>edit_rubrik_neuigkeit_path(@neuigkeit.rubrik,@neuigkeit),:icon=>:pencil} - @toolbar_elements << {:hicon=>'icon-remove-circle', :text=> I18n.t('common.delete'),:path => rubrik_neuigkeit_path(@neuigkeit.rubrik,@neuigkeit), :method=> :delete,:confirm=>"Sure?" } - @toolbar_elements << {:hicon=>'icon-plus', :text=> "publish",:path => publish_rubrik_neuigkeit_path(@neuigkeit.rubrik,@neuigkeit),:confirm=>"Sure?" } + if params[:verwalten] + @toolbar_elements << {:hicon=>'icon-plus', :text=> "publish",:path => publish_rubrik_neuigkeit_path(@neuigkeit.rubrik,@neuigkeit),:confirm=>"Sure?" } if can? :publish, @neuigkeit + + @toolbar_elements << {:text=>I18n.t('common.edit'),:path=>edit_rubrik_neuigkeit_path(@neuigkeit.rubrik,@neuigkeit),:icon=>:pencil} if can? :edit, @neuigkeit + @toolbar_elements << {:hicon=>'icon-remove-circle', :text=> I18n.t('common.delete'),:path => rubrik_neuigkeit_path(@neuigkeit.rubrik,@neuigkeit), :method=> :delete,:confirm=>"Sure?" } if can? :delete, @neuigkeit + else + @toolbar_elements << {:text=>I18n.t('common.verwalten'),:path=>rubrik_neuigkeit_path(@neuigkeit.rubrik,@neuigkeit,{:verwalten=>true}),:icon=>:pencil} if can? :verwalten, @neuigkeit end end - def new + def new @neuigkeit = Neuigkeit.new @rubrik=Rubrik.find(params[:rubrik_id]) unless params[:rubrik_id].nil? @neuigkeit.rubrik=@rubrik unless @rubrik.nil? - end + end - def publish + def publish @neuigkeit = Neuigkeit.find(params[:id]) @neuigkeit.publish @neuigkeit.save + if params[:verwalten] + redirect_to verwalten_rubrik_path(@neuigkeit.rubrik) + end redirect_to @neuigkeit - end - def edit + + end + def edit @neuigkeit = Neuigkeit.find(params[:id]) end @@ -38,7 +45,7 @@ class NeuigkeitenController < ApplicationController respond_to do |format| if @neuigkeit.save - format.html { redirect_to @neuigkeit, notice: 'Neuigkeit was successfully created.' } + format.html { redirect_to [@neuigkeit.rubrik,@neuigkeit], notice: 'Neuigkeit was successfully created.' } else format.html { render action: "new" } diff --git a/app/models/neuigkeit.rb b/app/models/neuigkeit.rb index 5c16b36..f7b8b2b 100755 --- a/app/models/neuigkeit.rb +++ b/app/models/neuigkeit.rb @@ -22,7 +22,7 @@ class Neuigkeit < ActiveRecord::Base translates :title,:text, :versioning=>true, :fallbacks_for_empty_translations => true has_one :calentry, :as => :object mount_uploader :picture, PictureUploader - scope :published, -> {where("datum <= ? AND datum IS NOT NULL", Time.now.to_date)} + scope :published, -> {where("datum <= ? AND datum IS NOT NULL", Time.now.to_date).order(:datum).reverse_order} scope :recent, -> { published.where("updated_at >= ? ",Time.now - 7.days)} def datum_nilsave self.datum.nil? ? Time.now + 42.years : self.datum diff --git a/app/views/gremien/verwalten.html.erb b/app/views/gremien/verwalten.html.erb new file mode 100644 index 0000000..99309c1 --- /dev/null +++ b/app/views/gremien/verwalten.html.erb @@ -0,0 +1,27 @@ +
| Name | +Desc | +Typ | ++ | + | + |
|---|---|---|---|---|---|
| <%= gremium.name %> | +<%= gremium.desc %> | +<%= gremium.typ %> | +<%= link_to 'Show', gremium %> | +<%= link_to 'Edit', edit_gremium_path(gremium) %> | +<%= link_to 'Destroy', gremium, method: :delete, data: { confirm: 'Are you sure?' } %> | +