Commits

Thomas Waldmann  committed 0a70177

user: changed method names for better PEP8 compliance

  • Participants
  • Parent commits 30634c5

Comments (0)

Files changed (5)

File MoinMoin/_tests/test_user.py

         assert theuser.valid
 
     def testSubscriptionSubscribedPage(self):
-        """ user: tests isSubscribedTo  """
+        """ user: tests is_subscribed_to  """
         pagename = u'HelpMiscellaneous'
         name = u'__Jürgen Herman__'
         password = name
         # Login - this should replace the old password in the user file
         theUser = user.User(name=name, password=password)
         theUser.subscribe(pagename)
-        assert theUser.isSubscribedTo([pagename]) # list(!) of pages to check
+        assert theUser.is_subscribed_to([pagename]) # list(!) of pages to check
 
     def testSubscriptionSubPage(self):
-        """ user: tests isSubscribedTo on a subpage """
+        """ user: tests is_subscribed_to on a subpage """
         pagename = u'HelpMiscellaneous'
         testPagename = u'HelpMiscellaneous/FrequentlyAskedQuestions'
         name = u'__Jürgen Herman__'
         # Login - this should replace the old password in the user file
         theUser = user.User(name=name, password=password)
         theUser.subscribe(pagename)
-        assert not theUser.isSubscribedTo([testPagename]) # list(!) of pages to check
+        assert not theUser.is_subscribed_to([testPagename]) # list(!) of pages to check
 
     def test_upgrade_password_from_ssha_to_ssha256(self):
         """
         result_before = theUser.quicklinks
         assert result_before == []
 
-        result = theUser.isQuickLinkedTo([pagename])
+        result = theUser.is_quicklinked_to([pagename])
         assert not result
 
-        # test for addQuicklink()
-        theUser.addQuicklink(u'Test_page_added')
+        # add quicklink
+        theUser.quicklink(u'Test_page_added')
         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')
+        # remove quicklink
+        theUser.quickunlink(u'Test_page_added')
         result_on_removal = theUser.quicklinks
         expected = []
         assert result_on_removal == expected
         theUser = user.User(name=name, password=password)
 
         # no item name added to trail
-        result = theUser.getTrail()
+        result = theUser.get_trail()
         expected = []
         assert result == expected
 
         # item name added to trail
-        theUser.addTrail(u'item_added')
-        result = theUser.getTrail()
+        theUser.add_trail(u'item_added')
+        theUser = user.User(name=name, password=password)
+        result = theUser.get_trail()
         expected = [u'MoinTest:item_added']
         assert result == expected
 

File MoinMoin/apps/frontend/views.py

 @frontend.route('/<itemname:item_name>', defaults=dict(rev=CURRENT), methods=['GET'])
 @frontend.route('/+show/+<rev>/<itemname:item_name>', methods=['GET'])
 def show_item(item_name, rev):
-    flaskg.user.addTrail(item_name)
+    flaskg.user.add_trail(item_name)
     item_displayed.send(app._get_current_object(),
                         item_name=item_name)
     try:
 @frontend.route('/+meta/<itemname:item_name>', defaults=dict(rev=CURRENT))
 @frontend.route('/+meta/+<rev>/<itemname:item_name>')
 def show_item_meta(item_name, rev):
-    flaskg.user.addTrail(item_name)
+    flaskg.user.add_trail(item_name)
     try:
         item = Item.create(item_name, rev_id=rev)
     except AccessDenied:
     msg = None
     if not u.valid:
         msg = _("You must login to use this action: %(action)s.", action="quicklink/quickunlink"), "error"
-    elif not flaskg.user.isQuickLinkedTo([item_name]):
-        if not u.addQuicklink(item_name):
+    elif not flaskg.user.is_quicklinked_to([item_name]):
+        if not u.quicklink(item_name):
             msg = _('A quicklink to this page could not be added for you.'), "error"
     else:
-        if not u.removeQuicklink(item_name):
+        if not u.quickunlink(item_name):
             msg = _('Your quicklink to this page could not be removed.'), "error"
     if msg:
         flash(*msg)
         msg = _("You must login to use this action: %(action)s.", action="subscribe/unsubscribe"), "error"
     elif not u.may.read(item_name):
         msg = _("You are not allowed to subscribe to an item you may not read."), "error"
-    elif u.isSubscribedTo([item_name]):
+    elif u.is_subscribed_to([item_name]):
         # Try to unsubscribe
         if not u.unsubscribe(item_name):
             msg = _("Can't remove regular expression subscription!") + u' ' + \
             else:
                 if app.cfg.user_email_verification:
                     u = user.User(auth_username=user_kwargs['username'])
-                    is_ok, msg = u.mailVerificationLink()
+                    is_ok, msg = u.mail_email_verification()
                     if is_ok:
                         flash(_('Account verification required, please see the email we sent to your address.'), "info")
                     else:
                 users = user.search_users(email=email)
                 u = users and user.User(users[0][ITEMID])
             if u and u.valid:
-                is_ok, msg = u.mailAccountData()
+                is_ok, msg = u.mail_password_recovery()
                 if not is_ok:
                     flash(msg, "error")
             flash(_("If this account exists, you will be notified."), "info")
                             # disable account
                             flaskg.user.profile[DISABLED] = True
                             # send verification mail
-                            is_ok, msg = flaskg.user.mailVerificationLink()
+                            is_ok, msg = flaskg.user.mail_email_verification()
                             if is_ok:
                                 _logout()
                                 flaskg.user.save()

File MoinMoin/templates/itemviews.html

             {%- if endpoint == 'frontend.quicklink_item' and user.valid %}
                 <li>
                     <a href="{{ url_for(endpoint, item_name=item_name) }}" title="{{ title }}" rel="nofollow">
-                        {%- if user.isQuickLinkedTo([item_name]) %}
+                        {%- if user.is_quicklinked_to([item_name]) %}
                             {{ _('Remove Link') }}
                         {%- else %}
                             {{ _('Add Link') }}
             {%- if endpoint == 'frontend.subscribe_item' and user.valid %}
                 <li>
                     <a href="{{ url_for(endpoint, item_name=item_name) }}" title="{{ title }}" rel="nofollow">
-                        {%- if user.isSubscribedTo([item_name]) %}
+                        {%- if user.is_subscribed_to([item_name]) %}
                             {{ _('Unsubscribe') }}
                         {%- else %}
                             {{ _('Subscribe') }}

File MoinMoin/themes/__init__.py

         """
         user = self.user
         breadcrumbs = []
