fix callback form

feature/docker
Dmitriy Shesterkin 9 years ago
parent 70e9d880d1
commit f06e38110b
  1. 1
      requirements/base.txt
  2. 12
      src/callback/forms.py
  3. 14
      src/callback/models.py
  4. 2
      src/callback/urls.py
  5. 18
      src/callback/views.py
  6. 1
      src/dokumentor/settings/base.py
  7. 2
      src/dokumentor/static/js/callback.js
  8. 2
      src/dokumentor/templates/callback/callback_form.html
  9. 2
      src/dokumentor/templates/callback/req_avail_new.txt
  10. 0
      src/index_blocks/__init__.py
  11. 84
      src/index_blocks/cms_plugins.py
  12. 32
      src/index_blocks/forms.py
  13. 0
      src/index_blocks/migrations/__init__.py
  14. 28
      src/index_blocks/models.py
  15. 11
      src/index_blocks/templates/desc_block.html
  16. 16
      src/index_blocks/templates/extended_block.html
  17. 17
      src/index_blocks/templates/extended_text_block.html
  18. 12
      src/index_blocks/templates/index_block.html
  19. 15
      src/index_blocks/templates/reg_form.html
  20. 10
      src/index_blocks/templates/slideshow_block.html
  21. 16
      src/index_blocks/tests.py
  22. 1
      src/index_blocks/views.py

@ -50,7 +50,6 @@ pylint==1.6.5
pyparsing==2.2.0
PyPDF2==1.26.0
python-dateutil==2.6.0
python-memcached==1.58
pytils==0.3
pytz==2017.2
reportlab==3.4.0

@ -3,7 +3,7 @@ from django import forms
from captcha.fields import CaptchaField
from . import models
from callback import models
class ReqAvailForm(forms.ModelForm):
@ -16,7 +16,6 @@ class ReqAvailForm(forms.ModelForm):
def __init__(self, *args, **kwargs):
super(ReqAvailForm, self).__init__(*args, **kwargs)
self.fields['name'].label = u'Ваше имя'
self.fields['name'].widget.attrs['placeholder'] = u'Ваше имя, отчество'
self.fields['phone'].widget.attrs['placeholder'] = u'Ваш номер телефона или e-mail'
self.fields['name'].widget.attrs['width'] = u'Ваше имя, отчество'
@ -31,13 +30,4 @@ class ReqAvailForm(forms.ModelForm):
else:
raise forms.ValidationError(u"Заполните все поля")
return cleaned_data
#name = self.cleaned_data.get('name', '').strip()
#phone = self.cleaned_data.get('phone', '').strip()
#if not name:
# raise forms.ValidationError(u'Укажите Ваше имя.')
#if not phone:
# raise forms.ValidationError(u'Укажите Ваш телефон.')
return self.cleaned_data

@ -3,11 +3,10 @@ import os.path
from django.conf import settings
from django.db import models
from django.db.models import Q
class ReqAvail(models.Model):
"""Заказ товара."""
"""Обратная связь"""
NEW_STATUS = 0
DONE_STATUS = 1
@ -20,10 +19,6 @@ class ReqAvail(models.Model):
phone = models.CharField(u'Телефон или e-mail', max_length=50)
message = models.TextField(u'Текст сообщения')
user = models.ForeignKey(settings.AUTH_USER_MODEL, related_name='messages', null=True, blank=True)
# email = models.EmailField(u'E-mail', default='', blank=True)
# region = models.ForeignKey(Region, verbose_name=u"Регион", blank=False, null=False, default='')
#good = models.ForeignKey(CatalogItem, verbose_name=u'Товар', null=True, blank=True)
status = models.PositiveSmallIntegerField(u'Статус', choices=STATUS_CHOICES, default=NEW_STATUS)
status_changed = models.DateTimeField(u'Статус изменен', null=True, blank=True, editable=False)
@ -38,7 +33,12 @@ class ReqAvail(models.Model):
def __unicode__(self):
return u'Сообщение %s от %s' % (
#self.good if self.good_id else u'(Ничего)',
self.name[:20],
self.created_at.strftime("%d.%m.%Y %H:%M"),
)
def __str__(self):
return u'Сообщение %s от %s' % (
self.name[:20],
self.created_at.strftime("%d.%m.%Y %H:%M"),
)

