Browse Source

Add task list and basic info to client side

devel
bashmak 8 years ago
parent
commit
f6dff35596
  1. 166
      clientsideapp/locale/ru/LC_MESSAGES/django.po
  2. 14
      clientsideapp/templates/clientsideapp/ext.html
  3. 35
      clientsideapp/templates/clientsideapp/index.html
  4. 52
      clientsideapp/templates/clientsideapp/tasklist.html
  5. 4
      clientsideapp/urls.py
  6. 15
      clientsideapp/views.py
  7. 9
      static/clientside/custom.css
  8. 15
      taskapp/templatetags/tasktags.py

166
clientsideapp/locale/ru/LC_MESSAGES/django.po

@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2018-04-24 23:27+0300\n"
"POT-Creation-Date: 2018-05-03 17:15+0300\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: Dmitry Novikov nerosketch@gmail.com\n"
"Language: ru\n"
@ -19,19 +19,19 @@ msgstr ""
"%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"
#: clientsideapp/templates/clientsideapp/debt_buy.html:6
#: templates/clientsideapp/debt_buy.html:6
msgid "Debts"
msgstr "Задолженность"
#: clientsideapp/templates/clientsideapp/debt_buy.html:11
#: templates/clientsideapp/debt_buy.html:11
msgid "repayment of debts"
msgstr "Оплатить задолженность"
#: clientsideapp/templates/clientsideapp/debt_buy.html:18
#: templates/clientsideapp/debt_buy.html:18
msgid "Are you sure you want to spend a payment?"
msgstr "Вы уверены что хотите провести платёж?"
#: clientsideapp/templates/clientsideapp/debt_buy.html:21
#: templates/clientsideapp/debt_buy.html:21
#, python-format
msgid ""
"From your account, they withdraw funds in <b>%(amount)s</b> rub.<br/> As a "
@ -42,98 +42,105 @@ msgstr ""
"результате у вас на счету останется %(ballance_after)s руб.<br/"
">Администратор сразу сможет видеть что у вас закрыта задолженность."
#: clientsideapp/templates/clientsideapp/debt_buy.html:26
#: templates/clientsideapp/debt_buy.html:26
msgid "Description of payment"
msgstr "Описание платежа"
#: clientsideapp/templates/clientsideapp/debt_buy.html:34
#: templates/clientsideapp/debt_buy.html:34
msgid "Confirm"
msgstr "Подтвердить"
#: clientsideapp/templates/clientsideapp/debt_buy.html:37
#: templates/clientsideapp/debt_buy.html:37
msgid "Cancel"
msgstr "Отменить"
#: clientsideapp/templates/clientsideapp/debts.html:6
#: templates/clientsideapp/debts.html:6
msgid "Your debt"
msgstr "Ваши долги"
#: clientsideapp/templates/clientsideapp/debts.html:11
#: templates/clientsideapp/debts.html:11
#: templates/clientsideapp/tasklist.html:11
msgid "State"
msgstr "Состояние"
#: clientsideapp/templates/clientsideapp/debts.html:12
#: templates/clientsideapp/debts.html:12
msgid "Summ"
msgstr "Сумма"
#: clientsideapp/templates/clientsideapp/debts.html:13
#: templates/clientsideapp/debts.html:13
msgid "Description"
msgstr "Описание"
#: clientsideapp/templates/clientsideapp/debts.html:14
#: templates/clientsideapp/debts.html:14
#: templates/clientsideapp/tasklist.html:12
msgid "Date of create"
msgstr "Дата создания"
#: clientsideapp/templates/clientsideapp/debts.html:15
#: templates/clientsideapp/debts.html:15
msgid "Date of pay"
msgstr "Дата платежа"
#: clientsideapp/templates/clientsideapp/debts.html:16
#: clientsideapp/templates/clientsideapp/debts.html:38
#: templates/clientsideapp/debts.html:16 templates/clientsideapp/debts.html:38
msgid "Pay"
msgstr "Оплатить"
#: clientsideapp/templates/clientsideapp/debts.html:23
#: clientsideapp/templates/clientsideapp/ext.html:63
#: clientsideapp/templates/clientsideapp/modal_service_buy.html:19
#: clientsideapp/templates/clientsideapp/services.html:26
#: clientsideapp/templates/clientsideapp/services.html:55
#: templates/clientsideapp/debts.html:23 templates/clientsideapp/ext.html:78
#: templates/clientsideapp/modal_service_buy.html:19
#: templates/clientsideapp/services.html:26
#: templates/clientsideapp/services.html:55
msgid "currency"
msgstr "руб."
#: clientsideapp/templates/clientsideapp/debts.html:31
#: templates/clientsideapp/debts.html:31
msgid "Created paid"
msgstr "Создан оплаченным"
#: clientsideapp/templates/clientsideapp/debts.html:33
#: templates/clientsideapp/debts.html:33
msgid "Not yet paid"
msgstr "Ещё не оплачен"
#: clientsideapp/templates/clientsideapp/debts.html:45
#: templates/clientsideapp/debts.html:45
msgid "You have no debt"
msgstr "У вас нет долгов"
#: clientsideapp/templates/clientsideapp/ext.html:7
#: clientsideapp/templates/clientsideapp/ext.html:41
#: templates/clientsideapp/ext.html:7 templates/clientsideapp/ext.html:41
msgid "Personal account"
msgstr "Личный кабинет"
#: clientsideapp/templates/clientsideapp/ext.html:46
#: templates/clientsideapp/ext.html:46
msgid "Pays"
msgstr "Платежи"
#: clientsideapp/templates/clientsideapp/ext.html:51
#: templates/clientsideapp/ext.html:51
msgid "Services"
msgstr "Услуги"
#: clientsideapp/templates/clientsideapp/ext.html:55
#: templates/clientsideapp/ext.html:55
msgid "Language"
msgstr "Язык"
#: templates/clientsideapp/ext.html:69
msgid "Other"
msgstr "Другое"
#: clientsideapp/templates/clientsideapp/ext.html:57
#: templates/clientsideapp/ext.html:71
msgid "Show debts and pay it"
msgstr "Посмотреть долги и оплатить"
#: clientsideapp/templates/clientsideapp/ext.html:58
#: templates/clientsideapp/ext.html:72
msgid "Show task history"
msgstr "Посмотреть заявки"
#: templates/clientsideapp/ext.html:73
msgid "Quit"
msgstr "Выйти"
#: clientsideapp/templates/clientsideapp/ext.html:63
#: templates/clientsideapp/ext.html:78
#, python-format
msgid "Your balance is <b>%(ballance)s</b>"
msgstr "Ваш балланс <b>%(ballance)s</b>"
#: clientsideapp/templates/clientsideapp/ext.html:74
#: templates/clientsideapp/ext.html:89
msgid ""
"<strong>Attantion!</strong> You are is admin, and do not be active here, "
"please back to admin side. Client side to you for reference only."
@ -142,15 +149,39 @@ msgstr ""
"из кабинета пользователя, производите их из админки. Кабинет клиента для вас "
"только для ознакомления."
#: clientsideapp/templates/clientsideapp/modal_service_buy.html:5
#: templates/clientsideapp/index.html:7
msgid "Account info"
msgstr "Информация о вашей учётной записи"
#: templates/clientsideapp/index.html:11
msgid "Username"
msgstr "Логин"
#: templates/clientsideapp/index.html:14
msgid "fio"
msgstr "ФИО"
#: templates/clientsideapp/index.html:17
msgid "Primary telephone"
msgstr "Основной номер телефона"
#: templates/clientsideapp/index.html:20
msgid "Ip Address"
msgstr "ip адрес"
#: templates/clientsideapp/index.html:24
msgid "Address"
msgstr "Адрес"
#: templates/clientsideapp/modal_service_buy.html:5
msgid "Pick service"
msgstr "Заказать услугу"
#: clientsideapp/templates/clientsideapp/modal_service_buy.html:8
#: templates/clientsideapp/modal_service_buy.html:8
msgid "Are you sure you want to order the service?"
msgstr "Вы уверены что хотите заказать услугу?"
#: clientsideapp/templates/clientsideapp/modal_service_buy.html:9
#: templates/clientsideapp/modal_service_buy.html:9
msgid ""
"Be careful, after purchasing the service you will <b>withdraw money</b>, and "
"you will be able to use the purchased service."
@ -158,64 +189,64 @@ msgstr ""
"Будте внимательны, после заказа услуги с вашего счёта <b>снимутся средства</"
"b>, и вы сможете пользоваться купленной услугой."
#: clientsideapp/templates/clientsideapp/modal_service_buy.html:15
#: templates/clientsideapp/modal_service_buy.html:15
#, python-format
msgid ""
"Inbound speed: %(speedIn)s MBit/s<br> Outgoing speed: %(speedOut)s MBit/"
"s<br> Cost: %(amount)s rubles."
msgstr ""
#: clientsideapp/templates/clientsideapp/modal_service_buy.html:19
#: templates/clientsideapp/modal_service_buy.html:19
#, python-format
msgid "The cost is %(amount)s"
msgstr "Стоимость %(amount)s"
#: clientsideapp/templates/clientsideapp/modal_service_buy.html:23
#: clientsideapp/templates/clientsideapp/services.html:63
#: templates/clientsideapp/modal_service_buy.html:23
#: templates/clientsideapp/services.html:63
msgid "Pick"
msgstr "Заказать"
#: clientsideapp/templates/clientsideapp/modal_service_buy.html:25
#: templates/clientsideapp/modal_service_buy.html:25
msgid "Close"
msgstr "Закрыть"
#: clientsideapp/templates/clientsideapp/pays.html:6
#: templates/clientsideapp/pays.html:6
msgid "conducted payments"
msgstr "Проведённые платежи"
#: clientsideapp/templates/clientsideapp/pays.html:11
#: templates/clientsideapp/pays.html:11
msgid "Transaction Amount (rubles)"
msgstr "Сумма транзакции (руб)"
#: clientsideapp/templates/clientsideapp/pays.html:12
#: templates/clientsideapp/pays.html:12
msgid "Date of transaction"
msgstr "Дата транзакции"
#: clientsideapp/templates/clientsideapp/pays.html:13
#: templates/clientsideapp/pays.html:13
msgid "Comment"
msgstr "Комментарий"
#: clientsideapp/templates/clientsideapp/pays.html:25
#: templates/clientsideapp/pays.html:25
msgid "You have not spent payments"
msgstr "У вас нет проведённых платежей"
#: clientsideapp/templates/clientsideapp/services.html:14
#: templates/clientsideapp/services.html:14
msgid "Your current service"
msgstr "Ваша текущая услуга"
#: clientsideapp/templates/clientsideapp/services.html:19
#: templates/clientsideapp/services.html:19
msgid "The date of connection"
msgstr "Дата подключения"
#: clientsideapp/templates/clientsideapp/services.html:22
#: templates/clientsideapp/services.html:22
msgid "The date of finish service"
msgstr "Дата завершения услуги"
#: clientsideapp/templates/clientsideapp/services.html:25
#: templates/clientsideapp/services.html:25
msgid "Cost"
msgstr "Стоимость"
#: clientsideapp/templates/clientsideapp/services.html:35
#: templates/clientsideapp/services.html:35
msgid ""
"<strong>Attantion!</strong> You have not yet a service, for use the services "
"please purchase service you want."
@ -223,33 +254,52 @@ msgstr ""
"<strong>Внимание!</strong> У вас нет услуги, для использования ресурсов "
"приобретите нужную услугу из представленных тут."
#: clientsideapp/templates/clientsideapp/services.html:46
#: templates/clientsideapp/services.html:46
msgid "Services available for ordering"
msgstr "Доступные для заказа услуги"
#: clientsideapp/templates/clientsideapp/services.html:68
#: templates/clientsideapp/services.html:68
msgid "No services available for ordering"
msgstr "Нет доступных для заказа услуг"
#: clientsideapp/views.py:51
#: templates/clientsideapp/tasklist.html:6
msgid "Task history"
msgstr "История заявок"
#: templates/clientsideapp/tasklist.html:13
msgid "The nature of the damage"
msgstr "Характер заявки"
#: templates/clientsideapp/tasklist.html:14
msgid "Expected or real completion date"
msgstr "Ожидаемый или реальный срок выполнения"
#: templates/clientsideapp/tasklist.html:36
msgid "You didn't leave any requests for breakdowns."
msgstr "Заявки по вашей учётной записи не найдены"
#: views.py:51
#, python-format
msgid "Buy the service via user side, service '%s'"
msgstr "Покупка тарифного плана через личный кабинет, тариф '%s'"
#: clientsideapp/views.py:54
#: views.py:54
#, python-format
msgid "The service '%s' wan successfully activated"
msgstr "Услуга '%s' успешно подключена"
#: clientsideapp/views.py:84
#: views.py:84
msgid "Are you not sure that you want buy the service?"
msgstr "Вы не уверены что хотите оплатить долг?"
#: clientsideapp/views.py:86
#: views.py:86
msgid "Your account have not enough money"
msgstr "Недостаточно средств на счету"
#: clientsideapp/views.py:89
#: views.py:89
#, python-format
msgid "%(username)s paid the debt %(amount).2f"
msgstr "%(username)s заплатил долг в размере %(amount).2f"
msgid "Num of active tasks"
msgstr "Кол. активных заявок"

