aboutsummaryrefslogtreecommitdiffstats
path: root/examples/blogpost/models.py
diff options
context:
space:
mode:
authorTom Christie2012-08-29 19:54:38 +0100
committerTom Christie2012-08-29 19:54:38 +0100
commiteea2aa04378d27d79e7aba12ce95c697148bd57e (patch)
tree4ae3c67246c45df2b90e32376a067107fda486b2 /examples/blogpost/models.py
parentecd3733c5e229505baca5a870963f2dd492d6dd7 (diff)
downloaddjango-rest-framework-eea2aa04378d27d79e7aba12ce95c697148bd57e.tar.bz2
Remove examples (to be moved to a seperate project)
Diffstat (limited to 'examples/blogpost/models.py')
-rw-r--r--examples/blogpost/models.py41
1 files changed, 0 insertions, 41 deletions
diff --git a/examples/blogpost/models.py b/examples/blogpost/models.py
deleted file mode 100644
index 10732ab4..00000000
--- a/examples/blogpost/models.py
+++ /dev/null
@@ -1,41 +0,0 @@
-from django.db import models
-from django.template.defaultfilters import slugify
-import uuid
-
-
-def uuid_str():
- return str(uuid.uuid1())
-
-
-RATING_CHOICES = ((0, 'Awful'),
- (1, 'Poor'),
- (2, 'OK'),
- (3, 'Good'),
- (4, 'Excellent'))
-
-MAX_POSTS = 10
-
-
-class BlogPost(models.Model):
- key = models.CharField(primary_key=True, max_length=64, default=uuid_str, editable=False)
- title = models.CharField(max_length=128)
- content = models.TextField()
- created = models.DateTimeField(auto_now_add=True)
- slug = models.SlugField(editable=False, default='')
-
- def save(self, *args, **kwargs):
- """
- For the purposes of the sandbox, limit the maximum number of stored models.
- """
- self.slug = slugify(self.title)
- super(self.__class__, self).save(*args, **kwargs)
- for obj in self.__class__.objects.order_by('-created')[MAX_POSTS:]:
- obj.delete()
-
-
-class Comment(models.Model):
- blogpost = models.ForeignKey(BlogPost, editable=False, related_name='comments')
- username = models.CharField(max_length=128)
- comment = models.TextField()
- rating = models.IntegerField(blank=True, null=True, choices=RATING_CHOICES, help_text='How did you rate this post?')
- created = models.DateTimeField(auto_now_add=True)