[extensions-web/wip/ne0sight: 3/4] comments: fixed comment posting after upgrade to new django_comments
- From: Yuri Konotopov <ykonotopov src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [extensions-web/wip/ne0sight: 3/4] comments: fixed comment posting after upgrade to new django_comments
- Date: Mon, 25 Nov 2019 17:37:12 +0000 (UTC)
commit 120ca79639fd37a4e930e158c535e4c411f97830
Author: Yuri Konotopov <ykonotopov gnome org>
Date: Mon Nov 25 21:27:01 2019 +0400
comments: fixed comment posting after upgrade to new django_comments
sweettooth/ratings/forms.py | 9 ++++-----
1 file changed, 4 insertions(+), 5 deletions(-)
---
diff --git a/sweettooth/ratings/forms.py b/sweettooth/ratings/forms.py
index 49f3635..f25c877 100644
--- a/sweettooth/ratings/forms.py
+++ b/sweettooth/ratings/forms.py
@@ -1,12 +1,11 @@
-import datetime
-
from django.forms import fields, widgets
from django.conf import settings
from django.contrib.contenttypes.models import ContentType
from django_comments.forms import CommentForm
from django.utils.encoding import force_text
from django.utils.safestring import mark_safe
+from django.utils import timezone
from sweettooth.ratings.models import RatingComment
@@ -29,14 +28,14 @@ class RatingCommentForm(CommentForm):
def get_comment_model(self):
return RatingComment
- def get_comment_create_data(self):
+ def get_comment_create_data(self, site_id=None):
return dict(
content_type = ContentType.objects.get_for_model(self.target_object),
object_pk = force_text(self.target_object._get_pk_val()),
comment = self.cleaned_data["comment"],
rating = self.cleaned_data["rating"],
- submit_date = datetime.datetime.now(),
- site_id = settings.SITE_ID,
+ submit_date = timezone.now(),
+ site_id = site_id or getattr(settings, "SITE_ID", None),
is_public = True,
is_removed = False,
)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]