# HG changeset patch # User Marcin Kuzminski # Date 1285015640 -7200 # Node ID 460ad816820d9ba877e81d1b19599416f4408edf # Parent 853b9425742a2718d1f17f27197e4248d86a771d fixed bug when new repo had no last commiter, fixed bug when my_account updating information failed, by not uniq email address. diff -r 853b9425742a -r 460ad816820d pylons_app/controllers/admin/settings.py --- a/pylons_app/controllers/admin/settings.py Sun Sep 19 03:42:48 2010 +0200 +++ b/pylons_app/controllers/admin/settings.py Mon Sep 20 22:47:20 2010 +0200 @@ -38,7 +38,7 @@ 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 @@ -105,8 +105,8 @@ 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': @@ -260,7 +260,8 @@ # 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)) @@ -269,7 +270,11 @@ 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, diff -r 853b9425742a -r 460ad816820d pylons_app/lib/utils.py --- a/pylons_app/lib/utils.py Sun Sep 19 03:42:48 2010 +0200 +++ b/pylons_app/lib/utils.py Mon Sep 20 22:47:20 2010 +0200 @@ -221,6 +221,7 @@ revision = -1 message = '' + author = '' @LazyProperty def raw_id(self): @@ -414,7 +415,7 @@ 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() @@ -424,9 +425,9 @@ 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 + diff -r 853b9425742a -r 460ad816820d pylons_app/model/forms.py --- a/pylons_app/model/forms.py Sun Sep 19 03:42:48 2010 +0200 +++ b/pylons_app/model/forms.py Mon Sep 20 22:47:20 2010 +0200 @@ -209,18 +209,22 @@ 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): @@ -276,7 +280,7 @@ 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 diff -r 853b9425742a -r 460ad816820d pylons_app/templates/summary/summary.html --- a/pylons_app/templates/summary/summary.html Sun Sep 19 03:42:48 2010 +0200 +++ b/pylons_app/templates/summary/summary.html Mon Sep 20 22:47:20 2010 +0200 @@ -77,7 +77,7 @@
${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}