Commits

Marcin Kuzminski committed bdb6fbc

implements #293 gravatar link should be disabled when use_gravatar = false

Comments (0)

Files changed (4)

rhodecode/lib/base.py

 from pylons.templating import render_mako as render
 
 from rhodecode import __version__
+from rhodecode.lib import str2bool
 from rhodecode.lib.auth import AuthUser
 from rhodecode.lib.utils import get_repo_slug
 from rhodecode.model import meta
     def __before__(self):
         c.rhodecode_version = __version__
         c.rhodecode_name = config.get('rhodecode_title')
+        c.use_gravatar = str2bool(config.get('use_gravatar'))
         c.ga_code = config.get('rhodecode_ga_code')
         c.repo_name = get_repo_slug(request)
         c.backends = BACKENDS.keys()
         self.sa = meta.Session()
         self.scm_model = ScmModel(self.sa)
 
-        #c.unread_journal = scm_model.get_unread_journal()
-
     def __call__(self, environ, start_response):
         """Invoke the Controller"""
         # WSGIController.__call__ dispatches to the Controller method
 
 class BaseRepoController(BaseController):
     """
-    Base class for controllers responsible for loading all needed data
-    for those controllers, loaded items are
+    Base class for controllers responsible for loading all needed data for
+    repository loaded items are
 
-    c.rhodecode_repo: instance of scm repository (taken from cache)
-
+    c.rhodecode_repo: instance of scm repository
+    c.rhodecode_db_repo: instance of db
+    c.repository_followers: number of followers
+    c.repository_forks: number of forks
     """
 
     def __before__(self):
 
                 redirect(url('home'))
 
-            c.repository_followers = \
-                self.scm_model.get_followers(c.repo_name)
+            c.repository_followers = self.scm_model.get_followers(c.repo_name)
             c.repository_forks = self.scm_model.get_forks(c.repo_name)
 

rhodecode/lib/helpers.py

 #==============================================================================
 
 def gravatar_url(email_address, size=30):
-    if not str2bool(config['app_conf'].get('use_gravatar')) or \
-        email_address == 'anonymous@rhodecode.org':
+    if (not str2bool(config['app_conf'].get('use_gravatar')) or
+        not email_address or email_address == 'anonymous@rhodecode.org'):
         return url("/images/user%s.png" % size)
 
     ssl_enabled = 'https' == request.environ.get('wsgi.url_scheme')

rhodecode/templates/admin/users/user_edit.html

         <div class="field">
            <div class="gravatar_box">
                <div class="gravatar"><img alt="gravatar" src="${h.gravatar_url(c.user.email)}"/></div>
-               <p>
-               <strong>${_('Change your avatar at')} <a href="http://gravatar.com">gravatar.com</a></strong><br/> 
-               ${_('Using')} ${c.user.email}
-               </p>
+                <p>
+                %if c.use_gravatar:
+                <strong>${_('Change your avatar at')} <a href="http://gravatar.com">gravatar.com</a></strong>
+                <br/>${_('Using')} ${c.user.email}
+                %else:
+                <br/>${c.user.email}
+                %endif 
            </div>
         </div>
         <div class="field">

rhodecode/templates/admin/users/user_edit_my_account.html

                 <div class="gravatar_box">
                     <div class="gravatar"><img alt="gravatar" src="${h.gravatar_url(c.user.email)}"/></div>
                     <p>
-                    <strong>${_('Change your avatar at')} <a href="http://gravatar.com">gravatar.com</a></strong><br/> 
-                    ${_('Using')} ${c.user.email}
+                    %if c.use_gravatar:
+                    <strong>${_('Change your avatar at')} <a href="http://gravatar.com">gravatar.com</a></strong>
+                    <br/>${_('Using')} ${c.user.email}
+                    %else:
+                    <br/>${c.user.email}
+                    %endif 
                     </p>
                 </div>
              </div>   	    
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.