當前位置: 首頁>>代碼示例>>Python>>正文


Python Approval.delete方法代碼示例

本文整理匯總了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()
開發者ID:dailycavalier,項目名稱:airmozilla,代碼行數:45,代碼來源:views.py


注:本文中的airmozilla.main.models.Approval.delete方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。