Changeset - 460ad816820d
[Not reviewed]
celery
0 4 0
Marcin Kuzminski - 15 years ago 2010-09-20 22:47:20
marcin@python-works.com
fixed bug when new repo had no last commiter,
fixed bug when my_account updating information failed, by not uniq email address.
4 files changed with 32 insertions and 22 deletions:
0 comments (0 inline, 0 general)
pylons_app/controllers/admin/settings.py
Show inline comments
 
@@ -35,13 +35,13 @@ from pylons_app.lib.utils import repo2db
 
    set_hg_app_config, get_hg_settings, get_hg_ui_settings, make_ui
 
from pylons_app.model.db import User, UserLog, HgAppSettings, HgAppUi
 
from pylons_app.model.forms import UserForm, ApplicationSettingsForm, \
 
    ApplicationUiSettingsForm
 
from pylons_app.model.hg_model import HgModel
 
from pylons_app.model.user_model import UserModel
 
from pylons_app.lib.celerylib import tasks,run_task
 
from pylons_app.lib.celerylib import tasks, run_task
 
import formencode
 
import logging
 
import traceback
 
 
 
log = logging.getLogger(__name__)
 

	
 
@@ -102,14 +102,14 @@ class SettingsController(BaseController)
 
            repo2db_mapper(initial, rm_obsolete)
 
            invalidate_cache('cached_repo_list')
 
            h.flash(_('Repositories sucessfully rescanned'), category='success')            
 
        
 
        if setting_id == 'whoosh':
 
            repo_location = get_hg_ui_settings()['paths_root_path']
 
            full_index = request.POST.get('full_index',False)
 
            task = run_task(tasks.whoosh_index,repo_location,full_index)
 
            full_index = request.POST.get('full_index', False)
 
            task = run_task(tasks.whoosh_index, repo_location, full_index)
 
            
 
            h.flash(_('Whoosh reindex task scheduled'), category='success')
 
        if setting_id == 'global':
 
            
 
            application_form = ApplicationSettingsForm()()
 
            try:
 
@@ -257,22 +257,27 @@ class SettingsController(BaseController)
 
        # Or using helpers:
 
        #    h.form(url('admin_settings_my_account_update'),
 
        #           method='put')
 
        # url('admin_settings_my_account_update', id=ID)
 
        user_model = UserModel()
 
        uid = c.hg_app_user.user_id
 
        _form = UserForm(edit=True, old_data={'user_id':uid})()
 
        _form = UserForm(edit=True, old_data={'user_id':uid,
 
                                              'email':c.hg_app_user.email})()
 
        form_result = {}
 
        try:
 
            form_result = _form.to_python(dict(request.POST))
 
            user_model.update_my_account(uid, form_result)
 
            h.flash(_('Your account was updated succesfully'),
 
                    category='success')
 
                           
 
        except formencode.Invalid as errors:
 
            #c.user = self.sa.query(User).get(c.hg_app_user.user_id)
 
            c.user = self.sa.query(User).get(c.hg_app_user.user_id)
 
            c.user_repos = []
 
            for repo in c.cached_repo_list.values():
 
                if repo.dbrepo.user.username == c.user.username:
 
                    c.user_repos.append(repo)            
 
            return htmlfill.render(
 
                render('admin/users/user_edit_my_account.html'),
 
                defaults=errors.value,
 
                errors=errors.error_dict or {},
 
                prefix_error=False,
 
                encoding="UTF-8")
pylons_app/lib/utils.py
Show inline comments
 
@@ -218,12 +218,13 @@ def invalidate_cache(name, *args):
 
        region_invalidate(_full_changelog_cached, None, *args)
 
        
 
