当前位置: 首页>>代码示例>>Python>>正文


Python Approval.approved方法代码示例

本文整理汇总了Python中airmozilla.main.models.Approval.approved方法的典型用法代码示例。如果您正苦于以下问题:Python Approval.approved方法的具体用法?Python Approval.approved怎么用?Python Approval.approved使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在airmozilla.main.models.Approval的用法示例。


在下文中一共展示了Approval.approved方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_event

# 需要导入模块: from airmozilla.main.models import Approval [as 别名]
# 或者: from airmozilla.main.models.Approval import approved [as 别名]
 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,代码行数:28,代码来源:test_views.py

示例2: test_event

# 需要导入模块: from airmozilla.main.models import Approval [as 别名]
# 或者: from airmozilla.main.models.Approval import approved [as 别名]
    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,代码行数:51,代码来源:test_views.py

示例3: test_event_upcoming

# 需要导入模块: from airmozilla.main.models import Approval [as 别名]
# 或者: from airmozilla.main.models.Approval import approved [as 别名]
 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,代码行数:20,代码来源:test_views.py


注:本文中的airmozilla.main.models.Approval.approved方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。