fixes #139: New forum threads submitted locked/stickied are neither.

This commit is contained in:
albert
2011-10-17 00:13:36 -04:00
parent 3feeaf02e3
commit eee3351c0f
5 changed files with 31 additions and 2 deletions

View File

@@ -30,7 +30,7 @@ class ForumTopicsController < ApplicationController
end
def create
@forum_topic = ForumTopic.create(params[:forum_topic])
@forum_topic = ForumTopic.create(params[:forum_topic], :as => CurrentUser.role)
respond_with(@forum_topic)
end
@@ -38,7 +38,7 @@ class ForumTopicsController < ApplicationController
@forum_topic = ForumTopic.find(params[:id])
check_privilege(@forum_topic)
assign_special_attributes(@forum_topic)
@forum_topic.update_attributes(params[:forum_topic])
@forum_topic.update_attributes(params[:forum_topic], :as => CurrentUser.role)
respond_with(@forum_topic)
end

View File

@@ -119,6 +119,10 @@ class AnonymousUser
def update_column(*params)
end
def role
:anonymous
end
%w(member banned privileged contributor janitor moderator admin).each do |name|
define_method("is_#{name}?") do
false

View File

@@ -1,5 +1,6 @@
class ForumTopic < ActiveRecord::Base
attr_accessible :title, :original_post_attributes
attr_accessible :is_sticky, :is_locked, :as => :janitor
belongs_to :creator, :class_name => "User"
belongs_to :updater, :class_name => "User"
has_many :posts, :class_name => "ForumPost", :order => "forum_posts.id asc", :foreign_key => "topic_id", :dependent => :destroy

View File

@@ -199,6 +199,28 @@ class User < ActiveRecord::Base
end
end
def role
case level
when Levels::MEMBER
:member
when Levels::PRIVILEGED
:privileged
when Levels::CONTRIBUTOR
:contributor
when Levels::JANITOR
:janitor
when Levels::MODERATOR
:moderator
when Levels::ADMIN
:admin
end
end
def level_string
case level
when Levels::MEMBER

View File

@@ -1,5 +1,7 @@
<div id="c-forum-topics">
<div id="a-show">
<h1>Topic: <%= @forum_topic.title %></h1>
<% if @forum_topic.is_locked? %>
<div class="notice">
<p>This topic has been locked.</p>