Browse Source

make new customers application

devel
Dmitry Novikov 7 years ago
parent
commit
f205daf5bb
  1. 1
      djing/settings.py
  2. 1
      djing/urls.py
  3. 0
      new_customers/__init__.py
  4. 5
      new_customers/admin.py
  5. 5
      new_customers/apps.py
  6. 8
      new_customers/forms.py
  7. 98
      new_customers/locale/ru/LC_MESSAGES/django.po
  8. 38
      new_customers/migrations/0001_initial.py
  9. 0
      new_customers/migrations/__init__.py
  10. 57
      new_customers/models.py
  11. 17
      new_customers/templates/new_customers/potentialsubscriber_form.html
  12. 51
      new_customers/templates/new_customers/potentialsubscriber_list.html
  13. 12
      new_customers/urls.py
  14. 23
      new_customers/views.py
  15. 7
      templates/base.html

1
djing/settings.py

@ -58,6 +58,7 @@ INSTALLED_APPS = [
'messenger', 'messenger',
'msg_app', 'msg_app',
'group_app', 'group_app',
'new_customers',
'guardian', 'guardian',
'pinax_theme_bootstrap', 'pinax_theme_bootstrap',
'bootstrapform', 'bootstrapform',

1
djing/urls.py

@ -19,6 +19,7 @@ urlpatterns = [
path('ip_pool/', include('ip_pool.urls', namespace='ip_pool')), path('ip_pool/', include('ip_pool.urls', namespace='ip_pool')),
path('messenger/', include('messenger.urls', namespace='messenger')), path('messenger/', include('messenger.urls', namespace='messenger')),
path('gw/', include('gw_app.urls', namespace='gw_app')), path('gw/', include('gw_app.urls', namespace='gw_app')),
path('new_customers/', include('new_customers.urls', namespace='new_customers')),
path('fin/', include('finapp.urls', namespace='finapp')) path('fin/', include('finapp.urls', namespace='finapp'))
# Switch language # Switch language

0
new_customers/__init__.py

5
new_customers/admin.py

@ -0,0 +1,5 @@
from django.contrib import admin
from new_customers.models import PotentialSubscriber
admin.site.register(PotentialSubscriber)

5
new_customers/apps.py

@ -0,0 +1,5 @@
from django.apps import AppConfig
class NewCustomersConfig(AppConfig):
name = 'new_customers'

8
new_customers/forms.py

@ -0,0 +1,8 @@
from django import forms
from new_customers.models import PotentialSubscriber
class CustomerModelForm(forms.ModelForm):
class Meta:
model = PotentialSubscriber
exclude = ('make_data',)

98
new_customers/locale/ru/LC_MESSAGES/django.po

@ -0,0 +1,98 @@
# SOME DESCRIPTIVE TITLE.
# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
# This file is distributed under the same license as the PACKAGE package.
# Dmitry Novikov nerosketch@gmail.com, 2019.
#
#, fuzzy
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2019-06-17 00:43+0300\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: Dmitry Novikov nerosketch@gmail.com\n"
"Language: ru\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=4; plural=(n%10==1 && n%100!=11 ? 0 : n%10>=2 && n"
"%10<=4 && (n%100<12 || n%100>14) ? 1 : n%10==0 || (n%10>=5 && n%10<=9) || (n"
"%100>=11 && n%100<=14)? 2 : 3);\n"
#: models.py:11
msgid "fio"
msgstr "ФИО"
#: models.py:14
msgid "Telephone"
msgstr "Номер телефона"
#: models.py:24
msgid "User group"
msgstr "Группа нового абонента"
#: models.py:27
msgid "Town"
msgstr "Посёлок"
#: models.py:28
msgid "Town, if group does not already exist"
msgstr "Населённый пункт, если группа ещё не существует"
#: models.py:31
msgid "Street"
msgstr "Улица"
#: models.py:33
msgid "House"
msgstr "Дом"
#: models.py:39
msgid "Comment"
msgstr "Комментарий"
#: models.py:43
msgid "Create date"
msgstr "Дата создания"
#: models.py:45
msgid "Deadline connection"
msgstr "Планируемая дата подключения"
#: models.py:46
msgid "Date when connection must be finished"
msgstr "Дата, до которой подключение должно быть завершено"
#: models.py:55
msgid "Potential customer"
msgstr "Новый абонент"
#: models.py:56
msgid "Potential customers"
msgstr "Новые абоненты"
#: templates/new_customers/potentialsubscriber_form.html:5
msgid "Create potential client"
msgstr "Создать заявку на подключение"
#: templates/new_customers/potentialsubscriber_form.html:13
#: templates/new_customers/potentialsubscriber_list.html:45
msgid "Add"
msgstr "Добавить"
#: templates/new_customers/potentialsubscriber_list.html:8
#: templates/new_customers/potentialsubscriber_list.html:14
msgid "Potential subscribers"
msgstr "Заявки на подключение"
#: templates/new_customers/potentialsubscriber_list.html:21
msgid "New subscribers"
msgstr "Новые абоненты"
#: templates/new_customers/potentialsubscriber_list.html:22
msgid "People that may be clients"
msgstr "Подключки. Клиенты, которые должны стать абонентами"
#: templates/new_customers/potentialsubscriber_list.html:38
msgid "Not have new subscribers"
msgstr "Нет новых подключек"

38
new_customers/migrations/0001_initial.py

@ -0,0 +1,38 @@
# Generated by Django 2.0 on 2019-06-17 00:17
import django.core.validators
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
initial = True
dependencies = [
('group_app', '0003_auto_20180808_1236'),
]
operations = [
migrations.CreateModel(
name='PotentialSubscriber',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('fio', models.CharField(max_length=256, verbose_name='fio')),
('telephone', models.CharField(blank=True, max_length=16, validators=[django.core.validators.RegexValidator('^(\\+[7,8,9,3]\\d{10,11})?$')], verbose_name='Telephone')),
('town', models.CharField(blank=True, max_length=127, null=True, verbose_name='Town')),
('street', models.CharField(blank=True, max_length=127, null=True, verbose_name='Street')),
('house', models.CharField(blank=True, max_length=12, null=True, verbose_name='House')),
('description', models.TextField(blank=True, null=True, verbose_name='Comment')),
('make_data', models.DateTimeField(auto_now_add=True, verbose_name='Create date')),
('deadline', models.DateField(blank=True, null=True, verbose_name='Deadline connection')),
('group', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to='group_app.Group', verbose_name='User group')),
],
options={
'verbose_name': 'Potential customer',
'verbose_name_plural': 'Potential customers',
'db_table': 'new_customers',
'ordering': ('-id',),
},
),
]

