Happy5214 has uploaded a new change for review. (
https://gerrit.wikimedia.org/r/362324 )
Change subject: [WIP] Add ability to thank Flow posts
......................................................................
[WIP] Add ability to thank Flow posts
I still need to write the tests for this code.
Change-Id: Ie629aaa46aa007a39e6d5dce6400504bf73e5980
---
M pywikibot/flow.py
M pywikibot/site.py
2 files changed, 24 insertions(+), 0 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/pywikibot/core
refs/changes/24/362324/1
diff --git a/pywikibot/flow.py b/pywikibot/flow.py
index 5f8a006..17f97e4 100644
--- a/pywikibot/flow.py
+++ b/pywikibot/flow.py
@@ -535,3 +535,7 @@
"""
self.site.restore_post(self, reason)
self._load()
+
+ def thank(self):
+ """Thank the user who made this post."""
+ self.site.thank_post(self)
diff --git a/pywikibot/site.py b/pywikibot/site.py
index e2bc6cc..08b7b7a 100644
--- a/pywikibot/site.py
+++ b/pywikibot/site.py
@@ -6775,6 +6775,7 @@
comparison = data['compare']['*']
return comparison
+ # Thanks API calls
@need_extension('Thanks')
def thank_revision(self, revid, source=None):
"""Corresponding method to the 'action=thank' API action.
@@ -6794,6 +6795,25 @@
raise api.APIError('Thanking unsuccessful')
return data
+ @need_extension('Flow')
+ @need_extension('Thanks')
+ def thank_post(self, post):
+ """Corresponding method to the 'action=flowthank' API action.
+
+ @param post: The post to be thanked for.
+ @type post: Post
+ @raise APIError: On thanking oneself or other API errors.
+ @return: The API response.
+ """
+ post_id = post.uuid
+ token = self.tokens['csrf']
+ req = self._simple_request(action='flowthank',
+ postid=post_id, token=token)
+ data = req.submit()
+ if data['result']['success'] != 1:
+ raise api.APIError('Thanking unsuccessful')
+ return data
+
# Flow API calls
@need_extension('Flow')
def load_board(self, page):
--
To view, visit https://gerrit.wikimedia.org/r/362324
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ie629aaa46aa007a39e6d5dce6400504bf73e5980
Gerrit-PatchSet: 1
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: Happy5214 <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits