def edit_user(cls, uid, full_name=full_name, position=position, mobile_phone=mobile_phone, inner_phone=inner_phone, email=email, birth_date=birth_date, skype=skype, photo=photo): u = cls.query.filter_by(id=uid).first() if u: u.full_name = full_name u.position = position u.mobile_phone = mobile_phone u.inner_phone = inner_phone u.email = email if birth_date: u.birth_date = birth_date else: u.birth_date = None u.skype = skype db.session.add(u) if photo: p = u.photo = u.photo or File.create( name='photo.png', module='users', entity=u) p.makedir() p.update_hash() image.thumbnail(photo, width=100, height=100, fill=image.COVER).save( p.get_path(sufix="thumbnail")) image.resize(photo).save(p.get_path()) return u
def edit_user(cls, uid, full_name=full_name, position=position, mobile_phone=mobile_phone, inner_phone=inner_phone, email=email, birth_date=birth_date, skype=skype, photo=photo): u = cls.query.filter_by(id=uid).first() if u: u.full_name = full_name u.position = position u.mobile_phone = mobile_phone u.inner_phone = inner_phone u.email = email if birth_date: u.birth_date = birth_date else: u.birth_date = None u.skype = skype db.session.add(u) if photo: p = u.photo = u.photo or File.create(name='photo.png', module='users', entity=u) p.makedir() p.update_hash() image.thumbnail(photo, width = 100, height = 100, fill = image.COVER).save(p.get_path(sufix="thumbnail")) image.resize(photo).save(p.get_path()) return u
def _add_user_to_local_db(login, name, surname, email, department, photo, mobile_phone, inner_phone, birth_date, skype): try: user = User() user.login = login user.full_name = "{0} {1}".format(name, surname) user.mobile_phone = mobile_phone user.inner_phone = inner_phone user.email = email user.department = Department.get_by_name(department) user.birth_date = birth_date user.skype = skype db.session.add(user) db.session.flush() p = user.photo = File.create(name='photo.png', module='users', entity=user) p.makedir() p.update_hash() image.thumbnail(photo, width=100, height=100, fill=image.COVER).save(p.get_path(sufix="thumbnail")) image.resize(photo).save(p.get_path()) return True except: return False