This commit is contained in:
2014-05-02 18:56:37 +02:00
18 changed files with 87 additions and 21 deletions

View File

@@ -9,6 +9,10 @@ class HomeController < ApplicationController
end end
def kontakt def kontakt
end end
def intern
authorize! :seeintern, User
@neuigkeiten = Neuigkeit.intern.recent
end
def startdev def startdev
render 'setup_fetsite_dev' render 'setup_fetsite_dev'
end end

View File

@@ -10,7 +10,9 @@ class RubrikenController < ApplicationController
@neuigkeiten = @rubriken.collect(&:neuigkeiten).map(&:recent).flatten @neuigkeiten = @rubriken.collect(&:neuigkeiten).map(&:recent).flatten
@calentries= @rubriken.collect(&:calendar).collect(&:calentries).flatten @calentries= @rubriken.collect(&:calendar).collect(&:calentries).flatten
end end
def intern
end
def show def show
if can?(:shownonpublic, Rubrik) if can?(:shownonpublic, Rubrik)
@rubriken = Rubrik.all @rubriken = Rubrik.all

View File

@@ -16,17 +16,19 @@ class ThemenController < ApplicationController
# GET /themen/1.json # GET /themen/1.json
def show def show
@thema = Thema.find(params[:id]) @thema = Thema.find(params[:id])
redirect_to :controller=>'themengruppen', :id=>@thema.themengruppe.id, :action=>:show, :anchor=> "thema_"+params[:id].to_s
@fragen=@thema.fragen @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=>"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 = [{: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')} @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| respond_to do |format|
# format.html # show.html.erb format.html {
# format.json { render json: @thema } redirect_to :controller=>'themengruppen', :id=>@thema.themengruppe.id, :action=>:show, :anchor=> "thema_"+params[:id].to_s
# end }
format.js
end
end end
def verwalten def verwalten
@thema = Thema.find(params[:id]) @thema = Thema.find(params[:id])
@@ -83,6 +85,13 @@ class ThemenController < ApplicationController
format.js format.js
end end
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
# PUT /themen/1.json # PUT /themen/1.json
def update def update

View File

@@ -31,6 +31,7 @@ class Ability
# can :manage, :all # can :manage, :all
can :addfetuser, User can :addfetuser, User
can :addfetadmin, User can :addfetadmin, User
can [:show, :index], Studium can [:show, :index], Studium
can [:show, :index], Modulgruppe can [:show, :index], Modulgruppe
can [:show, :index], Modul can [:show, :index], Modul
@@ -78,6 +79,8 @@ class Ability
can :manage, Neuigkeit can :manage, Neuigkeit
can :shownonpublic, Rubrik can :shownonpublic, Rubrik
can :showunpublished, Neuigkeit can :showunpublished, Neuigkeit
can :seeintern, User
end end

View File

@@ -23,22 +23,27 @@ class Neuigkeit < ActiveRecord::Base
has_many :calentries, as: :object has_many :calentries, as: :object
mount_uploader :picture, PictureUploader mount_uploader :picture, PictureUploader
default_scope order(:datum).reverse_order
scope :published, -> {where("datum <= ? AND datum IS NOT NULL", Time.now.to_date).order(:datum).reverse_order} #scope :published, -> {where("datum <= ? AND datum IS NOT NULL", Time.now.to_date)}
scope :recent, -> { published.limit(15)} scope :recent, -> { published.limit(10)}
scope :unpublished, -> {where("datum >= ? OR datum IS NULL", Date.today)} 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}%")} scope :search, ->(query) {where("text like ? or title like ?", "%#{query}%", "%#{query}%")}
LINKTYPES=["Thema", "Gallery", "Lva","Studium","Fetprofile", "Gremium"] LINKTYPES=["Thema", "Gallery", "Lva","Studium","Fetprofile", "Gremium"]
accepts_nested_attributes_for :calentries, :allow_destroy=>true , :reject_if=> lambda{|a| a[:start].blank?} accepts_nested_attributes_for :calentries, :allow_destroy=>true , :reject_if=> lambda{|a| a[:start].blank?}
before_validation :sanitize 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 def datum_nilsave
self.datum.nil? ? Time.now + 42.years : self.datum self.datum.nil? ? Time.now + 42.years : self.datum
end end
def public def public?
self.rubrik.public && self.datum_nilsave >=Time.now.to_date self.rubrik.public
end end
def published? def published?
self.datum_nilsave>=Time.now.to_date self.datum_nilsave>=Time.now.to_date

View File

@@ -13,6 +13,7 @@
class Rubrik < ActiveRecord::Base class Rubrik < ActiveRecord::Base
attr_accessible :desc, :name, :prio, :calendar, :public attr_accessible :desc, :name, :prio, :calendar, :public
has_many :neuigkeiten, :class_name => "Neuigkeit" has_many :neuigkeiten, :class_name => "Neuigkeit"
has_many :published, :class_name => "Neuigkeit", :conditions=>["Neuigkeit.published"]
has_many :calentries, :through => :neuigkeiten, :as=>:object has_many :calentries, :through => :neuigkeiten, :as=>:object
resourcify resourcify
has_one :calendar has_one :calendar

View File

