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)
|
type = models.CharField(max_length=255)
|
||||||
name = 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)
|
data = fields.DictField(default={}, editable=False)
|
||||||
matches = models.IntegerField(default=0)
|
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,14 +36,14 @@ class Event(models.Model):
|
||||||
name_find = models.TextField(default='', editable=True)
|
name_find = models.TextField(default='', editable=True)
|
||||||
wikipediaId = models.CharField(max_length=1000, blank=True)
|
wikipediaId = models.CharField(max_length=1000, blank=True)
|
||||||
|
|
||||||
alternativeNames = fields.TupleField(default=[])
|
alternativeNames = fields.TupleField(default=())
|
||||||
|
|
||||||
objects = managers.EventManager()
|
objects = managers.EventManager()
|
||||||
|
|
||||||
#start yyyy-mm-dd|mm-dd|dow 00:00|00:00
|
#start yyyy-mm-dd|mm-dd|dow 00:00|00:00
|
||||||
start = models.CharField(default='', max_length=255)
|
start = models.CharField(default='', max_length=255)
|
||||||
startTime = models.BigIntegerField(default=None, null=True)
|
startTime = models.BigIntegerField(default=None, null=True)
|
||||||
|
|
||||||
#end yyyy-mm-dd|mm-dd|dow 00:00|00:01
|
#end yyyy-mm-dd|mm-dd|dow 00:00|00:01
|
||||||
end = models.CharField(default='', max_length=255)
|
end = models.CharField(default='', max_length=255)
|
||||||
endTime = models.BigIntegerField(default=None, null=True)
|
endTime = models.BigIntegerField(default=None, null=True)
|
||||||
|
@ -77,7 +77,7 @@ class Event(models.Model):
|
||||||
user.profile.capability('canEditEvents')):
|
user.profile.capability('canEditEvents')):
|
||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def get_matches(self, qs=None):
|
def get_matches(self, qs=None):
|
||||||
return get_matches(self, Event, 'event', qs)
|
return get_matches(self, Event, 'event', qs)
|
||||||
|
|
||||||
|
@ -130,7 +130,7 @@ class Event(models.Model):
|
||||||
def save(self, *args, **kwargs):
|
def save(self, *args, **kwargs):
|
||||||
if not self.name_sort:
|
if not self.name_sort:
|
||||||
self.set_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)
|
self.defined = len(filter(None, [getattr(self, key)
|
||||||
for key in ('start', 'end')])) > 0
|
for key in ('start', 'end')])) > 0
|
||||||
if self.endTime and self.startTime:
|
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')
|
user = models.ForeignKey(User, null=True, related_name='places')
|
||||||
|
|
||||||
name = models.CharField(max_length=1024)
|
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_sort = models.CharField(max_length=200, db_index=True)
|
||||||
name_find = models.TextField(default='', editable=False)
|
name_find = models.TextField(default='', editable=False)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue