Mercurial > public > sg101
comparison gpp/news/models.py @ 182:5c889b587416
Fixing #64. Updating all model save() methods to use *args and **kwargs. Django 1.2 has new keyword arguments.
author | Brian Neal <bgneal@gmail.com> |
---|---|
date | Sun, 28 Mar 2010 21:41:11 +0000 |
parents | e249b5f9d180 |
children | b4305e18d3af |
comparison
equal
deleted
inserted
replaced
181:500e5875a306 | 182:5c889b587416 |
---|---|
35 date_submitted = models.DateTimeField(auto_now_add=True, db_index=True) | 35 date_submitted = models.DateTimeField(auto_now_add=True, db_index=True) |
36 allow_comments = models.BooleanField(default=True) | 36 allow_comments = models.BooleanField(default=True) |
37 approved = models.BooleanField(default=False) | 37 approved = models.BooleanField(default=False) |
38 tags = TagField() | 38 tags = TagField() |
39 | 39 |
40 def save(self, force_insert = False, force_update = False): | 40 def save(self, *args, **kwargs): |
41 if self.approved: | 41 if self.approved: |
42 Story.objects.create(title=self.title, | 42 Story.objects.create(title=self.title, |
43 submitter=self.submitter, | 43 submitter=self.submitter, |
44 category=self.category, | 44 category=self.category, |
45 short_text=self.short_text, | 45 short_text=self.short_text, |
48 date_published=datetime.datetime.now(), | 48 date_published=datetime.datetime.now(), |
49 tags=self.tags) | 49 tags=self.tags) |
50 self.delete() | 50 self.delete() |
51 cache.delete('home_news') | 51 cache.delete('home_news') |
52 else: | 52 else: |
53 super(PendingStory, self).save(force_insert, force_update) | 53 super(PendingStory, self).save(*args, **kwargs) |
54 | 54 |
55 def __unicode__(self): | 55 def __unicode__(self): |
56 return self.title | 56 return self.title |
57 | 57 |
58 class Meta: | 58 class Meta: |
85 def can_comment_on(self): | 85 def can_comment_on(self): |
86 now = datetime.datetime.now() | 86 now = datetime.datetime.now() |
87 delta = now - self.date_published | 87 delta = now - self.date_published |
88 return delta.days < 30 | 88 return delta.days < 30 |
89 | 89 |
90 def save(self, force_insert=False, force_update=False): | 90 def save(self, *args, **kwargs): |
91 super(Story, self).save(force_insert, force_update) | 91 super(Story, self).save(*args, **kwargs) |
92 cache.delete('home_news') | 92 cache.delete('home_news') |
93 | 93 |