"Fossies" - the Fresh Open Source Software Archive

Member "taiga-back-5.0.6/taiga/hooks/gitlab/migrations/0001_initial.py" (15 Jan 2020, 999 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 "0001_initial.py" see the Fossies "Dox" file reference documentation.

    1 # -*- coding: utf-8 -*-
    2 from __future__ import unicode_literals
    3 
    4 from django.db import migrations
    5 from django.core.files import File
    6 
    7 import uuid
    8 
    9 
   10 def create_github_system_user(apps, schema_editor):
   11     # We get the model from the versioned app registry;
   12     # if we directly import it, it'll be the wrong version
   13     User = apps.get_model("users", "User")
   14     db_alias = schema_editor.connection.alias
   15     random_hash = uuid.uuid4().hex
   16     user = User.objects.using(db_alias).create(
   17         username="gitlab-{}".format(random_hash),
   18         email="gitlab-{}@taiga.io".format(random_hash),
   19         full_name="GitLab",
   20         is_active=False,
   21         is_system=True,
   22         bio="",
   23     )
   24     f = open("taiga/hooks/gitlab/migrations/logo.png", "rb")
   25     user.photo.save("logo.png", File(f))
   26     user.save()
   27 
   28 
   29 class Migration(migrations.Migration):
   30 
   31     dependencies = [
   32         ('users', '0011_user_theme')
   33     ]
   34 
   35     operations = [
   36         migrations.RunPython(create_github_system_user),
   37     ]