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


Python Notification.create_for_suggestion方法代碼示例

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


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

示例1: update_suggestion_and_save

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

        current_revision = suggestion.get_current_revision()
        if 'title' in self.cleaned_data:
            current_revision.title = self.cleaned_data['title'] or ''
        if 'description' in self.cleaned_data:
            current_revision.description = \
                self.cleaned_data['description'] or ''
        current_revision.save()

        suggestion.type = self.cleaned_data['type']
        if self.cleaned_data.get('image', None):
            suggestion.image = self.cleaned_data['image']

        if is_form_valid and submit == 'save':
            sx = (
                float(self.cropping['natural_width']) /
                float(self.cropping['display_width'])
            )
            sy = (
                float(self.cropping['natural_height']) /
                float(self.cropping['display_height'])
            )
            apply_cropping_to_image(
                suggestion.image,
                self.cropping['x'] * sx,
                self.cropping['y'] * sy,
                self.cropping['w'] * sx,
                self.cropping['h'] * sy,
            )

            suggestion.slug = slugify(
                suggestion.get_current_revision().title)
            suggestion.is_draft = False
            suggestion.save()

            notification = Notification.create_for_suggestion(suggestion)
            if notification.owner != suggestion.owner:
                notification.save()

        else:
            suggestion.save()

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


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