diff --git a/app/controllers/meetings_controller.rb b/app/controllers/meetings_controller.rb index c666945..5fc7193 100644 --- a/app/controllers/meetings_controller.rb +++ b/app/controllers/meetings_controller.rb @@ -21,6 +21,7 @@ class MeetingsController < ApplicationController m=Meeting.find(params[:id]) m.create_announcement(current_user) m.save + @meeting=Meeting.find(params[:id]) respond_to do |format| format.html {redirect_to m.parent} diff --git a/app/models/calentry.rb b/app/models/calentry.rb index 2f8d2fe..2d55bbb 100644 --- a/app/models/calentry.rb +++ b/app/models/calentry.rb @@ -85,9 +85,17 @@ end summary end end -def text - I18n.l(self.start) +" "+ I18n.t("cal.bis")+" "+ I18n.l(self.ende) -end + def icon_text + ApplicationController.helpers.fa_icon("calendar 2x") + self.text + end + def text + if (self.start.to_date - self.ende.to_date) < 1.day + format=:timeonly + else + format =:default + end + I18n.l(self.start) +" "+ I18n.t("cal.bis")+" "+ I18n.l(self.ende, :format=>format) + end scope :public, -> { where(:public => :true) } # scope :upcoming, -> { where("start >= ?" , Time.now).where("start <= ?", 28.days.from_now) } end diff --git a/app/models/meeting.rb b/app/models/meeting.rb index a8e3ff1..fffb525 100644 --- a/app/models/meeting.rb +++ b/app/models/meeting.rb @@ -21,6 +21,7 @@ class Meeting < ActiveRecord::Base def title self.text end + def text unless self.meetingtyp.try(:name).to_s.empty? t = self.meetingtyp.name.to_s+", " @@ -29,17 +30,22 @@ class Meeting < ActiveRecord::Base t = parent.title.to_s + ", " if self.name.empty? end t= t+ self.name.to_s - t = t + " " + I18n.l(self.calentry.start) unless self.calentry.nil? + # t = t + " " + I18n.l(self.calentry.start) unless self.calentry.nil? + t = t +" am "+ self.calentry.text unless self.calentry.nil? t end def create_announcement(user) + if self.neuigkeit.nil? n = Neuigkeit.new n.title=self.text n.text ="Agenda im Anhang" n.rubrik = self.meetingtyp.rubrik n.author=user + n.save self.neuigkeit= n + end + end def fix_calentry self.calentry.object=self unless self.calentry.nil? diff --git a/app/models/meetingtyp.rb b/app/models/meetingtyp.rb index bcbdd19..48e114d 100644 --- a/app/models/meetingtyp.rb +++ b/app/models/meetingtyp.rb @@ -1,12 +1,15 @@ class Meetingtyp < ActiveRecord::Base - attr_accessible :agendaintern, :desc, :name, :protocolintern, :rubrik_id + attr_accessible :agendaintern, :desc, :name, :protocolintern, :rubrik_id, :picture belongs_to :rubrik validate :rubrik, :presence=>true has_many :meetings has_one :calendar, through: :rubrik has_one :protocol, :class_name=>'Document', :conditions=>{:typ=>10}, :as=>:parent has_one :agenda , :as=>:parent, :conditions=>{:typ=>11}, :class_name=>'Document' -def text -self.name -end + + mount_uploader :picture, PictureUploader + + def text + self.name + end end diff --git a/app/models/neuigkeit.rb b/app/models/neuigkeit.rb index 17ebc8f..18a0c8e 100755 --- a/app/models/neuigkeit.rb +++ b/app/models/neuigkeit.rb @@ -39,7 +39,17 @@ class Neuigkeit < ActiveRecord::Base before_validation :sanitize after_save :update_cache - + def picture_robust + unless self.picture.url.nil? + return self.picture + else + if self.has_meeting? + return self.meeting.meetingtyp.picture + else + return self.picture + end + end + end def is_annoncement? !self.meeting.nil? end diff --git a/app/views/calentries/_calentry.html.erb b/app/views/calentries/_calentry.html.erb index d96f6b6..787c5de 100644 --- a/app/views/calentries/_calentry.html.erb +++ b/app/views/calentries/_calentry.html.erb @@ -1,13 +1,6 @@
-<% unless neuigkeit.picture.url.nil? %><%= image_tag neuigkeit.picture.thumb.url %>
+<% unless neuigkeit.picture_robust.url.nil? %><%= image_tag neuigkeit.picture_robust.thumb.url %>
<% end %>
<%= link_to image_tag(@neuigkeit.picture.big_thumb.url),@neuigkeit.picture.try(:url) %>
+
<%= link_to image_tag(@neuigkeit.picture_robust.big_thumb.url),@neuigkeit.picture_robust.try(:url) %>