Update Document model's uuid field to use Django's native UUIDField class.
This commit is contained in:
@@ -14,8 +14,17 @@ class Migration(migrations.Migration):
|
||||
migrations.CreateModel(
|
||||
name='NewVersionBlock',
|
||||
fields=[
|
||||
('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
|
||||
('document', models.ForeignKey(verbose_name='Document', to='documents.Document')),
|
||||
(
|
||||
'id', models.AutoField(
|
||||
verbose_name='ID', serialize=False, auto_created=True,
|
||||
primary_key=True
|
||||
)
|
||||
),
|
||||
(
|
||||
'document', models.ForeignKey(
|
||||
verbose_name='Document', to='documents.Document'
|
||||
)
|
||||
),
|
||||
],
|
||||
options={
|
||||
'verbose_name': 'New version block',
|
||||
|
||||
@@ -14,11 +14,21 @@ class Migration(migrations.Migration):
|
||||
migrations.AlterField(
|
||||
model_name='documenttype',
|
||||
name='delete_time_period',
|
||||
field=models.PositiveIntegerField(default=30, help_text='Amount of time after which documents of this type in the trash will be deleted.', null=True, verbose_name='Delete time period', blank=True),
|
||||
field=models.PositiveIntegerField(
|
||||
default=30, help_text='Amount of time after which documents '
|
||||
'of this type in the trash will be deleted.', null=True,
|
||||
verbose_name='Delete time period', blank=True
|
||||
),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='documenttype',
|
||||
name='delete_time_unit',
|
||||
field=models.CharField(default='days', choices=[('days', 'Days'), ('hours', 'Hours'), ('minutes', 'Minutes')], max_length=8, blank=True, null=True, verbose_name='Delete time unit'),
|
||||
field=models.CharField(
|
||||
default='days', choices=[
|
||||
('days', 'Days'), ('hours', 'Hours'),
|
||||
('minutes', 'Minutes')
|
||||
], max_length=8, blank=True, null=True,
|
||||
verbose_name='Delete time unit'
|
||||
),
|
||||
),
|
||||
]
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
import uuid
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
def convert_uuid_to_hex(apps, schema_editor):
|
||||
Document = apps.get_model('documents', 'Document')
|
||||
|
||||
for document in Document.objects.all():
|
||||
document.uuid = uuid.UUID(document.uuid).hex
|
||||
document.save()
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('documents', '0030_auto_20160309_1837'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.RunPython(convert_uuid_to_hex),
|
||||
]
|
||||
@@ -0,0 +1,20 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import migrations, models
|
||||
import uuid
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('documents', '0031_convert_uuid'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterField(
|
||||
model_name='document',
|
||||
name='uuid',
|
||||
field=models.UUIDField(default=uuid.uuid4, editable=False),
|
||||
),
|
||||
]
|
||||
@@ -149,9 +149,7 @@ class Document(models.Model):
|
||||
Defines a single document with it's fields and properties
|
||||
"""
|
||||
|
||||
uuid = models.CharField(
|
||||
default=UUID_FUNCTION, editable=False, max_length=48
|
||||
)
|
||||
uuid = models.UUIDField(default=uuid.uuid4, editable=False)
|
||||
document_type = models.ForeignKey(
|
||||
DocumentType, related_name='documents',
|
||||
verbose_name=_('Document type')
|
||||
|
||||
Reference in New Issue
Block a user