Repository: akvo/akvo-rsr

Issue:
Add organisations in project editor
## Test plan

GIVEN the project editor
WHEN looking at section 3, partners
THEN there should be an 'Add new organisation' button

GIVEN the 'Add new organisation' button is clicked
WHEN the modal appears
THEN it should be possible to add a new organisation with a name, long name, IATI organisation ID, organisation type, and description

WHEN adding a new organisation
THEN the name and long name fields should be filled in
AND the name, long name and IATI organisation ID should not already exist in the database yet

WHEN an organisation has been added
THEN the modal should disappear
AND the new organisation should be selectable in the organisation typeaheads, except for the reporting organisation typeahead
## Issue description

It should be possible for organisation Admins to add a new organisation while they're in the project editor, so that they don't have to visit the old admin.



Discussion:
@KasperBrandt For a modal dialog to add organisations, what set of fields would we need to support? The full set in the Django admin for adding organisations?


Resolving patch:
diff --git a/akvo/rsr/migrations/0035_auto_20151002_1511.py b/akvo/rsr/migrations/0035_auto_20151002_1511.py
new file mode 100644
--- /dev/null
+++ b/akvo/rsr/migrations/0035_auto_20151002_1511.py
@@ -0,0 +1,33 @@
+# -*- coding: utf-8 -*-
+from __future__ import unicode_literals
+
+from django.db import models, migrations
+import akvo.rsr.fields
+
+
+class Migration(migrations.Migration):
+
+    dependencies = [
+        ('rsr', '0034_auto_20150916_1402'),
+    ]
+
+    operations = [
+        migrations.AlterField(
+            model_name='organisation',
+            name='iati_org_id',
+            field=akvo.rsr.fields.ValidXMLCharField(null=True, default=None, max_length=75, blank=True, unique=True, verbose_name='IATI organisation ID', db_index=True),
+            preserve_default=True,
+        ),
+        migrations.AlterField(
+            model_name='organisation',
+            name='long_name',
+            field=akvo.rsr.fields.ValidXMLCharField(help_text='Full name of organisation (75 characters).', unique=True, max_length=75, verbose_name='long name', db_index=True),
+            preserve_default=True,
+        ),
+        migrations.AlterField(
+            model_name='organisation',
+            name='organisation_type',
+            field=akvo.rsr.fields.ValidXMLCharField(choices=[(b'N', 'NGO'), (b'G', 'Governmental'), (b'C', 'Commercial'), (b'K', 'Knowledge institution')], max_length=1, blank=True, null=True, verbose_name='organisation type', db_index=True),
+            preserve_default=True,
+        ),
+    ]
diff --git a/akvo/rsr/models/organisation.py b/akvo/rsr/models/organisation.py
--- a/akvo/rsr/models/organisation.py
+++ b/akvo/rsr/models/organisation.py
@@ -80,7 +80,7 @@ def org_type_from_iati_type(cls, iati_type):
                     u'(25 characters).')
     )
     long_name = ValidXMLCharField(
-        _(u'long name'), blank=True, max_length=75, unique=True,
+        _(u'long name'), max_length=75, db_index=True, unique=True,
         help_text=_(u'Full name of organisation (75 characters).'),
     )
     language = ValidXMLCharField(
@@ -88,7 +88,8 @@ def org_type_from_iati_type(cls, iati_type):
         help_text=_(u'The main language of the organisation'),
     )
     organisation_type = ValidXMLCharField(
-        _(u'organisation type'), max_length=1, db_index=True, choices=ORG_TYPES
+        _(u'organisation type'), max_length=1, db_index=True, choices=ORG_TYPES, blank=True,
+        null=True
     )
     new_organisation_type = models.IntegerField(
         _(u'IATI organisation type'), db_index=True,
@@ -97,7 +98,8 @@ def org_type_from_iati_type(cls, iati_type):
                                 u'matches your organisation.'),
     )
     iati_org_id = ValidXMLCharField(
-        _(u'IATI organisation ID'), max_length=75, blank=True, null=True, db_index=True, unique=True
+        _(u'IATI organisation ID'), max_length=75, blank=True, null=True, db_index=True,
+        unique=True, default=None
     )
     internal_org_ids = models.ManyToManyField(
         'self', through='InternalOrganisationID', symmetrical=False,


Test patch: