• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python models.Decision类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



在下文中一共展示了Decision类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
开发者ID:harryberto,项目名称:openconsent,代码行数:7,代码来源:decision_test_case.py


示例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 '&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,代码行数:25,代码来源:email_test.py


示例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")
开发者ID:samastur,项目名称:openconsent,代码行数:7,代码来源:html_test.py


示例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")
开发者ID:samastur,项目名称:openconsent,代码行数:7,代码来源:html_test.py


示例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
开发者ID:JayFliz,项目名称:econsensus,代码行数:7,代码来源:decision_test_case.py


示例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)
开发者ID:indigo79,项目名称:openconsent,代码行数:7,代码来源:model_test.py


示例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)
开发者ID:samastur,项目名称:openconsent,代码行数:9,代码来源:model_test.py


示例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)
开发者ID:amandao,项目名称:openconsent,代码行数:9,代码来源:decisions_test.py


示例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)
     
开发者ID:harryberto,项目名称:openconsent,代码行数:9,代码来源:view_test.py


示例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")
开发者ID:samastur,项目名称:openconsent,代码行数:10,代码来源:html_test.py


示例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')) 
开发者ID:samastur,项目名称:openconsent,代码行数:27,代码来源:decision_list_test.py


示例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()
开发者ID:samastur,项目名称:openconsent,代码行数:28,代码来源:decision_list_test.py


示例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')) 
开发者ID:samastur,项目名称:openconsent,代码行数:31,代码来源:decision_list_test.py


示例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)
开发者ID:samastur,项目名称:openconsent,代码行数:13,代码来源:decision_list_test.py


示例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)
开发者ID:samastur,项目名称:openconsent,代码行数:14,代码来源:html_test.py


示例16: assert_decisions_sorted_by_date_column

 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,代码行数:14,代码来源:decision_list_test.py


示例17: test_save_when_no_author

 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,代码行数:10,代码来源:model_test.py


示例18: test_emails_arent_sent_to_author

    def test_emails_arent_sent_to_author(self):
        """
        We want to make sure that when a user creates or changes an 
        item they are not sent an email. The email goes to those
        that do not already know the item has changed!
        """
        andy = User.objects.create_user("Andy", "[email protected]", password='password')
        billy = User.objects.create_user("Billy", "[email protected]", password='password')
        chris = User.objects.create_user("Chris", "[email protected]", password='password')
        
        decision = Decision(description='Test', status=0)
        decision.save(andy)
        
        #billy decides he wants to watch...
        decision.watchers = [billy]

        #andy changes the content
        mymail = OpenConsentEmailMessage('content_change', decision)
        
        #only watchers get mail, not the author
        self.assertNotIn(andy.email, mymail.to)
        self.assertIn(billy.email, mymail.to)         
        self.assertNotIn(chris.email, mymail.to)
开发者ID:indigo79,项目名称:openconsent,代码行数:23,代码来源:email_test.py


示例19: _process_email