@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
from django.conf.urls import patterns, url
from .views import req_avail
from callback.views import req_avail
urlpatterns = patterns('',
url(r'^send/$', req_avail, name='callback-send-message'),

@ -2,30 +2,26 @@
import json
from django.http import HttpResponseBadRequest, HttpResponse
from django.views.decorators.http import require_POST, require_GET
from django.views.decorators.http import require_POST
from django.views.decorators.csrf import csrf_protect
from django.template.loader import render_to_string
from django.core.mail import send_mail
from django.conf import settings
from .models import ReqAvail
from .forms import ReqAvailForm
from callback.models import ReqAvail
from callback.forms import ReqAvailForm
CALLBACK_SETTINGS = getattr(settings, 'CALLBACK_SETTINGS')
@require_POST
@csrf_protect
def req_avail(request, id=None):
"""Отправить сообщение или обработать запрос наличия товара на складе - AJAX."""
def req_avail(request):
"""Отправить сообщение AJAX."""
if not request.is_ajax():
return HttpResponseBadRequest()
if id:
good = get_object_or_404(CatalogItem, pk=id)
else:
good = None
form = ReqAvailForm(data=request.POST)
if form.is_valid():
@ -36,8 +32,8 @@ def req_avail(request, id=None):
req = ReqAvail.objects.create(
name=form.cleaned_data['name'].strip(),
phone=form.cleaned_data['phone'].strip(),
message=form.cleaned_data['message'],
user=user,
#good=good,
)
# отправить письма менеджерам
@ -49,7 +45,6 @@ def req_avail(request, id=None):
data = {
'success': form.is_valid(),
# 'field_errors': form.errors, # ошибки полей
'form_errors': form.non_field_errors(), # ошибки формы
}
if form.is_valid():
@ -58,4 +53,3 @@ def req_avail(request, id=None):
'msg': u'Ваша Сообщение отправлено!<br />Скоро с Вами свяжется наш менеджер.',
}
return HttpResponse(json.dumps(data), content_type='application/json')

@ -123,6 +123,7 @@ TEMPLATES = [
'django.template.context_processors.csrf',
'sekizai.context_processors.sekizai',
'cms.context_processors.cms_settings',
'callback.context_processors.add_forms'
],
},
},

