本文整理汇总了Python中notifications.models.Notification.create方法的典型用法代码示例。如果您正苦于以下问题:Python Notification.create方法的具体用法?Python Notification.create怎么用?Python Notification.create使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类notifications.models.Notification
的用法示例。
在下文中一共展示了Notification.create方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: create
# 需要导入模块: from notifications.models import Notification [as 别名]
# 或者: from notifications.models.Notification import create [as 别名]
def create(cls, *args, **kwargs):
task = cls(*args, **kwargs)
task.save()
from misc.models import Search # bidirectional import
Notification.create(
users=task.course.students,
heading='New task created',
text='{} created in {}'.format(task.name, task.course.name),
url=reverse('viewtask', args=(task.id,))
)
Search.add_words(kwargs['name'], task.id, Task)
return task
示例2: create
# 需要导入模块: from notifications.models import Notification [as 别名]
# 或者: from notifications.models.Notification import create [as 别名]
def create(cls, task, user, bonus):
sub = cls.objects.filter(user=user, task=task).first()
if sub is None:
sub = AssignSubmission(user=user, task=task, criteria=None, data=bonus['data'], mark=0)
else:
sub.data = bonus['data']
sub.save()
Notification.create(
users=[task.course.teacher],
heading='Task handed in',
text='{} handed in for {}'.format(user.get_full_name(), task.name),
url=reverse('viewtask', args=(task.id,))
)
return sub.on_submit(bonus)