Пример #1
0
def add_colour_ajax(request):
    new_colour = request.POST.get("new_colour", "")
    new_colour = capwords(new_colour)
    if new_colour:
        Colour.objects.get_or_create(name=new_colour)

    data = {"colours": Colour.objects.order_by("name"), "new_colour": new_colour}

    return render_to_response("stocks/colours/all.html", data, context_instance=RequestContext(request))
Пример #2
0
def add_ajax(request):
    new_category = request.POST.get('new_category', '')
    new_category = capwords(new_category)
    if new_category:
        Category.objects.get_or_create(name=new_category)

    data = {
        'categories': Category.objects.order_by('name'),
        'new_category': new_category,
    }

    return render_to_response(
        'stocks/categories/all.html',
        data,
        context_instance=RequestContext(request),
    )
Пример #3
0
def add_town_ajax(request):
    new_town = request.POST.get('new_town', '')
    new_town = capwords(new_town)
    if new_town:
        Town.objects.get_or_create(name=new_town)

    data = {
        'towns': Town.objects.order_by('name'),
        'new_town': new_town,
    }

    return render_to_response(
        'geography/towns.html',
        data,
        context_instance=RequestContext(request),
    )
Пример #4
0
def add_country_ajax(request):
    new_country = request.POST.get('new_country', '')
    new_country = capwords(new_country)
    if new_country:
        Country.objects.get_or_create(name=new_country)

    data = {
        'countries': Country.objects.order_by('name'),
        'new_country': new_country,
    }

    return render_to_response(
        'geography/countries.html',
        data,
        context_instance=RequestContext(request),
    )
Пример #5
0
def add_ajax(request):
    new_category = request.POST.get('new_category', '')
    new_category = capwords(new_category)
    if new_category:
        Category.objects.get_or_create(name=new_category)

    data = {
        'categories': Category.objects.order_by('name'),
        'new_category': new_category,
    }

    return render_to_response(
        'stocks/categories/all.html',
        data,
        context_instance=RequestContext(request),
    )
Пример #6
0
def add_colour_ajax(request):
    new_colour = request.POST.get('new_colour', '')
    new_colour = capwords(new_colour)
    if new_colour:
        Colour.objects.get_or_create(name=new_colour)

    data = {
        'colours': Colour.objects.order_by('name'),
        'new_colour': new_colour,
    }

    return render_to_response(
        'stocks/colours/all.html',
        data,
        context_instance=RequestContext(request),
    )
Пример #7
0
def add_ajax(request):
    new_warehouse = request.POST.get('new_warehouse', '')
    new_warehouse = capwords(new_warehouse)
    if new_warehouse:
        Warehouse.objects.get_or_create(name=new_warehouse)

    data = {
        'new_warehouse': new_warehouse,
        'warehouses': Warehouse.objects.order_by('name'),
    }

    return render_to_response(
        'warehouses/all.html',
        data,
        context_instance=RequestContext(request),
    )
Пример #8
0
def delete(request, supplier_type):
    supplier_id = int(request.POST.get('entry_id', 0))
    instance = SupplierFactory.create(supplier_type)
    label = capwords(supplier_type)

    try:
        supplier = instance.objects.get(pk=supplier_id)
        supplier.delete()
        messages.success(request, '%s Supplier deleted' % label)
    except instance.DoesNotExist:
        messages.error(request, '%s Supplier with id %i does not exist' % (label, supplier_id))

    if supplier_type == 'foreign':
        data = reverse('suppliers:index-foreign')
    else:
        data = reverse('suppliers:index-local')
    return HttpResponse(data, mimetype="application/javascript")
Пример #9
0
 def testCapwords(self):
     input_one = 'hey you'
     self.assertEquals(capwords(input_one), 'Hey You')
     input_two = 'HEY YOU'
     self.assertEquals(capwords(input_two), 'Hey You')
      
Пример #10
0
 def testCapwords(self):
     input_one = 'hey you'
     self.assertEquals(capwords(input_one), 'Hey You')
     input_two = 'HEY YOU'
     self.assertEquals(capwords(input_two), 'Hey You')