enabled forum

This commit is contained in:
Nicolas Bally 2015-02-17 17:59:26 +01:00
parent 7d752c420f
commit 03b2daffa5
3 changed files with 46 additions and 22 deletions

View File

@ -23,11 +23,12 @@ 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])
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
@ -38,7 +39,9 @@ class Forum::ForumTopicsController < ApplicationController
session[:topics] << @topic.id
end
else
redirect_to forum_forum_topics_path
end
end

View File

@ -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

View File

@ -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