当前位置: 首页>>代码示例>>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;未经允许,请勿转载。