当前位置: 首页>>代码示例>>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;未经允许,请勿转载。