Last active
August 29, 2015 14:08
-
-
Save bekatom/275692800eb5b93640e2 to your computer and use it in GitHub Desktop.
Vobi API get store list by company identification JQUERY AND DJANGO
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| $(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)); | |
| }); | |
| }); | |
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # -*- 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") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # 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