|
|
|
|
@ -1,4 +1,6 @@ |
|
|
|
|
import base64 |
|
|
|
|
import json |
|
|
|
|
|
|
|
|
|
from django.contrib.auth import authenticate, login |
|
|
|
|
from django.core.mail import mail_managers, mail_admins |
|
|
|
|
from django.core.paginator import Paginator, PageNotAnInteger, EmptyPage |
|
|
|
|
@ -19,6 +21,8 @@ from django.http import JsonResponse |
|
|
|
|
from datetime import datetime |
|
|
|
|
from django.conf import settings |
|
|
|
|
from django.contrib.sitemaps import Sitemap |
|
|
|
|
import xml.etree.ElementTree as ET |
|
|
|
|
from django.http import HttpResponse |
|
|
|
|
import kkb |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -192,7 +196,8 @@ class ProductView(CategoryBaseView, DetailView): |
|
|
|
|
p = Product.objects.get(slug=i) |
|
|
|
|
if p not in retval['ranee']: |
|
|
|
|
retval['ranee'].append(p) |
|
|
|
|
except: pass |
|
|
|
|
except: |
|
|
|
|
pass |
|
|
|
|
# import pdb;pdb.set_trace() |
|
|
|
|
if retval['ranee']: |
|
|
|
|
retval['ranee'] = retval['ranee'][::-1][:4] |
|
|
|
|
@ -375,7 +380,6 @@ def get_order_amount(request): |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def get_kazpost_tarif(weight, to): |
|
|
|
|
|
|
|
|
|
import requests |
|
|
|
|
import re |
|
|
|
|
|
|
|
|
|
@ -464,6 +468,58 @@ def kkb_result(request): |
|
|
|
|
return render(request, 'kkb_ok.jinja') |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def get_dpd_cities(request, *args, **kwargs): |
|
|
|
|
import requests |
|
|
|
|
|
|
|
|
|
url = "http://ws.dpd.ru/services/geography2?wsdl" |
|
|
|
|
headers = {'content-type': 'text/xml'} |
|
|
|
|
body = """<soapenv:Envelope |
|
|
|
|
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" |
|
|
|
|
xmlns:ns="http://dpd.ru/ws/geography/2015-05-20"> |
|
|
|
|
<soapenv:Header/> |
|
|
|
|
<soapenv:Body> |
|
|
|
|
<ns:getCitiesCashPay> |
|
|
|
|
<request> |
|
|
|
|
<auth> |
|
|
|
|
<clientNumber>{clientID}</clientNumber> |
|
|
|
|
<clientKey>{clientKey}</clientKey> |
|
|
|
|
</auth> |
|
|
|
|
<countryCode>KZ</countryCode> |
|
|
|
|
</request> |
|
|
|
|
</ns:getCitiesCashPay> |
|
|
|
|
</soapenv:Body> |
|
|
|
|
</soapenv:Envelope> |
|
|
|
|
""" |
|
|
|
|
places = list() |
|
|
|
|
search = request.GET.get('search', '') |
|
|
|
|
|
|
|
|
|
body = body.format(clientID=settings.DPD_ID, clientKey=settings.DPD_KEY) |
|
|
|
|
try: |
|
|
|
|
response = requests.post(url, data=body, headers=headers) |
|
|
|
|
elements = ET.fromstring(response.content).findall(".//return") |
|
|
|
|
|
|
|
|
|
if search: |
|
|
|
|
for el in elements: |
|
|
|
|
if search.lower() in el.find('.//cityName').text.lower(): |
|
|
|
|
add_items(el, places) |
|
|
|
|
else: |
|
|
|
|
for el in elements: |
|
|
|
|
add_items(el, places) |
|
|
|
|
|
|
|
|
|
data = json.dumps(places) |
|
|
|
|
except: |
|
|
|
|
data = json.dumps({'msg': 'false'}) |
|
|
|
|
return HttpResponse(data, content_type='json') |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def add_items(el, places): |
|
|
|
|
places.append({'id': el.find('.//cityId').text, |
|
|
|
|
'text': '{0} {1}'.format( |
|
|
|
|
el.find('.//abbreviation').text, |
|
|
|
|
el.find('.//cityName').text |
|
|
|
|
)}) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class ProductSitemap(Sitemap): |
|
|
|
|
changefreq = "daily" |
|
|
|
|
priority = 0.8 |
|
|
|
|
|