Esempio n. 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'))
Esempio n. 2
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'))
Esempio n. 3
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'))
Esempio n. 4
0
def templates_add():
    if g.role.can_add_templates:
        if request.method == 'GET':
            return render_template('templates_add.j2', title='Add template', current_link='templates')
        elif request.method == 'POST':
            if request.form['expires']:
                Template(name=request.form.get('name'),
                         subject=request.form.get('subject'),
                         body=request.form.get('body'),
                         added_by=request.form.get('added_by'),
                         added_on=datetime.now(),
                         expires_on=request.form.get('expires'))
            else:
                Template(name=request.form.get('name'),
                         subject=request.form.get('subject'),
                         body=request.form.get('body'),
                         added_by=request.form.get('added_by'),
                         added_on=datetime.now())
            commit()
            return redirect(url_for('.templates'))
Esempio n. 5
0
def templates_edit(template_id):
    if g.role.can_edit_templates:
        if request.method == 'GET':
            return render_template('templates_edit.j2', title='Edit Template', current_link='templates', template=Template.get(tid=template_id))
        elif request.method == 'POST':
            template = Template.get(tid=template_id)
            template.name = request.form.get('name')
            template.subject = request.form.get('subject')
            template.body = request.form.get('body')
            template.expires_on = request.form.get('expires')
            commit()
            return redirect(url_for('.templates'))
Esempio n. 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()
Esempio n. 7
0
def templates_remove(template_id):
    if g.role.can_delete_templates:
        Template.get(tid=template_id).delete()
        commit()
        return redirect(url_for('.templates'))
Esempio n. 8
0
def templates():
    templates = Template.get_all()
    return render_template('templates.j2', title='Templates', current_link='templates', templates=templates)