Commit 375d9fa86cab56c837afe25d6d17c1509ef55a3a
1 parent
48941bf0
Making better use of `get_model()` to replace hardcoded `Comment` instances.
This makes comment form integration easier. Documentation updated.
Showing
2 changed files
with
3 additions
and
6 deletions
| @@ -9,7 +9,8 @@ from django.utils.encoding import force_text | @@ -9,7 +9,8 @@ from django.utils.encoding import force_text | ||
| 9 | from django.utils.text import get_text_list | 9 | from django.utils.text import get_text_list |
| 10 | from django.utils import timezone | 10 | from django.utils import timezone |
| 11 | from django.utils.translation import pgettext_lazy, ungettext, ugettext, ugettext_lazy as _ | 11 | from django.utils.translation import pgettext_lazy, ungettext, ugettext, ugettext_lazy as _ |
| 12 | -from django_comments.models import Comment | 12 | + |
| 13 | +from . import get_model | ||
| 13 | 14 | ||
| 14 | COMMENT_MAX_LENGTH = getattr(settings, 'COMMENT_MAX_LENGTH', 3000) | 15 | COMMENT_MAX_LENGTH = getattr(settings, 'COMMENT_MAX_LENGTH', 3000) |
| 15 | DEFAULT_COMMENTS_TIMEOUT = getattr(settings, 'COMMENTS_TIMEOUT', (2 * 60 * 60)) # 2h | 16 | DEFAULT_COMMENTS_TIMEOUT = getattr(settings, 'COMMENTS_TIMEOUT', (2 * 60 * 60)) # 2h |
| @@ -127,7 +128,7 @@ class CommentDetailsForm(CommentSecurityForm): | @@ -127,7 +128,7 @@ class CommentDetailsForm(CommentSecurityForm): | ||
| 127 | comment apps should override this, get_comment_create_data, and perhaps | 128 | comment apps should override this, get_comment_create_data, and perhaps |
| 128 | check_for_duplicate_comment to provide custom comment models. | 129 | check_for_duplicate_comment to provide custom comment models. |
| 129 | """ | 130 | """ |
| 130 | - return Comment | 131 | + return get_model() |
| 131 | 132 | ||
| 132 | def get_comment_create_data(self): | 133 | def get_comment_create_data(self): |
| 133 | """ | 134 | """ |
| @@ -86,10 +86,6 @@ field:: | @@ -86,10 +86,6 @@ field:: | ||
| 86 | class CommentFormWithTitle(CommentForm): | 86 | class CommentFormWithTitle(CommentForm): |
| 87 | title = forms.CharField(max_length=300) | 87 | title = forms.CharField(max_length=300) |
| 88 | 88 | ||
| 89 | - def get_comment_model(self): | ||
| 90 | - # Use our custom comment model instead of the default one. | ||
| 91 | - return CommentWithTitle | ||
| 92 | - | ||
| 93 | def get_comment_create_data(self): | 89 | def get_comment_create_data(self): |
| 94 | # Use the data of the superclass, and add in the title field | 90 | # Use the data of the superclass, and add in the title field |
| 95 | data = super(CommentFormWithTitle, self).get_comment_create_data() | 91 | data = super(CommentFormWithTitle, self).get_comment_create_data() |
Please
register
or
login
to post a comment