#.........这里部分代码省略.........
        #Must match email 'to' address to organization
        org_match = re.search('([\w\-\.]+)@\w[\w\-]+\.+[\w\-]+', mail['To'])
        if org_match:
            self._print_if_verbose(verbosity, "Found email 'to' '%s'" % org_match.group(1))
            try:
                organization = Organization.objects.get(slug=org_match.group(1))
                self._print_if_verbose(verbosity, "Matched email to organization '%s'" % organization.name)
            except:
                logger.error("[EMAIL REJECTED] From '%s' Reason: '%s' does not correspond to any known Organization" \
                             % (mail['From'], org_match.group(1)))
                return
        else:
            logger.error("[EMAIL REJECTED] From '%s' Reason: Couldn't pull Organization from '%s'" % (mail['From'], mail['To']))
            return

        #User must be a member of the Organization
        if organization not in Organization.active.get_for_user(user):
            self._print_if_verbose(verbosity, "User %s is not a member of Organization %s" % (user.username, organization.name))
            logger.error("[EMAIL REJECTED] From '%s' Reason: User '%s' is not a member of Organization '%s'" \
                         % (mail['From'], user.username, organization.name))
            return

        #Look for feedback types in the message body
        rating = Feedback.COMMENT_STATUS                    
        description = msg_string                        
        parse_feedback = re.match('(\w+)\s*:\s*([\s\S]*)', msg_string, re.IGNORECASE)
        if parse_feedback:
            description = parse_feedback.group(2)
            rating_match = re.match('question|danger|concerns|consent|comment', parse_feedback.group(1), re.IGNORECASE)
            if rating_match:
                self._print_if_verbose(verbosity, "Found feedback rating '%s'" % rating_match.group())
                rating = rating_int(rating_match.group().lower())

        # Determine whether email is in reply to a notification
        subject_match = re.search('\[(\d+)(?:\\\\(\d+)(?:\\\\(\d+))?)?\]', mail['Subject'])
        if subject_match:
            #process comment or feedback against feedback
            if subject_match.group(2):
                self._print_if_verbose(verbosity, "Found feedback id '%s' in Subject" % subject_match.group(2))
                try:
                    feedback = Feedback.objects.get(pk=subject_match.group(2))
                except:
                    logger.error("[EMAIL REJECTED] From '%s' Reason: id '%s' does not correspond to any known Feedback" \
                                 % (mail['From'], subject_match.group(2)))
                    return
                
                if parse_feedback and rating_match:
                    decision = feedback.decision
                    self._print_if_verbose(verbosity, "Creating feedback with rating '%s' and description '%s'." % (rating, description))
                    feedback = Feedback(author=user, decision=decision, rating=rating, description=description)
                    feedback.save()
                    logger.info("User '%s' added feedback via email to decision #%s" % (user, decision.id))
                    self._print_if_verbose(verbosity, "Found corresponding object '%s'" % decision.excerpt)
                else:
                    comment_text = msg_string                
                    self._print_if_verbose(verbosity, "Creating comment '%s'." % (comment_text))
                    comment = Comment(user=user,
                                     comment = comment_text,
                                     content_object=feedback, 
                                     object_pk=feedback.id,
                                     content_type=ContentType.objects.get(app_label="publicweb", model="feedback"),
                                     submit_date = timezone.now(),
                                     site = Site.objects.get_current())
                    comment.save()
                    logger.info("User '%s' added comment via email to feedback #%s" % (user, feedback.id))
                    self._print_if_verbose(verbosity, "Found corresponding object '%s'" % feedback.description)
            
            #process feedback against decision
            elif subject_match.group(1):
                self._print_if_verbose(verbosity, "Found decision id '%s' in Subject" % subject_match.group(1))
                try:
                    decision = Decision.objects.get(pk=subject_match.group(1))
                except:
                    logger.error("[EMAIL REJECTED] From '%s' Reason: id '%s' does not correspond to any known Decision" \
                                 % (mail['From'], subject_match.group(1)))
                    return
    
                self._print_if_verbose(verbosity, "Creating feedback with rating '%s' and description '%s'." % (rating, description))
                feedback = Feedback(author=user, decision=decision, rating=rating, description=description)
                feedback.save()
                logger.info("User '%s' added feedback via email to decision #%s" % (user, decision.id))
                self._print_if_verbose(verbosity, "Found corresponding object '%s'" % decision.excerpt)
                
            else:
                self._print_if_verbose(verbosity, "No id found in message subject: %s" % mail['Subject'])                
                logger.error("[EMAIL REJECTED] From '%s' Reason: No id present." \
                             % mail['From'])
        # Email was not in reply to a notification so create a new proposal
        else:
            proposal_match = re.search('proposal', mail['Subject'], re.IGNORECASE)
            if proposal_match:
                decision = Decision(author=user, editor=user, status=Decision.PROPOSAL_STATUS, organization=organization, \
                                    description=msg_string)
                decision.save()
                self._print_if_verbose(verbosity, "User '%s' created decision #%s via email" % (user, decision.id))                
                logger.info("User '%s' created decision #%s via email" % (user, decision.id))

            else:
                logger.error("[EMAIL REJECTED] From '%s' Reason: Email was not in reply to a notification and body didn't contain keyword 'proposal'" \
                             % mail['From'])
开发者ID:Administr8Me,项目名称:econsensus,代码行数:101,代码来源:process_email.py


示例20: test_watchercount_changes

 def test_watchercount_changes(self):
     decision = Decision(description="Decision test data")
     decision.save(self.user)
     decision.add_watcher(self.user)
     self.assertEqual(1, decision.watchercount())
开发者ID:amandao,项目名称:openconsent,代码行数:5,代码来源:model_test.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python models.Feedback类代码示例发布时间:2022-05-25
下一篇:
Python portal.Portal类代码示例发布时间:2022-05-25
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap