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
def kontakt
end
def intern
authorize! :seeintern, User
@neuigkeiten = Neuigkeit.intern.recent
end
def startdev
render 'setup_fetsite_dev'
end

View File

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

View File

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

View File

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

View File

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

View File

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

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("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">

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 class="row-fluid">
<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>

View File

@@ -1,3 +1,4 @@
<% 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 %>

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| %>
<li><%= render l.neuigkeit %></li>
<% end %>
<% thema.nlinks.each do |l| %>
<li><%= render l.neuigkeit %></li>
<% end %>
</ul>
</div>
</li>

View File

@@ -4,7 +4,7 @@
# Formtastic::FormBuilder.default_text_field_size = 50
# 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.
Formtastic::FormBuilder.default_text_area_width = "40"

View File

@@ -91,10 +91,12 @@
#resources :neuigkeiten, :except => [:index] do
#end
resources :neuigkeiten, :only =>[:show]
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

View File

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