Prevent the creation of a duplicate gogs user if you have the gogs plugin enabled
parent
ed69c48f73
commit
04fb04340a
|
@ -15,18 +15,20 @@ def create_gogs_system_user(apps, schema_editor):
|
||||||
# if we directly import it, it'll be the wrong version
|
# if we directly import it, it'll be the wrong version
|
||||||
User = apps.get_model("users", "User")
|
User = apps.get_model("users", "User")
|
||||||
db_alias = schema_editor.connection.alias
|
db_alias = schema_editor.connection.alias
|
||||||
random_hash = uuid.uuid4().hex
|
|
||||||
user = User.objects.using(db_alias).create(
|
if not User.objects.using(db_alias).filter(is_system=True, username__startswith="gogs-").exists():
|
||||||
username="gogs-{}".format(random_hash),
|
random_hash = uuid.uuid4().hex
|
||||||
email="gogs-{}@taiga.io".format(random_hash),
|
user = User.objects.using(db_alias).create(
|
||||||
full_name="Gogs",
|
username="gogs-{}".format(random_hash),
|
||||||
is_active=False,
|
email="gogs-{}@taiga.io".format(random_hash),
|
||||||
is_system=True,
|
full_name="Gogs",
|
||||||
bio="",
|
is_active=False,
|
||||||
)
|
is_system=True,
|
||||||
f = open("{}/logo.png".format(CUR_DIR), "rb")
|
bio="",
|
||||||
user.photo.save("logo.png", File(f))
|
)
|
||||||
user.save()
|
f = open("{}/logo.png".format(CUR_DIR), "rb")
|
||||||
|
user.photo.save("logo.png", File(f))
|
||||||
|
user.save()
|
||||||
|
|
||||||
|
|
||||||
class Migration(migrations.Migration):
|
class Migration(migrations.Migration):
|
||||||
|
|
Loading…
Reference in New Issue