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


Python models.SavedExportSchema类代码示例

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


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

示例1: test_revert_new_exports_restore_old

    def test_revert_new_exports_restore_old(self):
        saved_export_schema = SavedExportSchema(index=['my-domain', 'xmlns'])
        saved_export_schema.doc_type += DELETED_SUFFIX
        saved_export_schema.save()
        self.new_exports[0].legacy_saved_export_schema_id = saved_export_schema._id

        reverted = revert_new_exports(self.new_exports)
        self.assertEqual(len(reverted), 1)
        self.assertFalse(reverted[0].doc_type.endswith(DELETED_SUFFIX))
        saved_export_schema.delete()
开发者ID:saketkanth,项目名称:commcare-hq,代码行数:10,代码来源:test_export_conversion.py

示例2: export_data_shared

def export_data_shared(export_tag, format=None, filename=None,
                       previous_export_id=None, filter=None,
                       use_cache=True, max_column_size=2000,
                       separator='|'):
    """
    Shared method for export. If there is data, return an HTTPResponse
    with the appropriate data. If there is not data returns None.
    """
    if previous_export_id and not SavedExportSchema.get_db().doc_exist(previous_export_id):
        return HttpResponseNotFound(
            _('No previous export with id "{id}" found'.format(id=previous_export_id)))

    if not filename:
        filename = export_tag

    files = DefaultExportSchema(index=export_tag).get_export_files(
        format=format,
        previous_export_id=previous_export_id,
        filter=filter,
        use_cache=use_cache,
        max_column_size=max_column_size,
        separator=separator
    )
    if files and files.checkpoint:
        return export_response(files.file, format, filename, files.checkpoint)
    else:
        return None
开发者ID:kkrampa,项目名称:commcare-hq,代码行数:27,代码来源:shortcuts.py

示例3: test_system_property_conversion

    def test_system_property_conversion(self, _):
        saved_export_schema = SavedExportSchema.wrap(self.get_json('system_properties'))
        with mock.patch(
                'corehq.apps.export.models.new.FormExportDataSchema.generate_schema_from_builds',
                return_value=self.schema):
            instance = convert_saved_export_to_export_instance(self.domain, saved_export_schema)

        self.assertEqual(instance.name, 'System Properties')

        # Check for first repeat table
        table = instance.get_table(MAIN_TABLE)
        self.assertEqual(table.label, 'Forms')

        expected_paths = [
            ([PathNode(name='xmlns')], None, True),
            ([PathNode(name='form'), PathNode(name='meta'), PathNode(name='userID')], None, True),
            ([PathNode(name='form'), PathNode(name='case'), PathNode(name='@case_id')], None, True),
            (
                [PathNode(name='form'), PathNode(name='case'), PathNode(name='@case_id')],
                CASE_NAME_TRANSFORM,
                True
            ),
        ]
        for path, transform, selected in expected_paths:
            index, column = table.get_column(path, 'ExportItem', transform)
            self.assertEqual(column.selected, selected, '{} selected is not {}'.format(path, selected))
开发者ID:saketkanth,项目名称:commcare-hq,代码行数:26,代码来源:test_export_conversion.py

示例4: test_repeat_conversion

    def test_repeat_conversion(self, _):
        saved_export_schema = SavedExportSchema.wrap(self.get_json('repeat'))
        with mock.patch(
                'corehq.apps.export.models.new.FormExportDataSchema.generate_schema_from_builds',
                return_value=self.schema):
            instance = convert_saved_export_to_export_instance(self.domain, saved_export_schema)

        self.assertEqual(instance.name, 'Repeat Tester')
        table = instance.get_table([PathNode(name='form'), PathNode(name='repeat', is_repeat=True)])
        self.assertEqual(table.label, 'Repeat: question1')
        self.assertTrue(table.selected)

        index, column = table.get_column(
            [PathNode(name='form'),
             PathNode(name='repeat', is_repeat=True),
             PathNode(name='question2')],
            'ExportItem',
            None
        )
        self.assertEqual(column.label, 'Question Two')
        self.assertEqual(column.selected, True)

        index, column = table.get_column(
            [PathNode(name='number')],
            'ExportItem',
            None
        )
        self.assertEqual(column.selected, True)
开发者ID:saketkanth,项目名称:commcare-hq,代码行数:28,代码来源:test_export_conversion.py

示例5: test_basic_conversion

    def test_basic_conversion(self, _):

        saved_export_schema = SavedExportSchema.wrap(self.get_json('basic'))
        with mock.patch(
                'corehq.apps.export.models.new.FormExportDataSchema.generate_schema_from_builds',
                return_value=self.schema):
            instance = convert_saved_export_to_export_instance(self.domain, saved_export_schema)

        self.assertEqual(instance.split_multiselects, False)
        self.assertEqual(instance.transform_dates, True)
        self.assertEqual(instance.name, 'Tester')
        self.assertEqual(instance.export_format, 'csv')
        self.assertEqual(instance.is_deidentified, False)
        self.assertEqual(instance.include_errors, False)

        table = instance.get_table(MAIN_TABLE)
        self.assertEqual(table.label, 'My Forms')

        index, column = table.get_column(
            [PathNode(name='form'), PathNode(name='question1')],
            'ExportItem',
            None,
        )
        self.assertEqual(column.label, 'Question One')
        self.assertEqual(column.selected, True)
