Mercurial > public > sg101
comparison comments/models.py @ 1028:5ba2508939f7
Django 1.8 changes; first batch.
author | Brian Neal <bgneal@gmail.com> |
---|---|
date | Tue, 15 Dec 2015 21:01:07 -0600 |
parents | 4619290d171d |
children |
comparison
equal
deleted
inserted
replaced
1027:cd4db27c90e3 | 1028:5ba2508939f7 |
---|---|
4 import datetime | 4 import datetime |
5 | 5 |
6 from django.db import models | 6 from django.db import models |
7 from django.conf import settings | 7 from django.conf import settings |
8 from django.contrib.contenttypes.models import ContentType | 8 from django.contrib.contenttypes.models import ContentType |
9 from django.contrib.contenttypes import generic | 9 from django.contrib.contenttypes.fields import GenericForeignKey |
10 from django.contrib.auth.models import User | 10 from django.contrib.auth.models import User |
11 from django.core import urlresolvers | 11 from django.core import urlresolvers |
12 | 12 |
13 from core.markup import site_markup | 13 from core.markup import site_markup |
14 | 14 |
30 | 30 |
31 class Comment(models.Model): | 31 class Comment(models.Model): |
32 """My own version of a Comment class that can attach comments to any other model.""" | 32 """My own version of a Comment class that can attach comments to any other model.""" |
33 content_type = models.ForeignKey(ContentType) | 33 content_type = models.ForeignKey(ContentType) |
34 object_id = models.PositiveIntegerField(db_index=True) | 34 object_id = models.PositiveIntegerField(db_index=True) |
35 content_object = generic.GenericForeignKey('content_type', 'object_id') | 35 content_object = GenericForeignKey('content_type', 'object_id') |
36 user = models.ForeignKey(User) | 36 user = models.ForeignKey(User) |
37 comment = models.TextField(max_length=COMMENT_MAX_LENGTH) | 37 comment = models.TextField(max_length=COMMENT_MAX_LENGTH) |
38 html = models.TextField(blank=True) | 38 html = models.TextField(blank=True) |
39 creation_date = models.DateTimeField() | 39 creation_date = models.DateTimeField() |
40 ip_address = models.IPAddressField('IP Address') | 40 ip_address = models.GenericIPAddressField('IP Address') |
41 is_public = models.BooleanField(default=True, | 41 is_public = models.BooleanField(default=True, |
42 help_text='Uncheck this field to make the comment invisible.') | 42 help_text='Uncheck this field to make the comment invisible.') |
43 is_removed = models.BooleanField(default=False, | 43 is_removed = models.BooleanField(default=False, |
44 help_text='Check this field to replace the comment with a ' \ | 44 help_text='Check this field to replace the comment with a ' \ |
45 '"This comment has been removed" message') | 45 '"This comment has been removed" message') |