Skip to content
This repository has been archived by the owner on Apr 26, 2022. It is now read-only.

Commit

Permalink
only allow user group assignment to forum after it is created
Browse files Browse the repository at this point in the history
  • Loading branch information
jlapier committed Apr 26, 2012
1 parent 16b4bf4 commit 2908368
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 6 deletions.
2 changes: 1 addition & 1 deletion app/controllers/forums_controller.rb
Expand Up @@ -72,7 +72,7 @@ def create
respond_to do |format|
if @forum.save
flash[:notice] = "Forum #{@forum.name} was successfully created."
format.html { redirect_to forums_path }
format.html { redirect_to edit_forum_path(@forum) }
format.xml { render :xml => @forum, :status => :created, :location => @forum }
else
format.html { render :action => "new" }
Expand Down
3 changes: 3 additions & 0 deletions app/models/user_group.rb
Expand Up @@ -55,6 +55,9 @@ def forums
end

def add_forum(forum, access)
if forum.new_record?
raise "no forum ID found!"
end
self.special ||= {}
self.special[:forums] ||= {}
self.special[:forums][forum.id.to_s] = access
Expand Down
4 changes: 4 additions & 0 deletions app/views/forums/_form.html.erb
Expand Up @@ -15,12 +15,16 @@
<td><%= f.label :description %>:</td>
<td><%= f.text_area :description, :rows => 5, :cols => 80, :style => "height: 100px;" %></td>
</tr>
<% if @forum.new_record? %>
<tr><td></td><td><em>After you create this forum, you can set the group access.</em></td></tr>
<% else %>
<tr>
<td><%= f.label :group_access %>:</td>
<td>
<%= render :partial => 'group_access' %>
</td>
</tr>
<% end %>
<tr>
<td></td>
<td><%= submit_tag @forum.new_record? ? "Make this Forum!" : "Save Changes" %></td>
Expand Down
6 changes: 2 additions & 4 deletions app/views/forums/index.html.erb
Expand Up @@ -41,7 +41,7 @@
<div class="subject">
<%= link_to message_post.subject,
forum_message_post_path(message_post.forum, message_post) %> by
<%= message_post.user.name %>
<%= message_post.user ? message_post.user.name : 'unknown user' %>
<em>(<%= pluralize message_post.child_posts.count, "reply" %>)</em>
</div>
<div class="date_and_forum">
Expand All @@ -54,9 +54,7 @@

<br />

<% if is_admin? %>
<p>
<% content_for :admin_bar do %>
<%= link_to 'change forum list order', sort_forums_path %> |
<%= link_to 'create a new forum', new_forum_path %>
</p>
<% end %>
2 changes: 1 addition & 1 deletion app/views/message_posts/_message_in_forum.html.erb
Expand Up @@ -19,7 +19,7 @@
<%= link_to message.most_recent_reply.subject, forum_message_post_path(@forum, message),
:page => MessagePost.last_page_number_for(:thread_id => message),
:anchor => "bottom" %> <br/>
<em><%= message.most_recent_reply.user.name %></em>
<em><%= message.most_recent_reply.try(:user).try(:name) or 'unknown user' %></em>
<em><%= post_time message.most_recent_reply.created_at %></em>
<% else -%>
<em>no replies</em>
Expand Down

0 comments on commit 2908368

Please sign in to comment.