From: Guillaume Pellerin Date: Fri, 15 Jul 2016 16:17:41 +0000 (+0200) Subject: rm nationalities, fix str in admin person X-Git-Url: https://git.parisson.com/?a=commitdiff_plain;h=8f813a7d3c9c9fbd88e419b66e6edd79e32ecca1;p=mezzo.git rm nationalities, fix str in admin person --- diff --git a/app/organization/team/migrations/0005_remove_person_nationality.py b/app/organization/team/migrations/0005_remove_person_nationality.py new file mode 100644 index 00000000..78bda7a6 --- /dev/null +++ b/app/organization/team/migrations/0005_remove_person_nationality.py @@ -0,0 +1,19 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.9.7 on 2016-07-15 16:15 +from __future__ import unicode_literals + +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ('organization-team', '0004_auto_20160715_1807'), + ] + + operations = [ + migrations.RemoveField( + model_name='person', + name='nationality', + ), + ] diff --git a/app/organization/team/models.py b/app/organization/team/models.py index 74d92066..bd006b62 100644 --- a/app/organization/team/models.py +++ b/app/organization/team/models.py @@ -115,8 +115,7 @@ class Person(AdminThumbMixin, Photo): gender = models.CharField(_('gender'), max_length=16, choices=GENDER_CHOICES, blank=True) first_name = models.CharField(_('first name'), max_length=255, blank=True, null=True) last_name = models.CharField(_('last name'), max_length=255, blank=True, null=True) - birthday = models.DateField(_('birthday'), blank=True) - nationality = NationalityField(_('nationality'), blank=True) + birthday = models.DateField(_('birthday'), blank=True, null=True) bio = RichTextField(_('biography'), blank=True) organization = models.ForeignKey('Organization', verbose_name=_('organization'), blank=True, null=True, on_delete=models.SET_NULL) @@ -124,8 +123,8 @@ class Person(AdminThumbMixin, Photo): verbose_name = _('person') ordering = ['last_name',] - def __unicode__(self): - return ' '.join((self.user.first_name, self.user.last_name)) + def __str__(self): + return ' '.join((self.first_name, self.last_name)) # def get_absolute_url(self): # return reverse("festival-artist-detail", kwargs={'slug': self.slug}) diff --git a/app/organization/team/nationalities/fields.py b/app/organization/team/nationalities/fields.py index 5dff15eb..17924066 100644 --- a/app/organization/team/nationalities/fields.py +++ b/app/organization/team/nationalities/fields.py @@ -1,6 +1,5 @@ from django.db.models.fields import CharField - class Nationality(object): """ Class represents a nationality. @@ -20,16 +19,16 @@ class Nationality(object): self.code = code def __unicode__(self): - return self.code or '' + return str(self.code or '') def __eq__(self, other): - return self.code == other + return self.code == str(other) def __ne__(self, other): return not self.__eq__(other) def __cmp__(self, other): - return cmp(self.code, other) + return cmp(self.code, str(other)) def __hash__(self): return hash(self.code) @@ -67,7 +66,7 @@ class NationalityDescriptor(object): return Nationality(code=instance.__dict__[self.field.name]) def __set__(self, instance, value): - instance.__dict__[self.field.name] = value + instance.__dict__[self.field.name] = str(value) class NationalityField(CharField): @@ -106,7 +105,7 @@ class NationalityField(CharField): # Convert the Nationality to unicode for database insertion. if value is None: return None - return value + return str(value) # If south is installed, ensure that NationalityField will be introspected just