Skip to content

Commit

Permalink
Merge branch 'stable'
Browse files Browse the repository at this point in the history
  • Loading branch information
nijel committed Apr 30, 2021
2 parents a52d203 + ce5cfaa commit 5433c3b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
2 changes: 2 additions & 0 deletions weblate/accounts/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,8 @@ def get_all_user_mails(user, entries=None):
kwargs["social__in"] = entries
emails = set(VerifiedEmail.objects.filter(**kwargs).values_list("email", flat=True))
emails.add(user.email)
emails.discard(None)
emails.discard("")
return emails


Expand Down
12 changes: 7 additions & 5 deletions weblate/auth/management/commands/createadmin.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,13 @@ def handle(self, *args, **options):
This is useful mostly for setup inside appliances, when user wants to be able to
login remotely and change password then.
"""
email = options["email"]
if not email:
email = "admin@example.com"
self.stdout.write(f"Blank e-mail for admin, using {email} instead!")
try:
user = User.objects.filter(
Q(username=options["username"]) | Q(email=options["email"])
Q(username=options["username"]) | Q(email=email)
).get()
except User.DoesNotExist:
user = None
Expand All @@ -89,14 +93,12 @@ def handle(self, *args, **options):

if user and options["update"]:
self.stdout.write(f"Updating user {user.username}")
user.email = options["email"]
user.email = email
if password is not None and not user.check_password(password):
user.set_password(password)
else:
self.stdout.write("Creating user {}".format(options["username"]))
user = User.objects.create_user(
options["username"], options["email"], password
)
user = User.objects.create_user(options["username"], email, password)
user.full_name = options["name"]
user.is_superuser = True
user.is_active = True
Expand Down

0 comments on commit 5433c3b

Please sign in to comment.