changeset 699:52da7cba88a6 beta

Code refactor for auth func, preparing for ldap support css updates. turned off graph,and branches for git changelog
author Marcin Kuzminski <marcin@python-works.com>
date Tue, 16 Nov 2010 08:52:31 +0100
parents 4cd0709b6d4b
children 07fd56c36bfe
files rhodecode/controllers/changelog.py rhodecode/lib/auth.py rhodecode/lib/celerylib/tasks.py rhodecode/model/forms.py rhodecode/public/css/style.css rhodecode/templates/admin/repos/repo_edit.html rhodecode/templates/admin/users/user_edit_my_account.html rhodecode/templates/changelog/changelog.html
diffstat 8 files changed, 66 insertions(+), 47 deletions(-) [+]
line wrap: on
line diff
--- a/rhodecode/controllers/changelog.py	Mon Nov 15 18:38:54 2010 +0100
+++ b/rhodecode/controllers/changelog.py	Tue Nov 16 08:52:31 2010 +0100
@@ -74,7 +74,9 @@
 
     def _graph(self, repo, size, p):
         revcount = size
-        if not repo.revisions:return json.dumps([]), 0
+        if not repo.revisions or repo.alias == 'git':
+            c.jsdata = json.dumps([])
+            return
 
         max_rev = repo.revisions[-1]
 
--- a/rhodecode/lib/auth.py	Mon Nov 15 18:38:54 2010 +0100
+++ b/rhodecode/lib/auth.py	Tue Nov 16 08:52:31 2010 +0100
@@ -73,6 +73,15 @@
     return bcrypt.hashpw(password, hashed) == hashed
 
 def authfunc(environ, username, password):
+    """
+    Authentication function used in Mercurial/Git/ and access controll,
+    firstly checks for db authentication then if ldap is enabled for ldap
+    authentication
+    :param environ: needed only for using in Basic auth, can be None
+    :param username: username
+    :param password: password
+    """
+
     user = UserModel().get_by_username(username, cache=False)
 
     if user:
--- a/rhodecode/lib/celerylib/tasks.py	Mon Nov 15 18:38:54 2010 +0100
+++ b/rhodecode/lib/celerylib/tasks.py	Tue Nov 16 08:52:31 2010 +0100
@@ -65,7 +65,9 @@
 def get_commits_stats(repo_name, ts_min_y, ts_max_y):
     from rhodecode.model.db import Statistics, Repository
     log = get_commits_stats.get_logger()
-    author_key_cleaner = lambda k: person(k).replace('"', "") #for js data compatibilty
+
+    #for js data compatibilty
+    author_key_cleaner = lambda k: person(k).replace('"', "")
 
     commits_by_day_author_aggregate = {}
     commits_by_day_aggregate = {}
@@ -91,8 +93,8 @@
         return True
 
     if last_rev == repo.revisions[-1] and len(repo.revisions) > 1:
-        #pass silently without any work if we're not on first revision or current
-        #state of parsing revision(from db marker) is the last revision
+        #pass silently without any work if we're not on first revision or 
+        #current state of parsing revision(from db marker) is the last revision
         return True
 
     if cur_stats:
--- a/rhodecode/model/forms.py	Mon Nov 15 18:38:54 2010 +0100
+++ b/rhodecode/model/forms.py	Tue Nov 16 08:52:31 2010 +0100
@@ -24,7 +24,7 @@
     Email, Bool, StringBoolean
 from pylons import session
 from pylons.i18n.translation import _
-from rhodecode.lib.auth import check_password, get_crypt_password
+from rhodecode.lib.auth import authfunc, get_crypt_password
 from rhodecode.model import meta
 from rhodecode.model.user import UserModel
 from rhodecode.model.repo import RepoModel
@@ -94,26 +94,21 @@
         password = value['password']
         username = value['username']
         user = UserModel().get_by_username(username)
