本文整理汇总了Python中publicweb.models.Decision类的典型用法代码示例。如果您正苦于以下问题:Python Decision类的具体用法?Python Decision怎么用?Python Decision使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Decision类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: create_and_return_decision
def create_and_return_decision(self, description='Decision Time',
status=Decision.PROPOSAL_STATUS):
decision = Decision(description=description, status=status)
decision.author = self.user
decision.save()
return decision
示例2: test_emails_dont_contain_escaped_characters
def test_emails_dont_contain_escaped_characters(self):
"""
We want to verify that the emails sent out do not contain
confusing text like '&' instead of '&' or ''<'
instead of '<'
All plaintext emails should be marked 'safe' in the Django template.
"""
decision = Decision(description='&', status=0)
decision.save(self.user)
mymail = OpenConsentEmailMessage('new', decision)
self.assertNotIn('&', mymail.subject)
self.assertNotIn('&', mymail.body)
mymail = OpenConsentEmailMessage('status_change', decision, old_object=decision)
self.assertNotIn('&', mymail.subject)
self.assertNotIn('&', mymail.body)
mymail = OpenConsentEmailMessage('content_change', decision)
self.assertNotIn('&', mymail.subject)
self.assertNotIn('&', mymail.body)
示例3: test_urlize
def test_urlize(self):
decision = Decision(description="text www.google.com text")
decision.save()
path = reverse('publicweb_decision_detail', args=[decision.id])
response = self.client.get(path)
self.assertContains(response, '<a href="http://www.google.com" rel="nofollow">www.google.com</a>', 1,
msg_prefix="Failed to urlize text")
示例4: test_decision_linebreaks
def test_decision_linebreaks(self):
decision = Decision(description="text\ntext")
decision.save()
path = reverse('publicweb_decision_detail', args=[decision.id])
response = self.client.get(path)
self.assertContains(response, 'text<br />text', 1,
msg_prefix="Failed to line break text")
示例5: create_and_return_decision
def create_and_return_decision(self, description='Decision Time',
status=Decision.PROPOSAL_STATUS, deadline=now().date()):
decision = Decision(description=description, status=status, organization=self.bettysorg, deadline=deadline)
decision.author = self.user
decision.save()
return decision
示例6: test_model_feedbackcount_changes
def test_model_feedbackcount_changes(self):
decision = Decision(description="Decision test data")
decision.save(self.user)
self.instance_attribute_has_value(decision,"feedbackcount",0)
feedback = Feedback(description="Feedback test data", decision=decision)
feedback.save()
self.instance_attribute_has_value(decision,"feedbackcount",1)
示例7: test_feedback_statistics
def test_feedback_statistics(self):
decision = Decision(description="Decision test data")
self.model_has_attribute(decision, "get_feedback_statistics")
statistics = decision.get_feedback_statistics()
self.assertTrue("consent" in statistics)
self.assertTrue("concern" in statistics)
self.assertTrue("danger" in statistics)
self.assertTrue("question" in statistics)
self.assertTrue("comment" in statistics)
示例8: test_add_feedback
def test_add_feedback(self):
decision = Decision(status=Decision.PROPOSAL_STATUS, description='Make Eggs')
decision.save()
post_dict= {'rating': '2', 'description': 'The eggs are bad'}
response = self.client.post(reverse('publicweb_feedback_create', args=[decision.id]),
post_dict,
follow=True )
feedback = decision.feedback_set.all()[:1].get()
self.assertEquals('The eggs are bad', feedback.description)
示例9: test_feedback_author_is_assigned
def test_feedback_author_is_assigned(self):
decision = Decision(description="Test decision")
decision.save()
path = reverse('publicweb_feedback_create', args=[decision.id])
post_dict = {'description': 'Lorem Ipsum','rating': Feedback.COMMENT_STATUS }
response = self.client.post(path, post_dict)
self.assertRedirects(response,reverse('publicweb_item_detail', args=[decision.id]))
feedback = decision.feedback_set.get()
self.assertEqual(feedback.author, self.user)
示例10: test_feedback_linebreaks
def test_feedback_linebreaks(self):
decision = Decision(description="Lorem")
decision.save()
feedback = Feedback(description="text\ntext")
feedback.decision = decision
feedback.save()
path = reverse('publicweb_feedback_detail', args=[feedback.id])
response = self.client.get(path)
self.assertContains(response, 'text<br />text', 1,
msg_prefix="Failed to line break text")
示例11: test_list_page_sorted_by_watchers
def test_list_page_sorted_by_watchers(self):
adam = User.objects.get(username='Adam')
barry = User.objects.get(username='Barry')
charlie = User.objects.get(username='Charlie')
decision1 = Decision(description="Apple",
status=Decision.DECISION_STATUS)
decision1.save(self.user)
decision1.watchers.add(barry)
decision1.watchers.add(charlie)
decision2 = Decision(description="Coconut",
status=Decision.DECISION_STATUS)
decision2.save()
decision3 = Decision(description="Blackberry",
status=Decision.DECISION_STATUS)
decision3.save(self.user)
decision3.watchers.add(barry)
response = self.client.get(reverse('publicweb_item_list', args=['decision']), dict(sort='watchers'))
object_list = response.context['object_list']
self.assertEquals(decision1.id, getattr(object_list[0], 'id'))
self.assertEquals(decision3.id, getattr(object_list[1], 'id'))
self.assertEquals(decision2.id, getattr(object_list[2], 'id'))
示例12: assert_list_page_sorted_by_date_column
def assert_list_page_sorted_by_date_column(self, column):
# Create test decisions in reverse date order.
decision = Decision(description="Decision None 1",
status=Decision.DECISION_STATUS)
decision.save(self.user)
for i in range(5, 0, -1):
decision = Decision(description='Decision %d' % i,
status=Decision.DECISION_STATUS)
setattr(decision, column, datetime.date(2001, 3, i))
decision.save(self.user)
decision = Decision(description="Decision None 2",
status=Decision.DECISION_STATUS)
decision.save(self.user)
#note that we don't actually have to _display_ the field to sort bny it
response = self.client.get(reverse('publicweb_item_list', args=['decision']), dict(sort=column))
object_list = response.context['object_list']
for i in range(1, 6):
self.assertEquals(datetime.date(2001, 3, i), getattr(object_list[i-1], column))
self.assertEquals(None, getattr(object_list[5], column))
self.assertEquals(None, getattr(object_list[6], column))
Decision.objects.all().delete()
示例13: test_list_page_sorted_by_feedback
def test_list_page_sorted_by_feedback(self):
# Create test decisions in reverse date order.
decision1 = Decision(description="Apple",
status=Decision.DECISION_STATUS)
decision1.save(self.user)
feedback = Feedback(description="One", decision=decision1)
feedback.save()
feedback = Feedback(description="Two", decision=decision1)
feedback.save()
feedback = Feedback(description="Three", decision=decision1)
feedback.save()
decision2 = Decision(description="Coconut",
status=Decision.DECISION_STATUS)
decision2.save()
decision3 = Decision(description="Blackberry",
status=Decision.DECISION_STATUS)
decision3.save(self.user)
feedback = Feedback(description="One", decision=decision3)
feedback.save()
feedback = Feedback(description="Two", decision=decision3)
feedback.save()
response = self.client.get(reverse('publicweb_item_list', args=['decision']), dict(sort='feedback'))
object_list = response.context['object_list']
self.assertEquals(decision1.id, getattr(object_list[0], 'id'))
self.assertEquals(decision3.id, getattr(object_list[1], 'id'))
self.assertEquals(decision2.id, getattr(object_list[2], 'id'))
示例14: test_decisions_can_be_sorted_by_id
def test_decisions_can_be_sorted_by_id(self):
id_list = []
for i in range(5, 0, -1):
decision = Decision(description='Decision %d' % i)
decision.save(self.user)
id_list.append(decision.id)
response = self.client.get(reverse('publicweb_item_list', args=['proposal']), {'sort':'id'})
object_list = response.context['object_list']
for i in range(1, 6):
self.assertEquals(id_list[i-1], object_list[i-1].id)
示例15: test_feedback_author_shown
def test_feedback_author_shown(self):
self.user = self.login('Barry')
decision = Decision(description="Lorem Ipsum")
decision.save()
feedback = Feedback(description="Dolor sit")
feedback.author = self.user
feedback.decision = decision
feedback.save()
self.user = self.login('Adam')
path = reverse('publicweb_item_detail', args=[decision.id])
response = self.client.get(path)
barry = User.objects.get(username='Barry')
self.assertContains(response, barry.username)