Implement sticky forum threads
This commit is contained in:
@@ -9,4 +9,4 @@ class ReplyForm(forms.ModelForm):
|
||||
class TopicForm(forms.ModelForm):
|
||||
class Meta:
|
||||
model = models.Topic
|
||||
exclude = ('forum', 'rootPost')
|
||||
exclude = ('forum', 'rootPost', 'sticky')
|
||||
|
@@ -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')
|
||||
|
@@ -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>
|
||||
|
Reference in New Issue
Block a user