class EmptyChangeset(BaseChangeset):
 
    
 
    revision = -1
 
    message = ''
 
    author = ''
 
    
 
    @LazyProperty
 
    def raw_id(self):
 
        """
 
        Returns raw string identifing this changeset, useful for web
 
        representation.
 
@@ -411,22 +412,22 @@ kaoPN/\nD/gcgM+FD4W7ws8OW886PNg+UTp4jlX8
 
aq\ndrduZOxK5Ex9RxN2pZcx8So9XEozKw4D1Vdn6v0RFLdfeolM0r/U2d9buqRbvekZ/iv0IpulqrYr
 
\nl9sRo+rBEAyR+x8/ADg4OI4gyPyf3/8cHEcTJf+fpwB/ODg4jgSaoBfQ/QB+/s/BcSRR3f+H6Bng\n
 
e/8cHEcHpf1/CI+jHwEP3AToLtx8e9/9e//w8Hun6bHGDz+tvE+3uwfOxsW69+nYYw2WfjPHGtX9\n5A
 
MdfNQo9P+eS7youNdyVuJq4ot2zRsdnLgLCYYip/b7w5jKqUX51IREv4F/FJ7YBy96ja963sJS\n34yd
 
OXDGKEud/R8efZUt\n
 
"""    
 
    newdb = open('test.db','wb')
 
    newdb = open('test.db', 'wb')
 
    newdb.write(new_db_dump.decode('base64').decode('zlib'))
 
    newdb.close()
 
    
 
    
 
    #PART TWO make test repo
 
    if os.path.isdir('/tmp/vcs_test'):
 
        shutil.rmtree('/tmp/vcs_test')
 
        
 
    cur_dir = dn(dn(os.path.abspath(__file__)))
 
    tar = tarfile.open(jn(cur_dir,'tests',"vcs_test.tar.gz"))
 
    tar = tarfile.open(jn(cur_dir, 'tests', "vcs_test.tar.gz"))
 
    tar.extractall('/tmp')
 
    tar.close()
 
    
 
    
 
    
 
\ No newline at end of file
 
    
pylons_app/model/forms.py
Show inline comments
 
@@ -206,24 +206,28 @@ class ValidPath(formencode.validators.Fa
 
        else:
 
            msg = _('You need to specify * or ** at the end of path (ie. /tmp/*)')
 
        
 
        raise formencode.Invalid(msg, value, state,
 
                                     error_dict={'paths_root_path':msg})            
 

	
 
class UniqSystemEmail(formencode.validators.FancyValidator):
 
    def to_python(self, value, state):
 
        sa = meta.Session
 
        try:
 
            user = sa.query(User).filter(User.email == value).scalar()
 
            if user:
 
                raise formencode.Invalid(_("That e-mail address is already taken") ,
 
                                         value, state)
 
        finally:
 
            meta.Session.remove()
 
            
 
        return value 
 
def UniqSystemEmail(old_data):
 
    class _UniqSystemEmail(formencode.validators.FancyValidator):
 
        def to_python(self, value, state):
 
            if old_data['email'] != value:
 
                sa = meta.Session
 
                try:
 
                    user = sa.query(User).filter(User.email == value).scalar()
 
                    if user:
 
                        raise formencode.Invalid(_("That e-mail address is already taken") ,
 
                                                 value, state)
 
                finally:
 
                    meta.Session.remove()
 
                
 
            return value
 
        
 
    return _UniqSystemEmail
 
    
 
class ValidSystemEmail(formencode.validators.FancyValidator):
 
    def to_python(self, value, state):
 
        sa = meta.Session
 
        try:
 
            user = sa.query(User).filter(User.email == value).scalar()
 
@@ -273,13 +277,13 @@ def UserForm(edit=False, old_data={}):
 
            admin = StringBoolean(if_missing=False)
 
        else:
 
            password = All(UnicodeString(strip=True, min=8, not_empty=True), ValidPassword)
 
        active = StringBoolean(if_missing=False)
 
        name = UnicodeString(strip=True, min=3, not_empty=True)
 
        lastname = UnicodeString(strip=True, min=3, not_empty=True)
 
        email = All(Email(not_empty=True), UniqSystemEmail())
 
        email = All(Email(not_empty=True), UniqSystemEmail(old_data))
 
        
 
    return _UserForm
 

	
 
RegisterForm = UserForm
 

	
 
def PasswordResetForm():
pylons_app/templates/summary/summary.html
Show inline comments
 
@@ -74,13 +74,13 @@ E.onDOMReady(function(e){
 
			 <div class="field">
 
			  <div class="label">
 
			      <label>${_('Last change')}:</label>
 
			  </div>
 
			  <div class="input-short">
 
			      ${h.age(c.repo_info.last_change)} - ${h.rfc822date(c.repo_info.last_change)} 
 
			      ${_('by')} ${c.repo_info.get_changeset('tip').author} 
 
			      ${_('by')} ${h.get_changeset_safe(c.repo_info,'tip').author} 
 
			      
 
			  </div>
 
			 </div>
 
			
 
			 <div class="field">
 
			  <div class="label">
0 comments (0 inline, 0 general)