enabled forum
This commit is contained in:
parent
7d752c420f
commit
03b2daffa5
@ -23,22 +23,25 @@ class Forum::ForumTopicsController < ApplicationController
|
|||||||
end
|
end
|
||||||
|
|
||||||
def index
|
def index
|
||||||
@forum_topics = ForumTopic.all
|
@forum_topics = ForumTopic.where(:enabled => true).all
|
||||||
end
|
end
|
||||||
|
|
||||||
def show
|
def show
|
||||||
@topic = ForumTopic.find(params[:id])
|
|
||||||
session[:topics] = session[:topics] || []
|
if @topic = ForumTopic.where(:enabled => true, :id => params[:id]).first
|
||||||
if session[:topics].include?(@topic.id)
|
session[:topics] = session[:topics] || []
|
||||||
topic_viewed = current_fuser.forum_user_topic_vieweds.where(:forum_topic_id => @topic.id).order("created_at DESC").first
|
if session[:topics].include?(@topic.id)
|
||||||
topic_viewed.updated_at = Time.now
|
topic_viewed = current_fuser.forum_user_topic_vieweds.where(:forum_topic_id => @topic.id).order("created_at DESC").first
|
||||||
topic_viewed.save
|
topic_viewed.updated_at = Time.now
|
||||||
|
topic_viewed.save
|
||||||
|
else
|
||||||
|
current_fuser.topic_vieweds << @topic
|
||||||
|
session[:topics] << @topic.id
|
||||||
|
|
||||||
|
end
|
||||||
else
|
else
|
||||||
current_fuser.topic_vieweds << @topic
|
redirect_to forum_forum_topics_path
|
||||||
session[:topics] << @topic.id
|
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
9
db/migrate/20150217165331_add_enabled_to_forum_topics.rb
Normal file
9
db/migrate/20150217165331_add_enabled_to_forum_topics.rb
Normal 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
|
34
db/schema.rb
34
db/schema.rb
@ -11,7 +11,7 @@
|
|||||||
#
|
#
|
||||||
# It's strongly recommended that you check this file into your version control system.
|
# 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|
|
create_table "admins", force: true do |t|
|
||||||
t.string "email", default: "", null: false
|
t.string "email", default: "", null: false
|
||||||
@ -24,20 +24,17 @@ ActiveRecord::Schema.define(version: 20150121145821) do
|
|||||||
t.datetime "last_sign_in_at"
|
t.datetime "last_sign_in_at"
|
||||||
t.string "current_sign_in_ip"
|
t.string "current_sign_in_ip"
|
||||||
t.string "last_sign_in_ip"
|
t.string "last_sign_in_ip"
|
||||||
t.datetime "created_at", null: false
|
t.datetime "created_at"
|
||||||
t.datetime "updated_at", null: false
|
t.datetime "updated_at"
|
||||||
|
t.string "avatar"
|
||||||
|
t.string "password_digest", default: "", null: false
|
||||||
|
t.string "remember_token"
|
||||||
t.string "username"
|
t.string "username"
|
||||||
t.string "name"
|
t.string "name"
|
||||||
t.string "firstname"
|
t.string "firstname"
|
||||||
t.string "file"
|
t.string "file"
|
||||||
t.string "avatar"
|
|
||||||
t.string "password_digest", default: "", null: false
|
|
||||||
t.string "remember_token"
|
|
||||||
end
|
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|
|
create_table "albums", force: true do |t|
|
||||||
t.string "name"
|
t.string "name"
|
||||||
t.boolean "super_admin"
|
t.boolean "super_admin"
|
||||||
@ -258,6 +255,7 @@ ActiveRecord::Schema.define(version: 20150121145821) do
|
|||||||
t.text "description"
|
t.text "description"
|
||||||
t.datetime "created_at", null: false
|
t.datetime "created_at", null: false
|
||||||
t.datetime "updated_at", null: false
|
t.datetime "updated_at", null: false
|
||||||
|
t.boolean "enabled"
|
||||||
end
|
end
|
||||||
|
|
||||||
add_index "forum_topics", ["forum_user_id"], name: "index_forum_topics_on_forum_user_id", using: :btree
|
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.string "firstname"
|
||||||
t.text "bio"
|
t.text "bio"
|
||||||
t.string "avatar"
|
t.string "avatar"
|
||||||
|
t.string "localisation"
|
||||||
|
t.boolean "moderator"
|
||||||
t.string "email", default: "", null: false
|
t.string "email", default: "", null: false
|
||||||
t.string "password_digest", default: "", null: false
|
t.string "password_digest", default: "", null: false
|
||||||
t.string "reset_password_token"
|
t.string "reset_password_token"
|
||||||
@ -481,8 +481,8 @@ ActiveRecord::Schema.define(version: 20150121145821) do
|
|||||||
t.text "content"
|
t.text "content"
|
||||||
t.datetime "sendmail"
|
t.datetime "sendmail"
|
||||||
t.boolean "archive"
|
t.boolean "archive"
|
||||||
t.datetime "created_at", null: false
|
t.datetime "created_at"
|
||||||
t.datetime "updated_at", null: false
|
t.datetime "updated_at"
|
||||||
t.string "email_from"
|
t.string "email_from"
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -804,4 +804,16 @@ ActiveRecord::Schema.define(version: 20150121145821) do
|
|||||||
|
|
||||||
add_index "topics", ["admin_id"], name: "index_topics_on_admin_id", using: :btree
|
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
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user