@ -11,7 +11,7 @@ $(document).ready(function() {
clear_form_errors(form);
}
});
})
});
function show_req_avail_form(action) {
var form = $('#req-avail-form');

@ -1,7 +1,7 @@
<form id="req-avail-form" action="" method="post" title="Задать вопрос">
{% csrf_token %}
<div class='grey-box'>
<div style="margin: 0px 0px 20px 0px;">Оставьте свои контакты и мы перезвоним вам, ответим на все ваши вопросы</div>
<div style="margin: 0 0 20px 0;">Оставьте свои контакты и мы перезвоним вам, ответим на все ваши вопросы</div>
<p>{{ reqf.name }}</p>
<p>{{ reqf.phone }}</p>
<p>{{ reqf.message }}</p>

@ -7,7 +7,7 @@
{% if req.good %}
Название: {{ req.good }}
{% else %}
По общим вопросам
Текст сообщения:
{{ req.message }}
{% endif %}

@ -1,84 +0,0 @@
#-*- coding: utf -8-*-
from cms.plugin_base import CMSPluginBase
from cms.plugin_pool import plugin_pool
from index_blocks.models import IndexBlockPlugin, ExtendedTextBlockPlugin, ExtendedBlockPlugin, DescTextBlockPlugin
from index_blocks.forms import IndexBlockForm, ExtendedBlockForm, ExtendedTextBlockForm, DescBlockForm
from myauth.forms import RegistrationForm
from django.utils.translation import ugettext as _
class CMSIndexBlockPlugin(CMSPluginBase):
model = IndexBlockPlugin
form = IndexBlockForm
name = u'Блок на главной (картинка и текст)'
render_template = "index_block.html"
def render(self, context, instance, placeholder):
context.update({
'object':instance,
'placeholder':placeholder
})
return context
class CMSExtendedTextBlockPlugin(CMSPluginBase):
model = ExtendedTextBlockPlugin
form = ExtendedTextBlockForm
name = u'Раскрывающийся блок'
render_template = "extended_text_block.html"
def render(self, context, instance, placeholder):
context.update({
'object':instance,
'placeholder':placeholder
})
return context
class CMSExtendedBlockPlugin(CMSPluginBase):
model = ExtendedBlockPlugin
form = ExtendedBlockForm
name = u'Раскрывающийся блок с картинкой'
render_template = "extended_block.html"
def render(self, context, instance, placeholder):
context.update({
'object':instance,
'placeholder':placeholder
})
return context
class CMSDescTextBlockPlugin(CMSPluginBase):
model = DescTextBlockPlugin
form = ExtendedBlockForm
name = u'Заголовок/описание'
render_template = "desc_block.html"
def render(self, context, instance, placeholder):
context.update({
'object':instance,
'placeholder':placeholder
})
return context
class CMSSlideshowBlockPlugin(CMSPluginBase):
model = IndexBlockPlugin
form = IndexBlockForm
name = u'Кадр слайдшоу'
render_template = "slideshow_block.html"
def render(self, context, instance, placeholder):
context.update({
'object':instance,
'placeholder':placeholder
})
return context
plugin_pool.register_plugin(CMSExtendedTextBlockPlugin)
# plugin_pool.register_plugin(CMSIndexBlockPlugin)
plugin_pool.register_plugin(CMSExtendedBlockPlugin)
plugin_pool.register_plugin(CMSDescTextBlockPlugin)
# plugin_pool.register_plugin(CMSSlideshowBlockPlugin)

@ -1,32 +0,0 @@
from django.forms.models import ModelForm
from .models import IndexBlockPlugin, ExtendedTextBlockPlugin, ExtendedBlockPlugin, DescTextBlockPlugin
from django import forms
class IndexBlockForm(ModelForm):
class Meta:
model = IndexBlockPlugin
exclude = ('page', 'position', 'placeholder', 'language', 'plugin_type')
class ExtendedTextBlockForm(ModelForm):
class Meta:
model = ExtendedTextBlockPlugin
exclude = ('page', 'position', 'placeholder', 'language', 'plugin_type')
class ExtendedBlockForm(ModelForm):
class Meta:
model = ExtendedBlockPlugin
exclude = ('page', 'position', 'placeholder', 'language', 'plugin_type')
class DescBlockForm(ModelForm):
class Meta:
model = ExtendedBlockPlugin
exclude = ('page', 'position', 'placeholder', 'language', 'plugin_type')

@ -1,28 +0,0 @@
from django.db import models
from cms.models.pluginmodel import CMSPlugin
from djangocms_text_ckeditor.fields import HTMLField
class IndexBlockPlugin(CMSPlugin):
image = models.ImageField(upload_to="uploads/images/")
title = models.CharField(max_length=100)
description = models.TextField()
class DescTextBlockPlugin(CMSPlugin):
title = models.CharField(max_length=100)
description = models.TextField()
class ExtendedTextBlockPlugin(CMSPlugin):
order = models.PositiveIntegerField(default=1)
title = models.CharField(max_length=100)
description = HTMLField()
extended_description = HTMLField()
class ExtendedBlockPlugin(CMSPlugin):
image = models.ImageField(upload_to="uploads/images/")
title = models.CharField(max_length=100)
description = models.TextField()
extended_description = models.TextField()

@ -1,11 +0,0 @@
{% load thumbnail %}
<article class='desc-block'>
<div class='desc-block-text'>
<a href="#">{{ object.title }}</a>
</div>
<div class='desc-triangle hidden'></div>
<div class='clear'></div>
<div class='desc-block-more hidden'>
{{ object.description|safe }}
</div>
</article>

@ -1,16 +0,0 @@
{% load thumbnail %}
<article class='extended-block'>
<div class='extended-block-img left'>
{% thumbnail object.image.name "190x132" crop="center" as img %}
<img src="{{ img.url }}" width="{{ img.width }}" height="{{ img.height }}" {% if picture.alt %}alt="{{ picture.alt }}" {% endif %}{% if picture.longdesc %}title="{{ picture.longdesc }}" {% endif %}/>
</div>
<div class='extended-block-text extended-block-toggle'>
<h3>{{ object.title }}</h3>
{{ object.description|safe }}
</div>
<div class='extended-block-more extended-block-toggle hidden'>
<h3>{{ object.title }}</h3>
{{ object.extended_description|safe }}
</div>
<div class='clear'></div>
</article>

@ -1,17 +0,0 @@
{% load thumbnail %}
<article class='extended-block'>
<div class='extended-block-text'>
<div class='order left'>{{ object.order }}</div>
<div class='left text'>
<h3>{{ object.title }}</h3>
{{ object.description|safe }}
</div>
</div>
<div class='extended-triangle hidden'></div>
<div class='clear'></div>
<div class='extended-block-more hidden'>
<div class="text">
{{ object.extended_description|safe }}
</div>
</div>
</article>

@ -1,12 +0,0 @@
{% load thumbnail %}
<article class='index-block left'>
<div class='index-block-img'>
{% thumbnail object.image.name "250x110" crop="center" as img %}
<img src="{{ img.url }}" width="{{ img.width }}" height="{{ img.height }}" {% if picture.alt %}alt="{{ picture.alt }}" {% endif %}{% if picture.longdesc %}title="{{ picture.longdesc }}" {% endif %}/>
{% endthumbnail %}
</div>
<div class='index-block-text'>
<h3>{{ object.title }}</h3>
{{ object.description|safe }}
</div>
</article>

@ -1,15 +0,0 @@
{% load thumbnail %}
<article class='desc-block'>
<div class='desc-block-text'>
<div class='left text'>
<a href="#">{{ object.title }}</a>
</div>
</div>
<div class='desc-triangle hidden'></div>
<div class='clear'></div>
<div class='desc-block-more hidden'>
<div class="text">
{{ object.description|safe }}
</div>
</div>
</article>

@ -1,10 +0,0 @@
{% load thumbnail %}
<li>
{% thumbnail object.image.name "650x450" crop="center" as img %}
<img src="{{ img.url }}" width="{{ img.width }}" height="{{ img.height }}" {% if picture.alt %}alt="{{ picture.alt }}" {% endif %}{% if picture.longdesc %}title="{{ picture.longdesc }}" {% endif %}/>
{% endthumbnail %}
<div class='index-banner-caption'>
{% if object.title %}<h1>{{ object.title }}</h1>{% endif %}
{{ object.description|safe|default:'' }}
</div>
</li>

@ -1,16 +0,0 @@
"""
This file demonstrates writing tests using the unittest module. These will pass
when you run "manage.py test".
Replace this with more appropriate tests for your application.
"""
from django.test import TestCase
class SimpleTest(TestCase):
def test_basic_addition(self):
"""
Tests that 1 + 1 always equals 2.
"""
self.assertEqual(1 + 1, 2)

@ -1 +0,0 @@
# Create your views here.
Loading…
Cancel
Save