Skip to content

Commit

Permalink
Merge 7ffba78 into 8c700c6
Browse files Browse the repository at this point in the history
  • Loading branch information
jackodsteel committed Dec 4, 2019
2 parents 8c700c6 + 7ffba78 commit 62f8b87
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 6 deletions.
4 changes: 4 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ Unreleased
* Parameters ``mod_note`` and ``reason_id`` to
:meth:`.ThingModerationMixin.remove` to optionally apply a removal reason on
removal
* Parameters ``allowable_content`` and ``max_emojis`` to
:meth:`~.SubredditRedditorFlairTemplates.add`,
:meth:`~.SubredditLinkFlairTemplates.add`, and
:meth:`~.SubredditFlairTemplates.update`, as well as its child classes.

**Deprecated**

Expand Down
46 changes: 40 additions & 6 deletions praw/models/reddit/subreddit.py
Original file line number Diff line number Diff line change
Expand Up @@ -1264,16 +1264,20 @@ def _add(
background_color=None,
text_color=None,
mod_only=None,
allowable_content=None,
max_emojis=None,
):
url = API_PATH["flairtemplate_v2"].format(subreddit=self.subreddit)
data = {
"css_class": css_class,
"allowable_content": allowable_content,
"background_color": background_color,
"text_color": text_color,
"css_class": css_class,
"flair_type": self.flair_type(is_link),
"max_emojis": max_emojis,
"mod_only": bool(mod_only),
"text": text,
"text_color": text_color,
"text_editable": bool(text_editable),
"mod_only": bool(mod_only),
}
self.subreddit._reddit.post(url, data=data)

Expand Down Expand Up @@ -1308,6 +1312,8 @@ def update(
background_color=None,
text_color=None,
mod_only=None,
allowable_content=None,
max_emojis=None,
):
"""Update the flair template provided by ``template_id``.
Expand All @@ -1323,6 +1329,12 @@ def update(
``'light'`` or ``'dark'``.
:param mod_only: (boolean) Indicate if the flair can only be used by
moderators.
:param allowable_content: If specified, most be one of ``'all'``,
``'emoji'``, or ``'text'`` to restrict content to that type.
If set to ``'emoji'`` then the ``'text'`` param must be a
valid emoji string, for example ``':snoo:'``.
:param max_emojis: (int) Maximum emojis in the flair
(Reddit defaults this value to 10).
For example to make a user flair template text_editable, try:
Expand All @@ -1342,13 +1354,15 @@ def update(
"""
url = API_PATH["flairtemplate_v2"].format(subreddit=self.subreddit)
data = {
"allowable_content": allowable_content,
"background_color": background_color,
"css_class": css_class,
"flair_template_id": template_id,
"max_emojis": max_emojis,
"mod_only": mod_only,
"text": text,
"css_class": css_class,
"background_color": background_color,
"text_color": text_color,
"text_editable": text_editable,
"mod_only": mod_only,
}
self.subreddit._reddit.post(url, data=data)

Expand Down Expand Up @@ -1381,6 +1395,8 @@ def add(
background_color=None,
text_color=None,
mod_only=None,
allowable_content=None,
max_emojis=None,
):
"""Add a Redditor flair template to the associated subreddit.
Expand All @@ -1394,6 +1410,12 @@ def add(
``'light'`` or ``'dark'``.
:param mod_only: (boolean) Indicate if the flair can only be used by
moderators.
:param allowable_content: If specified, most be one of ``'all'``,
``'emoji'``, or ``'text'`` to restrict content to that type.
If set to ``'emoji'`` then the ``'text'`` param must be a
valid emoji string, for example ``':snoo:'``.
:param max_emojis: (int) Maximum emojis in the flair
(Reddit defaults this value to 10).
For example, to add an editable Redditor flair try:
Expand All @@ -1411,6 +1433,8 @@ def add(
background_color=background_color,
text_color=text_color,
mod_only=mod_only,
allowable_content=allowable_content,
max_emojis=max_emojis,
)

def clear(self):
Expand Down Expand Up @@ -1453,6 +1477,8 @@ def add(
background_color=None,
text_color=None,
mod_only=None,
allowable_content=None,
max_emojis=None,
):
"""Add a link flair template to the associated subreddit.
Expand All @@ -1466,6 +1492,12 @@ def add(
``'light'`` or ``'dark'``.
:param mod_only: (boolean) Indicate if the flair can only be used by
moderators.
:param allowable_content: If specified, most be one of ``'all'``,
``'emoji'``, or ``'text'`` to restrict content to that type.
If set to ``'emoji'`` then the ``'text'`` param must be a
valid emoji string, for example ``':snoo:'``.
:param max_emojis: (int) Maximum emojis in the flair
(Reddit defaults this value to 10).
For example, to add an editable link flair try:
Expand All @@ -1483,6 +1515,8 @@ def add(
background_color=background_color,
text_color=text_color,
mod_only=mod_only,
allowable_content=allowable_content,
max_emojis=max_emojis,
)

def clear(self):
Expand Down

0 comments on commit 62f8b87

Please sign in to comment.