"Fossies" - the Fresh Open Source Software Archive

Member "taiga-back-5.0.6/taiga/projects/issues/migrations/0003_auto_20141210_1108.py" (15 Jan 2020, 1001 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_20141210_1108.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.db import connection
    6 from taiga.projects.userstories.models import *
    7 from taiga.projects.tasks.models import *
    8 from taiga.projects.issues.models import *
    9 from taiga.projects.models import *
   10 
   11 def _fix_tags_model(tags_model):
   12     table_name = tags_model._meta.db_table
   13     query = "select id from (select id, unnest(tags) tag from %s) x where tag LIKE '%%,%%'"%(table_name)
   14     cursor = connection.cursor()
   15     cursor.execute(query)
   16     for row in cursor.fetchall():
   17         id = row[0]
   18         instance = tags_model.objects.get(id=id)
   19         instance.tags = [tag.replace(",",  "") for tag in instance.tags]
   20         instance.save()
   21 
   22 
   23 def fix_tags(apps, schema_editor):
   24     _fix_tags_model(Issue)
   25 
   26 
   27 class Migration(migrations.Migration):
   28 
   29     dependencies = [
   30         ('issues', '0002_issue_external_reference'),
   31     ]
   32 
   33     operations = [
   34         migrations.RunPython(fix_tags),
   35     ]