diff --git a/app/controllers/forum/forum_topics_controller.rb b/app/controllers/forum/forum_topics_controller.rb index a4606ee..7770867 100644 --- a/app/controllers/forum/forum_topics_controller.rb +++ b/app/controllers/forum/forum_topics_controller.rb @@ -23,22 +23,25 @@ class Forum::ForumTopicsController < ApplicationController end def index - @forum_topics = ForumTopic.all + @forum_topics = ForumTopic.where(:enabled => true).all end def show - @topic = ForumTopic.find(params[:id]) - session[:topics] = session[:topics] || [] - if session[:topics].include?(@topic.id) - topic_viewed = current_fuser.forum_user_topic_vieweds.where(:forum_topic_id => @topic.id).order("created_at DESC").first - topic_viewed.updated_at = Time.now - topic_viewed.save - else - current_fuser.topic_vieweds << @topic - session[:topics] << @topic.id + + if @topic = ForumTopic.where(:enabled => true, :id => params[:id]).first + session[:topics] = session[:topics] || [] + if session[:topics].include?(@topic.id) + topic_viewed = current_fuser.forum_user_topic_vieweds.where(:forum_topic_id => @topic.id).order("created_at DESC").first + topic_viewed.updated_at = Time.now + topic_viewed.save + else + current_fuser.topic_vieweds << @topic + session[:topics] << @topic.id + end + else + redirect_to forum_forum_topics_path end - end diff --git a/db/migrate/20150217165331_add_enabled_to_forum_topics.rb b/db/migrate/20150217165331_add_enabled_to_forum_topics.rb new file mode 100644 index 0000000..58288d1 --- /dev/null +++ b/db/migrate/20150217165331_add_enabled_to_forum_topics.rb @@ -0,0 +1,9 @@ +class AddEnabledToForumTopics < ActiveRecord::Migration + def change + add_column :forum_topics, :enabled, :boolean + ForumTopic.all.each do |forum_topic| + forum_topic.enabled = true + forum_topic.save + end + end +end diff --git a/db/schema.rb b/db/schema.rb index 1fe9842..128da59 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 20150121145821) do +ActiveRecord::Schema.define(version: 20150217165331) do create_table "admins", force: true do |t| t.string "email", default: "", null: false @@ -24,20 +24,17 @@ ActiveRecord::Schema.define(version: 20150121145821) do t.datetime "last_sign_in_at" t.string "current_sign_in_ip" t.string "last_sign_in_ip" - t.datetime "created_at", null: false - t.datetime "updated_at", null: false + t.datetime "created_at" + t.datetime "updated_at" + t.string "avatar" + t.string "password_digest", default: "", null: false + t.string "remember_token" t.string "username" t.string "name" t.string "firstname" t.string "file" - t.string "avatar" - t.string "password_digest", default: "", null: false - t.string "remember_token" end - add_index "admins", ["email"], name: "index_admins_on_email", unique: true, using: :btree - add_index "admins", ["reset_password_token"], name: "index_admins_on_reset_password_token", unique: true, using: :btree - create_table "albums", force: true do |t| t.string "name" t.boolean "super_admin" @@ -258,6 +255,7 @@ ActiveRecord::Schema.define(version: 20150121145821) do t.text "description" t.datetime "created_at", null: false t.datetime "updated_at", null: false + t.boolean "enabled" end add_index "forum_topics", ["forum_user_id"], name: "index_forum_topics_on_forum_user_id", using: :btree @@ -291,6 +289,8 @@ ActiveRecord::Schema.define(version: 20150121145821) do t.string "firstname" t.text "bio" t.string "avatar" + t.string "localisation" + t.boolean "moderator" t.string "email", default: "", null: false t.string "password_digest", default: "", null: false t.string "reset_password_token" @@ -481,8 +481,8 @@ ActiveRecord::Schema.define(version: 20150121145821) do t.text "content" t.datetime "sendmail" t.boolean "archive" - t.datetime "created_at", null: false - t.datetime "updated_at", null: false + t.datetime "created_at" + t.datetime "updated_at" t.string "email_from" end @@ -804,4 +804,16 @@ ActiveRecord::Schema.define(version: 20150121145821) do add_index "topics", ["admin_id"], name: "index_topics_on_admin_id", using: :btree + create_table "year_paiements", force: true do |t| + t.text "paiement_type" + t.text "nature" + t.string "cheque_number" + t.string "bank_name" + t.date "paid_at" + t.integer "amout" + t.integer "join_year_id" + t.datetime "created_at" + t.datetime "updated_at" + end + end