14
clientsideapp/templates/clientsideapp/ext.html

@ -51,10 +51,24 @@
<a href="{{ client_side_services }}">{% trans 'Services' %}</a>
</li>
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown">{% trans 'Language' %} <b class="caret"></b></a>
<ul class="dropdown-menu">
{% url 'set_language' as set_language_url %}
{% for lang in LANGUAGES %}
<li><a href="#" id="langfrm_{{ lang.0 }}" onclick="document.setLang{{ lang.0 }}.submit();">{{ lang.1 }}</a></li>
<form name="setLang{{ lang.0}}" action="{{ set_language_url }}" method="POST" class="hidden">{% csrf_token %}
<input type="hidden" name="language" value="{{ lang.0 }}">
</form>
{% endfor %}
</ul>
</li>
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown">{% trans 'Other' %} <b class="caret"></b></a>
<ul class="dropdown-menu">
<li><a href="{% url 'client_side:debts' %}">{% trans 'Show debts and pay it' %}</a></li>
<li><a href="{% url 'client_side:task_history' %}">{% trans 'Show task history' %}</a></li>
<li><a href="{% url 'acc_app:logout' %}">{% trans 'Quit' %}</a></li>
</ul>
</li>

35
clientsideapp/templates/clientsideapp/index.html

@ -1,4 +1,39 @@
{% extends 'clientsideapp/ext.html' %}
{% load i18n %}
{% block client_main %}
<div class="panel panel-default">
<div class="panel-heading">{% trans 'Account info' %}</div>
<div class="panel-body">
{% with user=request.user %}
<dl class="dl-horizontal">
<dt>{% trans 'Username' %}</dt>
<dd>{{ user.username }}</dd>
<dt>{% trans 'fio' %}</dt>
<dd>{{ user.fio }}</dd>
<dt>{% trans 'Primary telephone' %}</dt>
<dd>{{ user.telephone }}</dd>
<dt>{% trans 'Ip Address' %}</dt>
<dd>{{ user.ip_address }}</dd>
{% if user.street %}
<dt>{% trans 'Address' %}</dt>
<dd>{{ user.street.name }}, {{ user.house|default:'' }}</dd>
{% endif %}
{% if num_active_tasks > 0 %}
<dt>{% trans 'Num of active tasks' %}</dt>
<dd>{{ num_active_tasks }}</dd>
{% endif %}
</dl>
{% endwith %}
</div>
</div>
{% include 'custom_pages/main_page.htm' %}
{% endblock %}