-        if user is None:
-            raise formencode.Invalid(self.message('invalid_password',
-                                     state=State_obj), value, state,
-                                     error_dict=self.e_dict)
-        if user:
-            if user.active:
-                if user.username == username and check_password(password,
-                                                                user.password):
-                    return value
-                else:
-                    log.warning('user %s not authenticated', username)
-                    raise formencode.Invalid(self.message('invalid_password',
-                                             state=State_obj), value, state,
-                                             error_dict=self.e_dict)
-            else:
+
+        if authfunc(None, username, password):
+            return value
+        else:
+            if user and user.active is False:
                 log.warning('user %s is disabled', username)
                 raise formencode.Invalid(self.message('disabled_account',
                                          state=State_obj),
                                          value, state,
                                          error_dict=self.e_dict_disable)
+            else:
+                log.warning('user %s not authenticated', username)
+                raise formencode.Invalid(self.message('invalid_password',
+                                         state=State_obj), value, state,
+                                         error_dict=self.e_dict)
 
 class ValidRepoUser(formencode.validators.FancyValidator):
 
--- a/rhodecode/public/css/style.css	Mon Nov 15 18:38:54 2010 +0100
+++ b/rhodecode/public/css/style.css	Tue Nov 16 08:52:31 2010 +0100
@@ -825,16 +825,8 @@
 #content div.box div.form div.fields div.field div.input {
 margin:0 0 0 200px;
 }
-
 #content div.box-left div.form div.fields div.field div.input,#content div.box-right div.form div.fields div.field div.input {
-clear:both;
-overflow:hidden;
-border-top:1px solid #b3b3b3;
-border-left:1px solid #b3b3b3;
-border-right:1px solid #eaeaea;
-border-bottom:1px solid #eaeaea;
-margin:0;
-padding:7px 7px 6px;
+margin:0 0 0 0px;
 }
 
 #content div.box div.form div.fields div.field div.input input {
@@ -850,11 +842,7 @@
 padding:7px 7px 6px;
 }
 
-#content div.box-left div.form div.fields div.field div.input input,#content div.box-right div.form div.fields div.field div.input input {
-width:100%;
-border:none;
-padding:0;
-}
+
 
 #content div.box div.form div.fields div.field div.input input.small {
 width:30%;
@@ -2066,10 +2054,6 @@
 padding:0;
 }
 
-#content div.box div.form div.fields div.field div.label-checkbox,#content div.box div.form div.fields div.field div.label-radio,#content div.box div.form div.fields div.field div.label-textarea {
-padding:0 0 0 5px !important;
-}
-
 #content div.box div.form div.fields div.field div.label span,#login div.form div.fields div.field div.label span,#register div.form div.fields div.field div.label span {
 height:1%;
 display:block;
@@ -2098,11 +2082,17 @@
 margin:0;
 }
 
+#content div.box-left div.form div.fields div.field div.select,#content div.box-left div.form div.fields div.field div.checkboxes,#content div.box-left div.form div.fields div.field div.radios,#content div.box-right div.form div.fields div.field div.select,#content div.box-right div.form div.fields div.field div.checkboxes,#content div.box-right div.form div.fields div.field div.radios{
+margin:0 0 0 0px !important;
+padding:0;
+}
+
 #content div.box div.form div.fields div.field div.select,#content div.box div.form div.fields div.field div.checkboxes,#content div.box div.form div.fields div.field div.radios {
 margin:0 0 0 200px;
 padding:0;
 }
 
+
 #content div.box div.form div.fields div.field div.select a:hover,#content div.box div.form div.fields div.field div.select a.ui-selectmenu:hover,#content div.box div.action a:hover {
 color:#000;
 text-decoration:none;
--- a/rhodecode/templates/admin/repos/repo_edit.html	Mon Nov 15 18:38:54 2010 +0100
+++ b/rhodecode/templates/admin/repos/repo_edit.html	Tue Nov 16 08:52:31 2010 +0100
@@ -18,7 +18,7 @@
 </%def>
 
 <%def name="main()">