@@ -0,0 +1,9 @@
<% data_ext = attachment.datei.file.extension.downcase %>
<%= attachment.name %> </br>
<% if (!["jpg","png","jpeg"].find_index(data_ext).nil?) %>
<%= image_tag attachment.datei.thumb.url %>
<% else %>
<%= image_tag "pdf-logo.jpg" %>
<% end %>

View 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>

View File

@@ -19,9 +19,10 @@
<li><%= link_to I18n.t(:studien,:scope=>'home' ), studien_path %></li> <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.search"), search_home_index_path %></li>
<li> <%= link_to I18n.t("home.kontakt"), kontakt_home_index_path %></li> <li> <%= link_to I18n.t("home.kontakt"), kontakt_home_index_path %></li>
<% if can?(:seeintern, User) %>
<li> <li>
<%= link_to 'Admin' , config_path%> <%= link_to 'Intern' , intern_home_index_path %>
</li> </li><% end %>
</ul> </ul>
<ul class="nav navbar-nav"> <ul class="nav navbar-nav">
<li class="dropdown"> <li class="dropdown">

View File

@@ -0,0 +1,12 @@
<table>
<% attachment_list.each do |a| %>
<tr>
<td>
<%= render a %>
</td>
<td>
<%= link_to "Edit", edit_thema_attachment_path(a.thema,a) %>
</td>
</tr>
<% end %>
</table>

View File

@@ -13,7 +13,7 @@
</div> </div>
<div class="row-fluid"> <div class="row-fluid">
<div class="span12"> <div class="span12">
<%= f.input :text, :as=>:tinymce_text,:label=>false %> <%= f.input :text, :as=>:tinymce_text,:label=>false, :input_html=>{:rows=>20} %>
</div> </div>
</div> </div>

View File

@@ -1,3 +1,4 @@
<% verw_liste.each do |thema| %> <% verw_liste.each do |thema| %>
<li id="themen_<%= thema.id %>" class="sort" ><div class="contentbox handle" ><h2><%= thema.title %></h2> </div> <%= link_to edit_thema_path(thema),:remote=>true do %> Edit <% end %> <%= link_to fragen_thema_path(thema),:remote=>true do %> Fragen <% end %></li> <li id="themen_<%= thema.id %>" class="sort" ><div class="contentbox handle" ><h2><%= thema.title %></h2> </div>
<%= link_to thema_path(thema),:remote=>true do %> Show <% end %> <%= link_to edit_thema_path(thema),:remote=>true do %> Edit <% end %> <%= link_to fragen_thema_path(thema),:remote=>true do %> Fragen <% end %><%= link_to attachments_thema_path(thema),:remote=>true do %> Attachments <% end %></li>
<% end %> <% end %>

View File

@@ -0,0 +1 @@
$("#themaview").html("<%= escape_javascript(raw("<h2>"+I18n.t('thema.show')+"</h2>")+render(:partial=>"themen/attachment_list", :object=>@attachments) )%>");

View File

@@ -0,0 +1 @@
$("#themaview").html("<%= escape_javascript(raw("<h2>"+I18n.t('thema.show')+"</h2>")+render(:partial=>"themen/small", :object=>@thema) )%>");

View File

@@ -28,6 +28,9 @@
<% thema.nlinks.each do |l| %> <% thema.nlinks.each do |l| %>
<li><%= render l.neuigkeit %></li> <li><%= render l.neuigkeit %></li>
<% end %> <% end %>
<% thema.nlinks.each do |l| %>
<li><%= render l.neuigkeit %></li>
<% end %>
</ul> </ul>
</div> </div>
</li> </li>

View File

@@ -4,7 +4,7 @@
# Formtastic::FormBuilder.default_text_field_size = 50 # Formtastic::FormBuilder.default_text_field_size = 50
# Set the default text area height when input is a text. Default is 20. # Set the default text area height when input is a text. Default is 20.
Formtastic::FormBuilder.default_text_area_height = 5 Formtastic::FormBuilder.default_text_area_height = 10
# Set the default text area width when input is a text. Default is nil. # Set the default text area width when input is a text. Default is nil.
Formtastic::FormBuilder.default_text_area_width = "40" Formtastic::FormBuilder.default_text_area_width = "40"

View File

@@ -92,9 +92,11 @@
#end #end
resources :neuigkeiten, :only =>[:show] resources :neuigkeiten, :only =>[:show]
resources :rubriken do resources :rubriken do
collection do collection do
get 'verwalten' , :action => :alle_verwalten get 'verwalten' , :action => :alle_verwalten
get 'intern'
end end
member do member do
get 'verwalten' get 'verwalten'
@@ -120,7 +122,7 @@
resources :home, :only=>[:index] do resources :home, :only=>[:index] do
get :search, :on=>:collection get :search, :on=>:collection
collection do collection do
get 'intern'
get 'dev' get 'dev'
get 'startdev' get 'startdev'
get 'linksnotimplemented' get 'linksnotimplemented'
@@ -130,6 +132,7 @@
resources :themen do resources :themen do
member do member do
get :attachments
get :fragen get :fragen
get :verwalten get :verwalten
end end

View File

@@ -16,3 +16,4 @@ plugins:
- advimage - advimage
- heading - heading
heading_clear_tag: p heading_clear_tag: p
width: "100%"