0
new_customers/migrations/__init__.py

57
new_customers/models.py

@ -0,0 +1,57 @@
from django.shortcuts import resolve_url
from django.utils.translation import gettext_lazy as _
from django.db import models
from django.conf import settings
from django.core.validators import RegexValidator
from group_app.models import Group
class PotentialSubscriber(models.Model):
fio = models.CharField(_('fio'), max_length=256)
telephone = models.CharField(
max_length=16,
verbose_name=_('Telephone'),
blank=True,
validators=(RegexValidator(
getattr(settings, 'TELEPHONE_REGEXP', r'^(\+[7893]\d{10,11})?$')
),)
)
group = models.ForeignKey(
Group,
on_delete=models.SET_NULL,
blank=True, null=True,
verbose_name=_('User group')
)
town = models.CharField(
_('Town'),
help_text=_('Town, if group does not already exist'),
max_length=127, blank=True, null=True
)
street = models.CharField(_('Street'), max_length=127, blank=True, null=True)
house = models.CharField(
_('House'),
max_length=12,
null=True,
blank=True
)
description = models.TextField(
_('Comment'),
null=True,
blank=True
)
make_data = models.DateTimeField(_('Create date'), auto_now_add=True)
deadline = models.DateField(
_('Deadline connection'),
help_text=_('Date when connection must be finished'),
blank=True, null=True
)
def get_absolute_url(self):
return resolve_url('new_customers:user', uid=self.pk)
class Meta:
db_table = 'new_customers'
verbose_name = _('Potential customer')
verbose_name_plural = _('Potential customers')
ordering = '-id',

