Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added support for reordering flairs through reddit.flair.reorder #1956

Merged
merged 1 commit into from Aug 26, 2023

Conversation

NathanTech7713
Copy link
Contributor

I needed the ability to reorder flairs... So I added it.

I added the api path to endpoints.py, and added subreddit.flair.reorder which takes arguments of a list of flair ID's and the flair type as a string.

Hope this is okay

@LilSpazJoekp
Copy link
Member

Hope this is okay

Perfectly okay! Thanks for the MR, I'll take a look!

Copy link
Member

@LilSpazJoekp LilSpazJoekp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great start! I left several comments for improvements and a few questions. This will also need some tests written.

praw/endpoints.py Outdated Show resolved Hide resolved
praw/models/reddit/subreddit.py Outdated Show resolved Hide resolved
@@ -2020,6 +2025,7 @@ def configure(
url = API_PATH["flairconfig"].format(subreddit=self.subreddit)
self.subreddit._reddit.post(url, data=data)


Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would you mind executing the pre_push.py in the root of the repo?

praw/models/reddit/subreddit.py Outdated Show resolved Hide resolved
if flair_type not in ["USER_FLAIR", "LINK_FLAIR"]:
raise TypeError("'flair_type' must be either USER_FLAIR or LINK_FLAIR")
url = API_PATH["flairreorder"].format(subreddit=self.subreddit)
self.subreddit._reddit.patch(url+"?subreddit="+self.subreddit.display_name+"&flair_type="+flair_type, json=newlist)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you sure the arguments need to be url parameters?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you sure the arguments need to be url parameters?

Both posts I found on the subject did it this way, and it was the only method that worked for me... Not to say there isn't another way though

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you sure the arguments need to be url parameters?

Got confirmation from Reddit, yes, this is how to do it.

Run prepush.py

I got an error with this one:
Running: pre-commit run --all-files
[WinError 2] The system cannot find the file specified
Which file is that>

rebase to master

I did this following instructions on the web, and it doesn't seem to have made any difference? I've pushed my latest changes either way

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I got an error with this one:
Running: pre-commit run --all-files
[WinError 2] The system cannot find the file specified
Which file is that>

Did you by chance install dev dependencies? You can do this with pip install .[dev] in the repo root.

Got confirmation from Reddit, yes, this is how to do it.

If that is the case, then let's add a new params parameter to the patch method. See the get or post methods for how this is utilized.

@@ -2728,7 +2744,7 @@ def update(
:param submit_text_label: Custom label for submit text post button (``None`` for
default).
:param subreddit_type: One of ``"archived"``, ``"employees_only"``,
``"gold_only"``, ``"gold_restricted"``, ``"private"``, ``"public"``, or
``"gold_only"``, ``gold_restricted``, ``"private"``, ``"public"``, or
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you rebase on master?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry... How do I do this? As you can tell, I don't use git all that often! In fact I think this is only my first or maybe second pr that has been taken seriously :)

@github-actions
Copy link

github-actions bot commented Aug 3, 2023

This PR is stale because it has been open for 30 days with no activity.

Remove the Stale label or comment or this will be closed in 30 days.

@github-actions github-actions bot added the Stale Issue or pull request has been inactive for 20 days label Aug 3, 2023
@LilSpazJoekp LilSpazJoekp removed the Stale Issue or pull request has been inactive for 20 days label Aug 9, 2023
@LilSpazJoekp
Copy link
Member

Thanks for opening, I'll get this finished up for ya and merged in.

@LilSpazJoekp LilSpazJoekp merged commit 09b168a into praw-dev:master Aug 26, 2023
15 checks passed
@LilSpazJoekp
Copy link
Member

FYI I moved the method to subreddit.flair.templates.reorder and subreddit.flair.link_templates.reorder and it just needs a list of flair ids that are from subreddit.flair.templates and subreddit.flair.link_templates respectively.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants