changed infoscreen layout

This commit is contained in:
peter
2017-05-31 12:35:30 +02:00
parent 5660cd7748
commit 14e563ef95
2 changed files with 30 additions and 20 deletions

View File

@@ -16,9 +16,9 @@ class Neuigkeit < ActiveRecord::Base
attr_accessible :datum, :text, :title, :rubrik_id, :author_id,:picture,:picture_cache, :calentries_attributes, :flag_important
belongs_to :author, :class_name =>'User'
belongs_to :rubrik, :class_name =>'Rubrik', :foreign_key => "rubrik_id"
has_one :calendar, through: :rubrik
has_one :calendar, through: :rubrik
has_many :calentries, as: :object, :dependent=> :destroy
has_many :nlinks, :dependent=> :destroy
has_many :nlinks, :dependent=> :destroy
has_one :meeting
has_many :attachments, :as=>:parent
has_one :title_pic, :class_name=>"Attachment", :as=>:parent, :conditions=>["attachments.flag_titlepic =?", true]
@@ -60,11 +60,11 @@ class Neuigkeit < ActiveRecord::Base
end
def read_attribute(name,options={})
if translated?(name)
a=super(name,options)
a=self.translation_for(options[:locale] || I18n.locale).read_attribute(name) if self.no_fallbacks
a=super(name,options)
a=self.translation_for(options[:locale] || I18n.locale).read_attribute(name) if self.no_fallbacks
a
else
else
super(name)
end
end
@@ -91,7 +91,7 @@ class Neuigkeit < ActiveRecord::Base
!self.meeting.nil?
end
def self.published
where("datum <= ? AND datum IS NOT NULL", Time.now.to_date)
where("datum <= ? AND datum IS NOT NULL", Time.now.to_date)
end
def datum_nilsave
@@ -132,7 +132,17 @@ class Neuigkeit < ActiveRecord::Base
"...."
else
words[0..100].join(" ")+ " ..." unless words.nil?
end
end
def text_infoscreen_words
md = /<p>(?<text>[^\<\>]*)/.match Sanitize.clean(self.text,:elements=>['p'])
words=md[:text].split(" ") unless md.nil?
if words.nil? || words.empty?
"...."
else
words[0..1000].join(" ")+ " ..." unless words.nil?
end
end
def has_calentries?
@@ -143,7 +153,7 @@ class Neuigkeit < ActiveRecord::Base
end
def relevant_calentry
ce = self.calentries.min_by{|c| c.days_to_today * 1.3 * ((c.is_past?)? 2:1)} if self.is_event?
ce= self.meeting.calentry if self.has_meeting?
ce= self.meeting.calentry if self.has_meeting?
ce
end
def update_cache
@@ -151,8 +161,8 @@ class Neuigkeit < ActiveRecord::Base
self.update_column(:cache_order, (self.meeting.calentry.start.to_date - Date.today).to_i.abs * 1.3)
self.update_column(:cache_relevant_date, self.meeting.calentry.start.to_date)
self.touch
else
if self.is_event?
else
if self.is_event?
c = self.calentries.min_by{|c| c.days_to_today * 1.3 * ((c.is_past?)? 2:1)}
self.update_column(:cache_order, c.days_to_today * 1.3 * ((c.is_past?)? 2:1))
self.update_column(:cache_relevant_date, (c.is_past?) ? c.ende.to_date : c.start.to_date)
@@ -184,7 +194,7 @@ class Neuigkeit < ActiveRecord::Base
end
end
searchable do
text :text
text :text
text :datum
text :title
end