handle strange case when user account references a person that has been deleted
This commit is contained in:
parent
a02ccde5ff
commit
9c71572be8
2 changed files with 15 additions and 10 deletions
|
@ -1,5 +1,5 @@
|
||||||
#
|
#
|
||||||
# Copyright (c) 2013 Helmut Merz helmutm@cy55.de
|
# Copyright (c) 2015 Helmut Merz helmutm@cy55.de
|
||||||
#
|
#
|
||||||
# This program is free software; you can redistribute it and/or modify
|
# This program is free software; you can redistribute it and/or modify
|
||||||
# it under the terms of the GNU General Public License as published by
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
@ -67,10 +67,13 @@ class UserId(schema.TextLine):
|
||||||
mapping={'userId': userId}))
|
mapping={'userId': userId}))
|
||||||
person = getPersonForUser(context, principal=principal)
|
person = getPersonForUser(context, principal=principal)
|
||||||
if person is not None and person != context:
|
if person is not None and person != context:
|
||||||
raiseValidationError(
|
name = zapi.getName(person)
|
||||||
_(u'There is alread a person ($person) assigned to user $userId.',
|
if name:
|
||||||
mapping=dict(person=zapi.getName(person),
|
raiseValidationError(
|
||||||
userId=userId)))
|
_(u'There is already a person ($person) '
|
||||||
|
u'assigned to user $userId.',
|
||||||
|
mapping=dict(person=name,
|
||||||
|
userId=userId)))
|
||||||
|
|
||||||
|
|
||||||
class LoginName(schema.TextLine):
|
class LoginName(schema.TextLine):
|
||||||
|
@ -82,7 +85,7 @@ class LoginName(schema.TextLine):
|
||||||
super(LoginName, self)._validate(userId)
|
super(LoginName, self)._validate(userId)
|
||||||
if userId in getPrincipalFolder(self.context):
|
if userId in getPrincipalFolder(self.context):
|
||||||
raiseValidationError(
|
raiseValidationError(
|
||||||
_(u'There is alread a user with ID $userId.',
|
_(u'There is already a user with ID $userId.',
|
||||||
mapping=dict(userId=userId)))
|
mapping=dict(userId=userId)))
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
#
|
#
|
||||||
# Copyright (c) 2014 Helmut Merz helmutm@cy55.de
|
# Copyright (c) 2015 Helmut Merz helmutm@cy55.de
|
||||||
#
|
#
|
||||||
# This program is free software; you can redistribute it and/or modify
|
# This program is free software; you can redistribute it and/or modify
|
||||||
# it under the terms of the GNU General Public License as published by
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
@ -93,9 +93,11 @@ class Person(AdapterBase, BasePerson):
|
||||||
return
|
return
|
||||||
person = getPersonForUser(self.context, principal=principal)
|
person = getPersonForUser(self.context, principal=principal)
|
||||||
if person is not None and person != self.context:
|
if person is not None and person != self.context:
|
||||||
raise ValueError(
|
name = getName(person)
|
||||||
'There is alread a person (%s) assigned to user %s.'
|
if name:
|
||||||
% (getName(person), userId))
|
raise ValueError(
|
||||||
|
'There is already a person (%s) assigned to user %s.'
|
||||||
|
% (getName(person), userId))
|
||||||
pa = annotations(principal)
|
pa = annotations(principal)
|
||||||
loopsId = util.getUidForObject(self.context.getLoopsRoot())
|
loopsId = util.getUidForObject(self.context.getLoopsRoot())
|
||||||
ann = pa.get(ANNOTATION_KEY)
|
ann = pa.get(ANNOTATION_KEY)
|
||||||
|
|
Loading…
Add table
Reference in a new issue