52
clientsideapp/templates/clientsideapp/tasklist.html

@ -0,0 +1,52 @@
{% extends 'clientsideapp/ext.html' %}
{% load i18n %}
{% load tasktags %}
{% block client_main %}
<div class="page-header">
<h3>{% trans 'Task history' %}</h3>
</div>
<div class="panel panel-default">
<table class="table table-striped table-bordered">
<thead>
<tr>
<th class="col-xs-1">{% trans 'State' %}</th>
<th class="col-xs-3">{% trans 'Date of create' %}</th>
<th class="col-xs-4">{% trans 'The nature of the damage' %}</th>
<th class="col-xs-4">{% trans 'Expected or real completion date' %}</th>
</tr>
</thead>
<tbody>
{% for task in tasks %}
<tr>
<td>{{ task.get_state_display }}</td>
<td>
{% if task.time_of_create|is_current_year %}
{{ task.time_of_create|date:'d b H:i' }}
{% else %}
{{ task.time_of_create|date:'d b H:i. Y' }}
{% endif %}
</td>
<td>{{ task.get_mode_display }}</td>
<td>
{% if task.out_date|is_current_year %}
{{ task.out_date|date:'d E, l' }}
{% else %}
{{ task.out_date|date:'d E, l Y' }}
{% endif %}
</td>
</tr>
{% empty %}
<tr>
<td colspan="4">
{% trans "You didn't leave any requests for breakdowns." %}
<span class="glyphicon glyphicon-ok"></span>
</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
{% endblock %}

