1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/ihatemoney_ynh.git synced 2024-09-03 19:26:15 +02:00

Fixes an unwanted error "user already exists".

Doing a query with an AND SQL statement needs to be done with multiple "filter" callswith SQLAlchemy.

Here, we want to be sure that the username is not used AND that the project is the same than the eventual users that would match. The previous version of the code returned an user with the same name, even if the user wasn't in the right group.
This commit is contained in:
Alexis Metaireau 2011-07-30 01:51:13 +02:00
parent ab305ccbc6
commit e214b39b44

View file

@ -44,6 +44,6 @@ class MemberForm(Form):
submit = SubmitField("Add a member") submit = SubmitField("Add a member")
def validate_name(form, field): def validate_name(form, field):
if Person.query.filter( if Person.query.filter(Person.name == field.data)\
Person.name == field.data and Person.project == self.project).all(): .filter(Person.project == form.project).all():
raise ValidationError("This project already have this member") raise ValidationError("This project already have this member")