##// END OF EJS Templates
Don't store threads list of a tag, cause this data can be got from thread's tags relations
neko259 -
r909:ffe54c08 default
parent child Browse files
Show More
@@ -0,0 +1,18 b''
1 # -*- coding: utf-8 -*-
2 from __future__ import unicode_literals
3
4 from django.db import models, migrations
5
6
7 class Migration(migrations.Migration):
8
9 dependencies = [
10 ('boards', '0002_auto_20141118_2234'),
11 ]
12
13 operations = [
14 migrations.RemoveField(
15 model_name='tag',
16 name='threads',
17 ),
18 ]
@@ -268,18 +268,6 b' class Post(models.Model, Viewable):'
268 thread.last_edit_time = edit_time
268 thread.last_edit_time = edit_time
269 thread.save(update_fields=['last_edit_time'])
269 thread.save(update_fields=['last_edit_time'])
270
270
271 @transaction.atomic
272 def remove_tag(self, tag):
273 edit_time = timezone.now()
274
275 thread = self.get_thread()
276 thread.remove_tag(tag)
277 self.last_edit_time = edit_time
278 self.save(update_fields=['last_edit_time'])
279
280 thread.last_edit_time = edit_time
281 thread.save(update_fields=['last_edit_time'])
282
283 def get_url(self, thread=None):
271 def get_url(self, thread=None):
284 """
272 """
285 Gets full url to the post.
273 Gets full url to the post.
@@ -36,8 +36,6 b' class Tag(models.Model, Viewable):'
36 ordering = ('name',)
36 ordering = ('name',)
37
37
38 name = models.CharField(max_length=100, db_index=True)
38 name = models.CharField(max_length=100, db_index=True)
39 threads = models.ManyToManyField(Thread, null=True,
40 blank=True, related_name='tag+')
41
39
42 def __str__(self):
40 def __str__(self):
43 return self.name
41 return self.name
@@ -136,7 +136,6 b' class Thread(models.Model):'
136 """
136 """
137
137
138 self.tags.add(tag)
138 self.tags.add(tag)
139 tag.threads.add(self)
140
139
141 def get_opening_post(self, only_id=False):
140 def get_opening_post(self, only_id=False):
142 """
141 """
General Comments 0
You need to be logged in to leave comments. Login now