[Backport] Importing valid project without slug
parent
91697207cb
commit
8d2a4afe2a
|
@ -205,7 +205,8 @@ class ProjectImporterViewSet(mixins.ImportThrottlingPolicyMixin, CreateModelMixi
|
|||
except Exception:
|
||||
raise exc.WrongArguments(_("Invalid dump format"))
|
||||
|
||||
if Project.objects.filter(slug=dump['slug']).exists():
|
||||
slug = dump.get('slug', None)
|
||||
if slug is not None and Project.objects.filter(slug=slug).exists():
|
||||
del dump['slug']
|
||||
|
||||
if settings.CELERY_ENABLED:
|
||||
|
|
|
@ -1059,3 +1059,21 @@ def test_dump_import_throttling(client, settings):
|
|||
assert response.status_code == 201
|
||||
response = client.post(url, {'dump': data})
|
||||
assert response.status_code == 429
|
||||
|
||||
|
||||
def test_valid_dump_import_without_slug(client):
|
||||
project = f.ProjectFactory.create(slug="existing-slug")
|
||||
user = f.UserFactory.create()
|
||||
client.login(user)
|
||||
|
||||
url = reverse("importer-load-dump")
|
||||
|
||||
data = ContentFile(bytes(json.dumps({
|
||||
"name": "Project name",
|
||||
"description": "Valid project desc",
|
||||
"is_private": True
|
||||
}), "utf-8"))
|
||||
data.name = "test"
|
||||
|
||||
response = client.post(url, {'dump': data})
|
||||
assert response.status_code == 201
|
||||
|
|
Loading…
Reference in New Issue