def invite(email, sender_id, company_id): recipient = db.person_get(company_id=company_id, mail=email) if not email or not recipient: abort(400, 'No email address registered for this Person, please add one to send an invitation') token = db.generate_token(email) if not recipient.token else recipient.token mail.invite( email, db.person_get(company_id, user_id=sender_id).name, token )
def invite(email, sender_id, company_id): recipient = db.person_get(company_id=company_id, mail=email) if not email or not recipient: abort( 400, 'No email address registered for this Person, please add one to send an invitation' ) token = db.generate_token( email) if not recipient.token else recipient.token mail.invite(email, db.person_get(company_id, user_id=sender_id).name, token)
def delete(role_id): people = db.person_get(role_id=role_id) role = get(role_id=role_id) if people: abort(400, u'There are {} {}(s) registered. Remove those People first.'.format(len(people), role.name)) db.role_delete(role_id) notify(u'{} deleted a Role - <strong>%s</strong>' % role.name, action='delete', target='person')
def activate_form(token): person = db_wrapper.person_get(token=token) # Can't find user by this token so they must be active if not person: return redirect(url_for('login')) return render_template('activate.html', token=token, name=person.name, email=person.mail)
def delete(person_id, user_id, company_id): if person_id == user_id: abort(400, "You can't delete your own account. Coming soon!") if company.get(company_id).owner.id == person_id: abort(400, "You can't delete the company's owner") user_name = db.person_get(user_id=person_id).name db.person_delete(person_id) notify(u'{} deleted a Person - <strong>%s</strong>' % user_name, action='delete', target='person')
def delete(role_id): people = db.person_get(role_id=role_id) role = get(role_id=role_id) if people: abort(400, u'There are {} {}(s) registered. Remove those People first.'.format(len(people), role.name)) db.role_delete(role_id)
def delete(role_id): people = db.person_get(role_id=role_id) role = get(role_id=role_id) if people: abort( 400, u'There are {} {}(s) registered. Remove those People first.'. format(len(people), role.name)) db.role_delete(role_id)
def get(company_id=None, role_id=None, mail=None, search=None, sort_by=None, sort_dir=None, limit=None, offset=None): return db.person_get(company_id=company_id, role_id=role_id, search=search, sort_by=sort_by, sort_dir=sort_dir, limit=limit, offset=offset, mail=mail)
def activate_form(token): person = db_wrapper.person_get(token=token) # Can't find user by this token so they must be active if not person: return render_template( 'login.html', error_msg="Woops, we couldn't find your invitation. You'll need to ask your administrator to send a new one. " ) # Account already activated if person.active: return render_template( 'login.html', info_msg="Your account has already been activated. You can log in now." ) return render_template('activate.html', token=token, name=person.name, email=person.email)
def get(role_id=None, company_id=None, user_id=None): rank = None if user_id is None else db.person_get(user_id=user_id).role.rank return db.role_get(role_id=role_id, company_id=company_id, rank=rank)
def reset(email): new_password = db.reset_user(email) recipient = db.person_get(email=email) mail.reset(email, recipient.name.split(" ")[0], new_password)
def _notify(company_id, owner_id, body, message, action, target): user = db.person_get(user_id=owner_id) body = body.format(u'<b>{}</b>'.format(user.name)) db.notification_add(company_id, owner_id, user.image, body, action, target, message=message)