changeset 1278:2c58cbcfeabe

quicklinks/subscribed_items: use attributes directly, simplify code
author Thomas Waldmann <tw AT waldmann-edv DOT de>
date Sat, 03 Mar 2012 17:30:58 +0100
parents f0d1cbe58e53
children 7c19f8bb7298
files MoinMoin/_tests/test_user.py MoinMoin/themes/__init__.py MoinMoin/user.py
diffstat 3 files changed, 10 insertions(+), 29 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/_tests/test_user.py	Sat Mar 03 16:37:14 2012 +0100
+++ b/MoinMoin/_tests/test_user.py	Sat Mar 03 17:30:58 2012 +0100
@@ -303,7 +303,7 @@
         theUser = user.User(name=name, password=password)
 
         # no quick links exist yet
-        result_before = theUser.getQuickLinks()
+        result_before = theUser.quicklinks
         assert result_before == []
 
         result = theUser.isQuickLinkedTo([pagename])
@@ -311,13 +311,13 @@
 
         # test for addQuicklink()
         theUser.addQuicklink(u'Test_page_added')
-        result_on_addition = theUser.getQuickLinks()
+        result_on_addition = theUser.quicklinks
         expected = [u'MoinTest:Test_page_added']
         assert result_on_addition == expected
 
         # previously added page u'Test_page_added' is removed
         theUser.removeQuicklink(u'Test_page_added')
-        result_on_removal = theUser.getQuickLinks()
+        result_on_removal = theUser.quicklinks
         expected = []
         assert result_on_removal == expected
 
--- a/MoinMoin/themes/__init__.py	Sat Mar 03 16:37:14 2012 +0100
+++ b/MoinMoin/themes/__init__.py	Sat Mar 03 17:30:58 2012 +0100
@@ -220,8 +220,7 @@
                  for cls, endpoint, args, link_text, title in self.cfg.navi_bar]
 
         # Add user links to wiki links.
-        userlinks = self.user.getQuickLinks()
-        for text in userlinks:
+        for text in self.user.quicklinks:
             url, link_text, title = self.split_navilink(text)
             items.append(('userlink', url, link_text, title))
 
--- a/MoinMoin/user.py	Sat Mar 03 16:37:14 2012 +0100
+++ b/MoinMoin/user.py	Sat Mar 03 17:30:58 2012 +0100
@@ -306,7 +306,7 @@
         """
         if name in [NAME, DISABLED, ITEMID, ALIASNAME, ENC_PASSWORD, EMAIL, OPENID,
                     MAILTO_AUTHOR, SHOW_COMMENTS, RESULTS_PER_PAGE, EDIT_ON_DOUBLECLICK,
-                    THEME_NAME, LOCALE, TIMEZONE,
+                    THEME_NAME, LOCALE, TIMEZONE, SUBSCRIBED_ITEMS, QUICKLINKS,
                    ]:
             return self.profile[name]
         else:
@@ -492,14 +492,6 @@
     # -----------------------------------------------------------------
     # Subscribe
 
-    def getSubscriptionList(self):
-        """ Get list of pages this user has subscribed to
-
-        :rtype: list
-        :returns: pages this user has subscribed to
-        """
-        return self.profile[SUBSCRIBED_ITEMS]
-
     def isSubscribedTo(self, pagelist):
         """ Check if user subscription matches any page in pagelist.
 
@@ -521,7 +513,7 @@
         # Create text for regular expression search
         text = '\n'.join(pages)
 
-        for pattern in self.getSubscriptionList():
+        for pattern in self.subscribed_items:
             # Try simple match first
             if pattern in pages:
                 return True
@@ -546,7 +538,7 @@
         :returns: if page was subscribed
         """
         pagename = getInterwikiName(pagename)
-        subscribed_items = self.profile[SUBSCRIBED_ITEMS]
+        subscribed_items = self.subscribed_items
         if pagename not in subscribed_items:
             subscribed_items.append(pagename)
             self.save(force=True)
@@ -581,16 +573,6 @@
     # -----------------------------------------------------------------
     # Quicklinks
 
-    def getQuickLinks(self):
-        """ Get list of pages this user wants in the navibar
-
-        TODO: implement as a property
-
-        :rtype: list
-        :returns: quicklinks from user account
-        """
-        return self.profile[QUICKLINKS]
-
     def isQuickLinkedTo(self, pagelist):
         """ Check if user quicklink matches any page in pagelist.
 
@@ -601,7 +583,7 @@
         if not self.valid:
             return False
 
-        quicklinks = self.getQuickLinks()
+        quicklinks = self.quicklinks
         for pagename in pagelist:
             interWikiName = getInterwikiName(pagename)
             if interWikiName and interWikiName in quicklinks:
@@ -619,7 +601,7 @@
         :rtype: bool
         :returns: if pagename was added
         """
-        quicklinks = self.getQuickLinks()
+        quicklinks = self.quicklinks
         interWikiName = getInterwikiName(pagename)
         if interWikiName and interWikiName not in quicklinks:
             quicklinks.append(interWikiName)
@@ -637,7 +619,7 @@
         :rtype: bool
         :returns: if pagename was removed
         """
-        quicklinks = self.getQuickLinks()
+        quicklinks = self.quicklinks
         interWikiName = getInterwikiName(pagename)
         if interWikiName and interWikiName in quicklinks:
             quicklinks.remove(interWikiName)