Skip to content

Commit dd781c9

Browse files
committed
Added and updated migrations.
- Legacy-Id: 11286
1 parent ab20d00 commit dd781c9

2 files changed

Lines changed: 57 additions & 1 deletion

File tree

ietf/person/migrations/0011_populate_photos.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,12 @@
99
from django.conf import settings
1010
from django.utils.text import slugify
1111

12+
from ietf.person.name import name_parts
13+
1214
def photo_name(person,thumb=False):
1315
hasher = Hashids(salt='Person photo name salt',min_length=5)
14-
return '%s-%s%s' % ( slugify(person.ascii), hasher.encode(person.id), '-th' if thumb else '' )
16+
_, first, _, last, _ = name_parts(person.ascii)
17+
return '%s-%s%s' % ( slugify("%s %s" % (first, last)), hasher.encode(person.id), '-th' if thumb else '' )
1518

1619
def forward(apps,schema_editor):
1720
Person = apps.get_model('person','Person')
@@ -22,6 +25,8 @@ def forward(apps,schema_editor):
2225
break # Only interested in the files in the top directory
2326
image_basenames = [os.path.splitext(name)[0] for name in image_filenames]
2427
for person in Person.objects.all():
28+
if not person.name.strip():
29+
continue
2530
dirty = False
2631
if photo_name(person,thumb=False) in image_basenames:
2732
person.photo = os.path.join(settings.PHOTOS_DIRNAME, image_filenames[image_basenames.index(photo_name(person,thumb=False))])
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
# -*- coding: utf-8 -*-
2+
from __future__ import unicode_literals
3+
4+
from django.db import models, migrations
5+
import ietf.utils.storage
6+
7+
8+
class Migration(migrations.Migration):
9+
10+
dependencies = [
11+
('person', '0011_populate_photos'),
12+
]
13+
14+
operations = [
15+
migrations.AlterField(
16+
model_name='person',
17+
name='biography',
18+
field=models.TextField(help_text=b'Short biography for use on leadership pages. Use plain text or reStructuredText markup.', blank=True),
19+
preserve_default=True,
20+
),
21+
migrations.AlterField(
22+
model_name='person',
23+
name='photo',
24+
field=models.ImageField(storage=ietf.utils.storage.NoLocationMigrationFileSystemStorage(location=None), upload_to=b'photos', blank=True),
25+
preserve_default=True,
26+
),
27+
migrations.AlterField(
28+
model_name='person',
29+
name='photo_thumb',
30+
field=models.ImageField(storage=ietf.utils.storage.NoLocationMigrationFileSystemStorage(location=None), upload_to=b'photos', blank=True),
31+
preserve_default=True,
32+
),
33+
migrations.AlterField(
34+
model_name='personhistory',
35+
name='biography',
36+
field=models.TextField(help_text=b'Short biography for use on leadership pages. Use plain text or reStructuredText markup.', blank=True),
37+
preserve_default=True,
38+
),
39+
migrations.AlterField(
40+
model_name='personhistory',
41+
name='photo',
42+
field=models.ImageField(storage=ietf.utils.storage.NoLocationMigrationFileSystemStorage(location=None), upload_to=b'photos', blank=True),
43+
preserve_default=True,
44+
),
45+
migrations.AlterField(
46+
model_name='personhistory',
47+
name='photo_thumb',
48+
field=models.ImageField(storage=ietf.utils.storage.NoLocationMigrationFileSystemStorage(location=None), upload_to=b'photos', blank=True),
49+
preserve_default=True,
50+
),
51+
]

0 commit comments

Comments
 (0)