diff options
author | luxagraf <sng@luxagraf.net> | 2023-07-28 13:39:02 -0500 |
---|---|---|
committer | luxagraf <sng@luxagraf.net> | 2023-07-28 13:39:02 -0500 |
commit | 9a620cf42bf1fe6977e378bd834b41ff4a593dde (patch) | |
tree | cf41a0582681cecaf88a30bfe409f9c2be57972a /bak/unused_apps/ccg_notes/models.py | |
parent | 6e5897117124cd60ae81efb1574c6347f48e60e5 (diff) |
main: removed some apps I wasn't using and added bak to git to preserve
a copy of old apps
Diffstat (limited to 'bak/unused_apps/ccg_notes/models.py')
-rw-r--r-- | bak/unused_apps/ccg_notes/models.py | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/bak/unused_apps/ccg_notes/models.py b/bak/unused_apps/ccg_notes/models.py new file mode 100644 index 0000000..b235d36 --- /dev/null +++ b/bak/unused_apps/ccg_notes/models.py @@ -0,0 +1,36 @@ +from django.contrib.gis.db import models +from django.utils import timezone +from django.core.urlresolvers import reverse + +from taggit.managers import TaggableManager +from utils.widgets import markdown_to_html +from jrnl.models import render_images + + +class CcgNote(models.Model): + title = models.CharField(max_length=250, null=True, blank=True) + slug = models.SlugField(unique_for_date='pub_date', blank=True) + pub_date = models.DateTimeField(default=timezone.now) + date_last_updated = models.DateTimeField('Date', blank=True) + body_html = models.TextField(blank=True) + body_markdown = models.TextField('Note') + PUB_STATUS = ( + (0, 'Draft'), + (1, 'Published'), + ) + status = models.IntegerField(choices=PUB_STATUS, default=1) + tags = TaggableManager(blank=True) + + def __str__(self): + return self.title + + def get_absolute_url(self): + return reverse("ccg_notes:detail", kwargs={"year": self.pub_date.year, "month": self.pub_date.strftime("%m"), "slug": self.slug}) + + def save(self, *args, **kwargs): + md = render_images(self.body_markdown) + self.body_html = markdown_to_html(md) + if not self.id: + self.pub_date = timezone.now() + self.date_last_updated = timezone.now() + super(CcgNote, self).save() |