comparison news/models.py @ 998:e2c3d7ecfa30

Added tests for submit news.
author Brian Neal <bgneal@gmail.com>
date Fri, 20 Nov 2015 23:07:37 -0600
parents 19b86e684cc2
children 8386a8ebcbc7
comparison
equal deleted inserted replaced
997:19b86e684cc2 998:e2c3d7ecfa30
35 """Abstract model to collect common fields.""" 35 """Abstract model to collect common fields."""
36 title = models.CharField(max_length=255) 36 title = models.CharField(max_length=255)
37 submitter = models.ForeignKey(User) 37 submitter = models.ForeignKey(User)
38 category = models.ForeignKey(Category) 38 category = models.ForeignKey(Category)
39 short_text = models.TextField() 39 short_text = models.TextField()
40 long_text = models.TextField(blank=True) 40 long_text = models.TextField(default='', blank=True)
41 date_submitted = models.DateTimeField(db_index=True) 41 date_submitted = models.DateTimeField(db_index=True)
42 allow_comments = models.BooleanField(default=True) 42 allow_comments = models.BooleanField(default=True)
43 tags = TagField() 43 tags = TagField()
44 front_page_expiration = models.DateField(null=True, blank=True) 44 front_page_expiration = models.DateField(null=True, blank=True)
45 update_date = models.DateTimeField(db_index=True, blank=True) 45 update_date = models.DateTimeField(db_index=True, blank=True)
58 self.date_submitted = datetime.datetime.now() 58 self.date_submitted = datetime.datetime.now()
59 self.update_date = self.date_submitted 59 self.update_date = self.date_submitted
60 else: 60 else:
61 self.update_date = datetime.datetime.now() 61 self.update_date = datetime.datetime.now()
62 62
63 self.short_text = kwargs.pop('short_text', None) 63 self.short_text = kwargs.pop('short_text', '')
64 if self.short_text is None and self.short_markup: 64 if not self.short_text and self.short_markup:
65 self.short_text = site_markup(self.short_markup) 65 self.short_text = site_markup(self.short_markup)
66 66
67 self.long_text = kwargs.pop('long_text', None) 67 self.long_text = kwargs.pop('long_text', '')
68 if self.long_text is None and self.long_markup: 68 if not self.long_text and self.long_markup:
69 self.long_text = site_markup(self.long_markup) 69 self.long_text = site_markup(self.long_markup)
70 70
71 super(StoryBase, self).save(*args, **kwargs) 71 super(StoryBase, self).save(*args, **kwargs)
72 72
73 73