diff --git a/.gitignore b/.gitignore
index 0a52ebe..c3ba23e 100644
--- a/.gitignore
+++ b/.gitignore
@@ -2,6 +2,9 @@
*.pyo
.idea
.tmp
+.tmp/
+.tmp/eml
+.tmp/eml/*
*.sublime-project
*.sublime-workspace
*.db
diff --git a/api/views.py b/api/views.py
index 64e8a5a..5a95fd6 100644
--- a/api/views.py
+++ b/api/views.py
@@ -3,6 +3,8 @@ 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
+from store.models import Product
+
@csrf_exempt
def call_order(request):
@@ -20,3 +22,28 @@ def call_order(request):
except Exception as e:
retval = dict(error=True)
return JsonResponse(retval)
+
+@csrf_exempt
+def order_order(request):
+ retval = dict(error=False)
+
+ try:
+ item = Product.objects.get(pk=request.POST['item'])
+ mail_managers('Заказали товар', '''
+ Товар: {}
+ Имя: {}
+ Телефон: {}
+ Email: {}
+ Комментарий: {}
+ '''.format(
+ item.title,
+ request.POST['name'],
+ request.POST['phone'],
+ request.POST['email'],
+ request.POST['comment'],
+ ))
+ except Exception as e:
+ retval = dict(error=True)
+ return JsonResponse(retval)
+
+
diff --git a/batiskaf/templates/jinja2/base.jinja b/batiskaf/templates/jinja2/base.jinja
index b84add8..6868d42 100644
--- a/batiskaf/templates/jinja2/base.jinja
+++ b/batiskaf/templates/jinja2/base.jinja
@@ -12,7 +12,7 @@
-
+
@@ -238,7 +238,6 @@
{% endif %}
+
{% block footer_scripts %}
@@ -280,7 +317,7 @@
-
+
{% endblock footer_scripts %}
{% block jss %}{% endblock jss %}
{% if messages %}
diff --git a/batiskaf/templates/jinja2/category.jinja b/batiskaf/templates/jinja2/category.jinja
index fda46db..2651be7 100644
--- a/batiskaf/templates/jinja2/category.jinja
+++ b/batiskaf/templates/jinja2/category.jinja
@@ -121,7 +121,7 @@
href="/store/cart/add/?pk={{ product.variations.filter(in_stock__gt=0).order_by('price').first().pk }}&count=1&next={{ request.get_full_path()|urlencode }}"> Добавить в корзину
{% else %}
- Заказать
{% endif %}
diff --git a/batiskaf/templates/jinja2/index.jinja b/batiskaf/templates/jinja2/index.jinja
index 88df00f..2d86c0e 100644
--- a/batiskaf/templates/jinja2/index.jinja
+++ b/batiskaf/templates/jinja2/index.jinja
@@ -109,7 +109,7 @@
href="/store/cart/add/?pk={{ product.variations.filter(in_stock__gt=0).order_by('price').first().pk }}&count=1&next={{ request.get_full_path()|urlencode }}"> Добавить в корзину
{% else %}
- Заказать
{% endif %}
diff --git a/batiskaf/templates/jinja2/product.jinja b/batiskaf/templates/jinja2/product.jinja
index f2f9cc7..b0dab57 100644
--- a/batiskaf/templates/jinja2/product.jinja
+++ b/batiskaf/templates/jinja2/product.jinja
@@ -78,7 +78,9 @@
- Товара нет в наличии
+ Товара нет в наличии
+
Заказать
diff --git a/batiskaf/urls.py b/batiskaf/urls.py
index 49ad281..0100451 100644
--- a/batiskaf/urls.py
+++ b/batiskaf/urls.py
@@ -4,7 +4,7 @@ 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 api.urls import router
from rest_framework import routers
from api.views import *
# Serializers define the API representation.
@@ -24,6 +24,7 @@ urlpatterns = patterns(
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_order/$', 'api.views.order_order'),
url(r'^order/(?P.+)/print/$', order_print,
name='store_order_print'),
@@ -31,7 +32,7 @@ urlpatterns = patterns(
name='store_order_view'),
url(r'^store/', include('store.urls')),
url(r'^account/', include('accounts.urls')),
- url(r'^advantages/$', advantages,name='advantages'),
+ url(r'^advantages/$', advantages, name='advantages'),
url(r'^payment/$', payment, name='payment'),
url(r'^delivery/$', delivery, name='delivery'),
url(r'^contacts/$', contacts, name='contacts'),
diff --git a/static/js/_.js b/static/js/_.js
index 4e58d42..6128d6f 100644
--- a/static/js/_.js
+++ b/static/js/_.js
@@ -230,48 +230,101 @@ $(document).ready(function () {
$('#order-call-link').magnificPopup({
type: 'inline',
preloader: false,
+ });
+ $('.order-order-link').magnificPopup({
+ type: 'inline',
+ preloader: false,
+ callbacks: {
+ open: function () {
+ $('#order-form #id_item').val($(this)[0].ev.attr('data-itemid'));
+ }
+ }
});
- $('#call-form').on('submit', function(){
+ $('#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()){
+ if (!f_name.val()) {
f_name.parent().parent('.form-group').addClass('has-error');
is_full = false;
- }else{
+ } else {
f_name.parent().parent('.form-group').removeClass('has-error');
}
- if (!f_phone.val()){
+ if (!f_phone.val()) {
f_phone.parent().parent('.form-group').addClass('has-error');
is_full = false;
- }else{
+ } else {
f_phone.parent().parent('.form-group').removeClass('has-error');
}
- if (!f_time.val()){
+ if (!f_time.val()) {
f_time.parent().parent('.form-group').addClass('has-error');
is_full = false;
- }else{
+ } else {
f_time.parent().parent('.form-group').removeClass('has-error');
}
- if (is_full){
+ 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;
+ });
+
+ $('#order-form').on('submit', function () {
+ var f_name = $('#order-form #id_name');
+ var f_phone = $('#order-form #id_phone');
+ var f_email = $('#order-form #id_email');
+ var f_comment = $('#order-form #id_comment');
+ var f_item = $('#order-form #id_item');
+ 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 (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")
-
- }
+ type: "POST",
+ url: '/order_order/',
+ data: {
+ name: f_name.val(),
+ phone: f_phone.val(),
+ email: f_email.val(),
+ comment: f_comment.val(),
+ item: f_item.val(),
+ },
+ success: function (data) {
+
+ $.magnificPopup.close();
+ swal("Спасибо!", "Мы приняли вашу заявку! Наш менеджер свяжется с вами в ближайшее время.", "success")
+
+ }
});
}
//form-group has-error
diff --git a/static/less/_.css b/static/less/_.css
index 9cb5175..85dce77 100644
--- a/static/less/_.css
+++ b/static/less/_.css
@@ -942,7 +942,8 @@ ul.messages {
background: #F5F7FA;
padding: 15px;
}
-.call-form {
+.call-form,
+.order-form {
background: #FFF;
padding: 20px 30px;
text-align: left;
diff --git a/static/less/_.less b/static/less/_.less
index f1bf312..09c6ce9 100644
--- a/static/less/_.less
+++ b/static/less/_.less
@@ -815,7 +815,7 @@ ul.messages {
padding: 15px;
}
}
-.call-form {
+.call-form, .order-form {
background: #FFF;
padding: 20px 30px;
text-align: left;