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


Python DocumentController.create方法代码示例

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


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

示例1: test_doc_cad_update_post_empty_selection

# 需要导入模块: from openPLM.plmapp.controllers import DocumentController [as 别名]
# 或者: from openPLM.plmapp.controllers.DocumentController import create [as 别名]
    def test_doc_cad_update_post_empty_selection(self):
        doc1 = DocumentController.create("doc1", "Document", "a", self.user,
                self.DATA)
        doc2 = DocumentController.create("doc2", "Document", "a", self.user,
                self.DATA)
        self.controller.attach_to_document(doc1)
        self.controller.attach_to_document(doc2)
        data = {
                'form-TOTAL_FORMS' : '2',
                'form-INITIAL_FORMS' : '2',
                'form-MAX_NUM_FORMS' : '',

                'form-0-id' : doc1.get_attached_parts()[0].id,
                'form-0-part' : self.controller.id,
                'form-0-document' : doc1.id,
                'form-0-delete' : '',

                'form-1-id' : doc2.get_attached_parts()[0].id,
                'form-1-part' : self.controller.id,
                'form-1-document' : doc2.id,
                'form-1-delete' : '',
            }
        response = self.post(self.base_url + "doc-cad/", data, page="doc-cad")
        self.assertEqual(2, response.context["documents"].count())
        forms_ = response.context["forms"]
        self.assertEqual(set((doc1.id, doc2.id)),
                set(f.instance.document.id for f in forms_.values()))
开发者ID:amarh,项目名称:openPLM,代码行数:29,代码来源:part.py

示例2: test_doc_cad

# 需要导入模块: from openPLM.plmapp.controllers import DocumentController [as 别名]
# 或者: from openPLM.plmapp.controllers.DocumentController import create [as 别名]
 def test_doc_cad(self):
     doc1 = DocumentController.create("doc1", "Document", "a", self.user, self.DATA)
     doc2 = DocumentController.create("doc2", "Document", "a", self.user, self.DATA)
     self.controller.attach_to_document(doc1)
     self.controller.attach_to_document(doc2)
     response = self.get(self.base_url + "doc-cad/", page="doc-cad")
     self.assertEqual(2, len(list(response.context["object_doc_cad"])))
开发者ID:esimorre,项目名称:openplm,代码行数:9,代码来源:views.py

示例3: test_attached_documents_two_parts

# 需要导入模块: from openPLM.plmapp.controllers import DocumentController [as 别名]
# 或者: from openPLM.plmapp.controllers.DocumentController import create [as 别名]
 def test_attached_documents_two_parts(self):
     doc = DocumentController.create("Doc", "Document", "a", self.user,
             self.DATA)
     doc.attach_to_part(self.controller)
     doc2 = DocumentController.create("Doc2", "Document", "a", self.user,
             self.DATA)
     doc2.attach_to_part(self.controller)
     wanted = [
         {
             "id": doc.id,
             "reference": doc.reference,
             "type": doc.type,
             "revision": doc.revision,
             "name": doc.name,
         },
         {
             "id": doc2.id,
             "reference": doc2.reference,
             "type": doc2.type,
             "revision": doc2.revision,
             "name": doc2.name,
         },
     ]
     key = lambda x: x["id"]
     url = "/api/object/%d/attached_documents/" % self.controller.id
     data = self.get(url)
     self.assertEqual(sorted(data["documents"], key=key), sorted(wanted, key=key))
开发者ID:amarh,项目名称:openPLM,代码行数:29,代码来源:api.py

示例4: test_doc_cad_update_post_all_selected

# 需要导入模块: from openPLM.plmapp.controllers import DocumentController [as 别名]
# 或者: from openPLM.plmapp.controllers.DocumentController import create [as 别名]
    def test_doc_cad_update_post_all_selected(self):
        doc1 = DocumentController.create("doc1", "Document", "a", self.user,
                self.DATA)
        doc2 = DocumentController.create("doc2", "Document", "a", self.user,
                self.DATA)
        self.controller.attach_to_document(doc1)
        self.controller.attach_to_document(doc2)
        data = {
                'form-TOTAL_FORMS' : '2',
                'form-INITIAL_FORMS' : '2',
                'form-MAX_NUM_FORMS' : '',

                'form-0-id' : doc1.get_attached_parts()[0].id,
                'form-0-part' : self.controller.id,
                'form-0-document' : doc1.id,
                'form-0-delete' : 'on',

                'form-1-id' : doc2.get_attached_parts()[0].id,
                'form-1-part' : self.controller.id,
                'form-1-document' : doc2.id,
                'form-1-delete' : 'on',
            }
        response = self.post(self.base_url + "doc-cad/", data, page="doc-cad")
        self.assertEqual(0, response.context["documents"].count())
        self.assertFalse(response.context["forms"])
开发者ID:amarh,项目名称:openPLM,代码行数:27,代码来源:part.py

示例5: test_doc_cad

