Example #1
0
def queue_add():
    if request.method == 'GET':
        if g.role.can_add_queue_items:
            templates = Template.get_all()
            return render_template('queue_add.j2', title='Add to queue', current_link='queue', templates=templates)
        else:
            return redirect(url_for('.queue'))
    elif request.method == 'POST':
        if g.role.can_add_queue_items:
            if Customer.exists(email=request.form.get('email')):
                customer = Customer.get(email=request.form.get('email'))
                if Queue.exists(customer=customer):
                    flash('Customer is already in the queue', 'queue_error')
                    return redirect(url_for('.queue'))
            else:
                customer = Customer(first_name=request.form.get('first_name'),
                                    last_name=request.form.get('last_name'),
                                    email=request.form.get('email'),
                                    added_on=datetime.now())
                commit()
            template = Template.get(tid=request.form.get('template'))
            user = User.get(uid=g.user.uid)
            queue_item = Queue(customer=customer, user=user, template=template)
            customer.queue_item = queue_item
            commit()
            return redirect(url_for('.queue'))
        else:
            return redirect(url_for('.queue'))
Example #2
0
def queue_add_customer(customer_id):
    if g.role.can_add_queue_items:
        customer = Customer.get(cid=customer_id)
        templates = Template.get_all()
        return render_template('queue_add_customer.j2', title='Add Customer to Queue', current_link='queue', customer=customer, templates=templates)
    else:
        return redirect(url_for('.customers'))
Example #3
0
def customers_edit(customer_id):
    if g.role.can_edit_customers:
        if request.method == 'GET':
            return render_template('customers_edit.j2', title='Edit Customer', current_link='customers', customer=Customer.get(cid=customer_id))
        elif request.method == 'POST':
            customer = Customer.get(cid=customer_id)
            customer.first_name = request.form.get('first_name')
            customer.last_name = request.form.get('last_name')
            customer.email = request.form.get('email')
            commit()
            return redirect(url_for('.customers'))
Example #4
0
def queue_edit(queue_id):
    if g.role.can_edit_queue_items:
        if request.method == 'GET':
            queue_item = Queue.get(qid=queue_id)
            customer = Customer.get(cid=queue_item.customer.cid)
            templates = Template.get_all()
            return render_template('queue_edit.j2', title='Edit Customer in Queue', current_link='queue', queue_item=queue_item, customer=customer, templates=templates)
        elif request.method == 'POST':
            queue_item = Queue.get(qid=queue_id)
            queue_item.template = Template.get(tid=request.form.get('template'))
            return redirect(url_for('.queue'))
Example #5
0
def customers_add():
    if request.method == 'GET':
        return render_template('customers_add.j2', title='Add a Customer', current_link='customers')
    elif request.method == 'POST':
        pprint(request.form)
        current_time = datetime.now()
        Customer(first_name=request.form.get('first_name'),
                 last_name=request.form.get('last_name'),
                 email=request.form.get('email'),
                 added_on=current_time)
        commit()
        return redirect(url_for('.customers'))
Example #6
0
def setUp():
    group = Group(name='TestAdminGroup',
                  email_mask='*****@*****.**',
                  email_username='******',
                  email_password='******',
                  email_host='secure.example.com',
                  email_port=465)
    subgroup = Subgroup(gid=Group, name='TestAdminSubgroup')
    role = Role(name='TestAdmin',
                is_admin=True,
                is_group_admin=True,
                can_add_group_admin=True,
                can_remove_group_admin=True,
                is_subgroup_admin=True,
                can_add_subgroup_admin=True,
                can_remove_subgroup_admin=True,
                can_add_templates=True,
                can_edit_templates=True,
                can_delete_templates=True,
                can_add_users=True,
                can_edit_users=True,
                can_delete_users=True,
                can_add_groups=True,
                can_edit_groups=True,
                can_delete_groups=True,
                can_add_subgroups=True,
                can_edit_subgroups=True,
                can_delete_subgroups=True,
                can_add_queue_items=True,
                can_edit_queue_items=True,
                can_delete_queue_items=True,
                can_add_customers=True,
                can_edit_customers=True,
                can_delete_customers=True)
    User(first_name='Test',
         last_name='User',
         email='*****@*****.**',
         username='******',
         password='******',
         role=role,
         group=group,
         subgroup=subgroup,
         creation_date=datetime.now())
    Template()
    Customer()
    Queue()
Example #7
0
def customers_remove(customer_id):
    if g.role.can_delete_customers:
        Customer.get(cid=customer_id).delete()
        commit()
        return redirect(url_for('.customers'))
Example #8
0
def customers():
    customers = Customer.get_all()
    return render_template('customers.j2', title='Customers', current_link='customers', customers=customers)