Exemplo n.º 1
0
def profile():
    the_user = UserAccess().the_current_user()
    admins = AdminAccess().admins_of_current_user()
    employees = EmployeeAccess().employees_of_current_user()
    clients = ClientAccess().clients_of_current_user()
    admins_pending = AdminAccess().admins_pending_of_current_user()
    employees_pending = EmployeeAccess().employees_pending_of_current_user()

    return render_template('profile.html',
                           user=the_user,
                           admins=admins,
                           employees=employees,
                           clients=clients,
                           admins_pending=admins_pending,
                           employees_pending=employees_pending)
Exemplo n.º 2
0
Arquivo: admin.py Projeto: D015/callqr
def create_admin_view(corporation_slug_to_id, **kwargs):
    roles = RoleAccess(
        corporation_id=corporation_slug_to_id).roles_available_to_create_admin()

    roles_to_choose = [(i.id, i.name) for i in roles]

    form = AdminForm(roles_to_choose, corporation_slug_to_id)

    next_page = request.args.get('next')

    if request.method == 'POST':
        if form.submit_admin.data and form.validate_on_submit():
            AdminAccess(corporation_id=corporation_slug_to_id,
                        email=form.email_admin.data.strip(),
                        role_id=form.role_admin.data.strip()).create_admin()
            flash('Your admin is now live!')
            if next_page:
                return redirect(next_page)
            form.email_admin.data = ''
            form.role_admin.data = ''

        elif form.cancel_admin.data:
            if next_page:
                return redirect(next_page)
            form.email_admin.data = ''
            form.role_admin.data = ''

    return render_template('create_admin.html', form=form)
Exemplo n.º 3
0
Arquivo: admin.py Projeto: D015/callqr
def edit_admin(admin_slug_to_id, **kwargs):
    admin = kwargs['admin']

    roles_to_choose = [(admin.role_id, admin.role.name)]

    if kwargs.get('valid_myself') is not True:
        roles = RoleAccess(
            corporation_id=admin.corporation_id).roles_available_to_create_admin()

        roles_to_choose = [(i.id, i.name) for i in roles]

    form = EditAdminForm(roles_to_choose, admin, role=admin.role_id)
    if request.method == 'POST':
        if form.submit.data and form.validate_on_submit():
            AdminAccess(_obj=admin).edit_model_object(
                about=form.about.data.strip(),
                phone=None if form.phone.data.strip() == '' \
                    else form.phone.data.strip(),
                email=form.email.data.strip(),
                role_id=form.role.data.strip())

            flash('Your changes have been saved.')
            return redirect(url_for('admin', admin_slug_to_id=admin.slug))
    elif request.method == 'GET':
        form.about.data = admin.about
        form.phone.data = admin.phone
        form.email.data = admin.email
    return render_template('edit_admin.html',
                           title='Edit admin {}'.format(admin.id),
                           form=form, valid_myself=kwargs.get('valid_myself'))
Exemplo n.º 4
0
Arquivo: admin.py Projeto: D015/callqr
    def validate_email_admin(self, email_admin):
        admins = AdminAccess(corporation_id=self.corporation_id,
                             email=email_admin.data.strip()). \
            admins_in_corporation_by_email()

        if admins is not None:
            raise ValidationError('Please use a different Email.')
Exemplo n.º 5
0
def corporation(corporation_slug_to_id, **kwargs):
    companies = None
    if kwargs['valid_role_id']:
        companies = CompanyAccess(corporation_id=corporation_slug_to_id
                                  ).companies_by_corporation_id()
    admins = AdminAccess(
        corporation_id=corporation_slug_to_id).admins_by_corporation_id()

    return render_template('corporation.html',
                           companies=companies,
                           admins=admins,
                           corporation=kwargs['corporation'])
Exemplo n.º 6
0
Arquivo: admin.py Projeto: D015/callqr
def create_relationship_admin_to_user_view(admin_pending_slug):
    admin = AdminAccess(slug=admin_pending_slug). \
        create_relationship_admin_to_user()

    next_page = request.args.get('next')

    if admin:
        flash('The relationship admin to user is accepted')
    else:
        flash('Something went wrong!')

    if next_page:
        return redirect(next_page)
    return render_template('index.html')
Exemplo n.º 7
0
Arquivo: admin.py Projeto: D015/callqr
    def validate_phone(self, phone):

        if phone.data is not None and phone.data.strip() != '' \
                and phone.data.strip().isdigit() is False:
            raise ValidationError('Use only digits')

        if phone.data.strip().isdigit() is True \
                and int(phone.data.strip()) != self.admin.phone:

            admins = AdminAccess(corporation_id=self.admin.corporation_id,
                                 phone=phone.data.strip()). \
                admins_in_corporation_by_phone()

            if admins is not None:
                raise ValidationError('Please use a different Phone.')