def __init__(self, request, domain, export_id=None, minimal=False):
        self.request = request
        self.domain = domain
        self.presave = False
        self.transform_dates = False
        self.creating_new_export = not bool(export_id)
        self.minimal = minimal

        if export_id:
            self.custom_export = self.ExportSchemaClass.get(export_id)
            # also update the schema to include potential new stuff
            self.custom_export.update_schema()

            # enable configuring saved exports from this page
            saved_group = HQGroupExportConfiguration.get_for_domain(self.domain)
            self.presave = export_id in saved_group.custom_export_ids

            self.export_stock = self.has_stock_column()

            try:
                assert self.custom_export.doc_type == 'SavedExportSchema', 'bad export doc type'
                assert self.custom_export.type == self.export_type, 'wrong export type specified'
                assert self.custom_export.index[0] == domain, 'bad export doc domain'
            except __HOLE__, e:
                raise BadExportConfiguration(str(e))
        else:
            self.custom_export = self.ExportSchemaClass(type=self.export_type)
            self.export_stock = False
dataset/ETHPy150Open dimagi/commcare-hq/corehq/apps/export/custom_export_helpers.py/CustomExportHelper.__init__