Kalender überarbeitet Issue 91

This commit is contained in:
Andreas Stephanides
2013-11-28 10:14:36 +01:00
parent 6fa208dcbe
commit 0a507502ba
16 changed files with 72 additions and 19 deletions

View File

@@ -1,4 +1,3 @@
// Place all the styles related to the rubriken controller here. // Place all the styles related to the rubriken controller here.
// They will automatically be included in application.css. // They will automatically be included in application.css.
// You can use Sass (SCSS) here: http://sass-lang.com/ // You can use Sass (SCSS) here: http://sass-lang.com/

View File

@@ -4,6 +4,7 @@ class NeuigkeitenController < ApplicationController
def show def show
@neuigkeit = Neuigkeit.find(params[:id]) @neuigkeit = Neuigkeit.find(params[:id])
@rubrik=@neuigkeit.rubrik
if !params[:version].nil? if !params[:version].nil?
@neuigkeit.versions.reverse[params[:version].to_i].reify.save! @neuigkeit.versions.reverse[params[:version].to_i].reify.save!
@neuigkeit=Neuigkeit.find(params[:id]) @neuigkeit=Neuigkeit.find(params[:id])
@@ -30,6 +31,8 @@ class NeuigkeitenController < ApplicationController
@neuigkeit = Neuigkeit.new @neuigkeit = Neuigkeit.new
@rubrik=Rubrik.find(params[:rubrik_id]) unless params[:rubrik_id].nil? @rubrik=Rubrik.find(params[:rubrik_id]) unless params[:rubrik_id].nil?
@neuigkeit.rubrik=@rubrik unless @rubrik.nil? @neuigkeit.rubrik=@rubrik unless @rubrik.nil?
@calentries= [Calentry.new]
end end
def add_calentry def add_calentry
@neuigkeit=Neuigkeit.find(params[:id]) @neuigkeit=Neuigkeit.find(params[:id])

View File

@@ -4,6 +4,7 @@ class RubrikenController < ApplicationController
def index def index
@rubriken = Rubrik.all @rubriken = Rubrik.all
@neuigkeiten = Neuigkeit.recent @neuigkeiten = Neuigkeit.recent
@calentries= Calentry.all
end end
def show def show

View File

@@ -27,7 +27,7 @@ class Neuigkeit < ActiveRecord::Base
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)}
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
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
@@ -51,6 +51,9 @@ end
md = /<p>(?<text>[\w\s,\.!\?]*)/.match self.text md = /<p>(?<text>[\w\s,\.!\?]*)/.match self.text
md[:text].split(" ")[0..100].join(" ")+ " ..." md[:text].split(" ")[0..100].join(" ")+ " ..."
end end
def has_calentries?
!self.calentries.nil? && !self.calentries.empty?
end
private private
def sanitize def sanitize
self.calentries.each do |calentry| self.calentries.each do |calentry|

View File

@@ -16,13 +16,22 @@ class Rubrik < ActiveRecord::Base
has_many :calentries, :through => :neuigkeiten, :as=>:object has_many :calentries, :through => :neuigkeiten, :as=>:object
resourcify resourcify
has_one :calendar has_one :calendar
validates :calender , :presence=>true validates :calendar , :presence=>true
before_validation :sanitize
def moderator def moderator
u=User.with_role(:newsmoderator).first u=User.with_role(:newsmoderator).first
if !u.nil? if !u.nil?
u.id u.id
end end
end end
def sanitize
if self.calendar.nil?
self.calendar=Calendar.new
end
self.calendar.name=self.name
self.calendar.public=self.public
self.calendar.save
end
end end

View File

@@ -0,0 +1,3 @@
<%= calendar calendar.calentries do |entry| %>
<div><%= link_to entry.name.to_s, polymorphic_path(entry.object) %></div>
<% end %>

View File

@@ -0,0 +1,3 @@
<%= calendar object do |entry| %>
<div><%= link_to entry.name.to_s, polymorphic_path(entry.object) %></div>
<% end %>

View File

@@ -1,9 +1,9 @@
<div class="contentbox"> <div class="contentbox">
<%= image_tag("/icon_kalender_small.png") %> <%= image_tag("/calendar-day-icon-small.png") %>
<% if calentry.start.to_date == calentry.ende.to_date <% if calentry.start.to_date == calentry.ende.to_date
format=:timeonly format=:timeonly
else else
format =:default format =:default
end%> end%>
<%= link_to I18n.l(calentry.start) +" bis "+ I18n.l(calentry.ende,:format=>format), calendar_path(calentry.calendar) %> <%= link_to I18n.l(calentry.start) +" bis "+ I18n.l(calentry.ende,:format=>format), calentry_path(calentry) %>
</div> </div>

View File

