Merged Air51/dokumentor.ru into master

remotes/origin/mitri4
Air51 9 years ago
commit 0e07c28cdb
  1. 6
      project/docs/autocomplete_light_registry.py
  2. 3
      project/docs/urls.py
  3. 2
      project/docs/views/__init__.py
  4. 22
      project/docs/views/ajax.py
  5. 2
      project/static/css/style.css
  6. 5
      project/templates/autocomplete_light/docs_country_choice.html
  7. 5
      project/templates/autocomplete_light/docs_measure_choice.html
  8. 2
      project/templates/base.html
  9. 55
      project/templates/docs/stub_js.html

@ -36,18 +36,20 @@ class AutocompleteCurrency(autocomplete_light.AutocompleteModelBase):
search_fields = ('name', '^abc_code', '^code') search_fields = ('name', '^abc_code', '^code')
class AutocompleteMeasure(autocomplete_light.AutocompleteModelBase): class AutocompleteMeasure(autocomplete_light.AutocompleteModelTemplate):
'''Автокомплит ед. измерения '''Автокомплит ед. измерения
''' '''
autocomplete_js_attributes = {'placeholder': u'Название ед. измерения'} autocomplete_js_attributes = {'placeholder': u'Название ед. измерения'}
search_fields = ('name', 'full_name', '^code') search_fields = ('name', 'full_name', '^code')
choice_template = 'autocomplete_light/docs_measure_choice.html'
class AutocompleteCountry(autocomplete_light.AutocompleteModelBase): class AutocompleteCountry(autocomplete_light.AutocompleteModelTemplate):
'''Автокомплит стран '''Автокомплит стран
''' '''
autocomplete_js_attributes = {'placeholder': u'Название страны'} autocomplete_js_attributes = {'placeholder': u'Название страны'}
search_fields = ('name', 'full_name', '^code') search_fields = ('name', 'full_name', '^code')
choice_template = 'autocomplete_light/docs_country_choice.html'
autocomplete_light.register(Country, AutocompleteCountry, name='ACCountry') autocomplete_light.register(Country, AutocompleteCountry, name='ACCountry')

