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


Python models.Approval類代碼示例

本文整理匯總了Python中airmozilla.main.models.Approval的典型用法代碼示例。如果您正苦於以下問題:Python Approval類的具體用法?Python Approval怎麽用?Python Approval使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了Approval類的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: test_event_remove_approval

 def test_event_remove_approval(self):
     """Deleting an Event DOES remove associated Approval."""
     event = Event.objects.get(id=22)
     approval = Approval(event=event)
     approval.save()
     self._successful_delete(event)
     self._refresh_ok(approval, exists=False)
開發者ID:akatsoulas,項目名稱:airmozilla,代碼行數:7,代碼來源:test_models.py

示例2: test_approval_remove

 def test_approval_remove(self):
     """Deleting an Approval does not delete associated Event."""
     event = Event.objects.get(id=22)
     approval = Approval(event=event)
     approval.save()
     self._successful_delete(approval)
     self._refresh_ok(event)
開發者ID:akatsoulas,項目名稱:airmozilla,代碼行數:7,代碼來源:test_models.py

示例3: test_user_remove

 def test_user_remove(self):
     """Deleting a User does not delete associated Approval."""
     event = Event.objects.get(id=22)
     user = User.objects.get(id=1)
     approval = Approval(event=event, user=user)
     approval.save()
     self._successful_delete(user)
     self._refresh_ok(approval)
開發者ID:akatsoulas,項目名稱:airmozilla,代碼行數:8,代碼來源:test_models.py

示例4: test_group_remove

 def test_group_remove(self):
     """Deleting a Group does not delete associated Approval."""
     event = Event.objects.get(id=22)
     group = Group.objects.create(name='testapprover')
     approval = Approval(event=event, group=group)
     approval.save()
     self._successful_delete(group)
     self._refresh_ok(approval)
開發者ID:akatsoulas,項目名稱:airmozilla,代碼行數:8,代碼來源:test_models.py

示例5: test_approval_review

 def test_approval_review(self):
     app = Approval(event=Event.objects.get(id=22),
                    group=Group.objects.get(id=1))
     app.save()
     url = reverse('manage:approval_review', kwargs={'id': app.id})
     response_not_in_group = self.client.get(url)
     self.assertRedirects(response_not_in_group,
                          reverse('manage:approvals'))
     User.objects.get(username='fake').groups.add(1)
     response = self.client.get(url)
     eq_(response.status_code, 200)
     response_approve = self.client.post(url, {'approve': 'approve'})
     self.assertRedirects(response_approve, reverse('manage:approvals'))
     app = Approval.objects.get(id=app.id)
     ok_(app.approved)
     ok_(app.processed)
     eq_(app.user, User.objects.get(username='fake'))
開發者ID:groovecoder,項目名稱:airmozilla,代碼行數:17,代碼來源:test_views.py

示例6: test_event

 def test_event(self):
     """Event view page loads correctly if the event is public and
        scheduled and approved; request a login otherwise."""
     event = Event.objects.get(title='Test event')
     group = Group.objects.get()
     approval = Approval(event=event, group=group)
     approval.save()
     event_page = reverse('main:event', kwargs={'slug': event.slug})
     response_fail_approval = self.client.get(event_page)
     eq_(response_fail_approval.status_code, 200)
     ok_('not approved' in response_fail_approval.content)
     approval.approved = True
     approval.processed = True
     approval.save()
     response_ok = self.client.get(event_page)
     eq_(response_ok.status_code, 200)
     event.public = False
     event.save()
     response_fail = self.client.get(event_page)
     self.assertRedirects(response_fail, reverse('main:login'))
     event.public = True
     event.status = Event.STATUS_INITIATED
     event.save()
     response_fail = self.client.get(event_page)
     eq_(response_fail.status_code, 200)
     ok_('not scheduled' in response_fail.content)
開發者ID:groovecoder,項目名稱:airmozilla,代碼行數:26,代碼來源:test_views.py

示例7: test_event_upcoming

 def test_event_upcoming(self):
     """View an upcoming event and it should show the local time"""
     event = Event.objects.get(title='Test event')
     date = datetime.datetime(2099, 1, 1, 18, 0, 0).replace(tzinfo=utc)
     event.start_time = date
     event.save()
     group = Group.objects.get()
     approval = Approval(event=event, group=group)
     approval.approved = True
     approval.save()
     event_page = reverse('main:event', kwargs={'slug': event.slug})
     response = self.client.get(event_page)
     eq_(response.status_code, 200)
     assert event.location
     ok_(event.location.name in response.content)
     # 18:00 in UTC on that 1st Jan 2099 is 10AM in Pacific time
     assert event.location.timezone == 'US/Pacific'
     ok_('10:00AM' in response.content)
開發者ID:v1ka5,項目名稱:airmozilla,代碼行數:18,代碼來源:test_views.py

示例8: _event_process

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,代碼行數:43,代碼來源:views.py

示例9: test_event

    def test_event(self):
        """Event view page loads correctly if the event is public and
           scheduled and approved; request a login otherwise."""
        event = Event.objects.get(title="Test event")
        group = Group.objects.get()
        approval = Approval(event=event, group=group)
        approval.save()
        event_page = reverse("main:event", kwargs={"slug": event.slug})
        response_fail_approval = self.client.get(event_page)
        eq_(response_fail_approval.status_code, 200)
        ok_("not approved" in response_fail_approval.content)
        approval.approved = True
        approval.processed = True
        approval.save()
        response_ok = self.client.get(event_page)
        eq_(response_ok.status_code, 200)
        event.privacy = Event.PRIVACY_COMPANY
        event.save()
        response_fail = self.client.get(event_page)
        self.assertRedirects(response_fail, reverse("main:login"))
        event.privacy = Event.PRIVACY_CONTRIBUTORS
        event.save()
        response_fail = self.client.get(event_page)
        self.assertRedirects(response_fail, reverse("main:login"))
        event.privacy = Event.PRIVACY_PUBLIC
        event.status = Event.STATUS_INITIATED
        event.save()
        response_fail = self.client.get(event_page)
        eq_(response_fail.status_code, 200)
        ok_("not scheduled" in response_fail.content)

        self.client.logout()
        event.privacy = Event.PRIVACY_COMPANY
        event.status = Event.STATUS_SCHEDULED
        event.save()
        response_fail = self.client.get(event_page)
        self.assertRedirects(response_fail, reverse("main:login"))

        nigel = User.objects.create_user("nigel", "[email protected]", "secret")
        UserProfile.objects.create(user=nigel, contributor=True)
        assert self.client.login(username="nigel", password="secret")

        response_fail = self.client.get(event_page)
        self.assertRedirects(response_fail, reverse("main:login"))

        event.privacy = Event.PRIVACY_CONTRIBUTORS
        event.save()
        response_ok = self.client.get(event_page)
        eq_(response_ok.status_code, 200)
開發者ID:dailycavalier,項目名稱:airmozilla,代碼行數:49,代碼來源:test_views.py


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