"Fossies" - the Fresh Open Source Software Archive

Member "taiga-back-5.0.6/taiga/projects/history/migrations/0003_auto_20140917_1405.py" (15 Jan 2020, 1404 Bytes) of package /linux/www/taiga-back-5.0.6.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Python source code syntax highlighting (style: standard) with prefixed line numbers. Alternatively you can here view or download the uninterpreted source code file. For more information about "0003_auto_20140917_1405.py" see the Fossies "Dox" file reference documentation.

    1 # -*- coding: utf-8 -*-
    2 from __future__ import unicode_literals
    3 
    4 from django.db import models, migrations
    5 from django.conf import settings
    6 import taiga.base.db.models.fields
    7 
    8 def change_fk_with_tuple_pk_and_name(apps, schema_editor):
    9     HistoryEntry = apps.get_model("history", "HistoryEntry")
   10 
   11     for item in HistoryEntry.objects.all():
   12         if item.delete_comment_user_old:
   13             item.delete_comment_user = {"pk": item.delete_comment_user_old.pk, "name": item.delete_comment_user_old.name}
   14         else:
   15             item.delete_comment_user = None
   16         item.save()
   17 
   18 class Migration(migrations.Migration):
   19 
   20     dependencies = [
   21         migrations.swappable_dependency(settings.AUTH_USER_MODEL),
   22         ('history', '0002_auto_20140916_0936'),
   23     ]
   24 
   25     operations = [
   26         migrations.RenameField(
   27             model_name='historyentry',
   28             old_name='delete_comment_user',
   29             new_name='delete_comment_user_old',
   30         ),
   31         migrations.AddField(
   32             model_name='historyentry',
   33             name='delete_comment_user',
   34             field=taiga.base.db.models.fields.JSONField(null=True, blank=True, default=None),
   35             preserve_default=True,
   36         ),
   37 
   38         migrations.RunPython(change_fk_with_tuple_pk_and_name),
   39 
   40         migrations.RemoveField(
   41             model_name='historyentry',
   42             name='delete_comment_user_old',
   43         ),
   44     ]