Migrate all document languages and use the 'terminology' language abbreviation. gh-issue #211
This commit is contained in:
26
mayan/apps/documents/migrations/0025_auto_20150718_0742.py
Normal file
26
mayan/apps/documents/migrations/0025_auto_20150718_0742.py
Normal file
@@ -0,0 +1,26 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
import pycountry
|
||||
|
||||
from django.db import models, migrations
|
||||
|
||||
|
||||
def change_bibliographic_to_terminology(apps, schema_editor):
|
||||
Document = apps.get_model('documents', 'Document')
|
||||
|
||||
for document in Document.objects.all():
|
||||
language = pycountry.languages.get(bibliographic=document.language)
|
||||
document.language = language.terminology
|
||||
document.save()
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('documents', '0024_auto_20150715_0714'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.RunPython(change_bibliographic_to_terminology),
|
||||
]
|
||||
@@ -10,7 +10,7 @@ from smart_settings import Namespace
|
||||
|
||||
# TODO: Findout method to make languages names' translatable.
|
||||
# YAML fails to serialize ugettext_lazy and ugettext is not allowed at this level
|
||||
LANGUAGE_CHOICES = [(i.bibliographic, i.name) for i in list(pycountry.languages)]
|
||||
LANGUAGE_CHOICES = [(i.terminology, i.name) for i in list(pycountry.languages)]
|
||||
|
||||
namespace = Namespace(name='documents', label=_('Documents'))
|
||||
setting_storage_backend = namespace.add_setting(global_name='DOCUMENTS_STORAGE_BACKEND', default='storage.backends.filebasedstorage.FileBasedStorage')
|
||||
|
||||
Reference in New Issue
Block a user