Changeset - 52da7cba88a6
[Not reviewed]
beta
0 8 0
Marcin Kuzminski - 15 years ago 2010-11-16 08:52:31
marcin@python-works.com
Code refactor for auth func, preparing for ldap support
css updates.
turned off graph,and branches for git changelog
8 files changed with 66 insertions and 47 deletions:
0 comments (0 inline, 0 general)
rhodecode/controllers/changelog.py
Show inline comments
 
@@ -71,13 +71,15 @@ class ChangelogController(BaseController
 

	
 
        return render('changelog/changelog.html')
 

	
 

	
 
    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]
 

	
 
        offset = 1 if p == 1 else  ((p - 1) * revcount + 1)
 

	
 
        rev_start = repo.revisions[(-1 * offset)]
rhodecode/lib/auth.py
Show inline comments
 
@@ -70,12 +70,21 @@ def get_crypt_password(password):
 
    return bcrypt.hashpw(password, bcrypt.gensalt(10))
 

	
 
def check_password(password, hashed):
 
    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:
 
        if user.active:
 

	
 
            if user.username == 'default' and user.active:
rhodecode/lib/celerylib/tasks.py
Show inline comments
 
@@ -62,13 +62,15 @@ def whoosh_index(repo_location, full_ind
 

	
 
@task
 
@locked_task
 
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 = {}
 
    repos_path = get_repos_path()
 
    p = os.path.join(repos_path, repo_name)
 
    repo = get_repo(p)
 
@@ -88,14 +90,14 @@ def get_commits_stats(repo_name, ts_min_
 
    if cur_stats:
 
        last_rev = cur_stats.stat_on_revision
 
    if not repo.revisions:
 
        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:
 
        commits_by_day_aggregate = OrderedDict(
 
                                       json.loads(
 
                                        cur_stats.commit_activity_combined))
rhodecode/model/forms.py
Show inline comments
 
@@ -21,13 +21,13 @@ for SELECT use formencode.All(OneOf(list
 
"""
 
from formencode import All
 
from formencode.validators import UnicodeString, OneOf, Int, Number, Regex, \
 
    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
 
from rhodecode.model.db import User
 
from webhelpers.pylonslib.secure_form import authentication_token
 
from vcs import BACKENDS
 
@@ -91,32 +91,27 @@ class ValidAuth(formencode.validators.Fa
 
    e_dict_disable = {'username':messages['disabled_account']}
 

	
 
    def validate_python(self, value, state):
 
        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):
 

	
 
    def to_python(self, value, state):
 
        sa = meta.Session()
 
        try:
rhodecode/public/css/style.css
Show inline comments
 
@@ -822,22 +822,14 @@ color:#393939;
 
font-weight:700;
 
}
 
 
#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 {
 
background:#FFF;
 
border-top:1px solid #b3b3b3;
 
border-left:1px solid #b3b3b3;
 
@@ -847,17 +839,13 @@ color:#000;
 
font-family:Lucida Grande, Verdana, Lucida Sans Regular, Lucida Sans Unicode, Arial, sans-serif;
 
font-size:11px;
 
margin:0;
 
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%;
 
}
 
 
#content div.box div.form div.fields div.field div.input input.medium {
 
@@ -2063,16 +2051,12 @@ padding:0 20px 10px;
 
clear:both;
 
overflow:hidden;
 
margin:0;
 
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;
 
color:#363636;
 
margin:0;
 
padding:2px 0 0;
 
@@ -2095,17 +2079,23 @@ border-bottom:1px solid #c6d880;
 
}
 
 
#content div.box-left div.form div.fields div.field div.textarea,#content div.box-right div.form div.fields div.field div.textarea,#content div.box div.form div.fields div.field div.select select,#content div.box table th.selected input,#content div.box table td.selected input {
 
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;
 
}
 
 
#content div.box div.form div.fields div.field div.select a.ui-selectmenu-focus,#content div.box div.action a.ui-selectmenu-focus {
rhodecode/templates/admin/repos/repo_edit.html
Show inline comments
 
@@ -15,13 +15,13 @@
 

	
 
<%def name="page_nav()">
 
	${self.menu('admin')}
 
</%def>
 

	
 
<%def name="main()">
 
<div class="box">
 
<div class="box box-left">
 
    <!-- box / title -->
 
    <div class="title">
 
        ${self.breadcrumbs()}      
 
    </div>
 
    ${h.form(url('repo', repo_name=c.repo_info.repo_name),method='put')}
 
    <div class="form">
 
@@ -29,21 +29,21 @@
 
        <div class="fields">
 
            <div class="field">
 
                <div class="label">
 
                    <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">
 
                <div class="label">
 
                    <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">
 
                <div class="label label-textarea">
 
                    <label for="description">${_('Description')}:</label>
 
                </div>
 
@@ -277,7 +277,26 @@
 
            };
 
        }();
 
            
 
        </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
rhodecode/templates/admin/users/user_edit_my_account.html
Show inline comments
 
@@ -27,49 +27,49 @@
 
	        <div class="fields">
 
	             <div class="field">
 
	                <div class="label">
 
	                    <label for="username">${_('Username')}:</label>
 
	                </div>
 
	                <div class="input">
 
	                    ${h.text('username')}
 
	                    ${h.text('username',class_="medium")}
 
	                </div>
 
	             </div>
 
	            
 
	             <div class="field">
 
	                <div class="label">
 
	                    <label for="new_password">${_('New password')}:</label>
 
	                </div>
 
	                <div class="input">
 
	                    ${h.password('new_password')}
 
	                    ${h.password('new_password',class_="medium")}
 
	                </div>
 
	             </div>
 
	            
 
	             <div class="field">
 
	                <div class="label">
 
	                    <label for="name">${_('First Name')}:</label>
 
	                </div>
 
	                <div class="input">
 
	                    ${h.text('name')}
 
	                    ${h.text('name',class_="medium")}
 
	                </div>
 
	             </div>
 
	            
 
	             <div class="field">
 
	                <div class="label">
 
	                    <label for="lastname">${_('Last Name')}:</label>
 
	                </div>
 
	                <div class="input">
 
	                    ${h.text('lastname')}
 
	                    ${h.text('lastname',class_="medium")}
 
	                </div>
 
	             </div>
 
	            
 
	             <div class="field">
 
	                <div class="label">
 
	                    <label for="email">${_('Email')}:</label>
 
	                </div>
 
	                <div class="input">
 
	                    ${h.text('email')}
 
	                    ${h.text('email',class_="medium")}
 
	                </div>
 
	             </div>
 
	            
 
	            <div class="buttons">
 
	              ${h.submit('save','Save',class_="ui-button ui-widget ui-state-default ui-corner-all")}
 
	              ${h.reset('reset','Reset',class_="ui-button ui-widget ui-state-default ui-corner-all")}
rhodecode/templates/changelog/changelog.html
Show inline comments
 
@@ -75,14 +75,16 @@ ${c.repo_name} ${_('Changelog')} - ${c.r
 
									%endfor
 
								   %else:	
 
                                        <div class="parent">${_('No parents')}</div>   
 
                                   %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>
 
									%endfor
 
								</span>																	
 
						</div>				
0 comments (0 inline, 0 general)