diff --git a/app/controllers/emails_controller.rb b/app/controllers/emails_controller.rb new file mode 100644 index 0000000..7a96c05 --- /dev/null +++ b/app/controllers/emails_controller.rb @@ -0,0 +1,7 @@ +class EmailsController < ApplicationController + load_and_authorize_resource + + def index + + end +end diff --git a/app/controllers/rubriken_controller.rb b/app/controllers/rubriken_controller.rb index b6c5e0e..966edf1 100755 --- a/app/controllers/rubriken_controller.rb +++ b/app/controllers/rubriken_controller.rb @@ -16,7 +16,7 @@ class RubrikenController < ApplicationController @rubriken= Rubrik.accessible_by(current_ability, :show) @neuigkeiten = Neuigkeit.accessible_by(current_ability, :list).page(params[:page]).per(3) - @calentries= (@rubriken.map {|r| r.calendar}).collect(&:calentries).flatten.select {|c| c.object !=nil} + @calentries= (@rubriken.map {|r| r.calendar.calentries.of_month(Date.new(params[:year],params[:month],1))}).flatten.select {|c| c.object !=nil} respond_to do |format| format.html format.js {render action: :show} diff --git a/app/mailers/news_mailer.rb b/app/mailers/news_mailer.rb index 9a283f6..bfb3b1a 100644 --- a/app/mailers/news_mailer.rb +++ b/app/mailers/news_mailer.rb @@ -28,7 +28,7 @@ render locals: {current_user: User.first} @user=user self.message.perform_deliveries = false unless user.flag_getemails @ability = Ability.new(user) - @calentries = Calentry.limit(100) + @calentries = Calentry.of_month(Date.today).limit(100) # @neuigkeiten=Neuigkeit.accessiblße_by(ability).published_scope.where("cache_order<2") mail(to: user.email, content_type: "text/html", subject: "sdf") render locals: {c_user: user} diff --git a/app/models/ability.rb b/app/models/ability.rb index 6dfe69d..d59a3bf 100755 --- a/app/models/ability.rb +++ b/app/models/ability.rb @@ -227,7 +227,8 @@ end can :doadmin, User end - unless user.has_role?("fetadmin") + if user.has_role?("fetadmin") + end end diff --git a/app/models/calentry.rb b/app/models/calentry.rb index e25032e..6421632 100644 --- a/app/models/calentry.rb +++ b/app/models/calentry.rb @@ -14,14 +14,14 @@ class Calentry < ActiveRecord::Base attr_accessible :ende, :start, :summary, :typ,:calendar_ids, :calendar, :dauer, :object_id, :object_type - belongs_to :calendar + belongs_to :calendar, touch: true #belongs_to :neuigkeit validates :start, :presence => true validates :object, :presence => true validates :typ, :presence => true before_save :get_public belongs_to :object, polymorphic: true, touch: true # Objekt zu dem der Calentry gehört (derzeit ein Newsartikel) - scope :of_month,(d) -> {where("start >= ? AND start <= ?", d.beginning_of_month, d.end_of_month)} + scope :of_month, ->(d) {where("start >= ? AND start <= ?", d.beginning_of_month, d.end_of_month)} scope :upcoming, ->{ where("start >= ?", Time.now).order(:start)} scope :recent,-> { where("start <= ?", Time.now).order(:start).reverse_order} validate do |entry| @@ -31,7 +31,10 @@ class Calentry < ActiveRecord::Base end resourcify - + def self.updated_at + #Calentry.select("MAX(updated_at) as m_updated_at").first.m_updated_at + Calentry.all.max_by(&:updated_at).updated_at + end def is_upcomming? self.start > Time.now end diff --git a/app/models/survey/answer.rb b/app/models/survey/answer.rb index a7d2c78..244bafe 100644 --- a/app/models/survey/answer.rb +++ b/app/models/survey/answer.rb @@ -1,5 +1,5 @@ class Survey::Answer < ActiveRecord::Base - belongs_to :choice, class_name: 'Survey::Choice' + belongs_to :choice, class_name: 'Survey::Choice', touch: true belongs_to :user # attr_accessible :title, :body end diff --git a/app/models/survey/choice.rb b/app/models/survey/choice.rb index 22f8dbf..7fca518 100644 --- a/app/models/survey/choice.rb +++ b/app/models/survey/choice.rb @@ -1,5 +1,5 @@ class Survey::Choice < ActiveRecord::Base - belongs_to :question, class_name: 'Survey::Question' + belongs_to :question, class_name: 'Survey::Question', touch: true attr_accessible :picture, :sort, :text, :icon, :picture_cache, :remove_picture, :question_id has_many :answers, class_name: 'Survey::Answer', dependent: :destroy include ActionView::Helpers::TagHelper diff --git a/app/models/survey/question.rb b/app/models/survey/question.rb index 9500d05..b10c199 100644 --- a/app/models/survey/question.rb +++ b/app/models/survey/question.rb @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- class Survey::Question < ActiveRecord::Base attr_accessible :text, :title, :typ, :choice_ids, :parent_type, :parent_id - belongs_to :parent, polymorphic: true + belongs_to :parent, polymorphic: true, touch: true has_many :choices, dependent: :destroy, class_name: "Survey::Choice" has_many :answers, through: :choices include IsCommentable diff --git a/app/views/news_mailer/daily_reminder.html.erb b/app/views/news_mailer/daily_reminder.html.erb index 5b18aeb..b8a3a5a 100644 --- a/app/views/news_mailer/daily_reminder.html.erb +++ b/app/views/news_mailer/daily_reminder.html.erb @@ -1,8 +1,9 @@ <%= stylesheet_link_tag "http://"+ActionMailer::Base.default_url_options[:host].to_s + "/assets/themes/blue2/application.css", :media=>"all" %> <% @calentries.each do |ce| %> -