开发者ID:saketkanth,项目名称:commcare-hq,代码行数:25,代码来源:test_export_conversion.py

示例6: commit

 def commit(self, request):
     try:
         saved_export = SavedExportSchema.get(self.export_id)
     except ResourceNotFound:
         raise ExportNotFound()
     self.export_type = saved_export.type
     saved_export.delete()
     messages.success(request, _("Custom export was deleted."))
开发者ID:puttarajubr,项目名称:commcare-hq,代码行数:8,代码来源:views.py

示例7: get_saved_exports

 def get_saved_exports(self):
     startkey = json.dumps([self.domain, ""])[:-3]
     endkey = "%s{" % startkey
     exports = SavedExportSchema.view("couchexport/saved_export_schemas",
         startkey=startkey, endkey=endkey,
         include_docs=True).all()
     exports = filter(lambda x: x.type == "case", exports)
     return exports
开发者ID:nikhilvarma22,项目名称:commcare-hq,代码行数:8,代码来源:export.py

示例8: show_in_navigation

 def show_in_navigation(cls, domain=None, project=None, user=None):
     startkey = json.dumps([domain, ""])[:-3]
     return SavedExportSchema.view("couchexport/saved_export_schemas",
         startkey=startkey,
         limit=1,
         include_docs=False,
         stale=settings.COUCH_STALE_QUERY,
     ).count() > 0
开发者ID:nikhilvarma22,项目名称:commcare-hq,代码行数:8,代码来源:export.py

示例9: commit

 def commit(self, request):
     try:
         saved_export = SavedExportSchema.get(self.export_id)
     except ResourceNotFound:
         raise ExportNotFound()
     self.export_type = saved_export.type
     saved_export.delete()
     touch_exports(self.domain)
     messages.success(request, mark_safe(_("Export <strong>{}</strong> " "was deleted.").format(saved_export.name)))
开发者ID:philipkaare,项目名称:commcare-hq,代码行数:9,代码来源:views.py

示例10: post

 def post(self, request, *args, **kwargs):
     try:
         saved_export = SavedExportSchema.get(self.export_id)
     except ResourceNotFound:
         return HttpResponseRedirect(request.META['HTTP_REFERER'])
     self.export_type = saved_export.type
     saved_export.delete()
     messages.success(request, _("Custom export was deleted."))
     return super(DeleteCustomExportView, self).post(request, *args, **kwargs)
开发者ID:dszafranek,项目名称:commcare-hq,代码行数:9,代码来源:views.py

示例11: show_in_navigation

 def show_in_navigation(cls, request, *args, **kwargs):
     domain = kwargs.get("domain")
     startkey = json.dumps([domain, ""])[:-3]
     return (
         SavedExportSchema.view(
             "couchexport/saved_export_schemas", startkey=startkey, limit=1, include_docs=False
         ).all()
         > 0
     )
开发者ID:mchampanis,项目名称:core-hq,代码行数:9,代码来源:export.py

示例12: test_stock_conversion

 def test_stock_conversion(self, _):
     saved_export_schema = SavedExportSchema.wrap(self.get_json('stock'))
     with mock.patch(
             'corehq.apps.export.models.new.CaseExportDataSchema.generate_schema_from_builds',
             return_value=self.schema):
         instance = convert_saved_export_to_export_instance(self.domain, saved_export_schema)
     table = instance.get_table(MAIN_TABLE)
     path = [PathNode(name='stock')]
     index, column = table.get_column(path, 'ExportItem', None)
     self.assertTrue(column.selected)
开发者ID:saketkanth,项目名称:commcare-hq,代码行数:10,代码来源:test_export_conversion.py

示例13: _convert_export

    def _convert_export(self, mock_path, export_file_name, force=False):
        saved_export_schema = SavedExportSchema.wrap(self.get_json(export_file_name))

        with mock.patch.object(SavedExportSchema, "save", return_value="False Save"):
            with mock.patch(mock_path, return_value=self.schema):
                instance, meta = convert_saved_export_to_export_instance(
                    self.domain, saved_export_schema, force_convert_columns=force
                )

        return instance, meta
开发者ID:dimagi,项目名称:commcare-hq,代码行数:10,代码来源:test_export_conversion.py

示例14: delete_custom_export

def delete_custom_export(req, domain, export_id):
    """
    Delete a custom export
    """
    try:
        saved_export = SavedExportSchema.get(export_id)
    except ResourceNotFound:
        return HttpResponseRedirect(req.META['HTTP_REFERER'])
    saved_export.delete()
    messages.success(req, "Custom export was deleted.")
    return _redirect_to_export_home(saved_export.type, domain)
开发者ID:kennknowles,项目名称:commcare-hq,代码行数:11,代码来源:views.py

示例15: handle

    def handle(self, *args, **options):
        if len(args) != 1:
            raise CommandError("Syntax: ./manage.py migrate_export_types [default type]!")

        default_type = args[0]
        for export in SavedExportSchema.view("couchexport/saved_export_schemas", include_docs=True):
            if not export.type:
                print "migrating %s" % export
                export.type = default_type
                if not options["dryrun"]:
                    export.save()
        print "Done!"
开发者ID:nnestle,项目名称:commcare-hq,代码行数:12,代码来源:migrate_export_types.py


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