本文整理汇总了Python中airmozilla.main.models.Approval.delete方法的典型用法代码示例。如果您正苦于以下问题:Python Approval.delete方法的具体用法?Python Approval.delete怎么用?Python Approval.delete使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类airmozilla.main.models.Approval
的用法示例。
在下文中一共展示了Approval.delete方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _event_process
# 需要导入模块: from airmozilla.main.models import Approval [as 别名]
# 或者: from airmozilla.main.models.Approval import delete [as 别名]
def _event_process(request, form, event):
"""Generate and clean associated event data for an event request
or event edit: timezone application, approvals update and
notifications, creator and modifier."""
if not event.creator:
event.creator = request.user
event.modified_user = request.user
tz = pytz.timezone(request.POST['timezone'])
event.start_time = tz_apply(event.start_time, tz)
if event.archive_time:
event.archive_time = tz_apply(event.archive_time, tz)
if 'approvals' in form.cleaned_data:
event.save()
approvals_old = [app.group for app in event.approval_set.all()]
approvals_new = form.cleaned_data['approvals']
approvals_add = set(approvals_new).difference(approvals_old)
approvals_remove = set(approvals_old).difference(approvals_new)
for approval in approvals_add:
group = Group.objects.get(name=approval)
app = Approval(group=group, event=event)
app.save()
emails = [u.email for u in group.user_set.all()]
subject = ('[Air Mozilla] Approval requested: "%s"' %
event.title)
message = render_to_string(
'manage/_email_approval.html',
{
'group': group.name,
'manage_url': request.build_absolute_uri(
reverse('manage:approvals')
),
'title': event.title,
'creator': event.creator.email,
'datetime': event.start_time,
'description': event.description
}
)
email = EmailMessage(subject, message,
settings.EMAIL_FROM_ADDRESS, emails)
email.send()
for approval in approvals_remove:
app = Approval.objects.get(group=approval, event=event)
app.delete()