-        trail = user.getTrail()
+        trail = user.get_trail()
         for interwiki_item_name in trail:
             wiki_name, item_name = split_interwiki(interwiki_item_name)
             err = not is_known_wiki(wiki_name)

File MoinMoin/user.py

 
     # Subscribed Items -------------------------------------------------------
 
-    def isSubscribedTo(self, pagelist):
+    def is_subscribed_to(self, pagelist):
         """ Check if user subscription matches any page in pagelist.
 
         The subscription contains interwiki page names. e.g 'WikiName:Page_Name'
         if interWikiName and interWikiName in subscribed_items:
             subscribed_items.remove(interWikiName)
             self.save(force=True)
-        return not self.isSubscribedTo([pagename])
+        return not self.is_subscribed_to([pagename])
 
     # Quicklinks -------------------------------------------------------------
 
-    def isQuickLinkedTo(self, pagelist):
+    def is_quicklinked_to(self, pagelist):
         """ Check if user quicklink matches any page in pagelist.
 
         :param pagelist: list of pages to check for quicklinks
 
         return False
 
-    def addQuicklink(self, pagename):
+    def quicklink(self, pagename):
         """ Adds a page to the user quicklinks
 
         Add links as interwiki names.
             return True
         return False
 
-    def removeQuicklink(self, pagename):
+    def quickunlink(self, pagename):
         """ Remove a page from user quicklinks
 
         Remove interwiki name from quicklinks.
 
     # Trail ------------------------------------------------------------------
 
-    def addTrail(self, item_name):
+    def add_trail(self, item_name):
         """ Add item name to trail.
 
         :param item_name: the item name (unicode) to add to the trail
         if trail != trail_in_session:
             session['trail'] = trail
 
-    def getTrail(self):
+    def get_trail(self):
         """ Return list of recently visited item names.
 
         :rtype: list
 
     # Other ------------------------------------------------------------------
 
-    def isCurrentUser(self):
+    def is_current_user(self):
         """ Check if this user object is the user doing the current request """
         return flaskg.user.name == self.name
 
         self.save()
         return True
 
-    def mailAccountData(self, cleartext_passwd=None):
+    def mail_password_recovery(self, cleartext_passwd=None):
         """ Mail a user who forgot his password a message enabling
             him to login again.
         """
         mailok, msg = sendmail.sendmail(subject, text, to=[self.email], mail_from=self._cfg.mail_from)
         return mailok, msg
 
-    def mailVerificationLink(self):
+    def mail_email_verification(self):
         """ Mail a user a link to verify his email address. """
         token = self.generate_recovery_token()