@@ -16,7 +16,7 @@
</div> </div>
<div class="row-fluid"> <div class="row-fluid">
<div class="span6"> <div class="span6">
<%= f.input :calendars, :as=> :radio %> <%= f.input :calendar, :as=> :radio %>
</div> </div>
<div class="span6"> <div class="span6">
<%= f.input :typ %> <%= f.input :typ %>

View File

@@ -14,6 +14,9 @@ Bezüglich Design und Steuerung sind Vorschläge erwünscht.
<p><%= link_to "Steuerelemente und Komponenten", "http://getbootst<rap.com/2.3.2/index.html" %></p> <p><%= link_to "Steuerelemente und Komponenten", "http://getbootst<rap.com/2.3.2/index.html" %></p>
<p>Um bei der Entwicklung mitzuhelfen braucht nur Ruby on Rails installiert werden</p> <p>Um bei der Entwicklung mitzuhelfen braucht nur Ruby on Rails installiert werden</p>
<p><%= link_to "Getting Started" , home_startdev_path%></p> <p><%= link_to "Getting Started" , home_startdev_path%></p>
<p> Das Kalender Feature wird überarbeitet, in Zukunft soll folgender Link nicht mehr funktionieren <%= link_to "Kalender", calendars_path %>
</p>
</div> </div>
<p><%= I18n.t('home.hallobeiderfet') %></p> <p><%= I18n.t('home.hallobeiderfet') %></p>
<%= render 'beispiele' %> <%= render 'beispiele' %>

View File

@@ -10,7 +10,8 @@
<small><%= neuigkeit.rubrik.name %></small> <small><%= neuigkeit.rubrik.name %></small>
<small class="pull-right"><%= "am "+ I18n.l(neuigkeit.try(:datum).try(:to_date)) unless neuigkeit.try(:datum).try(:to_date).nil? %></small> <small class="pull-right"><%= "am "+ I18n.l(neuigkeit.try(:datum).try(:to_date)) unless neuigkeit.try(:datum).try(:to_date).nil? %></small>
</div> </div>
<h1><%= neuigkeit.title%></h1> <h1><%= image_tag("/calendar-day-icon-small.png") if neuigkeit.has_calentries? %>
<%= neuigkeit.title%></h1>
<%= raw(neuigkeit.text_first_words) unless neuigkeit.text.nil?%> <%= raw(neuigkeit.text_first_words) unless neuigkeit.text.nil?%>
</div> </div>
</div> </div>

View File

@@ -1,11 +1,28 @@
<%= render 'tabs' %> <%= render 'tabs' %>
<h1><%= I18n.t("rubrik.title")%></h1> <p id="notice"><%= notice %></p>
<ul class="unstyled linkbox-list" style="max-width:70em"> <div class="container-fluid">
<div class="row-fluid">
<div class="span12">
<h1><%= I18n.t("rubrik.title")%></h1>
</div>
</div>
<div class="row-fluid">
<div class="span9">
<ul class="unstyled linkbox-list" style="max-width:70em">
<% @neuigkeiten.each do |n| %> <% @neuigkeiten.each do |n| %>
<li><%= render n %> </li> <li><%= render n %> </li>
<% end %> <% end %>
</ul> </ul>
</div>
<div class="span3">
<%= render 'calendars/calentries', :object=>@calentries %>
</div>
</div>
</div>

View File

@@ -1,7 +1,8 @@
<%= render 'tabs' %> <%= render 'tabs' %>
<p id="notice"><%= notice %></p> <p id="notice"><%= notice %></p>
<div class="container-fluid">
<div class="row-fluid">
<div class="span12">
<h1><%= @rubrik.name %></h1> <h1><%= @rubrik.name %></h1>
<p> <p>
<%= @rubrik.desc %> <%= @rubrik.desc %>
@@ -12,8 +13,10 @@
<%= m.email%>, <%= m.email%>,
<% end%> <% end%>
</i> </i>
</div></div>
<div class="row-fluid">
<div class="span9">
<% @neuigkeiten.each_slice(1) do |row| %> <% @neuigkeiten.each_slice(1) do |row| %>
<ul class="unstyled" style="max-width:70em"> <ul class="unstyled" style="max-width:70em">
<% row.each do |neuigkeit| %> <% row.each do |neuigkeit| %>
@@ -24,10 +27,18 @@
</ul> </ul>
<% end %> <% end %>
</div>
<div class="span3">
<%= render 'calendars/calentries', :object=>@rubrik.calendar.calentries %>
</div>
</div>
<br> <br>
<%= render 'layouts/pretty_toolbar', :object=> @toolbar_elements %> <%= render 'layouts/pretty_toolbar', :object=> @toolbar_elements %>
</div>

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.3 KiB

BIN
public/icon_kalender.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 92 KiB