Beispiel #1
0
    def test_import(self):
        c = Client()

        admin_email, admin_password = create_superuser()
        c.login(username=admin_email, password=admin_password)

        zip_path = os.path.join(settings.BASE_DIR, 'legacy', 'testdata', '08_12_2015.zip')
        import_zip(zip_path)
Beispiel #2
0
    def import_legacy_catalog(self, request):
        if request.method == 'POST':
            form = ImportLegacyDatabaseForm(request.POST, request.FILES)
            if form.is_valid():
                feedbacks = import_zip(request.FILES['zip_file'])
                for (error, feedback) in feedbacks:
                    if error > 0:
                        messages.error(request, feedback)
                    else:
                        messages.success(request, feedback)
        else:
            form = ImportLegacyDatabaseForm()

        context = self.each_context(request)
        context['form'] = form
        
        return render(request, 'admin/import.html', context)