diff --git a/requirements/base.txt b/requirements/base.txt index dc3d649..eed5e99 100644 --- a/requirements/base.txt +++ b/requirements/base.txt @@ -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 diff --git a/src/callback/forms.py b/src/callback/forms.py index 3e02291..367aada 100644 --- a/src/callback/forms.py +++ b/src/callback/forms.py @@ -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 diff --git a/src/callback/models.py b/src/callback/models.py index c882733..073bb35 100644 --- a/src/callback/models.py +++ b/src/callback/models.py @@ -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"), ) diff --git a/src/callback/urls.py b/src/callback/urls.py index 8945254..fbae108 100644 --- a/src/callback/urls.py +++ b/src/callback/urls.py @@ -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'), diff --git a/src/callback/views.py b/src/callback/views.py index ef0073c..d79e3e4 100644 --- a/src/callback/views.py +++ b/src/callback/views.py @@ -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'Ваша Сообщение отправлено!
Скоро с Вами свяжется наш менеджер.', } return HttpResponse(json.dumps(data), content_type='application/json') - diff --git a/src/dokumentor/settings/base.py b/src/dokumentor/settings/base.py index 27a5ed1..0559d83 100644 --- a/src/dokumentor/settings/base.py +++ b/src/dokumentor/settings/base.py @@ -123,6 +123,7 @@ TEMPLATES = [ 'django.template.context_processors.csrf', 'sekizai.context_processors.sekizai', 'cms.context_processors.cms_settings', + 'callback.context_processors.add_forms' ], }, }, diff --git a/src/dokumentor/static/js/callback.js b/src/dokumentor/static/js/callback.js index 564f6c8..4903def 100644 --- a/src/dokumentor/static/js/callback.js +++ b/src/dokumentor/static/js/callback.js @@ -11,7 +11,7 @@ $(document).ready(function() { clear_form_errors(form); } }); -}) +}); function show_req_avail_form(action) { var form = $('#req-avail-form'); diff --git a/src/dokumentor/templates/callback/callback_form.html b/src/dokumentor/templates/callback/callback_form.html index 174362a..c0ebad0 100644 --- a/src/dokumentor/templates/callback/callback_form.html +++ b/src/dokumentor/templates/callback/callback_form.html @@ -1,7 +1,7 @@
{% csrf_token %}
-
Оставьте свои контакты и мы перезвоним вам, ответим на все ваши вопросы
+
Оставьте свои контакты и мы перезвоним вам, ответим на все ваши вопросы

{{ reqf.name }}

{{ reqf.phone }}

{{ reqf.message }}

diff --git a/src/dokumentor/templates/callback/req_avail_new.txt b/src/dokumentor/templates/callback/req_avail_new.txt index 15c26d2..d87b692 100644 --- a/src/dokumentor/templates/callback/req_avail_new.txt +++ b/src/dokumentor/templates/callback/req_avail_new.txt @@ -7,7 +7,7 @@ {% if req.good %} Название: {{ req.good }} {% else %} -По общим вопросам +Текст сообщения: {{ req.message }} {% endif %} diff --git a/src/index_blocks/__init__.py b/src/index_blocks/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/src/index_blocks/cms_plugins.py b/src/index_blocks/cms_plugins.py deleted file mode 100644 index 4e1d628..0000000 --- a/src/index_blocks/cms_plugins.py +++ /dev/null @@ -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) diff --git a/src/index_blocks/forms.py b/src/index_blocks/forms.py deleted file mode 100644 index b39f373..0000000 --- a/src/index_blocks/forms.py +++ /dev/null @@ -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') - diff --git a/src/index_blocks/migrations/__init__.py b/src/index_blocks/migrations/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/src/index_blocks/models.py b/src/index_blocks/models.py deleted file mode 100644 index d54a2d7..0000000 --- a/src/index_blocks/models.py +++ /dev/null @@ -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() diff --git a/src/index_blocks/templates/desc_block.html b/src/index_blocks/templates/desc_block.html deleted file mode 100644 index 797eaf5..0000000 --- a/src/index_blocks/templates/desc_block.html +++ /dev/null @@ -1,11 +0,0 @@ -{% load thumbnail %} - diff --git a/src/index_blocks/templates/extended_block.html b/src/index_blocks/templates/extended_block.html deleted file mode 100644 index 8cccef2..0000000 --- a/src/index_blocks/templates/extended_block.html +++ /dev/null @@ -1,16 +0,0 @@ -{% load thumbnail %} -
-
- {% thumbnail object.image.name "190x132" crop="center" as img %} - -
-
-

{{ object.title }}

- {{ object.description|safe }} -
- -
-
diff --git a/src/index_blocks/templates/extended_text_block.html b/src/index_blocks/templates/extended_text_block.html deleted file mode 100644 index 04cf97b..0000000 --- a/src/index_blocks/templates/extended_text_block.html +++ /dev/null @@ -1,17 +0,0 @@ -{% load thumbnail %} -
-
-
{{ object.order }}
-
-

{{ object.title }}

- {{ object.description|safe }} -
-
- -
- -
diff --git a/src/index_blocks/templates/index_block.html b/src/index_blocks/templates/index_block.html deleted file mode 100644 index 5f790f1..0000000 --- a/src/index_blocks/templates/index_block.html +++ /dev/null @@ -1,12 +0,0 @@ -{% load thumbnail %} -
-
- {% thumbnail object.image.name "250x110" crop="center" as img %} - - {% endthumbnail %} -
-
-

{{ object.title }}

- {{ object.description|safe }} -
-
\ No newline at end of file diff --git a/src/index_blocks/templates/reg_form.html b/src/index_blocks/templates/reg_form.html deleted file mode 100644 index 1f8f470..0000000 --- a/src/index_blocks/templates/reg_form.html +++ /dev/null @@ -1,15 +0,0 @@ -{% load thumbnail %} - diff --git a/src/index_blocks/templates/slideshow_block.html b/src/index_blocks/templates/slideshow_block.html deleted file mode 100644 index 146a1f6..0000000 --- a/src/index_blocks/templates/slideshow_block.html +++ /dev/null @@ -1,10 +0,0 @@ -{% load thumbnail %} -
  • - {% thumbnail object.image.name "650x450" crop="center" as img %} - - {% endthumbnail %} -
    - {% if object.title %}

    {{ object.title }}

    {% endif %} - {{ object.description|safe|default:'' }} -
    -
  • diff --git a/src/index_blocks/tests.py b/src/index_blocks/tests.py deleted file mode 100644 index 501deb7..0000000 --- a/src/index_blocks/tests.py +++ /dev/null @@ -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) diff --git a/src/index_blocks/views.py b/src/index_blocks/views.py deleted file mode 100644 index 60f00ef..0000000 --- a/src/index_blocks/views.py +++ /dev/null @@ -1 +0,0 @@ -# Create your views here.