Ejemplo n.º 1
0
class ProductImporter(DataImporter):
    identifier = "product_importer"
    name = _("Product Importer")
    meta_base_class = ProductMetaBase
    model = Product
    relation_field = "product"

    def get_related_models(self):
        return [Product, ShopProduct]

    example_files = [
        ImporterExampleFile("product_sample_import.xls",
                            ("application/vnd.ms-excel", "application/excel")),
        ImporterExampleFile(
            "product_sample_import.xlsx",
            "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
        ),
        ImporterExampleFile(
            "product_sample_complex_import.xlsx",
            "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
        ),
        ImporterExampleFile("product_sample_import.csv", "text/csv")
    ]

    @classmethod
    def get_example_file_content(cls, example_file, request):
        from shuup.default_importer.samples import get_sample_file_content
        return get_sample_file_content(example_file.file_name)
Ejemplo n.º 2
0
class CompanyContactImporter(DataImporter):
    identifier = "company_importer"
    name = _("Company Contact Importer")

    meta_base_class = AddressHandlerMeta
    model = Contact

    example_files = [
        ImporterExampleFile(
            "company_contact_sample.xlsx",
            "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
        )
    ]

    def get_related_models(self):
        return [Contact, CompanyContact]

    def get_row_model(self, row):
        return CompanyContact

    @classmethod
    def get_example_file_content(cls, example_file, request):
        from shuup.default_importer.samples import get_sample_file_content

        return get_sample_file_content(example_file.file_name)
Ejemplo n.º 3
0
class ProductImporter(DataImporter):
    identifier = "product_importer"
    name = _("Product Importer")
    meta_base_class = ProductMetaBase
    model = Product
    relation_field = "product"
    help_template = "shuup/default_importers/product_help.jinja"

    def get_related_models(self):
        return [Product, ShopProduct]

    example_files = [
        ImporterExampleFile(
            "product_sample_import.xls",
            ("application/vnd.ms-excel", "application/excel")
        ),
        ImporterExampleFile(
            "product_sample_import.xlsx",
            "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
        ),
        ImporterExampleFile(
            "product_sample_complex_import.xlsx",
            "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
        ),
        ImporterExampleFile(
            "product_sample_import_with_images.xlsx",
            "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
        ),
        ImporterExampleFile(
            "product_sample_import.csv",
            "text/csv"
        )
    ]

    @classmethod
    def get_example_file_content(cls, example_file, request):
        from shuup.default_importer.samples import get_sample_file_content
        return get_sample_file_content(example_file.file_name)

    @classmethod
    def get_help_context_data(cls, request):
        from shuup.admin.shop_provider import get_shop
        return {
            "has_media_browse_permission": has_permission(request.user, "media.browse"),
            "supplier": Supplier.objects.enabled().filter(shops=get_shop(request)).first()
        }
Ejemplo n.º 4
0
class DummyImporter(DataImporter):
    identifier = "dummy_importer"
    name = "Dummy Importer"
    model = Contact

    example_files = [
        ImporterExampleFile("sample_dummy_importer.csv", "text/csv", "shuup_testing/sample_dummy_importer.jinja")
    ]

    def get_related_models(self):
        return [Contact, PersonContact]

    def get_row_model(self, row):
        return PersonContact
Ejemplo n.º 5
0
class DummyFileImporter(DataImporter):
    identifier = "dummy_file_importer"
    name = "Dummy File Importer"
    model = Contact

    example_files = [ImporterExampleFile("doesn_exit.csv", "text/csv")]

    def get_related_models(self):
        return [Contact, PersonContact]

    def get_row_model(self, row):
        return PersonContact

    @classmethod
    def get_example_file_content(cls, example_file, request):
        return None