prevent editing label after thread was locked

This commit is contained in:
jomo
2015-01-25 17:10:15 +01:00
parent 0050d6285b
commit 31dcf02083
2 changed files with 4 additions and 3 deletions
+3 -2
View File
@@ -44,7 +44,7 @@ class ForumthreadsController < ApplicationController
def update def update
if mod? || @thread.author.is?(current_user) if mod? || @thread.author.is?(current_user)
@thread.user_editor = current_user @thread.user_editor = current_user
@thread.attributes = (mod? ? thread_params([:sticky, :locked, :forum_id]) : thread_params) @thread.attributes = (mod? ? thread_params([:sticky, :locked, :forum_id, :label_id]) : thread_params)
old_content = @thread.content_was old_content = @thread.content_was
if @thread.save if @thread.save
@thread.send_new_mention_mail(old_content) @thread.send_new_mention_mail(old_content)
@@ -83,7 +83,8 @@ class ForumthreadsController < ApplicationController
end end
def thread_params(add = []) def thread_params(add = [])
a = [:title, :content, :label_id] a = [:title, :content]
a << :label_id unless @thread.locked?
a += add a += add
params.require(:forumthread).permit(a) params.require(:forumthread).permit(a)
end end
+1 -1
View File
@@ -29,7 +29,7 @@
<% end %> <% end %>
</table> </table>
<div class="table-cell"> <div class="table-cell">
<%= f.select :label_id, labels, {}, class: "auto-width" %> <%= f.select :label_id, labels, {}, class: "auto-width", disabled: (@thread.locked? && !mod?) %>
</div> </div>
<div class="table-cell full-width"> <div class="table-cell full-width">
<%= f.text_field :title, placeholder: "Title" %> <%= f.text_field :title, placeholder: "Title" %>