mirror of
https://github.com/samuelclay/NewsBlur.git
synced 2025-09-18 21:50:56 +00:00
Fixing missing usernames in msocialprofile, due to botched deleted user refactor.
This commit is contained in:
parent
9bd863f74f
commit
d67d591973
1 changed files with 10 additions and 0 deletions
|
@ -161,6 +161,9 @@ class MSocialProfile(mongo.Document):
|
|||
profile = cls.objects.create(user_id=user_id)
|
||||
profile.save()
|
||||
|
||||
if not profile.username:
|
||||
profile.save()
|
||||
|
||||
return profile
|
||||
|
||||
@property
|
||||
|
@ -171,6 +174,8 @@ class MSocialProfile(mongo.Document):
|
|||
return None
|
||||
|
||||
def save(self, *args, **kwargs):
|
||||
if not self.username:
|
||||
self.import_user_fields()
|
||||
if not self.subscription_count:
|
||||
self.count_follows(skip_save=True)
|
||||
if self.bio and len(self.bio) > MSocialProfile.bio.max_length:
|
||||
|
@ -433,6 +438,11 @@ class MSocialProfile(mongo.Document):
|
|||
return [u for u in self.follower_user_ids if u != self.user_id]
|
||||
return self.follower_user_ids
|
||||
|
||||
def import_user_fields(self):
|
||||
user = User.objects.get(pk=self.user_id)
|
||||
self.username = user.username
|
||||
self.email = user.email
|
||||
|
||||
def count_follows(self, skip_save=False):
|
||||
self.subscription_count = UserSubscription.objects.filter(user__pk=self.user_id).count()
|
||||
self.shared_stories_count = MSharedStory.objects.filter(user_id=self.user_id).count()
|
||||
|
|
Loading…
Add table
Reference in a new issue