[Oi-commits] r1112 - in trunk: forum templates/forum
oi-commits at pardus.org.tr
oi-commits at pardus.org.tr
Fri Mar 7 15:02:41 EET 2008
Author: jnmbk
Date: Fri Mar 7 15:02:41 2008
New Revision: 1112
Modified:
trunk/forum/models.py
trunk/forum/views.py
trunk/templates/forum/topic.html
Log:
better way of editing topic and permission fixes
Modified: trunk/forum/models.py
=================================================================
--- trunk/forum/models.py (original)
+++ trunk/forum/models.py Fri Mar 7 15:02:41 2008
@@ -59,11 +59,8 @@
return '/forum/%s/%s/quote/%s/' % (self.topic.forum.slug, self.topic.id, self.id)
def get_edit_url(self):
- """ returns topic edit url if it's first post """
- if self.topic.post_set.order_by("created")[0].id == self.id:
- return '/forum/%s/%s/edit/' % (self.topic.forum.slug, self.topic.id)
- else:
- return '/forum/%s/%s/edit/%s/' % (self.topic.forum.slug, self.topic.id, self.id)
+ """ returns topic edit url of the post """
+ return '/forum/%s/%s/edit/%s/' % (self.topic.forum.slug, self.topic.id, self.id)
def get_hide_url(self):
return '/forum/%s/%s/hide/%s/' % (self.topic.forum.slug, self.topic.id, self.id)
@@ -85,6 +82,7 @@
("can_see_post_ip", "Can see author ip"),
("can_hide_post", "Can hide"),
("can_see_hidden_posts", "Can see hidden posts"),
+ ("can_edit_post", "Can edit post"),
)
def save(self):
@@ -195,6 +193,7 @@
("can_tag_topic", "Can tag topic"),
("can_see_hidden_topics", "Can see hidden topics"),
("can_merge_topic", "Can merge topic"),
+ ("can_edit_topic", "Can edit topic"),
)
def save(self):
Modified: trunk/forum/views.py
=================================================================
--- trunk/forum/views.py (original)
+++ trunk/forum/views.py Fri Mar 7 15:02:41 2008
@@ -179,7 +179,7 @@
topic = get_object_or_404(Topic, pk=topic_id)
first_post = topic.post_set.order_by('created')[0]
- if not request.user.has_perm('forum.change_topic') and not first_post.author == request.user:
+ if not request.user.has_perm('forum.change_topic'):
return HttpResponse('Opps, wrong way :)')
if forum.locked or topic.locked:
Modified: trunk/templates/forum/topic.html
=================================================================
--- trunk/templates/forum/topic.html (original)
+++ trunk/templates/forum/topic.html Fri Mar 7 15:02:41 2008
@@ -39,7 +39,12 @@
<div id="post_message_top_date">
{{ post.created|date:"d-m-Y H:i" }}
</div>
- {% if perms.forum.change_post %}
+ {% if perms.forum.can_edit_topic %}
+ <div id="post_message_top_button">
+ <a href="{{ topic.get_edit_url }}">edit_topic</a>
+ </div>
+ {% endif %}
+ {% if perms.forum.can_edit_post %}
<div id="post_message_top_button">
<a href="{{ post.get_edit_url }}"><img src="/media/dijital/img/forum/duzenle.jpg" border="0" /></a>
</div>
More information about the Oi-commits
mailing list