Prevent the creation of a duplicate gogs user if you have the gogs plugin enabled

remotes/origin/issue/4795/notification_even_they_are_disabled
David Barragán Merino 2016-07-29 12:40:54 +02:00
parent ed69c48f73
commit 04fb04340a
1 changed files with 14 additions and 12 deletions

View File

@ -15,6 +15,8 @@ def create_gogs_system_user(apps, schema_editor):
# if we directly import it, it'll be the wrong version
User = apps.get_model("users", "User")
db_alias = schema_editor.connection.alias
if not User.objects.using(db_alias).filter(is_system=True, username__startswith="gogs-").exists():
random_hash = uuid.uuid4().hex
user = User.objects.using(db_alias).create(
username="gogs-{}".format(random_hash),