diff options
| author | Alexis Metaireau <alexis@notmyidea.org> | 2011-07-30 01:51:13 +0200 |
|---|---|---|
| committer | Alexis Metaireau <alexis@notmyidea.org> | 2011-07-30 01:51:13 +0200 |
| commit | e214b39b4434c10589b548c387ad9a0e9dd98d2c (patch) | |
| tree | bc3a41d3ac3219098c43870990a1429373b9bed2 /budget/forms.py | |
| parent | ab305ccbc6abf3aa990832da4f5161c813860e5c (diff) | |
| download | ihatemoney-mirror-e214b39b4434c10589b548c387ad9a0e9dd98d2c.zip ihatemoney-mirror-e214b39b4434c10589b548c387ad9a0e9dd98d2c.tar.gz ihatemoney-mirror-e214b39b4434c10589b548c387ad9a0e9dd98d2c.tar.bz2 | |
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.
Diffstat (limited to 'budget/forms.py')
| -rw-r--r-- | budget/forms.py | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/budget/forms.py b/budget/forms.py index 1e265ee..45da1f3 100644 --- a/budget/forms.py +++ b/budget/forms.py @@ -44,6 +44,6 @@ class MemberForm(Form): submit = SubmitField("Add a member") def validate_name(form, field): - if Person.query.filter( - Person.name == field.data and Person.project == self.project).all(): + if Person.query.filter(Person.name == field.data)\ + .filter(Person.project == form.project).all(): raise ValidationError("This project already have this member") |
