Exemplo n.º 1
0
def tags(request):
    """
    Returns all product tags
    """
    from servo.lib.utils import json_response
    tags = TaggedItem.objects.filter(content_type__model="product")
    tags = tags.distinct("tag").values_list("tag", flat=True)
    return json_response(list(tags))
Exemplo n.º 2
0
def find_customer(request, phone):
    if not request.user.is_authenticated():
        raise PermissionDenied

    results = []

    for c in Customer.objects.filter(phone=phone):
        title = '%s - %s' % (c.phone, c.name)
        results.append({'id': c.pk, 'name': c.name, 'title': title})

    return json_response(results)
Exemplo n.º 3
0
def find_customer(request, phone):
    if not request.user.is_authenticated():
        raise PermissionDenied

    results = []

    for c in Customer.objects.filter(phone=phone):
        title = '%s - %s' % (c.phone, c.name)
        results.append({'id': c.pk, 'name': c.name, 'title': title})

    return json_response(results)
Exemplo n.º 4
0
def get_customer(request):
    """Return the selected customer data."""
    if not request.user.is_authenticated():
        raise PermissionDenied

    if not request.GET.get('c'):
        return

    customer = get_object_or_404(Customer, pk=request.GET['c'])
    request.session['checkin_customer'] = customer.pk

    fdata = {'fname': customer.firstname, 'lname': customer.lastname}
    fdata['city'] = customer.city
    fdata['email'] = customer.email
    fdata['phone'] = customer.phone
    fdata['country'] = customer.country
    fdata['postal_code'] = customer.zip_code
    fdata['address'] = customer.street_address

    return json_response(fdata)
Exemplo n.º 5
0
def get_customer(request):
    """
    Returns the selected customer data
    """
    if not request.user.is_authenticated():
        raise PermissionDenied

    if not request.GET.get('c'):
        return

    customer = get_object_or_404(Customer, pk=request.GET['c'])
    request.session['checkin_customer'] = customer.pk

    fdata = {'fname': customer.firstname, 'lname': customer.lastname}
    fdata['city'] = customer.city
    fdata['email'] = customer.email
    fdata['phone'] = customer.phone
    fdata['country'] = customer.country
    fdata['postal_code'] = customer.zip_code
    fdata['address'] = customer.street_address

    return json_response(fdata)