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


Python Document.programs方法代码示例

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


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

示例1: test_create_document_object

# 需要导入模块: from documents.models import Document [as 别名]
# 或者: from documents.models.Document import programs [as 别名]
    def test_create_document_object(self):
        doc = Document(title="foo", document_type=DocumentType.objects.all()[0],
            notes="bonk")
        doc.file.save(name="whee", content=ContentFile("wee willy wonka"))
        doc.programs = Program.objects.all()[:2]  
        doc.authors = [self.john.id]

        self.assertItemsEqual([doc], Document.objects.all())
开发者ID:aptivate,项目名称:intranet-documents,代码行数:10,代码来源:tests.py

示例2: test_document_page_changelist

# 需要导入模块: from documents.models import Document [as 别名]
# 或者: from documents.models.Document import programs [as 别名]
    def test_document_page_changelist(self):
        doc = Document(title='foo bar', document_type=DocumentType.objects.all()[0],
            notes="bonk")
        # from lib.monkeypatch import breakpoint
        # breakpoint()
        doc.file.save(name="foo", content=ContentFile("foo bar baz"))
        doc.authors = [self.john]
        doc.programs = [Program.objects.all()[1]]
        doc.save()

        doc2 = Document(title='foo baz', document_type=DocumentType.objects.all()[1],
            notes="whee")
        # from lib.monkeypatch import breakpoint
        # breakpoint()
        doc2.file.save(name="foo", content=ContentFile("foo bar baz"))
        doc2.authors = [self.ringo]
        doc2.programs = [Program.objects.all()[2]]
        doc2.save()
        
        response = self.client.get(reverse('search'), {'q': 'foo'})
        self.assertEqual(response.status_code, 200)
        
        table, queryset = self.assert_search_results_table_get_queryset(response)
        
        self.assertEqual(2, len(queryset), "Unexpected search results: %s" %
            queryset)
        from haystack.utils import get_identifier
        result = [q for q in queryset if q.id == get_identifier(doc)]
        self.assertEqual(get_identifier(doc), result[0].id)
        result = result[0]
        # print object.__str__(queryset[0])

        self.assertEqual("<a href='%s'>%s</a>" % (doc.get_absolute_url(),
            doc.title), table.render_title(doc.title, result))

        row = [r for r in table.page.object_list if r.record.pk == doc.id][0]
        self.assertEqual("<a href='%s'>%s</a>" % (doc.get_absolute_url(),
            doc.title), row['title'])
        self.assertEqual(doc.authors.all()[0].full_name, row['author_names'])
        self.assertEqual(doc.created, row['created'])
        self.assertEqual(doc.programs.all()[0].name, row['programs'])
        self.assertEqual(doc.document_type.name, row['document_type'])
开发者ID:aptivate,项目名称:intranet-documents,代码行数:44,代码来源:tests.py

示例3: handle_noargs

# 需要导入模块: from documents.models import Document [as 别名]
# 或者: from documents.models.Document import programs [as 别名]
 def handle_noargs(self, **options):
     doc_dir = os.path.join(os.path.dirname(__file__), '..', '..',
         'fixtures')
     
     doctypes = DocumentType.objects.all()
     programs = Program.objects.all()
     users = IntranetUser.objects.all()
     
     for i in range(1000):
         for f in os.listdir(doc_dir):
             doc = Document()
             doc.title = random.random()
             doc.file = File(open(os.path.join(doc_dir, f)))
             doc.notes = random.random()
             doc.document_type = random.choice(doctypes)
             doc.save()
             doc.programs = random.sample(programs, 2)
             doc.authors = random.sample(users, 1)
开发者ID:aptivate,项目名称:intranet-documents,代码行数:20,代码来源:add_thousands_of_documents.py


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