forked from 0x2620/pandora
Entity.alternativeNames: default to () not [] (fixes #2896)
Otherwise this:
self.name_find = '||' + '||'.join((self.name,) + self.alternativeNames) + '||'
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
fails because () + [] is an error. I guess this must have been
introduced by the DictField/TupleField rewrite.
Without this fix, it is impossible to create a new entity.
Basically the same logic is used for Event and Place too so I've made
the same change to those, and, in passing, fix another copy of the bug
fixed for Entity.name_find in fe7f961
.
This commit is contained in:
parent
9a4c24cdb4
commit
0c98cd080e
6 changed files with 69 additions and 6 deletions
21
pandora/entity/migrations/0002_auto_20160304_1641.py
Normal file
21
pandora/entity/migrations/0002_auto_20160304_1641.py
Normal file
|
@ -0,0 +1,21 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# Generated by Django 1.9.2 on 2016-03-04 16:41
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import migrations
|
||||
import oxdjango.fields
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('entity', '0001_initial'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterField(
|
||||
model_name='entity',
|
||||
name='alternativeNames',
|
||||
field=oxdjango.fields.TupleField(default=()),
|
||||
),
|
||||
]
|
|
@ -35,7 +35,7 @@ class Entity(models.Model):
|
|||
|
||||
type = models.CharField(max_length=255)
|
||||
name = models.CharField(max_length=255)
|
||||
alternativeNames = fields.TupleField(default=[])
|
||||
alternativeNames = fields.TupleField(default=())
|
||||
|
||||
data = fields.DictField(default={}, editable=False)
|
||||
matches = models.IntegerField(default=0)
|
||||
|
|
21
pandora/event/migrations/0003_auto_20160304_1644.py
Normal file
21
pandora/event/migrations/0003_auto_20160304_1644.py
Normal file
|
@ -0,0 +1,21 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# Generated by Django 1.9.2 on 2016-03-04 16:44
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import migrations
|
||||
import oxdjango.fields
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('event', '0002_auto_20160219_1537'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterField(
|
||||
model_name='event',
|
||||
name='alternativeNames',
|
||||
field=oxdjango.fields.TupleField(default=()),
|
||||
),
|
||||
]
|
|
@ -36,7 +36,7 @@ class Event(models.Model):
|
|||
name_find = models.TextField(default='', editable=True)
|
||||
wikipediaId = models.CharField(max_length=1000, blank=True)
|
||||
|
||||
alternativeNames = fields.TupleField(default=[])
|
||||
alternativeNames = fields.TupleField(default=())
|
||||
|
||||
objects = managers.EventManager()
|
||||
|
||||
|
@ -130,7 +130,7 @@ class Event(models.Model):
|
|||
def save(self, *args, **kwargs):
|
||||
if not self.name_sort:
|
||||
self.set_name_sort()
|
||||
self.name_find = '||' + self.name + '||'.join(self.alternativeNames) + '||'
|
||||
self.name_find = '||' + '||'.join((self.name,) + self.alternativeNames) + '||'
|
||||
self.defined = len(filter(None, [getattr(self, key)
|
||||
for key in ('start', 'end')])) > 0
|
||||
if self.endTime and self.startTime:
|
||||
|
|
21
pandora/place/migrations/0002_auto_20160304_1644.py
Normal file
21
pandora/place/migrations/0002_auto_20160304_1644.py
Normal file
|
@ -0,0 +1,21 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# Generated by Django 1.9.2 on 2016-03-04 16:44
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import migrations
|
||||
import oxdjango.fields
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('place', '0001_initial'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterField(
|
||||
model_name='place',
|
||||
name='alternativeNames',
|
||||
field=oxdjango.fields.TupleField(default=()),
|
||||
),
|
||||
]
|
|
@ -23,7 +23,7 @@ class Place(models.Model):
|
|||
user = models.ForeignKey(User, null=True, related_name='places')
|
||||
|
||||
name = models.CharField(max_length=1024)
|
||||
alternativeNames = fields.TupleField(default=[])
|
||||
alternativeNames = fields.TupleField(default=())
|
||||
name_sort = models.CharField(max_length=200, db_index=True)
|
||||
name_find = models.TextField(default='', editable=False)
|
||||
|
||||
|
|
Loading…
Reference in a new issue