# 需要导入模块: from openPLM.plmapp.controllers import DocumentController [as 别名]
# 或者: from openPLM.plmapp.controllers.DocumentController import create [as 别名]
 def test_doc_cad(self):
     doc1 = DocumentController.create("doc1", "Document", "a", self.user,
             self.DATA)
     doc2 = DocumentController.create("doc2", "Document", "a", self.user,
             self.DATA)
     self.controller.attach_to_document(doc1)
     self.controller.attach_to_document(doc2)
     doc2.object.state = doc2.object.lifecycle.last_state
     doc2.object.save()
     response = self.get(self.base_url + "doc-cad/", page="doc-cad")
     self.assertEqual(2, response.context["documents"].count())
     forms_ = response.context["forms"]
     self.assertEqual([doc1.id], [f.instance.document.id for f in forms_.values()])
开发者ID:amarh,项目名称:openPLM,代码行数:15,代码来源:part.py

示例6: test_attach_to_part

# 需要导入模块: from openPLM.plmapp.controllers import DocumentController [as 别名]
# 或者: from openPLM.plmapp.controllers.DocumentController import create [as 别名]
 def test_attach_to_part(self):
     doc = DocumentController.create("Doc", "Document", "a", self.user,
             self.DATA)
     data = self.get("/api/object/%d/attach_to_part/%d/" %
             (doc.id, self.controller.id))
     self.assertEqual("ok", data["result"])
     self.assertEqual(self.controller.id, doc.get_attached_parts()[0].id)
开发者ID:amarh,项目名称:openPLM,代码行数:9,代码来源:api.py

示例7: test_files

# 需要导入模块: from openPLM.plmapp.controllers import DocumentController [as 别名]
# 或者: from openPLM.plmapp.controllers.DocumentController import create [as 别名]
 def test_files(self):
     doc = DocumentController.create("Doc", "Document", "a", self.user, self.DATA)
     doc.object.state =doc.object.lifecycle.official_state
     doc.object.save()
     doc.add_reader(self.restricted_user)
     self.assertViewErrorGet(doc.plmobject_url + "files/")
     self.assertViewErrorGet(doc.plmobject_url + "files/add/")
开发者ID:amarh,项目名称:openPLM,代码行数:9,代码来源:restricted.py

示例8: test_revise_one_deprecated_document_attached_post

# 需要导入模块: from openPLM.plmapp.controllers import DocumentController [as 别名]
# 或者: from openPLM.plmapp.controllers.DocumentController import create [as 别名]
 def test_revise_one_deprecated_document_attached_post(self):
     """
     Tests a post request to revise a part which has one deprecated
     attached document.
     This document must not be suggested when the user revises the part.
     """
     document = DocumentController.create("RefDocument", "Document", "a", self.user, self.DATA)
     self.controller.attach_to_document(document)
     document.object.state = document.lifecycle.last_state
     document.object.save()
     data = { "revision" : "b",
              "parents-TOTAL_FORMS" : "0",
              "parents-INITIAL_FORMS" : "0",
              "children-TOTAL_FORMS" : "0",
              "children-INITIAL_FORMS" : "0",
              "documents-TOTAL_FORMS" : "1",
              "documents-INITIAL_FORMS" : "1",
              "documents-0-selected" : "",
              "documents-0-document" : document.id,
              }
     response = self.post(self.base_url + "revisions/", data)
     # even if we submit a formset, it should not be parsed
     revisions = self.controller.get_next_revisions()
     self.assertEqual(1, len(revisions))
     rev = revisions[0].part
     # ensure document is still attached to the old revision
     documents = self.controller.get_attached_documents().values_list("document", flat=True)
     self.assertEqual([document.id], list(documents))
     # ensure document is not attached to the new revision
     self.assertFalse(rev.documentpartlink_part.now().exists())
     # ensure only the old revision is attached to document
     self.assertEqual([self.controller.id],
         list(document.get_attached_parts().values_list("part", flat=True)))
开发者ID:amarh,项目名称:openPLM,代码行数:35,代码来源:part.py

示例9: test_attach_doc_part_post

# 需要导入模块: from openPLM.plmapp.controllers import DocumentController [as 别名]
# 或者: from openPLM.plmapp.controllers.DocumentController import create [as 别名]
 def test_attach_doc_part_post(self):
     doc = DocumentController.create("Doc", "Document", "a", self.user,
             self.DATA)
     self.assertAjaxErrorPost("/ajax/attach/%d/" % doc.id,
             type=self.ctrl.type, reference=self.ctrl.reference,
             revision=self.ctrl.revision)
     self.assertFalse(self.ctrl.get_attached_documents())
开发者ID:amarh,项目名称:openPLM,代码行数:9,代码来源:restricted.py

示例10: test_revise_one_attached_revised_document_post

