diff --git a/searchapp/locale/ru/LC_MESSAGES/django.po b/searchapp/locale/ru/LC_MESSAGES/django.po new file mode 100644 index 0000000..6268af7 --- /dev/null +++ b/searchapp/locale/ru/LC_MESSAGES/django.po @@ -0,0 +1,44 @@ +# 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, 2018. +# +#, fuzzy +msgid "" +msgstr "" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2018-04-09 11:15+0300\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" + +#: templates/searchapp/index.html:8 +#, python-format +msgid "Search by %(searchstring)s" +msgstr "Поиск по %(searchstring)s" + +#: templates/searchapp/index.html:16 +msgid "Change search string there" +msgstr "Измените строку поиска" + +#: templates/searchapp/index.html:21 +msgid "Find" +msgstr "Найти" + +#: templates/searchapp/index.html:46 templates/searchapp/index.html:75 +msgid "Nothing to found" +msgstr "Ничего не найдено" + +#: templates/searchapp/index.html:49 templates/searchapp/index.html:78 +msgid "You can change search string and try again" +msgstr "Вы можете изменить строку поиска и попробовать ещё раз" + +#: templates/searchapp/index.html:68 +#, python-format +msgid "Network state is %(netw_status)s" +msgstr "Сетевой статус: %(netw_status)s" diff --git a/searchapp/templates/searchapp/index.html b/searchapp/templates/searchapp/index.html index e9ad24e..da43e41 100644 --- a/searchapp/templates/searchapp/index.html +++ b/searchapp/templates/searchapp/index.html @@ -1,19 +1,24 @@ {% extends 'base.html' %} +{% load i18n %} {% block main %}
-

Поиск по "{{ s }}"

+

+ {% blocktrans trimmed with searchstring=s %} + Search by {{ searchstring }} + {% endblocktrans %} +

- +
@@ -22,8 +27,11 @@
{% for ab in abons %} - -

{{ ab.username_display|safe }}

+
+

+ + {{ ab.username_display|safe }} +

{{ ab.fio|safe }} @@ -35,10 +43,45 @@ {% empty %} -

Ничего не найдено

+

+ + {% trans 'Nothing to found' %} +

- Результат поиска пуст, попробуйте изменить строку поиска, и попробуйте найти ещё раз. + {% trans 'You can change search string and try again' %} +

+
+ {% endfor %} + {% for dev in devices %} + +

+ + {{ dev.comment|safe }} +

+ +

+ {% if dev.ip_address %} + {{ dev.ip_address }}, + {% endif %} + {% if dev.mac_addr %} + {{ dev.mac_addr }}, + {% endif %} + {{ dev.get_devtype_display }}, + {% blocktrans trimmed with netw_status=dev.get_status_display %} + Network state is {{ netw_status }} + {% endblocktrans %} +

+
+ {% empty %} + +

+ + {% trans 'Nothing to found' %} +

+ +

+ {% trans 'You can change search string and try again' %}

{% endfor %} diff --git a/searchapp/views.py b/searchapp/views.py index d6f880d..cf6f348 100644 --- a/searchapp/views.py +++ b/searchapp/views.py @@ -3,7 +3,8 @@ from django.db.models import Q from django.shortcuts import render from django.utils.html import escape from abonapp.models import Abon -from mydefs import ip_addr_regex +from devapp.models import Device +from djing import MAC_ADDR_REGEX, IP_ADDR_REGEX from django.contrib.auth.decorators import login_required @@ -17,21 +18,32 @@ def home(request): s = s.replace('+', '') if s: - if bool(re.match(ip_addr_regex, s)): + if re.match(IP_ADDR_REGEX, s): abons = Abon.objects.filter(ip_address=s) + devices = Device.objects.filter(ip_address=s) else: abons = Abon.objects.filter( Q(fio__icontains=s) | Q(username__icontains=s) | Q(telephone__icontains=s) ) + if re.match(MAC_ADDR_REGEX, s): + devices = Device.objects.filter(mac_addr=s) + else: + devices = Device.objects.filter(comment__icontains=s) + else: abons = [] + devices = [] for abn in abons: abn.fio = replace_without_case(escape(abn.fio), s, "%s" % s) abn.username_display = replace_without_case(escape(abn.username), s, "%s" % s) abn.telephone = replace_without_case(escape(abn.telephone), s, "%s" % s) + for dev in devices: + dev.comment = replace_without_case(escape(dev.comment), s, "%s" % s) + return render(request, 'searchapp/index.html', { 'abons': abons, + 'devices': devices, 's': s }) diff --git a/taskapp/handle.sh b/taskapp/handle.sh deleted file mode 100755 index 8ac380f..0000000 --- a/taskapp/handle.sh +++ /dev/null @@ -1,49 +0,0 @@ -#!/usr/bin/env bash - -FIRST="$1" # $1 - 'start' or 'change' -FAIL_MODE="$2" # $2 - mode -RESERVED="$3" # $3 - (dev ip) -STATE="$4" # $4 - state -AUTHOR_TEL="$5" # $5 - author telephone -RECIPIENT_TEL="$6" # $6 - recipient telephone -DESCR="$7" # $7 - description -ABON_FIO="$8" # $8 - abon fio -ABON_ADDR="$9" # $9 - abon address -ABON_TEL="${10}" # $10- abon telephone -ABON_GRP="${11}" # $11- имя группы абонента - - -text='' -if [[ "$FIRST" == "start" ]] -then - text="Нов" -else - text="Изм" -fi - -# Если сигнал самому себе то молчим -if [[ "$AUTHOR_TEL" == "$RECIPIENT_TEL" ]] -then - exit -fi - -# Если задача 'На выполнении' то молчим -if [[ "$STATE" == "C" ]] -then - exit -fi - -# Если задача завершена -if [[ "$STATE" == "F" ]] -then - text="Задача завершена" - # Меняем телефон назначения на телефон автора, т.к. при завершении - # идёт оповещение автору о выполнении - RECIPIENT_TEL="$AUTHOR_TEL" -fi - -FULLTEXT="$text: $ABON_FIO. $ABON_ADDR $ABON_TEL. $ABON_GRP. $FAIL_MODE. $DESCR" - -echo "TO $RECIPIENT_TEL: $FULLTEXT" - -/usr/bin/gammu-smsd-inject EMS $RECIPIENT_TEL -text "$FULLTEXT" -unicode