diff --git a/taiga/hooks/gitlab/migrations/0002_auto_20150703_1102.py b/taiga/hooks/gitlab/migrations/0002_auto_20150703_1102.py new file mode 100644 index 00000000..4613c4ac --- /dev/null +++ b/taiga/hooks/gitlab/migrations/0002_auto_20150703_1102.py @@ -0,0 +1,50 @@ +# -*- coding: utf-8 -*- +from __future__ import unicode_literals + +from django.db import models, migrations +from django.core.files import File + +def update_gitlab_system_user_photo_to_v2(apps, schema_editor): + # We get the model from the versioned app registry; + # if we directly import it, it'll be the wrong version + User = apps.get_model("users", "User") + db_alias = schema_editor.connection.alias + + try: + user = User.objects.using(db_alias).get(username__startswith="gitlab-", + is_active=False, + is_system=True) + f = open("taiga/hooks/gitlab/migrations/logo-v2.png", "rb") + user.photo.save("logo.png", File(f)) + user.save() + except User.DoesNotExist: + pass + +def update_gitlab_system_user_photo_to_v1(apps, schema_editor): + # We get the model from the versioned app registry; + # if we directly import it, it'll be the wrong version + User = apps.get_model("users", "User") + db_alias = schema_editor.connection.alias + + try: + user = User.objects.using(db_alias).get(username__startswith="gitlab-", + is_active=False, + is_system=True) + f = open("taiga/hooks/gitlab/migrations/logo.png", "rb") + user.photo.save("logo.png", File(f)) + user.save() + except User.DoesNotExist: + pass + + +class Migration(migrations.Migration): + + dependencies = [ + ('gitlab', '0001_initial'), + ('users', '0011_user_theme'), + ] + + operations = [ + migrations.RunPython(update_gitlab_system_user_photo_to_v2, + update_gitlab_system_user_photo_to_v1), + ] diff --git a/taiga/hooks/gitlab/migrations/logo-v2.png b/taiga/hooks/gitlab/migrations/logo-v2.png new file mode 100644 index 00000000..01063fc3 Binary files /dev/null and b/taiga/hooks/gitlab/migrations/logo-v2.png differ