17
new_customers/templates/new_customers/potentialsubscriber_form.html

@ -0,0 +1,17 @@
{% load i18n bootstrap3 %}
<form role="form" action="{% url 'new_customers:new_user' %}" method="post">{% csrf_token %}
<div class="modal-header primary">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
<h4 class="modal-title"><span class="glyphicon glyphicon-question-sign"></span>{% trans 'Create potential client' %}</h4>
</div>
<div class="modal-body">
{% bootstrap_form form %}
<div class="btn-group">
<button type="submit" class="btn btn-primary">
<span class="glyphicon glyphicon-plus"></span> {% trans 'Add' %}
</button>
</div>
</div>
</form>

51
new_customers/templates/new_customers/potentialsubscriber_list.html

@ -0,0 +1,51 @@
{% extends request.is_ajax|yesno:'bajax.html,base.html' %}
{% load i18n %}
{% block breadcrumb %}
<ol class="breadcrumb">
<li><span class="glyphicon glyphicon-home"></span></li>
<li class="active">{% trans 'Potential subscribers' %}</li>
</ol>
{% endblock %}
{% block page_header %}
<h3>{% trans 'Potential subscribers' %}</h3>
{% endblock %}
{% block main %}
<div class="panel panel-default">
<div class="panel-heading">
<h3 class="panel-title">{% trans 'New subscribers' %}</h3>
<span>{% trans 'People that may be clients' %}</span>
</div>
<div class="list-group">
{% for new_user in object_list %}
{% with user_group=new_user.group %}
<a href="{{ new_user.get_absolute_url }}" class="list-group-item">
{% if user_group.deadline %}
<div class="pull-right">
<small>{{ user_group.deadline|date:'d M, H:i:s' }}</small>
</div>
{% endif %}
<h4>{{ new_user.fio }}</h4>
</a>
{% endwith %}
{% empty %}
<a href="#" class="list-group-item">
<p class="list-group-item-text">{% trans 'Not have new subscribers' %}</p>
</a>
{% endfor %}
</div>
<div class="panel-footer">
<div class="btn-group">
<a href="{% url 'new_customers:new_user' %}" class="btn btn-default btn-modal">
<span class="glyphicon glyphicon-plus"></span> {% trans 'Add' %}
</a>
</div>
</div>
</div>
{% endblock %}

12
new_customers/urls.py

@ -0,0 +1,12 @@
from django.urls import path
from new_customers import views
app_name = 'new_customers'
urlpatterns = [
path('', views.CustomersList.as_view(), name='customers_list'),
path('new/', views.CustomerNew.as_view(), name='new_user'),
path('<int:uid>/', views.CustomerDetail.as_view(), name='user'),
]

23
new_customers/views.py

@ -0,0 +1,23 @@
from django.contrib.auth.mixins import PermissionRequiredMixin
from django.views.generic import ListView, DetailView, CreateView
from djing.global_base_views import OrderingMixin
from djing.lib.mixins import LoginAdminMixin, LoginAdminPermissionMixin
from new_customers.forms import CustomerModelForm
from new_customers.models import PotentialSubscriber
class CustomersList(LoginAdminMixin, OrderingMixin, ListView):
model = PotentialSubscriber
class CustomerDetail(LoginAdminPermissionMixin, DetailView):
model = PotentialSubscriber
pk_url_kwarg = 'uid'
permission_required = 'new_customers.view_potentialsubscriber'
class CustomerNew(LoginAdminMixin, PermissionRequiredMixin, CreateView):
model = PotentialSubscriber
form_class = CustomerModelForm
permission_required = 'new_customers.add_potentialsubscriber'

7
templates/base.html

@ -122,6 +122,13 @@
</li> </li>
{% endif %} {% endif %}
{% url 'new_customers:customers_list' as newclist %}
<li{% if newclist in request.path %} class="active"{% endif %}>
<a href="{{ newclist }}">
<span class="glyphicon glyphicon-question-sign"></span> {% trans 'Potential subscribers' %}
</a>
</li>
</ul> </ul>
</div> </div>

Loading…
Cancel
Save