0001_initial.py 999 B

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