comparison MoinMoin/user.py @ 22:a47550d21d2d

quicklinks: avoid dupes, dont render as interwiki if wiki == self imported from: moin--main--1.5--patch-23
author Thomas Waldmann <tw@waldmann-edv.de>
date Sat, 24 Sep 2005 14:35:31 +0000
parents da9701a3facb
children 55ff4feb0f59
comparison
equal deleted inserted replaced
21:5109effab437 22:a47550d21d2d
666 666
667 @param pagename: name of the page to quicklink 667 @param pagename: name of the page to quicklink
668 @param remove: unsubscribe pagename if set 668 @param remove: unsubscribe pagename if set
669 @type remove: bool 669 @type remove: bool
670 @rtype: bool 670 @rtype: bool
671 @return: true, if page was NEWLY quicklinked. 671 @return: True, if quicklinks were added/removed.
672 """ 672 """
673 changed = False
674 if self._cfg.interwikiname:
675 iwpagename = "%s:%s" % (self._cfg.interwikiname, pagename)
676 else:
677 iwpagename = None
673 if remove: 678 if remove:
674 if pagename in self.quicklinks: 679 if pagename in self.quicklinks:
675 self.quicklinks.remove(pagename) 680 self.quicklinks.remove(pagename)
676 return 1 681 changed = True
677 682 if iwpagename in self.quicklinks:
678 # check for our own interwiki name 683 self.quicklinks.remove(iwpagename)
679 if self._cfg.interwikiname: 684 changed = True
680 pagename = "%s:%s" % (self._cfg.interwikiname, pagename)
681
682 if remove and (pagename in self.quicklinks):
683 self.quicklinks.remove(pagename)
684 return 1
685
686 else: 685 else:
687 # add the interwiki name! 686 # add the interwiki name and remove non-interwiki name, if present!
688 if pagename not in self.quicklinks: 687 if pagename in self.quicklinks:
689 self.quicklinks.append(pagename) 688 self.quicklinks.remove(pagename)
690 return 1 689 changed = True
691 return 0 690 if iwpagename not in self.quicklinks:
691 self.quicklinks.append(iwpagename)
692 changed = True
693 return changed
692 694
693 def subscribePage(self, pagename, remove=False): 695 def subscribePage(self, pagename, remove=False):
694 """ Subscribe or unsubscribe to a wiki page. 696 """ Subscribe or unsubscribe to a wiki page.
695 697
696 Note that you need to save the user data to make this stick! 698 Note that you need to save the user data to make this stick!