Implement sticky forum threads

This commit is contained in:
Trever Fischer
2012-02-19 22:28:14 -05:00
parent e30e814e57
commit bfc09616ff
3 changed files with 6 additions and 2 deletions

View File

@@ -9,4 +9,4 @@ class ReplyForm(forms.ModelForm):
class TopicForm(forms.ModelForm):
class Meta:
model = models.Topic
exclude = ('forum', 'rootPost')
exclude = ('forum', 'rootPost', 'sticky')

View File

@@ -59,6 +59,10 @@ class Topic(models.Model):
created = models.DateTimeField(editable=False, auto_now_add=True)
updated = models.DateTimeField(editable=False, auto_now=True)
slug = models.SlugField(editable=False, blank=True)
sticky = models.BooleanField(default=False)
class Meta:
ordering = ['-sticky', '-updated']
def save(self, *args, **kwargs):
unique_slug(self, slug_source='title', slug_field='slug')

View File

@@ -19,7 +19,7 @@
</tr>
{% if topics %}
{% for topic in topics %}
<tr class="{%cycle 'even' 'odd' %}">
<tr class="{%cycle 'even' 'odd' %} {% if topic.sticky %}sticky{% endif %}">
<td><a href="{{topic.get_absolute_url}}">{{ topic.title }}</a></td>
<td>{{ topic.created }} </td>
<td>{{topic.lastPost.created}} by {{ topic.lastPost.user }} </td>