diff --git a/.gitignore b/.gitignore index 6a591b3..0a52ebe 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,7 @@ *.pyc *.pyo .idea +.tmp *.sublime-project *.sublime-workspace *.db diff --git a/api/urls.py b/api/urls.py index 2500ff9..bedaed1 100644 --- a/api/urls.py +++ b/api/urls.py @@ -1,15 +1,5 @@ from django.conf.urls import url, include from .views import * -from rest_framework import routers - -# Serializers define the API representation. - -# Routers provide an easy way of automatically determining the URL conf. -router = routers.DefaultRouter() -router.register(r'cart', CartViewSet) # Wire up our API using automatic URL routing. # Additionally, we include login URLs for the browsable API. -urlpatterns = [ - url(r'^', include(router.urls)), -] diff --git a/api/views.py b/api/views.py index 01448a7..64e8a5a 100644 --- a/api/views.py +++ b/api/views.py @@ -1,12 +1,22 @@ -from rest_framework import serializers, viewsets - - -class CartSerializer(serializers.Serializer): - session = serializers.CharField(max_length=500) - items = serializers.CharField(max_length=500) - - -class CartViewSet(viewsets.ViewSet): - serializer_class = CartSerializer - +from django.core.mail import mail_managers +from django.http import JsonResponse +from rest_framework.response import Response +from rest_framework.decorators import api_view +from django.views.decorators.csrf import csrf_exempt +@csrf_exempt +def call_order(request): + retval = dict(error=False) + try: + mail_managers('Заказали звонок', ''' + Имя: {} + Телефон: {} + Время: {} + '''.format( + request.POST['name'], + request.POST['phone'], + request.POST['time'], + )) + except Exception as e: + retval = dict(error=True) + return JsonResponse(retval) diff --git a/batiskaf/settings.py b/batiskaf/settings.py index ebb09c4..0d33a4a 100644 --- a/batiskaf/settings.py +++ b/batiskaf/settings.py @@ -19,7 +19,10 @@ ADMINS = ( ('spacenergy', 'spacenergy@me.com'), ) -MANAGERS = ADMINS +MANAGERS = ( + ('spacenergy', 'spacenergy@me.com'), + ('admin', 'admin@batiskaf-kz.kz'), +) # Quick-start development settings - unsuitable for production # See https://docs.djangoproject.com/en/1.7/howto/deployment/checklist/ diff --git a/batiskaf/templates/jinja2/base.jinja b/batiskaf/templates/jinja2/base.jinja index 1a83a73..fbbdd4d 100644 --- a/batiskaf/templates/jinja2/base.jinja +++ b/batiskaf/templates/jinja2/base.jinja @@ -16,6 +16,7 @@ + {% block stylesheet %}{% endblock stylesheet %} @@ -67,12 +68,20 @@
Мой аккаунт | Новости | Моя корзина {% if (request|cart).items|length > 0 %} - {{ (request|cart).items|length }}{% endif %} | Войти
+ {{ (request|cart).items|length }}{% endif %} | Войти- Карта сайта | Поисковые запросы | Поиск | Контакты | RSS + Карта сайта | Поисковые запросы | Поиск | Контакты | RSS
@@ -365,6 +236,37 @@ {% endfor %} {% endif %} +
{% block footer_scripts %} @@ -377,6 +279,7 @@ + {% endblock footer_scripts %} {% block jss %}{% endblock jss %} diff --git a/batiskaf/urls.py b/batiskaf/urls.py index bf9c759..49ad281 100644 --- a/batiskaf/urls.py +++ b/batiskaf/urls.py @@ -1,7 +1,16 @@ from django.conf.urls import patterns, include, url from django.contrib import admin +from api.views import call_order from store.views import order_view, order_print from main.views import * +from rest_framework import routers +#from api.urls import router +from rest_framework import routers +from api.views import * +# Serializers define the API representation. + +# Routers provide an easy way of automatically determining the URL conf. +router = routers.DefaultRouter(trailing_slash=True) admin.site.site_header = 'Админка Batiskaf-kz.kz' admin.site.site_title = 'Админка Batiskaf-kz.kz' @@ -11,8 +20,10 @@ urlpatterns = patterns( '', url(r'^$', 'main.views.index', name='index'), + url(r'^api/', include(router.urls)), url(r'^news/', include('news.urls')), url(r'^get_order_amount/$', 'store.views.get_order_amount'), + url(r'^order_call/$', 'api.views.call_order'), url(r'^order/(?P