http://www.mediawiki.org/wiki/Special:Code/pywikipedia/9037
Revision: 9037 Author: saper Date: 2011-03-12 23:12:11 +0000 (Sat, 12 Mar 2011) Log Message: ----------- Handle Special:Mypage/skin.css and js files properly
* Allow the page owner to put custom styles and scripts * Check editusercss or edituserjs permissions introduced in 1.16 in addition to the obsolete editusercssjs
https://bugzilla.wikimedia.org/show_bug.cgi?id=12110
Modified Paths: -------------- trunk/pywikipedia/wikipedia.py
Modified: trunk/pywikipedia/wikipedia.py =================================================================== --- trunk/pywikipedia/wikipedia.py 2011-03-12 23:09:14 UTC (rev 9036) +++ trunk/pywikipedia/wikipedia.py 2011-03-12 23:12:11 UTC (rev 9037) @@ -1690,11 +1690,18 @@ elif self.site().has_api() and self.namespace() in [2,3] \ and (self.title().endswith('.css') or \ self.title().endswith('.js')): - # API enable: if title ends with .css or .js in ns2,3 - # it needs permission 'editusercssjs' - sysop = self._getActionUser(action='editusercssjs', - restriction=self.editRestriction, - sysop=True) + titleparts = self.title().split("/") + userpageowner = titleparts[0].split(":")[1] + if userpageowner != username: + # API enable: if title ends with .css or .js in ns2,3 + # it needs permission to edit user pages + if self.title().endswith('css'): + permission = 'editusercss' + else: + permission = 'edituserjs' + sysop = self._getActionUser(action=permission, + restriction=self.editRestriction, + sysop=True)
# If there is an unchecked edit restriction, we need to load the page if self._editrestriction: @@ -4940,6 +4947,10 @@ else: self._load(sysop = sysop) index = self._userIndex(sysop) + # Handle obsolete editusercssjs permission + if right in ['editusercss', 'edituserjs'] \ + and right not in self._rights[index]: + return 'editusercssjs' in self._rights[index] return right in self._rights[index]
def server_time(self):