Commit 258a9851089335d17e54c99520d308dc16973ebf
- Diff rendering mode:
- inline
- side by side
pm/forum/models.py
(3 / 2)
|   | |||
| 34 | 34 | ||
| 35 | 35 | def first_post(self): | |
| 36 | 36 | return Post.objects.filter(topic=self)[0] | |
| 37 | |||
| 37 | 38 | def last_read_post(self): | |
| 38 | 39 | read = TopicRead.objects.select_related( | |
| 39 | 40 | ).filter(topic=self, user=get_current_user() | |
| 40 | ) | ||
| 41 | ).order_by('-post__creation') | ||
| 41 | 42 | if len(read) == 0: | |
| 42 | 43 | return self.first_post() | |
| 43 | 44 | else: | |
| … | … | ||
| 100 | 100 | return Post.objects.filter(topic=id).order_by('creation')[0] | |
| 101 | 101 | ||
| 102 | 102 | def mark_read(topic): | |
| 103 | TopicRead.objects.filter(topic=topic,user=get_current_user()).delete() | ||
| 103 | TopicRead.objects.filter(topic=topic,user=get_current_user()).delete() | ||
| 104 | 104 | t = TopicRead(post=topic.last_post, topic=topic, user=get_current_user()) | |
| 105 | 105 | t.save() | |
| 106 | 106 |

