Task #417 - Fixing create project api handler
parent
3f8af102ab
commit
e79f0380dd
|
@ -747,7 +747,7 @@ def project_post_save(sender, instance, created, **kwargs):
|
|||
if not created:
|
||||
return
|
||||
|
||||
template_slug = getattr(instance, "template", settings.DEFAULT_PROJECT_TEMPLATE)
|
||||
template_slug = getattr(instance, "template", None) or settings.DEFAULT_PROJECT_TEMPLATE
|
||||
template = ProjectTemplate.objects.get(slug=template_slug)
|
||||
template.apply_to_project(instance)
|
||||
|
||||
|
|
|
@ -0,0 +1,20 @@
|
|||
import pytest
|
||||
|
||||
from django.conf import settings
|
||||
from django.core.urlresolvers import reverse
|
||||
|
||||
from .. import factories as f
|
||||
|
||||
pytestmark = pytest.mark.django_db
|
||||
|
||||
|
||||
def test_api_create_project(client):
|
||||
f.ProjectTemplateFactory.create(slug=settings.DEFAULT_PROJECT_TEMPLATE)
|
||||
user = f.UserFactory.create()
|
||||
url = reverse("projects-list")
|
||||
data = {"name": "project name", "slug": "project-slug", "description": "project description"}
|
||||
|
||||
client.login(user)
|
||||
response = client.json.post(url, data)
|
||||
|
||||
assert response.status_code == 201
|
Loading…
Reference in New Issue