fix profile uri
This commit is contained in:
parent
aaffc8f3cd
commit
5a1de1e7a7
1 changed files with 7 additions and 7 deletions
|
@ -4,7 +4,7 @@ from loguru import logger
|
|||
from tqdm import tqdm
|
||||
|
||||
from takahe.utils import Takahe
|
||||
from users.models import Preference, User
|
||||
from users.models import APIdentity, User
|
||||
|
||||
|
||||
class Command(BaseCommand):
|
||||
|
@ -18,13 +18,13 @@ class Command(BaseCommand):
|
|||
|
||||
def handle(self, *args, **options):
|
||||
count = 0
|
||||
for user in tqdm(User.objects.all()):
|
||||
for identity in tqdm(APIdentity.objects.filter(local=True)):
|
||||
if (
|
||||
user.identity
|
||||
and not user.identity.takahe_identity.profile_uri.startswith("http")
|
||||
identity.is_active
|
||||
and not identity.takahe_identity.profile_uri.startswith("http")
|
||||
):
|
||||
user.identity.takahe_identity.profile_uri = user.absolute_url
|
||||
user.identity.takahe_identity.save(update_fields=["profile_uri"])
|
||||
Takahe.update_state(user.identity.takahe_identity, "edited")
|
||||
identity.takahe_identity.profile_uri = identity.user.absolute_url
|
||||
identity.takahe_identity.save(update_fields=["profile_uri"])
|
||||
Takahe.update_state(identity.takahe_identity, "edited")
|
||||
count += 1
|
||||
self.stdout.write(self.style.SUCCESS(f"{count} user(s) fixed"))
|
||||
|
|
Loading…
Add table
Reference in a new issue