"Fossies" - the Fresh Open Source Software Archive

Member "taiga-back-5.0.6/taiga/projects/wiki/migrations/0002_remove_wikipage_watchers.py" (15 Jan 2020, 1147 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 "0002_remove_wikipage_watchers.py" see the Fossies "Dox" file reference documentation.

    1 # -*- coding: utf-8 -*-
    2 from __future__ import unicode_literals
    3 
    4 from django.db import connection
    5 from django.db import models, migrations
    6 from django.contrib.contenttypes.models import ContentType
    7 from taiga.base.utils.contenttypes import update_all_contenttypes
    8 
    9 def create_notifications(apps, schema_editor):
   10     update_all_contenttypes(verbosity=0)
   11     sql="""
   12 INSERT INTO notifications_watched (object_id, created_date, content_type_id, user_id, project_id)
   13 SELECT wikipage_id AS object_id, now() AS created_date, {content_type_id} AS content_type_id, user_id, project_id
   14 FROM wiki_wikipage_watchers INNER JOIN wiki_wikipage ON wiki_wikipage_watchers.wikipage_id = wiki_wikipage.id""".format(content_type_id=ContentType.objects.get(model='wikipage').id)
   15     cursor = connection.cursor()
   16     cursor.execute(sql)
   17 
   18 
   19 class Migration(migrations.Migration):
   20 
   21     dependencies = [
   22         ('notifications', '0004_watched'),
   23         ('wiki', '0001_initial'),
   24     ]
   25 
   26     operations = [
   27         migrations.RunPython(create_notifications),
   28         migrations.RemoveField(
   29             model_name='wikipage',
   30             name='watchers',
   31         ),
   32     ]