diff --git a/app/controllers/home_controller.rb b/app/controllers/home_controller.rb index 019cff1..ba318ee 100755 --- a/app/controllers/home_controller.rb +++ b/app/controllers/home_controller.rb @@ -9,6 +9,10 @@ class HomeController < ApplicationController end def kontakt end + def intern + authorize! :seeintern, User + @neuigkeiten = Neuigkeit.intern.recent + end def startdev render 'setup_fetsite_dev' end diff --git a/app/controllers/rubriken_controller.rb b/app/controllers/rubriken_controller.rb index 4e44a20..436b990 100755 --- a/app/controllers/rubriken_controller.rb +++ b/app/controllers/rubriken_controller.rb @@ -10,7 +10,9 @@ class RubrikenController < ApplicationController @neuigkeiten = @rubriken.collect(&:neuigkeiten).map(&:recent).flatten @calentries= @rubriken.collect(&:calendar).collect(&:calentries).flatten end - + def intern + + end def show if can?(:shownonpublic, Rubrik) @rubriken = Rubrik.all diff --git a/app/controllers/themen_controller.rb b/app/controllers/themen_controller.rb index 2f5fa51..3a95e58 100644 --- a/app/controllers/themen_controller.rb +++ b/app/controllers/themen_controller.rb @@ -16,17 +16,19 @@ class ThemenController < ApplicationController # GET /themen/1.json def show @thema = Thema.find(params[:id]) - redirect_to :controller=>'themengruppen', :id=>@thema.themengruppe.id, :action=>:show, :anchor=> "thema_"+params[:id].to_s + @fragen=@thema.fragen @toolbar_elements = [{:icon=>:pencil, :hicon=>'icon-pencil', :text=>"Verwalten", :path=>verwalten_thema_path(@thema)}] @toolbar_elements = [{:icon=>:pencil, :hicon=>'icon-pencil', :text=>I18n.t('thema.edit'), :path=>edit_thema_path(@thema)}] @toolbar_elements << {:hicon=>'icon-remove-circle', :text=>I18n.t('thema.remove'), :path=>thema_path(@thema), :method=>:delete, :confirm=>I18n.t('thema.sure')} - # respond_to do |format| - # format.html # show.html.erb - # format.json { render json: @thema } - # end + respond_to do |format| + format.html { + redirect_to :controller=>'themengruppen', :id=>@thema.themengruppe.id, :action=>:show, :anchor=> "thema_"+params[:id].to_s + } + format.js + end end def verwalten @thema = Thema.find(params[:id]) @@ -83,6 +85,13 @@ class ThemenController < ApplicationController format.js end end + def attachments + @thema = Thema.find(params[:id]) + @attachments=@thema.attachments + respond_to do |format| + format.js + end + end # PUT /themen/1 # PUT /themen/1.json def update diff --git a/app/models/ability.rb b/app/models/ability.rb index 86f364a..f61425f 100755 --- a/app/models/ability.rb +++ b/app/models/ability.rb @@ -31,6 +31,7 @@ class Ability # can :manage, :all can :addfetuser, User can :addfetadmin, User + can [:show, :index], Studium can [:show, :index], Modulgruppe can [:show, :index], Modul @@ -78,6 +79,8 @@ class Ability can :manage, Neuigkeit can :shownonpublic, Rubrik can :showunpublished, Neuigkeit + can :seeintern, User + end diff --git a/app/models/neuigkeit.rb b/app/models/neuigkeit.rb index 6abeba6..72946df 100755 --- a/app/models/neuigkeit.rb +++ b/app/models/neuigkeit.rb @@ -23,22 +23,27 @@ class Neuigkeit < ActiveRecord::Base has_many :calentries, as: :object mount_uploader :picture, PictureUploader - - scope :published, -> {where("datum <= ? AND datum IS NOT NULL", Time.now.to_date).order(:datum).reverse_order} - scope :recent, -> { published.limit(15)} + default_scope order(:datum).reverse_order + #scope :published, -> {where("datum <= ? AND datum IS NOT NULL", Time.now.to_date)} + scope :recent, -> { published.limit(10)} scope :unpublished, -> {where("datum >= ? OR datum IS NULL", Date.today)} - scope :public, ->{includes(:rubrik).where("rubriken.public"=>:true)} + scope :public, ->{includes(:rubrik).where("rubriken.public"=>true)} + scope :intern, ->{includes(:rubrik).where("rubriken.public"=>false)} + scope :search, ->(query) {where("text like ? or title like ?", "%#{query}%", "%#{query}%")} LINKTYPES=["Thema", "Gallery", "Lva","Studium","Fetprofile", "Gremium"] accepts_nested_attributes_for :calentries, :allow_destroy=>true , :reject_if=> lambda{|a| a[:start].blank?} before_validation :sanitize - has_many :nlinks - + has_many :nlinks + def self.published + where("datum <= ? AND datum IS NOT NULL", Time.now.to_date) + end + def datum_nilsave self.datum.nil? ? Time.now + 42.years : self.datum end - def public - self.rubrik.public && self.datum_nilsave >=Time.now.to_date + def public? + self.rubrik.public end def published? self.datum_nilsave>=Time.now.to_date diff --git a/app/models/rubrik.rb b/app/models/rubrik.rb index 67810de..74340d2 100755 --- a/app/models/rubrik.rb +++ b/app/models/rubrik.rb @@ -13,6 +13,7 @@ class Rubrik < ActiveRecord::Base attr_accessible :desc, :name, :prio, :calendar, :public has_many :neuigkeiten, :class_name => "Neuigkeit" + has_many :published, :class_name => "Neuigkeit", :conditions=>["Neuigkeit.published"] has_many :calentries, :through => :neuigkeiten, :as=>:object resourcify has_one :calendar diff --git a/app/views/attachments/_attachment.html.erb b/app/views/attachments/_attachment.html.erb new file mode 100644 index 0000000..1fc66d3 --- /dev/null +++ b/app/views/attachments/_attachment.html.erb @@ -0,0 +1,9 @@ + <% data_ext = attachment.datei.file.extension.downcase %> + + <%= attachment.name %> + <% if (!["jpg","png","jpeg"].find_index(data_ext).nil?) %> + <%= image_tag attachment.datei.thumb.url %> + <% else %> + <%= image_tag "pdf-logo.jpg" %> + <% end %> + diff --git a/app/views/home/intern.html.erb b/app/views/home/intern.html.erb new file mode 100644 index 0000000..b419c02 --- /dev/null +++ b/app/views/home/intern.html.erb @@ -0,0 +1,10 @@ +