Skip to content

Instantly share code, notes, and snippets.

@bekatom
Last active August 29, 2015 14:08
Show Gist options
  • Select an option

  • Save bekatom/275692800eb5b93640e2 to your computer and use it in GitHub Desktop.

Select an option

Save bekatom/275692800eb5b93640e2 to your computer and use it in GitHub Desktop.
Vobi API get store list by company identification JQUERY AND DJANGO
$(document).ready(function() {
// GETS Store list by compnay identification
$.get("/get-store-list/" + $("#company-identity").val() ,
function (data) {
var result = data.Result;
$.each(result, function(i, item) {
$('#sales-store-list').append($('<option></option>').val(result[i].Id).html(result[i].Name));
});
});
});
# -*- coding: utf-8 -*-
__author__ = 'Beka'
from django.http import HttpResponse
from apps.dictionaries.models import Companies
from openvobi.settings import VOBI_API_HEADERS
from django.contrib.auth.decorators import login_required
import requests
import json
@login_required()
def get_store_list(request, identification=None):
company = Companies.objects.get(identification=identification)
url = '%s/GetStoreListRequest' % company.server_api_host
params = {
"ClientHeader": {"UserName": company.api_user, "Password": company.api_pass, "Database": company.database}}
r = requests.post(url, data=json.dumps(params), headers=VOBI_API_HEADERS)
json_response = json.dumps(r.json())
return HttpResponse(json_response, "application/json")
# IN URLS.PY FILE
url(r'^get-store-list/(?P<identification>\d+)/', 'apps.vobi_api.dictionaries.get_store_list',
name='Get store list'),
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment