[PATCH 1 of 3 v3] admin: users: factorize check for default user

Thomas De Schampheleire patrickdepinguin at gmail.com
Thu Jun 4 13:28:23 EDT 2015


On June 4, 2015 6:54:26 PM CEST, Mads Kiilerich <mads at kiilerich.com> wrote:
>On 06/03/2015 10:05 PM, Thomas De Schampheleire wrote:
>> # HG changeset patch
>> # User Thomas De Schampheleire <thomas.de.schampheleire at gmail.com>
>> # Date 1433359538 -7200
>> #      Wed Jun 03 21:25:38 2015 +0200
>> # Node ID 6a6119935ed636def910c4c4495ac2e4213d9ae7
>> # Parent  6e8effd028bf41a132aee02e52ffc0bf990dadf4
>> admin: users: factorize check for default user
>>
>> Note that one specific unittest has been commented because it relies
>on
>> pytest features (monkeypatch). When pytest is the default test
>runner, the
>> test should be uncommented.
>>
>> diff --git a/kallithea/controllers/admin/users.py
>b/kallithea/controllers/admin/users.py
>> --- a/kallithea/controllers/admin/users.py
>> +++ b/kallithea/controllers/admin/users.py
>> @@ -34,6 +34,7 @@ from pylons import request, tmpl_context
>>   from pylons.controllers.util import redirect
>>   from pylons.i18n.translation import _
>>   from sqlalchemy.sql.expression import func
>> +from webob.exc import HTTPNotFound
>>   
>>   import kallithea
>>   from kallithea.lib.exceptions import DefaultUserException, \
>> @@ -233,14 +234,17 @@ class UsersController(BaseController):
>>           # url('user', id=ID)
>>           User.get_or_404(-1)
>>   
>> +    def _get_user_or_raise_if_default(self, id):
>> +        try:
>> +            return User.get_or_404(id, allow_default=False)
>> +        except DefaultUserException:
>> +            h.flash(_("The default user cannot be edited"),
>category='warning')
>
>i guess this really should be an error?
>
>I can fix on the fly.

Yes, error is more appropriate...

Thanks,
Thomas




More information about the kallithea-general mailing list