Permalink
Browse files

Added support for link flair templates adding and clearing.

  • Loading branch information...
1 parent 8550870 commit 5053d972b8b735715da2ac5ea47a1dc652970893 @bboe bboe committed Apr 19, 2012
Showing with 15 additions and 6 deletions.
  1. +7 −4 reddit/__init__.py
  2. +8 −2 reddit/reddit_test.py
View
@@ -326,19 +326,22 @@ def _subscribe(self, sr_id=None, sr_name=None, unsubscribe=False):
@reddit.decorators.require_login
@reddit.decorators.require_moderator
- def add_flair_template(self, subreddit, text, css_class, text_editable):
+ def add_flair_template(self, subreddit, text, css_class, text_editable,
+ is_link=False):
"""Adds a flair template to the given subreddit."""
params = {'r': six.text_type(subreddit),
'text': text,
'css_class': css_class,
- 'text_editable': six.text_type(text_editable)}
+ 'text_editable': six.text_type(text_editable),
+ 'flair_type': 'LINK_FLAIR' if is_link else 'USER_FLAIR'}
return self.request_json(self.config['flairtemplate'], params)
@reddit.decorators.require_login
@reddit.decorators.require_moderator
- def clear_flair_templates(self, subreddit):
+ def clear_flair_templates(self, subreddit, is_link=False):
"""Clear flair templates for the given subreddit."""
- params = {'r': six.text_type(subreddit)}
+ params = {'r': six.text_type(subreddit),
+ 'flair_type': 'LINK_FLAIR' if is_link else 'USER_FLAIR'}
return self.request_json(self.config['clearflairtemplates'], params)
@reddit.decorators.require_login
View
@@ -417,12 +417,18 @@ def setUp(self):
self.configure()
self.subreddit = self.r.get_subreddit(self.sr)
- def test_add_template(self):
+ def test_add_user_template(self):
self.subreddit.add_flair_template('text', 'css', True)
- def test_clear(self):
+ def test_add_link_template(self):
+ self.subreddit.add_flair_template('text', 'css', True, True)
+
+ def test_clear_user_templates(self):
self.subreddit.clear_flair_templates()
+ def test_clear_link_templates(self):
+ self.subreddit.clear_flair_templates(True)
+
class LocalOnlyTest(unittest.TestCase, BasicHelper):
def setUp(self):

0 comments on commit 5053d97

Please sign in to comment.