Repository: kartoza/prj.app

Issue:
Admin page for certifying orgs should include project name in listing
<img width="349" alt="screen shot 2017-08-16 at 10 27 37 am" src="https://user-images.githubusercontent.com/178003/29354369-ac789756-826d-11e7-8901-6c5fadd25fb9.png">

Consider the above screenshot - how will it work when Kartoza registers as a certifying organization for two projects (InaSAFE and QGIS)? Can you include the project name in the listing to make it clear e.g.:

QGIS - Kartoza
QGIS - Birds Eye
InaSAFE - Kartoza



Discussion:

Resolving patch:
diff --git a/django_project/certification/forms.py b/django_project/certification/forms.py
--- a/django_project/certification/forms.py
+++ b/django_project/certification/forms.py
@@ -51,6 +51,7 @@ class Meta:
             'organisation_phone',
             'logo',
             'organisation_owners',
+            'project',
         )
 
     def __init__(self, *args, **kwargs):
@@ -76,11 +77,12 @@ def __init__(self, *args, **kwargs):
         self.fields['organisation_owners'].label_from_instance = \
             lambda obj: "%s <%s>" % (obj.get_full_name(), obj)
         self.fields['organisation_owners'].initial = [self.user]
+        self.fields['project'].initial = self.project
+        self.fields['project'].widget = forms.HiddenInput()
         self.helper.add_input(Submit('submit', 'Submit'))
 
     def save(self, commit=True):
         instance = super(CertifyingOrganisationForm, self).save(commit=False)
-        instance.project = self.project
         instance.save()
         self.save_m2m()
         return instance
diff --git a/django_project/certification/migrations/0010_auto_20170817_1718.py b/django_project/certification/migrations/0010_auto_20170817_1718.py
new file mode 100644
--- /dev/null
+++ b/django_project/certification/migrations/0010_auto_20170817_1718.py
@@ -0,0 +1,23 @@
+# -*- coding: utf-8 -*-
+from __future__ import unicode_literals
+
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+
+    dependencies = [
+        ('certification', '0009_auto_20170710_0708'),
+    ]
+
+    operations = [
+        migrations.AlterField(
+            model_name='certifyingorganisation',
+            name='name',
+            field=models.CharField(help_text='name of organisation or institution', max_length=200),
+        ),
+        migrations.AlterUniqueTogether(
+            name='certifyingorganisation',
+            unique_together=set([('name', 'project')]),
+        ),
+    ]
diff --git a/django_project/certification/models/certifying_organisation.py b/django_project/certification/models/certifying_organisation.py
--- a/django_project/certification/models/certifying_organisation.py
+++ b/django_project/certification/models/certifying_organisation.py
@@ -81,8 +81,7 @@ class CertifyingOrganisation(SlugifyingMixin, models.Model):
         help_text=_('name of organisation or institution'),
         max_length=200,
         null=False,
-        blank=False,
-        unique=True
+        blank=False
     )
 
     organisation_email = models.CharField(
@@ -143,12 +142,13 @@ class Meta:
 
         app_label = 'certification'
         ordering = ['name']
+        unique_together = ['name', 'project']
 
     def save(self, *args, **kwargs):
         super(CertifyingOrganisation, self).save(*args, **kwargs)
 
     def __unicode__(self):
-        return self.name
+        return '%s - %s' % (self.project.name, self.name)
 
     def get_absolute_url(self):
         """Return URL to certifying organisation detail page.


Test patch: