Skip to content

Commit

Permalink
Account flair methods: allow obeying pref
Browse files Browse the repository at this point in the history
This adds an optional preference to the Account flair_text and
flair_css_class methods that will return None if the user has their
flair disabled in the subreddit, to allow using these methods both for
"what flair is set to" as well as "what flair displays as".
  • Loading branch information
Deimos committed May 12, 2015
1 parent 3e0db05 commit bedf7e9
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions r2/r2/models/account.py
Original file line number Diff line number Diff line change
Expand Up @@ -677,10 +677,14 @@ def set_subreddit_style(self, sr, use_style):
def flair_enabled_in_sr(self, sr_id):
return getattr(self, 'flair_%s_enabled' % sr_id, True)

def flair_text(self, sr_id):
def flair_text(self, sr_id, obey_disabled=False):
if obey_disabled and not self.flair_enabled_in_sr(sr_id):
return None
return getattr(self, 'flair_%s_text' % sr_id, None)

def flair_css_class(self, sr_id):
def flair_css_class(self, sr_id, obey_disabled=False):
if obey_disabled and not self.flair_enabled_in_sr(sr_id):
return None
return getattr(self, 'flair_%s_css_class' % sr_id, None)

def can_flair_in_sr(self, user, sr):
Expand Down

0 comments on commit bedf7e9

Please sign in to comment.