4
clientsideapp/urls.py

@ -1,4 +1,3 @@
# -*- coding:utf-8 -*-
from django.conf.urls import url
from . import views
@ -10,5 +9,6 @@ urlpatterns = [
url(r'^services$', views.services, name='services'),
url(r'^services/(?P<srv_id>\d+)/buy$', views.buy_service, name='buy_service'),
url(r'^debts$', views.debts_list, name='debts'),
url(r'^debts/(?P<d_id>\d+)$', views.debt_buy, name='debt_buy')
url(r'^debts/(?P<d_id>\d+)$', views.debt_buy, name='debt_buy'),
url(r'^tasks$', views.task_history, name='task_history')
]

15
clientsideapp/views.py

@ -1,4 +1,3 @@
# coding=utf-8
from django.contrib.auth.decorators import login_required
from django.contrib.gis.shortcuts import render_to_text
from django.shortcuts import render, get_object_or_404, redirect
@ -8,13 +7,17 @@ from django.utils.translation import gettext_lazy as _, gettext
from abonapp.models import AbonLog, InvoiceForPayment, Abon
from tariff_app.models import Tariff
from taskapp.models import Task
from mydefs import LogicError
from agent import NasFailedResult, NasNetworkError
@login_required
def home(request):
return render(request, 'clientsideapp/index.html')
num_active_tasks = Task.objects.filter(abon=request.user, state='S').count()
return render(request, 'clientsideapp/index.html', {
'num_active_tasks': num_active_tasks
})
@login_required
@ -105,3 +108,11 @@ def debt_buy(request, d_id):
'amount': debt.amount,
'ballance_after': abon.ballance - debt.amount
})
@login_required
def task_history(request):
tasks = Task.objects.filter(abon=request.user)
return render(request, 'clientsideapp/tasklist.html', {
'tasks': tasks
})

9
static/clientside/custom.css

@ -24,3 +24,12 @@ body{
padding: 88px 15px 0;
}
@media (min-width: 768px){
.dl-horizontal dt {
width: 240px;
}
.dl-horizontal dd{
margin-left: 260px;
}
}

15
taskapp/templatetags/tasktags.py

@ -1,11 +1,12 @@
from datetime import datetime
from typing import Union
from datetime import datetime, date
from django import template
register = template.Library()
@register.simple_tag
def is_today(time):
def is_today(time: datetime):
if type(time) is not datetime:
raise TypeError
now = datetime.now()
@ -13,8 +14,16 @@ def is_today(time):
@register.simple_tag
def is_yesterday(time):
def is_yesterday(time: datetime):
if type(time) is not datetime:
raise TypeError
now = datetime.now()
return now.day - 1 == time.day
@register.filter
def is_current_year(time: Union[datetime, date]):
if not isinstance(time, (datetime, date)):
raise TypeError
now = datetime.now()
return now.year == time.year
Loading…
Cancel
Save