Intern Bereich
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
|
||||
@@ -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
|
||||
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
|
||||
|
||||
@@ -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
|
||||
|
||||
10
app/views/home/intern.html.erb
Normal file
10
app/views/home/intern.html.erb
Normal file
@@ -0,0 +1,10 @@
|
||||
<h1> FET Intern NEU </h1>
|
||||
<h2>Neuigkeiten</h2>
|
||||
<ul class="unstyled linkbox-list" style="max-width:70em">
|
||||
<% @neuigkeiten.each do |n| %>
|
||||
<li><%= render n if can?(:show, n) %> </li>
|
||||
<% end %>
|
||||
</ul>
|
||||
|
||||
<h2></h2>
|
||||
|
||||
@@ -19,9 +19,10 @@
|
||||
<li><%= link_to I18n.t(:studien,:scope=>'home' ), studien_path %></li>
|
||||
<li> <%= link_to I18n.t("home.search"), search_home_index_path %></li>
|
||||
<li> <%= link_to I18n.t("home.kontakt"), kontakt_home_index_path %></li>
|
||||
<% if can?(:seeintern, User) %>
|
||||
<li>
|
||||
<%= link_to 'Admin' , config_path%>
|
||||
</li>
|
||||
<%= link_to 'Intern' , intern_home_index_path %>
|
||||
</li><% end %>
|
||||
</ul>
|
||||
<ul class="nav navbar-nav">
|
||||
<li class="dropdown">
|
||||
|
||||
@@ -92,9 +92,11 @@
|
||||
|
||||
#end
|
||||
resources :neuigkeiten, :only =>[:show]
|
||||
|
||||
resources :rubriken do
|
||||
collection do
|
||||
get 'verwalten' , :action => :alle_verwalten
|
||||
get 'intern'
|
||||
end
|
||||
member do
|
||||
get 'verwalten'
|
||||
@@ -120,7 +122,7 @@
|
||||
resources :home, :only=>[:index] do
|
||||
get :search, :on=>:collection
|
||||
collection do
|
||||
|
||||
get 'intern'
|
||||
get 'dev'
|
||||
get 'startdev'
|
||||
get 'linksnotimplemented'
|
||||
@@ -130,6 +132,7 @@
|
||||
|
||||
resources :themen do
|
||||
member do
|
||||
get :attachments
|
||||
get :fragen
|
||||
get :verwalten
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user