Parent

Included Modules

Class/Module Index [+]

Quicksearch

Neuigkeit

Schema Information

Table name: neuigkeiten

id         :integer          not null, primary key
title      :string(255)
text       :text
datum      :datetime
rubrik_id  :integer
created_at :datetime         not null
updated_at :datetime         not null
author_id  :integer

Constants

FLAG_CONFIRM
FLAG_ICONS
LINKTYPES

scope :search, ->(query) {where(“text like ? or title like ?”, “%#{query}%”, “%#{query}%”)}

Attributes

no_fallbacks[RW]

Public Class Methods

published() click to toggle source
# File app/models/neuigkeit.rb, line 93
def self.published
  where("datum <= ? AND datum IS NOT NULL", Time.now.to_date)
end

Public Instance Methods

datum_nilsave() click to toggle source
# File app/models/neuigkeit.rb, line 97
def datum_nilsave
      self.datum.nil? ? Time.now + 42.years : self.datum
end
globalize_fallbacks(locale) click to toggle source
# File app/models/neuigkeit.rb, line 54
def globalize_fallbacks(locale)
  if self.no_fallbacks
  [locale]
  else
    super
  end
end
has_calentries?() click to toggle source
# File app/models/neuigkeit.rb, line 148
def has_calentries?
  !self.calentries.nil? && !self.calentries.empty?
end
has_meeting?() click to toggle source
# File app/models/neuigkeit.rb, line 90
def has_meeting?
  !self.meeting.nil?
end
is_annoncement?() click to toggle source
# File app/models/neuigkeit.rb, line 87
def is_annoncement?
  !self.meeting.nil?
end
is_event?() click to toggle source
# File app/models/neuigkeit.rb, line 151
def is_event?
  self.has_calentries?
end
load_from_facebook(link) click to toggle source
# File app/models/neuigkeit.rb, line 116
def load_from_facebook(link)
  event=FbGraph::Event.new(link).fetch(:access_token=>"CAABtfB8SO7kBADyHVHnWHqsxsU1bqqmeDdZCp7V1KF9G4o3oFHcZBq0IB8X3ird4muVIPuWKZB8jL1o9JCON60Lmnvk8rkZA2dyZAuU95dC0SWzOEnhtAEkyzZCN6hkKXdl87o38OloLBivc2kjJYmpUVKzdZAD5ywxKG7Hv5FWxXf6amWA782JSmcxgWsRDH4ZAZBXsUrhpnILNOVoKSBf1mGyfrFiPvA3QZD")
  self.title=event.name
  self.text=event.description
  unless event.start_time.nil?
    ce=Calentry.new(:start=>event.start_time, :ende=>event.end_time , :typ=>1)
    ce.ende=ce.start if ce.ende.nil?
    self.calentries<< ce
    ce.save

  end
end
name() click to toggle source
# File app/models/neuigkeit.rb, line 113
def name
  self.title
end
picture_robust() click to toggle source
# File app/models/neuigkeit.rb, line 71
def picture_robust
  unless self.picture.url.nil?
    return self.picture
  else
    if self.has_meeting?
     return self.meeting.meetingtyp.picture
    else
      unless self.title_pic.nil?
      #  return self.attachments.where(flag_titlepic: true).first.datei
        return self.title_pic.datei
      else
        return self.picture
      end
    end
  end
end
public?() click to toggle source
# File app/models/neuigkeit.rb, line 100
def public?
  self.rubrik.public
end
publish() click to toggle source
# File app/models/neuigkeit.rb, line 107
def publish
  self.datum = Time.now
end
published?() click to toggle source
# File app/models/neuigkeit.rb, line 103
def published?
 self.datum_nilsave<=Time.now
end
read_attribute(name,options={}) click to toggle source
# File app/models/neuigkeit.rb, line 61
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
  else
    super(name)
  end
end
relevant_calentry() click to toggle source
# File app/models/neuigkeit.rb, line 154
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
end
reverse_publish() click to toggle source
# File app/models/neuigkeit.rb, line 110
def reverse_publish
  self.datum = nil
end
text_first_words() click to toggle source
# File app/models/neuigkeit.rb, line 128
def text_first_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..100].join(" ")+ " ..." unless  words.nil?

  end
end
text_infoscreen_words() click to toggle source
# File app/models/neuigkeit.rb, line 138
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
update_cache() click to toggle source
# File app/models/neuigkeit.rb, line 159
def update_cache
  if self.has_meeting? && !self.meeting.calentry.nil?
    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?
      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)
      self.touch
    else
      unless self.datum.nil?
        self.update_column(:cache_order, (((self.datum.to_date - Date.today).to_i)).abs)
        self.update_column(:cache_relevant_date, self.datum.to_date)
      else
        self.update_column(:cache_order,0)
      end
    end
  end
  unless self.published?
    self.update_column(:cache_order, self.cache_order-14)
  end
  if self.flag_important
    self.update_column(:cache_order, self.cache_order-10)
  end
  self.update_column(:cache_is_published, self.published?)
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.