@ -2,7 +2,7 @@
from django.conf.urls import * from django.conf.urls import *
from .views import (InvoiceViews, AktRabotViews, AktSverkiViews, DoverViews, PlatejkaViews, NakladnViews, FakturaViews) from .views import (InvoiceViews, AktRabotViews, AktSverkiViews, DoverViews, PlatejkaViews, NakladnViews, FakturaViews)
from .views import getview, index, get_pair, get_invoices, get_tbl_items, get_client_by_invoice, toggle_doc_status from .views import getview, index, get_invoices, get_tbl_items, get_client_by_invoice, toggle_doc_status
urlpatterns = patterns('docs.views', urlpatterns = patterns('docs.views',
@ -60,7 +60,6 @@ for name, klass in klasses:
url(r'^%s/(?P<id>\d+)/email/ajax/$' % name, getview, {'klass': klass, 'oper': 'email_ajax',}, url(r'^%s/(?P<id>\d+)/email/ajax/$' % name, getview, {'klass': klass, 'oper': 'email_ajax',},
name='docs_%s_email_ajax' % name), name='docs_%s_email_ajax' % name),
url(r'^ajax_get_pair/(?P<model>\w+)/(?P<param1>\w+)/(?P<param2>\w+)/(?P<val1>.+)/$', get_pair, name='ajax_get_pair'),
url(r'^ajax_get_invoices/$', get_invoices, name='ajax_get_invoices'), url(r'^ajax_get_invoices/$', get_invoices, name='ajax_get_invoices'),
url(r'^ajax_get_invoices/(?P<client_id>\d+)/$', get_invoices, name='ajax_get_invoices'), url(r'^ajax_get_invoices/(?P<client_id>\d+)/$', get_invoices, name='ajax_get_invoices'),
url(r'^ajax_get_tbl_items/(?P<invoice_id>\d+)/$', get_tbl_items, name='ajax_get_tbl_items'), url(r'^ajax_get_tbl_items/(?P<invoice_id>\d+)/$', get_tbl_items, name='ajax_get_tbl_items'),

@ -11,7 +11,7 @@ from .dover import DoverViews
from .platejka import PlatejkaViews from .platejka import PlatejkaViews
from .nakladn import NakladnViews from .nakladn import NakladnViews
from .faktura import FakturaViews from .faktura import FakturaViews
from .ajax import get_pair, get_invoices, get_tbl_items, get_client_by_invoice, toggle_doc_status from .ajax import get_invoices, get_tbl_items, get_client_by_invoice, toggle_doc_status
@login_required # важно!!! @login_required # важно!!!

@ -11,28 +11,6 @@ from ..models import Invoice
from project.customer.utils import raise_if_no_profile from project.customer.utils import raise_if_no_profile
def get_pair(request, model, param1, val1, param2):
if not request.is_ajax():
return HttpResponseBadRequest()
if model not in ('Country', 'Measure',):
return HttpResponseBadRequest()
raise_if_no_profile(request)
kwargs = {param1: val1}
try:
q_model = get_model('docs', model)
val2 = getattr(q_model.objects.get(**kwargs), param2)
except:
val2 = None
data = {
'val': val2,
}
return HttpResponse(json.dumps(data), mimetype='application/json')
def get_invoices(request, client_id=None): def get_invoices(request, client_id=None):
if not request.is_ajax(): if not request.is_ajax():
return HttpResponseBadRequest() return HttpResponseBadRequest()

@ -687,3 +687,5 @@ a.popup-unreg {background:url(../img/popup-trash.png) no-repeat 3px center;}
.italic {font-style: italic;} .italic {font-style: italic;}
.rm_profile {overflow:hidden;} .rm_profile {overflow:hidden;}
.rm_profile .list-col2 {border-left:none;} .rm_profile .list-col2 {border-left:none;}
.yourlabs-autocomplete { overflow: auto !important; }

@ -0,0 +1,5 @@
{% load i18n l10n %}
<span class="div" data-value="{{ choice.pk|unlocalize }}" data-code="{{ choice.code }}">
{{ choice }}
</span>

@ -0,0 +1,5 @@
{% load i18n l10n %}
<span class="div" data-value="{{ choice.pk|unlocalize }}" data-name="{{ choice.name }}" data-code="{{ choice.code }}">
{{ choice.name }} - {{ choice.full_name }}
</span>

@ -9,7 +9,7 @@
<title>{% block title %}{% endblock %} | Документор</title> <title>{% block title %}{% endblock %} | Документор</title>
<link rel="shortcut icon" href="{{ STATIC_URL }}favicon.ico" /> <link rel="shortcut icon" href="{{ STATIC_URL }}favicon.ico" />
<link rel="stylesheet" href="{{ STATIC_URL }}css/ui-lightness/jquery-ui-1.10.3.custom.css" /> <link rel="stylesheet" href="{{ STATIC_URL }}css/ui-lightness/jquery-ui-1.10.3.custom.css" />
<link rel="stylesheet" href="{{ STATIC_URL }}css/style.css?t=1489534321" /> <link rel="stylesheet" href="{{ STATIC_URL }}css/style.css?t=1489695907" />
{% render_block "css" %} {% render_block "css" %}
</head> </head>

@ -10,27 +10,40 @@
formCssClass: 'dynamic-form', formCssClass: 'dynamic-form',
}); });
var get_pair = function(model, class1, class2, param1, param2) { // units
$('body').on('selectChoice change', '.' + class1 + ' input', function() { $('body').on('selectChoice change', '.units input', function(e, choice, autocomplete) {
var $this = $(this); var name_input = $(this);
var this_val = $this.val(); var code_input = name_input.closest('.row_tbl_items').find('.units_kod input');
var $other_input = $this.closest('.row_tbl_items').find('.' + class2 + ' input');
$.get('/my/docs/ajax_get_pair/' + model + '/' + param1 + '/' + param2 + '/' + this_val + '/', function(data) { if (choice) {
if (data['val']) { //console.log(choice.data());
$other_input.val(data['val']); name_input.val(choice.data('name')); // short name
$this.css('color', 'black') code_input.val(choice.data('code'));
} name_input.css('color', 'black')
else { }
$other_input.val('-'); else {
$this.css('color', 'red') //console.log(choice, 'No choice!');
} code_input.val('-');
}); name_input.css('color', 'red')
}) }
} });
{# model должна быть разрешена в docs.views.get_pair #}
get_pair('Country', 'country_name', 'country_code', 'name', 'code'); // country
get_pair('Measure', 'units', 'units_kod', 'name', 'code'); $('body').on('selectChoice change', '.country_name input', function(e, choice, autocomplete) {
var name_input = $(this);
var code_input = name_input.closest('.row_tbl_items').find('.country_code input');
if (choice) {
//console.log(choice.data());
code_input.val(choice.data('code'));
name_input.css('color', 'black')
}
else {
//console.log(choice, 'No choice!');
code_input.val('-');
name_input.css('color', 'red')
}
});
$('#id_client').on('change', function() { $('#id_client').on('change', function() {
var client_id = $(this).val(); var client_id = $(this).val();
@ -50,7 +63,7 @@
}); });
select.prop('selectedIndex', 0); select.prop('selectedIndex', 0);
}) })
}) });
$('#id_invoice').on('change', function() { $('#id_invoice').on('change', function() {
var invoice_id = $(this).val(); var invoice_id = $(this).val();

Loading…
Cancel
Save