本文整理汇总了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