-<div class="box">
+<div class="box box-left">
     <!-- box / title -->
     <div class="title">
         ${self.breadcrumbs()}      
@@ -32,7 +32,7 @@
                     <label for="repo_name">${_('Name')}:</label>
                 </div>
                 <div class="input input-medium">
-                    ${h.text('repo_name',class_="small")}
+                    ${h.text('repo_name',class_="medium")}
                 </div>
              </div>
             <div class="field">
@@ -40,7 +40,7 @@
                     <label for="repo_type">${_('Type')}:</label>
                 </div>
                 <div class="input">
-                    ${h.select('repo_type','hg',c.backends,class_="small")}
+                    ${h.select('repo_type','hg',c.backends,class_="medium")}
                 </div>
              </div>             
             <div class="field">
@@ -280,4 +280,23 @@
         </script>      
 
 </div>
+
+<div class="box box-right">
+    <div class="title">
+        <h5>${_('Administration')}</h5>    
+    </div>
+    
+    <div class="form">
+    
+        <h3>${_('Reset statistics')}</h3>
+        <h3>${_('Reset cache')}</h3>
+        <h3>${_('Delete')}</h3>
+        
+        
+    
+    </div>
+    
+</div>
+
+
 </%def> 
\ No newline at end of file
--- a/rhodecode/templates/admin/users/user_edit_my_account.html	Mon Nov 15 18:38:54 2010 +0100
+++ b/rhodecode/templates/admin/users/user_edit_my_account.html	Tue Nov 16 08:52:31 2010 +0100
@@ -30,7 +30,7 @@
 	                    <label for="username">${_('Username')}:</label>
 	                </div>
 	                <div class="input">
-	                    ${h.text('username')}
+	                    ${h.text('username',class_="medium")}
 	                </div>
 	             </div>
 	            
@@ -39,7 +39,7 @@
 	                    <label for="new_password">${_('New password')}:</label>
 	                </div>
 	                <div class="input">
-	                    ${h.password('new_password')}
+	                    ${h.password('new_password',class_="medium")}
 	                </div>
 	             </div>
 	            
@@ -48,7 +48,7 @@
 	                    <label for="name">${_('First Name')}:</label>
 	                </div>
 	                <div class="input">
-	                    ${h.text('name')}
+	                    ${h.text('name',class_="medium")}
 	                </div>
 	             </div>
 	            
@@ -57,7 +57,7 @@
 	                    <label for="lastname">${_('Last Name')}:</label>
 	                </div>
 	                <div class="input">
-	                    ${h.text('lastname')}
+	                    ${h.text('lastname',class_="medium")}
 	                </div>
 	             </div>
 	            
@@ -66,7 +66,7 @@
 	                    <label for="email">${_('Email')}:</label>
 	                </div>
 	                <div class="input">
-	                    ${h.text('email')}
+	                    ${h.text('email',class_="medium")}
 	                </div>
 	             </div>
 	            
--- a/rhodecode/templates/changelog/changelog.html	Mon Nov 15 18:38:54 2010 +0100
+++ b/rhodecode/templates/changelog/changelog.html	Tue Nov 16 08:52:31 2010 +0100
@@ -78,8 +78,10 @@
                                    %endif  
                     									
 								<span class="logtags">
+									%if cs.branch:
 									<span class="branchtag" title="${'%s %s' % (_('branch'),cs.branch)}">
-									${h.link_to(cs.branch,h.url('files_home',repo_name=c.repo_name,revision=cs.raw_id))}</span>
+									   ${h.link_to(cs.branch,h.url('files_home',repo_name=c.repo_name,revision=cs.raw_id))}</span>
+									%endif
 									%for tag in cs.tags:
 										<span class="tagtag"  title="${'%s %s' % (_('tag'),tag)}">
 										${h.link_to(tag,h.url('files_home',repo_name=c.repo_name,revision=cs.raw_id))}</span>