parent
c964782f4d
commit
618688a069
11 changed files with 340 additions and 31 deletions
@ -0,0 +1,52 @@ |
||||
# -*- coding: utf-8 -*- |
||||
from django import forms |
||||
from django.utils.translation import ugettext_lazy as _ |
||||
from ckeditor.widgets import CKEditorWidget |
||||
from emencia.django.newsletter.models import Contact, ContactSettings, MailingList, Newsletter |
||||
from city.models import City |
||||
|
||||
|
||||
class ContactSettingsForm(forms.ModelForm): |
||||
city = forms.CharField(label=u'Город', widget=forms.HiddenInput() ,required=False) |
||||
periodic = forms.ChoiceField(choices=ContactSettings.PERIODIC_CHOICES, |
||||
label=_(u'Периодичность отправки')) |
||||
first_name = forms.CharField(label=_('first name')) |
||||
subscriber = forms.BooleanField(label=_('subscriber'), required=False) |
||||
valid = forms.BooleanField(label=_('valid email'), required=False) |
||||
tester = forms.BooleanField(label=_('contact tester'), required=False) |
||||
|
||||
class Meta: |
||||
model = ContactSettings |
||||
fields = ('periodic', 'exponent_practicum', 'organiser_practicum', 'theme', 'area', 'country', 'city', ) |
||||
|
||||
def save(self, commit=True): |
||||
contactsettings = super(ContactSettingsForm, self).save(commit=False) |
||||
if commit: |
||||
contactsettings.save() |
||||
contact = contactsettings.contact |
||||
contact.first_name = self.cleaned_data['first_name'] |
||||
contact.subscriber = self.cleaned_data['subscriber'] |
||||
contact.valid = self.cleaned_data['valid'] |
||||
contact.tester = self.cleaned_data['tester'] |
||||
contact.save() |
||||
return contactsettings |
||||
|
||||
def clean_periodic(self): |
||||
|
||||
return int(self.cleaned_data['periodic']) |
||||
|
||||
def clean_city(self): |
||||
return City.objects.none() |
||||
|
||||
class MailingListForm(forms.ModelForm): |
||||
class Meta: |
||||
model = MailingList |
||||
fields = ('name', 'description') |
||||
|
||||
class NewsletterForm(forms.ModelForm): |
||||
test_contacts = forms.CharField(label=u'Тестовые контакты', widget=forms.HiddenInput(), required=False) |
||||
content = forms.CharField(label=_('content'), widget=CKEditorWidget(config_name='newsletters')) |
||||
class Meta: |
||||
model = Newsletter |
||||
fields = ('title', 'content', 'mailing_list', 'test_contacts', 'header_sender', |
||||
'header_reply', 'status', 'sending_date', 'slug') |
||||
@ -0,0 +1,46 @@ |
||||
{% extends 'admin/base.html' %} |
||||
{% load static %} |
||||
|
||||
{% block scripts %} |
||||
<script src="{% static 'ckeditor/ckeditor/ckeditor.js' %}"></script> |
||||
<link href="{% static 'js/select/select2.css' %}" rel="stylesheet"/> |
||||
<script src="{% static 'js/select/select2.js' %}"></script> |
||||
<script> |
||||
$(function(){ |
||||
|
||||
$('#id_theme').select2({width: "element"}); |
||||
$('#id_country').select2({width: "element"}); |
||||
|
||||
}) |
||||
</script> |
||||
{% endblock %} |
||||
|
||||
|
||||
{% block body %} |
||||
|
||||
<form method="post" class="form-horizontal" name="form2" id="form2" enctype="multipart/form-data"> {% csrf_token %} |
||||
<fieldset> |
||||
|
||||
<div class="box span10"> |
||||
<div class="box-header well"> |
||||
<h2><i class="icon-pencil"></i>Изменения подписчика {{ object.contact.email }}</h2> |
||||
</div> |
||||
<div class="box-content"> |
||||
{% for field in form %} |
||||
<div class="control-group {% if field.errors %}error{% endif %}"> |
||||
<label class="control-label">{% if field.field.required %}<b>{{ field.label }}:</b>{% else %}{{ field.label }}{% endif %}</label> |
||||
<div class="controls">{{ field }} |
||||
<span class="help-inline">{{ field.errors }}</span> |
||||
</div> |
||||
</div> |
||||
{% endfor %} |
||||
</div> |
||||
</div> |
||||
</fieldset> |
||||
|
||||
<div class="controls"> |
||||
<input class="btn btn-large btn-primary" type="submit" value="Готово"> |
||||
<input class="btn btn-large" type="reset" value="Отмена"> |
||||
</div> |
||||
</form> |
||||
{% endblock %} |
||||
@ -1,10 +1,47 @@ |
||||
<!DOCTYPE html> |
||||
<html> |
||||
<head lang="en"> |
||||
<meta charset="UTF-8"> |
||||
<title></title> |
||||
</head> |
||||
<body> |
||||
контакты список |
||||
</body> |
||||
</html> |
||||
{% extends 'admin/base.html' %} |
||||
|
||||
{% block body %} |
||||
|
||||
<div class="box span10"> |
||||
<div class="box-header well"> |
||||
<h2><i class="icon-arrow-down"></i>Список контактов</h2> |
||||
</div> |
||||
<div class="box-content"> |
||||
|
||||
<table class="table table-hover"> |
||||
|
||||
<thead> |
||||
<tr> |
||||
<th>Email</th> |
||||
<th>Имя</th> |
||||
<th>Тестер</th> |
||||
<th>Подписчик</th> |
||||
<th>Потверждена подписка</th> |
||||
<th>Дата создания</th> |
||||
<th>Дата редактирования</th> |
||||
<th> </th> |
||||
</tr> |
||||
</thead> |
||||
<tbody> |
||||
{% for item in object_list %} |
||||
<tr> |
||||
<td>{{ item.email }}</td> |
||||
<td>{{ item.first_name }}</td> |
||||
<td>{% if item.tester %}<span class="label label-success">да</span>{% else %}<span class="label label-important">нет</span>{% endif %}</td> |
||||
<td>{% if item.subscriber %}<span class="label label-success">да</span>{% else %}<span class="label label-important">нет</span>{% endif %}</td> |
||||
<td>{% if item.activated %}<span class="label label-success">да</span>{% else %}<span class="label label-important">нет</span>{% endif %}</td> |
||||
<td>{{ item.creation_date|date:"Y-m-d H:i" }}</td> |
||||
<td>{{ item.modification_date|date:"Y-m-d H:i" }}</td> |
||||
|
||||
<td><a href="{% url 'newsletters_contact_update' item.contactsettings.id %}">Изменить</a> </td> |
||||
</tr> |
||||
{% endfor %} |
||||
</tbody> |
||||
</table> |
||||
|
||||
</div> |
||||
{# pagination #} |
||||
{% include 'admin/includes/admin_pagination.html' with page_obj=object_list %} |
||||
</div> |
||||
|
||||
{% endblock %} |
||||
@ -0,0 +1,39 @@ |
||||
{% extends 'admin/base.html' %} |
||||
|
||||
{% block body %} |
||||
|
||||
<div class="box span10"> |
||||
<div class="box-header well"> |
||||
<h2><i class="icon-arrow-down"></i>Списки рассылок</h2> |
||||
</div> |
||||
<div class="box-content"> |
||||
|
||||
<table class="table table-hover"> |
||||
|
||||
<thead> |
||||
<tr> |
||||
<th>Название</th> |
||||
<th>Подписчиков</th> |
||||
<th>Отписалось</th> |
||||
<th> </th> |
||||
</tr> |
||||
</thead> |
||||
<tbody> |
||||
{% for item in object_list %} |
||||
<tr> |
||||
<td>{{ item.name }}</td> |
||||
<td>{{ item.subscribers_count }}</td> |
||||
<td>{{ item.unsubscribers_count }}</td> |
||||
|
||||
<td><a href="{% url 'newsletters_mailinglist_update' item.id %}">Изменить</a> </td> |
||||
</tr> |
||||
{% endfor %} |
||||
</tbody> |
||||
</table> |
||||
<a class="btn btn-success" href="{% url 'newsletters_mailinglist_create' %}"><i class="icon-plus-sign icon-white"></i> Добавить новый список</a> |
||||
</div> |
||||
{# pagination #} |
||||
{% include 'admin/includes/admin_pagination.html' with page_obj=object_list %} |
||||
</div> |
||||
|
||||
{% endblock %} |
||||
@ -0,0 +1,31 @@ |
||||
{% extends 'admin/base.html' %} |
||||
{% load static %} |
||||
|
||||
{% block body %} |
||||
|
||||
<form method="post" class="form-horizontal" name="form2" id="form2" enctype="multipart/form-data"> {% csrf_token %} |
||||
<fieldset> |
||||
|
||||
<div class="box span10"> |
||||
<div class="box-header well"> |
||||
<h2><i class="icon-pencil"></i>{% if object %}Изменения{% else %}Создание{% endif %} списка рассылок</h2> |
||||
</div> |
||||
<div class="box-content"> |
||||
{% for field in form %} |
||||
<div class="control-group {% if field.errors %}error{% endif %}"> |
||||
<label class="control-label">{% if field.field.required %}<b>{{ field.label }}:</b>{% else %}{{ field.label }}{% endif %}</label> |
||||
<div class="controls">{{ field }} |
||||
<span class="help-inline">{{ field.errors }}</span> |
||||
</div> |
||||
</div> |
||||
{% endfor %} |
||||
</div> |
||||
</div> |
||||
</fieldset> |
||||
|
||||
<div class="controls"> |
||||
<input class="btn btn-large btn-primary" type="submit" value="Готово"> |
||||
<input class="btn btn-large" type="reset" value="Отмена"> |
||||
</div> |
||||
</form> |
||||
{% endblock %} |
||||
@ -0,0 +1,53 @@ |
||||
{% extends 'admin/base.html' %} |
||||
{% load static %} |
||||
|
||||
{% block scripts %} |
||||
<script src="{% static 'ckeditor/ckeditor/ckeditor.js' %}"></script> |
||||
<link href="{% static 'js/select/select2.css' %}" rel="stylesheet"/> |
||||
<script src="{% static 'js/select/select2.js' %}"></script> |
||||
<script> |
||||
$(function(){ |
||||
|
||||
$('select').select2({width: "element"}); |
||||
//$('#id_country').select2({width: "element"}); |
||||
|
||||
}) |
||||
</script> |
||||
{% endblock %} |
||||
|
||||
{% block body %} |
||||
|
||||
<form method="post" class="form-horizontal" name="form2" id="form2" enctype="multipart/form-data"> {% csrf_token %} |
||||
<fieldset> |
||||
|
||||
<div class="box span10"> |
||||
<div class="box-header well"> |
||||
<h2><i class="icon-pencil"></i>{% if object %}Изменения{% else %}Создание{% endif %} рассылки</h2> |
||||
</div> |
||||
<div class="box-content"> |
||||
{% for field in form %} |
||||
<div class="control-group {% if field.errors %}error{% endif %}"> |
||||
<label class="control-label">{% if field.field.required %}<b>{{ field.label }}:</b>{% else %}{{ field.label }}{% endif %}</label> |
||||
<div class="controls">{{ field }} |
||||
<span class="help-inline">{{ field.errors }}</span> |
||||
</div> |
||||
</div> |
||||
{% endfor %} |
||||
</div> |
||||
</div> |
||||
</fieldset> |
||||
|
||||
<div class="box span10"> |
||||
<div class="box-header well"> |
||||
<h2><i class="icon-pencil"></i>Прикрепить файлы</h2> |
||||
</div> |
||||
<div class="box-content"> |
||||
</div> |
||||
</div> |
||||
|
||||
<div class="controls"> |
||||
<input class="btn btn-large btn-primary" type="submit" value="Готово"> |
||||
<input class="btn btn-large" type="reset" value="Отмена"> |
||||
</div> |
||||
</form> |
||||
{% endblock %} |
||||
Loading…
Reference in new issue