Skip to content

Commit

Permalink
Issue #292 (the privacy issue)
Browse files Browse the repository at this point in the history
  • Loading branch information
Goran Topic committed May 9, 2018
1 parent f8639ca commit 6546af0
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
2 changes: 1 addition & 1 deletion raidar/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ class UserProfile(models.Model):
portrait_url = models.URLField(null=True, blank=True) # XXX not using... delete?
user = models.OneToOneField(User, on_delete=models.CASCADE, related_name="user_profile")
last_notified_at = models.IntegerField(db_index=True, default=0, editable=False)
privacy = models.PositiveSmallIntegerField(editable=False, choices=PRIVACY_CHOICES, default=PUBLIC)
privacy = models.PositiveSmallIntegerField(editable=False, choices=PRIVACY_CHOICES, default=SQUAD)

def __str__(self):
return self.user.username
Expand Down
18 changes: 11 additions & 7 deletions raidar/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,8 +145,10 @@ def download(request, url_id=None):
user_profile = UserProfile.objects.filter(user__accounts__name=member['account'])
if user_profile:
privacy = user_profile[0].privacy
if not is_self and (privacy == UserProfile.PRIVATE or (privacy == UserProfile.SQUAD and not own_account_names)):
encounter_showable = False
else:
privacy = UserProfile.SQUAD
if not is_self and (privacy == UserProfile.PRIVATE or (privacy == UserProfile.SQUAD and not own_account_names)):
encounter_showable = False

path = encounter.diskname()
if isfile(path) and (encounter_showable or request.user.is_staff):
Expand Down Expand Up @@ -357,11 +359,13 @@ def encounter(request, url_id=None, json=None):
user_profile = UserProfile.objects.filter(user__accounts__name=member['account'])
if user_profile:
privacy = user_profile[0].privacy
if 'self' not in member and (privacy == UserProfile.PRIVATE or (privacy == UserProfile.SQUAD and not own_account_names)):
member['name'] = ''
member['account'] = ''
private = True
encounter_showable = False
else:
privacy = UserProfile.SQUAD
if 'self' not in member and (privacy == UserProfile.PRIVATE or (privacy == UserProfile.SQUAD and not own_account_names)):
member['name'] = ''
member['account'] = ''
private = True
encounter_showable = False

max_player_dps = max(_safe_get(lambda: data['Metrics']['damage']['To']['*All']['dps']) for phasename, phase in dump['Category']['combat']['Phase'].items() for player, data in phase['Player'].items())
max_player_recv = max(_safe_get(lambda: data['Metrics']['damage']['From']['*All']['total']) for phasename, phase in dump['Category']['combat']['Phase'].items() for player, data in phase['Player'].items())
Expand Down

0 comments on commit 6546af0

Please sign in to comment.