def update( self, user: User, name: str=None, email: str=None, do_save=True, timezone: str='', ): if name is not None: user.display_name = name if email is not None: user.email = email user.timezone = timezone if do_save: self.save(user)
def update( self, user: User, name: str = None, email: str = None, password: str = None, timezone: str = None, groups: typing.Optional[typing.List[Group]] = None, do_save=True, ) -> User: if name is not None: user.display_name = name if email is not None: email_exist = self._check_email(email) if not email_exist: raise EmailValidationFailed( 'Email given form {} is uncorrect'.format(email)) # nopep8 user.email = email if password is not None: user.password = password if timezone is not None: user.timezone = timezone if groups is not None: # INFO - G.M - 2018-07-18 - Delete old groups for group in user.groups: if group not in groups: user.groups.remove(group) # INFO - G.M - 2018-07-18 - add new groups for group in groups: if group not in user.groups: user.groups.append(group) if do_save: self.save(user) return user