當前位置: 首頁>>代碼示例>>Python>>正文


Python Notification.create_for_review方法代碼示例

本文整理匯總了Python中notification.models.Notification.create_for_review方法的典型用法代碼示例。如果您正苦於以下問題:Python Notification.create_for_review方法的具體用法?Python Notification.create_for_review怎麽用?Python Notification.create_for_review使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在notification.models.Notification的用法示例。


在下文中一共展示了Notification.create_for_review方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: post

# 需要導入模塊: from notification.models import Notification [as 別名]
# 或者: from notification.models.Notification import create_for_review [as 別名]
    def post(self, request, goal_slug, suggestion_slug):  # noqa
        self._get_data(request, goal_slug, suggestion_slug)
        if not self.review:
            self._create_review()

        data = ReviewSerializer(self.review).data
        data.update(request.data)

        serializer = ReviewSerializer(instance=self.review, data=data)
        if serializer.is_valid():
            self.review = serializer.save(is_draft=False)
            update_rating_and_save(self.review.revision.suggestion)
            self.review.comments.filter(is_draft=False).delete()
            notification = Notification.create_for_review(self.review)
            if notification.owner != self.review.owner:
                notification.save()
            return Response(
                {'success': 1},
                status=status.HTTP_200_OK
            )
        else:
            return Response(
                {
                    'success': 0,
                    'errors': serializer.errors
                },
                status=status.HTTP_200_OK
            )
開發者ID:mnieber,項目名稱:shared-goals,代碼行數:30,代碼來源:react_views.py

示例2: __update_review_and_save

# 需要導入模塊: from notification.models import Notification [as 別名]
# 或者: from notification.models.Notification import create_for_review [as 別名]
    def __update_review_and_save(self, review, form, submit):
        is_form_valid = form.is_valid()

        if 'rating' in form.cleaned_data:
            review.rating = form.cleaned_data['rating']
        if 'experience' in form.cleaned_data:
            review.experience = form.cleaned_data['experience']
        if 'description' in form.cleaned_data:
            review.description = form.cleaned_data['description']

        if is_form_valid and submit == 'save':
            review.is_draft = False
            review.save()
            update_rating_and_save(review.revision.suggestion)

            review.comments.filter(is_draft=False).delete()

            notification = Notification.create_for_review(review)
            if notification.owner != review.owner:
                notification.save()
        else:
            review.save()

        return is_form_valid
開發者ID:mnieber,項目名稱:shared-goals,代碼行數:26,代碼來源:views.py


注:本文中的notification.models.Notification.create_for_review方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。