Commits

Stanislav Panasik committed 3593919

Only moderators can change the topic name

Comments (0)

Files changed (1)

 
     head_post_id = post.topic.posts.order_by('created')[0].id
     form_kwargs = dict(instance=post, initial={'title': post.topic.name})
-
-    if post.id == head_post_id:
+    
+    moderator = (request.user.is_superuser or
+                 request.user in post.topic.forum.moderators.all())
+    
+    form_class = EditPostForm
+    if post.id == head_post_id and moderator:
         form_class = EditHeadPostForm
-    else:
-        form_class = EditPostForm
 
     if request.method == 'POST':
         form = form_class(request.POST, request.FILES, **form_kwargs)