Commit cbb9b46fed8a8a78dfabd5961b0fcf7256b7ca72
1 parent
8ee805f8
Exists in
master
and in
1 other branch
Fixed CommunityAssociation
Signed-off-by: Macartur Sousa <macartur.sc@gmail.com>
Showing
2 changed files
with
7 additions
and
35 deletions
Show diff stats
src/colab-spb-plugin/src/colab_spb/migrations/0004_auto_20160518_1820.py
... | ... | @@ -1,32 +0,0 @@ |
1 | -# -*- coding: utf-8 -*- | |
2 | -from __future__ import unicode_literals | |
3 | - | |
4 | -from django.db import models, migrations | |
5 | - | |
6 | - | |
7 | -class Migration(migrations.Migration): | |
8 | - | |
9 | - dependencies = [ | |
10 | - ('colab_spb', '0003_auto_20160229_1804'), | |
11 | - ] | |
12 | - | |
13 | - operations = [ | |
14 | - migrations.AlterField( | |
15 | - model_name='communityassociations', | |
16 | - name='community', | |
17 | - field=models.ForeignKey(default=1, to='colab_noosfero.NoosferoCommunity'), | |
18 | - preserve_default=True, | |
19 | - ), | |
20 | - migrations.AlterField( | |
21 | - model_name='communityassociations', | |
22 | - name='group', | |
23 | - field=models.ForeignKey(default=1, to='colab_gitlab.GitlabGroup'), | |
24 | - preserve_default=True, | |
25 | - ), | |
26 | - migrations.AlterField( | |
27 | - model_name='communityassociations', | |
28 | - name='mail_list', | |
29 | - field=models.ForeignKey(default=1, to='super_archives.MailingList'), | |
30 | - preserve_default=True, | |
31 | - ), | |
32 | - ] |
src/colab-spb-plugin/src/colab_spb/models.py
... | ... | @@ -5,11 +5,15 @@ from django.db import models |
5 | 5 | |
6 | 6 | |
7 | 7 | class CommunityAssociations(models.Model): |
8 | - community = models.ForeignKey(noosfero.NoosferoCommunity, default=1) | |
9 | - group = models.ForeignKey(gitlab.GitlabGroup, default=1) | |
10 | - mail_list = models.ForeignKey(mailman.MailingList, default=1) | |
8 | + community = models.ForeignKey(noosfero.NoosferoCommunity, null=True) | |
9 | + group = models.ForeignKey(gitlab.GitlabGroup, null=True) | |
10 | + mail_list = models.ForeignKey(mailman.MailingList, null=True) | |
11 | 11 | |
12 | 12 | def __unicode__(self): |
13 | + if self.community is None or self.group.name is None \ | |
14 | + or self.mail_list.name is None: | |
15 | + return u'Invalid CommunityAssociation' | |
16 | + | |
13 | 17 | return u'Social: {} - Dev: {} - List: {}'.format(self.community.name, |
14 | 18 | self.group.name, |
15 | 19 | self.mail_list.name) | ... | ... |