# 需要导入模块: from openPLM.plmapp.controllers import DocumentController [as 别名]
# 或者: from openPLM.plmapp.controllers.DocumentController import create [as 别名]
 def test_revise_one_attached_revised_document_post(self):
     """
     Tests a post request to revise a part which has one attached document.
     The document has been revised and its revision is selected.
     """
     document = DocumentController.create("RefDocument", "Document", "a", self.user, self.DATA)
     self.controller.attach_to_document(document)
     d2 = document.revise("b")
     data = { "revision" : "b",
              "parents-TOTAL_FORMS" : "0",
              "parents-INITIAL_FORMS" : "0",
              "children-TOTAL_FORMS" : "0",
              "children-INITIAL_FORMS" : "0",
              "documents-TOTAL_FORMS" : "1",
              "documents-INITIAL_FORMS" : "1",
              "documents-0-selected" : "on",
              "documents-0-document" : d2.id,
              }
     response = self.post(self.base_url + "revisions/", data)
     revisions = self.controller.get_next_revisions()
     self.assertEqual(1, len(revisions))
     rev = revisions[0].part
     self.assertEqual("b", rev.revision)
     # ensure document is still attached to the old revision
     documents = self.controller.get_attached_documents().values_list("document", flat=True)
     self.assertEqual([document.id], list(documents))
     # ensure d2 is attached to the new revision
     documents = rev.documentpartlink_part.values_list("document", flat=True)
     self.assertEqual([d2.id], list(documents))
开发者ID:amarh,项目名称:openPLM,代码行数:31,代码来源:part.py

示例11: test_unlock

# 需要导入模块: from openPLM.plmapp.controllers import DocumentController [as 别名]
# 或者: from openPLM.plmapp.controllers.DocumentController import create [as 别名]
 def test_unlock(self):
     doc = DocumentController.create("Doc", "Document", "a", self.user,
             self.DATA)
     df = doc.add_file(self.get_file())
     doc.lock(df)
     self.assertApiErrorGet("/api/object/%d/unlock/%d/" % (doc.id, df.id))
     self.assertTrue(doc.files[0].locked)
开发者ID:amarh,项目名称:openPLM,代码行数:9,代码来源:restricted.py

示例12: test_add_file

# 需要导入模块: from openPLM.plmapp.controllers import DocumentController [as 别名]
# 或者: from openPLM.plmapp.controllers.DocumentController import create [as 别名]
 def test_add_file(self):
     doc = DocumentController.create("Doc", "Document", "a", self.user,
             self.DATA)
     mock_file = self.get_file()
     self.assertApiErrorPost("/api/object/%d/add_file/" % doc.id,
             filename=mock_file)
     self.assertFalse(doc.files)
开发者ID:amarh,项目名称:openPLM,代码行数:9,代码来源:restricted.py

示例13: test_invalid_download

# 需要导入模块: from openPLM.plmapp.controllers import DocumentController [as 别名]
# 或者: from openPLM.plmapp.controllers.DocumentController import create [as 别名]
 def test_invalid_download(self):
     doc = DocumentController.create("Doc", "Document", "a", self.user, self.DATA)
     df = doc.add_file(self.get_file("plop"))
     doc.object.state =doc.object.lifecycle.official_state
     doc.object.save()
     doc.add_reader(self.restricted_user)
     self.assertViewErrorGet("/file/%d/" % df.id)
开发者ID:amarh,项目名称:openPLM,代码行数:9,代码来源:restricted.py

示例14: test_get_files

# 需要导入模块: from openPLM.plmapp.controllers import DocumentController [as 别名]
# 或者: from openPLM.plmapp.controllers.DocumentController import create [as 别名]
 def test_get_files(self):
     doc = DocumentController.create("Doc", "Document", "a", self.user,
             self.DATA)
     df = doc.add_file(self.get_file())
     data = self.get("/api/object/%d/files/" % doc.id)
     self.assertEqual("ok", data["result"])
     self.assertEqual([df.id], [f["id"] for f in data["files"]])
开发者ID:amarh,项目名称:openPLM,代码行数:9,代码来源:api.py

示例15: test_revise_one_attached_revised_document_post_error

# 需要导入模块: from openPLM.plmapp.controllers import DocumentController [as 别名]
# 或者: from openPLM.plmapp.controllers.DocumentController import create [as 别名]
 def test_revise_one_attached_revised_document_post_error(self):
     """
     Tests a post request to revise a part which has one attached document.
     The document has been revised and has been selected instead of its revision.
     """
     document = DocumentController.create("RefDocument", "Document", "a", self.user, self.DATA)
     self.controller.attach_to_document(document)
     d2 = document.revise("b")
     self.controller.attach_to_document(d2)
     data = { "revision" : "b",
              "parents-TOTAL_FORMS" : "0",
              "parents-INITIAL_FORMS" : "0",
              "children-TOTAL_FORMS" : "0",
              "children-INITIAL_FORMS" : "0",
              "documents-TOTAL_FORMS" : "1",
              "documents-INITIAL_FORMS" : "1",
              "documents-0-selected" : "on",
              "documents-0-document" : document.id,
              }
     response = self.post(self.base_url + "revisions/", data)
     revisions = self.controller.get_next_revisions()
     # no revisions have been created
     self.assertEqual([], revisions)
     # ensure documents are still attached to the old revision
     documents = self.controller.get_attached_documents().values_list("document", flat=True)
     self.assertEqual(set((document.id, d2.id)), set(documents))
开发者ID:amarh,项目名称:openPLM,代码行数:28,代码来源:part.py


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