summaryrefslogtreecommitdiff
path: root/app/projects/models/code.py
diff options
context:
space:
mode:
Diffstat (limited to 'app/projects/models/code.py')
-rw-r--r--app/projects/models/code.py90
1 files changed, 0 insertions, 90 deletions
diff --git a/app/projects/models/code.py b/app/projects/models/code.py
deleted file mode 100644
index 495fc2f..0000000
--- a/app/projects/models/code.py
+++ /dev/null
@@ -1,90 +0,0 @@
-import datetime
-from django.db import models
-
-import markdown
-PUB_STATUS = (
- (0, 'Draft'),
- (1, 'Published'),
- )
-def markdown_processor(md):
- return markdown.markdown(md, ['footnotes'],safe_mode = False)
-
-
-class Code(models.Model):
- name = models.CharField(max_length=254)
- slug = models.SlugField()
- date_created = models.DateField('Date Created')
- status = models.IntegerField(choices=PUB_STATUS, default=0)
- body_html = models.TextField(blank=True)
-
- class Meta:
- verbose_name_plural = "Code"
- app_label = 'projects'
- ordering = ('-date_created',)
- # Returns the string representation of the model.
- def __unicode__(self):
- return self.slug
-
-class CodeBlogEntry(models.Model):
- title = models.CharField(max_length=254)
- slug = models.SlugField()
- body_markdown = models.TextField()
- body_html = models.TextField(blank=True)
- pub_date = models.DateTimeField('Date published', blank=True)
- status = models.IntegerField(choices=PUB_STATUS, default=0)
- enable_comments = models.BooleanField(default=True)
-
- class Meta:
- verbose_name_plural = "Code Blog"
- app_label = 'projects'
- ordering = ('-pub_date',)
-
- # Returns the string representation of the model.
- def __unicode__(self):
- return self.slug
-
- def get_absolute_url(self):
- return "/projects/code/%s/%s/" % (self.pub_date.strftime("%Y/%b/%d").lower(), self.slug)
-
- @property
- def get_previous_published(self):
- return self.get_previous_by_pub_date(status__exact=1)
-
- @property
- def get_next_published(self):
- return self.get_next_by_pub_date(status__exact=1)
-
-
- def comment_period_open(self):
- return self.enable_comments and datetime.datetime.today() - datetime.timedelta(30) <= self.pub_date
-
- def save(self):
- self.body_html = markdown_processor(self.body_markdown)
- if not self.id and self.pub_date == None:
- self.pub_date = datetime.datetime.now()
- super(CodeBlogEntry, self).save()
-
-
-
-DEMO_TEMPLATES = (
- (0, 'Blank'),
- (1, 'Basic_light'),
- )
-
-
-class CodeBlogDemo(models.Model):
- title = models.CharField(max_length=254)
- slug = models.SlugField()
- body = models.TextField(blank=True,null=True)
- head = models.TextField(blank=True,null=True)
- template= models.IntegerField(choices=DEMO_TEMPLATES, default=0)
- pub_date = models.DateTimeField('Date published',blank=True)
- class Meta:
- verbose_name_plural = "Demos"
- app_label = 'projects'
- ordering = ('-pub_date',)
-
- def save(self):
- if not self.id:
- self.pub_date = datetime.datetime.now()
- super(CodeBlogDemo, self).save()