本文整理汇总了Python中notification.models.Notification.remove方法的典型用法代码示例。如果您正苦于以下问题:Python Notification.remove方法的具体用法?Python Notification.remove怎么用?Python Notification.remove使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类notification.models.Notification
的用法示例。
在下文中一共展示了Notification.remove方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _post_async_submission
# 需要导入模块: from notification.models import Notification [as 别名]
# 或者: from notification.models.Notification import remove [as 别名]
def _post_async_submission(request, exercise, submission, errors=None):
"""
Creates or grades a submission.
Required parameters in the request are points, max_points and feedback. If
errors occur or submissions are no longer accepted, a dictionary with
"success" is False and "errors" list will be returned.
"""
if not errors:
errors = []
# Use form to parse and validate the request.
form = SubmissionCallbackForm(request.POST)
errors.extend(extract_form_errors(form))
if not form.is_valid():
submission.feedback = _(
"<div class=\"alert alert-error\">\n"
"<p>The exercise assessment service is malfunctioning. "
"Staff has been notified.</p>\n"
"<p>This submission is now marked as erroneous.</p>\n"
"</div>")
submission.set_error()
submission.save()
if exercise.course_instance.visible_to_students:
msg = "Exercise service returned with invalid grade request: {}"\
.format("\n".join(errors))
logger.error(msg, extra={"request": request})
email_course_error(request, exercise, msg, False)
return {
"success": False,
"errors": errors
}
# Grade the submission.
try:
submission.set_points(form.cleaned_data["points"],
form.cleaned_data["max_points"])
submission.feedback = form.cleaned_data["feedback"]
submission.grading_data = request.POST
if form.cleaned_data["error"]:
submission.set_error()
else:
submission.set_ready()
submission.save()
if form.cleaned_data["notify"]:
Notification.send(None, submission)
else:
Notification.remove(submission)
return {
"success": True,
"errors": []
}
# Produce error if something goes wrong during saving the points.
except Exception as e:
logger.exception("Unexpected error while saving grade"
" for {} and submission id {:d}".format(str(exercise), submission.id));
return {
"success": False,
"errors": [repr(e)]
}