Skip to content

Commit

Permalink
fix suspicious (boolean) in _update()
Browse files Browse the repository at this point in the history
  • Loading branch information
taoky committed Sep 10, 2023
1 parent 1ada0e2 commit 4598b72
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion server/user/interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -218,13 +218,22 @@ def _update(self, **kwargs):
for k, v in kwargs.items():
if k in {'group', 'nickname', 'name', 'sno', 'tel', 'email',
'gender', 'qq', 'website', 'school', 'grade', 'major', 'campus',
'aff', 'suspicious', 'suspicious_reason', 'suspicious_ddl'}:
'aff', 'suspicious_reason', 'suspicious_ddl'}:
v = v or None
try:
v is None or (self._validators[k] and self._validators[k](v))
except ValidationError as e:
raise WrongFormat(e.message)
setattr(self._obj, k, v)
elif k in {'suspicious'}:
# non-nullable values should not be set to None like above
if v is None:
raise WrongFormat()
try:
self._validators[k] and self._validators[k](v)
except ValidationError as e:
raise WrongFormat(e.message)
setattr(self._obj, k, v)
else:
raise WrongArguments()
self._obj.save()
Expand Down

0 comments on commit 4598b72

Please sign in to comment.