Repository: pretalx/pretalx

Issue:
cannot create organiser
## Expected Behavior

As an admin, I'd like to create new organizers.

## Current Behavior

![image](https://user-images.githubusercontent.com/2158203/46036518-f4bfae00-c105-11e8-9ffd-c20d61007e72.png)

## Steps to Reproduce

1. go to `/orga/organiser/new`
2. enter data into all non-disabled fields
3. press save
4. receive "This field is required." for the short form, which is disabled

## Your Environment

<!--- Include as many relevant details about the environment you experienced the bug in -->
* Version used: v0.8.0
* Environment name and version (e.g. Chrome 39, python 3.5): N/A
* Operating System and version (desktop or mobile): N/A
* Link to your instance, if in production: conference.c3w.at
cannot create organiser
## Expected Behavior

As an admin, I'd like to create new organizers.

## Current Behavior

![image](https://user-images.githubusercontent.com/2158203/46036518-f4bfae00-c105-11e8-9ffd-c20d61007e72.png)

## Steps to Reproduce

1. go to `/orga/organiser/new`
2. enter data into all non-disabled fields
3. press save
4. receive "This field is required." for the short form, which is disabled

## Your Environment

<!--- Include as many relevant details about the environment you experienced the bug in -->
* Version used: v0.8.0
* Environment name and version (e.g. Chrome 39, python 3.5): N/A
* Operating System and version (desktop or mobile): N/A
* Link to your instance, if in production: conference.c3w.at


Discussion:

Resolving patch:
diff --git a/src/pretalx/event/forms.py b/src/pretalx/event/forms.py
--- a/src/pretalx/event/forms.py
+++ b/src/pretalx/event/forms.py
@@ -44,7 +44,9 @@ class Meta:
 class OrganiserForm(ReadOnlyFlag, I18nModelForm):
     def __init__(self, *args, **kwargs):
         super().__init__(*args, **kwargs)
-        self.fields['slug'].disabled = True
+
+        if kwargs.get('instance'):
+            self.fields['slug'].disabled = True
 
     class Meta:
         model = Organiser


Test patch:
diff --git a/src/tests/functional/orga/test_organiser.py b/src/tests/functional/orga/test_organiser.py
--- a/src/tests/functional/orga/test_organiser.py
+++ b/src/tests/functional/orga/test_organiser.py
@@ -5,7 +5,26 @@
 from django.urls import reverse
 from django.utils.timezone import now
 
-from pretalx.event.models import Event
+from pretalx.event.models import Event, Organiser
+
+
+@pytest.mark.django_db
+def test_orga_create_organiser(superuser_client):
+    assert len(Organiser.objects.all()) == 0
+    response = superuser_client.post(
+        '/orga/organiser/new',
+        data={
+            'name_0': 'The bestest organiser',
+            'name_1': 'The bestest organiser',
+            'slug': 'organiser',
+        },
+        follow=True,
+    )
+    assert response.status_code == 200, response.content.decode()
+    assert len(Organiser.objects.all()) == 1
+    organiser = Organiser.objects.all().first()
+    assert str(organiser.name) == 'The bestest organiser', response.content.decode()
+    assert str(organiser) == str(organiser.name)
 
 
 @pytest.mark.django_db
diff --git a/src/tests/unit/orga/test_orga_permissions.py b/src/tests/unit/orga/test_orga_permissions.py
--- a/src/tests/unit/orga/test_orga_permissions.py
+++ b/src/tests/unit/orga/test_orga_permissions.py
@@ -16,6 +16,16 @@ def test_permissions_change_organiser_takes_event(orga_user, event):
     assert can_change_organiser_settings(orga_user, event) is True
 
 
+@pytest.mark.django_db
+def test_create_organiser_orga_user(orga_user):
+    assert can_change_organiser_settings(orga_user, None) is False
+
+
+@pytest.mark.django_db
+def test_create_organiser_superuser(superuser):
+    assert can_change_organiser_settings(superuser, None) is True
+
+
 def test_permissions_change_teams_doesnt_crash_on_unexpected_values():
     assert can_change_teams(None, None) is False
     assert can_change_teams(AnonymousUser, None) is False