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 @@
- -
@@ -116,19 +126,19 @@ {% for child in category.get_childs_ordered_by_count()|batch(2) %}
- {% for col in child %} - + {% endfor %}
@@ -142,147 +152,6 @@ {% endfor %} - {# #} - {# #} - {# #} - {# #} - {# #} - {# #} - {# #} - {# #} @@ -343,7 +212,9 @@

- Карта сайта  |  Поисковые запросы  |  Поиск  |  Контакты  |  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.+)/print/$', order_print, name='store_order_print'), diff --git a/main/backends/__init__.py b/main/backends/__init__.py new file mode 100644 index 0000000..15fc2ed --- /dev/null +++ b/main/backends/__init__.py @@ -0,0 +1 @@ +__author__ = 'OG' diff --git a/main/backends/email_backends.py b/main/backends/email_backends.py new file mode 100644 index 0000000..94d83dc --- /dev/null +++ b/main/backends/email_backends.py @@ -0,0 +1,13 @@ +from __future__ import absolute_import +import datetime +import os +from django.core.mail.backends import filebased + + +class EmailBackend(filebased.EmailBackend): + def _get_filename(self): + if self._fname is None: + timestamp = datetime.datetime.now().strftime("%Y%m%d-%H%M%S") + fname = "%s-%s.eml" % (timestamp, abs(id(self))) + self._fname = os.path.join(self.file_path, fname) + return self._fname diff --git a/static/js/_.js b/static/js/_.js index 679f5c4..4e58d42 100644 --- a/static/js/_.js +++ b/static/js/_.js @@ -226,21 +226,57 @@ $(document).ready(function () { selectCity(); }); - //swal({ - // title: "Заказать бесплатный звонок", - // text: "Write something interesting:", - // type: "input", - // showCancelButton: true, - // closeOnConfirm: false, - // animation: "slide-from-top", - // inputPlaceholder: "Write something" - //}, function (inputValue) { - // if (inputValue === false) return false; - // if (inputValue === "") { - // swal.showInputError("You need to write something!"); - // return false - // } - // swal("Nice!", "You wrote: " + inputValue, "success"); - //}); - -}); \ No newline at end of file + + $('#order-call-link').magnificPopup({ + type: 'inline', + preloader: false, + + }); + + $('#call-form').on('submit', function(){ + var f_name = $('#call-form #id_name'); + var f_phone = $('#call-form #id_phone'); + var f_time = $('#call-form #id_time'); + var is_full = true; + + if (!f_name.val()){ + f_name.parent().parent('.form-group').addClass('has-error'); + is_full = false; + }else{ + f_name.parent().parent('.form-group').removeClass('has-error'); + } + if (!f_phone.val()){ + f_phone.parent().parent('.form-group').addClass('has-error'); + is_full = false; + }else{ + f_phone.parent().parent('.form-group').removeClass('has-error'); + } + if (!f_time.val()){ + f_time.parent().parent('.form-group').addClass('has-error'); + is_full = false; + }else{ + f_time.parent().parent('.form-group').removeClass('has-error'); + } + if (is_full){ + $.ajax({ + type: "POST", + url: '/order_call/', + data: { + name: f_name.val(), + phone: f_phone.val(), + time: f_time.val(), + }, + success: function(data){ + + $.magnificPopup.close(); + swal("Спасибо!", "Мы приняли вашу заявку! Наш менеджер свяжется с вами в указанное время.", "success") + + } + }); + } + //form-group has-error + return false; + }) + +}) +; \ No newline at end of file diff --git a/static/less/_.css b/static/less/_.css index 03c1482..9cb5175 100644 --- a/static/less/_.css +++ b/static/less/_.css @@ -942,3 +942,11 @@ ul.messages { background: #F5F7FA; padding: 15px; } +.call-form { + background: #FFF; + padding: 20px 30px; + text-align: left; + max-width: 500px; + margin: 40px auto; + position: relative; +} diff --git a/static/less/_.less b/static/less/_.less index bead9f7..f1bf312 100644 --- a/static/less/_.less +++ b/static/less/_.less @@ -814,4 +814,13 @@ ul.messages { background: #F5F7FA; padding: 15px; } -} \ No newline at end of file +} +.call-form { + background: #FFF; + padding: 20px 30px; + text-align: left; + max-width: 500px; + margin: 40px auto; + position: relative +} +