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


Python Decision.save方法代码示例

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


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

示例1: test_decision_linebreaks

# 需要导入模块: from publicweb.models import Decision [as 别名]
# 或者: from publicweb.models.Decision import save [as 别名]
 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")
开发者ID:samastur,项目名称:openconsent,代码行数:9,代码来源:html_test.py

示例2: create_and_return_decision

# 需要导入模块: from publicweb.models import Decision [as 别名]
# 或者: from publicweb.models.Decision import save [as 别名]
 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
开发者ID:harryberto,项目名称:openconsent,代码行数:9,代码来源:decision_test_case.py

示例3: test_urlize

# 需要导入模块: from publicweb.models import Decision [as 别名]
# 或者: from publicweb.models.Decision import save [as 别名]
 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")
开发者ID:samastur,项目名称:openconsent,代码行数:9,代码来源:html_test.py

示例4: test_model_feedbackcount_changes

# 需要导入模块: from publicweb.models import Decision [as 别名]
# 或者: from publicweb.models.Decision import save [as 别名]
 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)
开发者ID:indigo79,项目名称:openconsent,代码行数:9,代码来源:model_test.py

示例5: create_and_return_decision

# 需要导入模块: from publicweb.models import Decision [as 别名]
# 或者: from publicweb.models.Decision import save [as 别名]
 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
开发者ID:JayFliz,项目名称:econsensus,代码行数:9,代码来源:decision_test_case.py

示例6: test_emails_dont_contain_escaped_characters

# 需要导入模块: from publicweb.models import Decision [as 别名]
# 或者: from publicweb.models.Decision import save [as 别名]
    def test_emails_dont_contain_escaped_characters(self):
        """
        We want to verify that the emails sent out do not contain
        confusing text like '&amp' instead of '&' or ''&lt'
        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('&amp', mymail.subject)
        self.assertNotIn('&amp', mymail.body)

        mymail = OpenConsentEmailMessage('status_change', decision, old_object=decision)
        
        self.assertNotIn('&amp', mymail.subject)
        self.assertNotIn('&amp', mymail.body)
        
        mymail = OpenConsentEmailMessage('content_change', decision)
        
        self.assertNotIn('&amp', mymail.subject)
        self.assertNotIn('&amp', mymail.body)
开发者ID:indigo79,项目名称:openconsent,代码行数:27,代码来源:email_test.py

示例7: test_add_feedback

# 需要导入模块: from publicweb.models import Decision [as 别名]
# 或者: from publicweb.models.Decision import save [as 别名]
 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)
开发者ID:amandao,项目名称:openconsent,代码行数:11,代码来源:decisions_test.py

示例8: test_feedback_author_is_assigned

# 需要导入模块: from publicweb.models import Decision [as 别名]
# 或者: from publicweb.models.Decision import save [as 别名]
 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)
     
开发者ID:harryberto,项目名称:openconsent,代码行数:11,代码来源:view_test.py

示例9: test_feedback_linebreaks

# 需要导入模块: from publicweb.models import Decision [as 别名]
# 或者: from publicweb.models.Decision import save [as 别名]
 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")
开发者ID:samastur,项目名称:openconsent,代码行数:12,代码来源:html_test.py

示例10: test_save_when_no_author

# 需要导入模块: from publicweb.models import Decision [as 别名]
# 或者: from publicweb.models.Decision import save [as 别名]
 def test_save_when_no_author(self):
     decision = Decision(description="Test", status=0)
     decision.author = None
     decision.save()
     decision = Decision.objects.get()
     decision.description = "A change."
     try:
         decision.save()
     except:
         self.fail("Failed to save object.")
开发者ID:samastur,项目名称:openconsent,代码行数:12,代码来源:model_test.py

示例11: test_decisions_can_be_sorted_by_id

# 需要导入模块: from publicweb.models import Decision [as 别名]
# 或者: from publicweb.models.Decision import save [as 别名]
 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)
开发者ID:samastur,项目名称:openconsent,代码行数:15,代码来源:decision_list_test.py

示例12: assert_decisions_sorted_by_date_column

# 需要导入模块: from publicweb.models import Decision [as 别名]
# 或者: from publicweb.models.Decision import save [as 别名]
 def assert_decisions_sorted_by_date_column(self, column):
     # Create test decisions in reverse date order.         
     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)
         
     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))
开发者ID:amandao,项目名称:openconsent,代码行数:16,代码来源:decision_list_test.py

示例13: test_feedback_author_shown

# 需要导入模块: from publicweb.models import Decision [as 别名]
# 或者: from publicweb.models.Decision import save [as 别名]
 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)
开发者ID:samastur,项目名称:openconsent,代码行数:16,代码来源:html_test.py

示例14: test_list_page_sorted_by_feedback

# 需要导入模块: from publicweb.models import Decision [as 别名]
# 或者: from publicweb.models.Decision import save [as 别名]
    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')) 
开发者ID:samastur,项目名称:openconsent,代码行数:33,代码来源:decision_list_test.py

示例15: assert_list_page_sorted_by_date_column

# 需要导入模块: from publicweb.models import Decision [as 别名]
# 或者: from publicweb.models.Decision import save [as 别名]
    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()
开发者ID:samastur,项目名称:openconsent,代码行数:30,代码来源:decision_list_test.py


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