lingo: add search field (#21626)
This commit is contained in:
parent
964d0a87aa
commit
2920cf5d79
|
@ -109,6 +109,11 @@ class BasketItemErrorListView(ListView):
|
||||||
template_name = 'lingo/basketitem_error_list.html'
|
template_name = 'lingo/basketitem_error_list.html'
|
||||||
paginate_by = 10
|
paginate_by = 10
|
||||||
|
|
||||||
|
def get_context_data(self, **kwargs):
|
||||||
|
context = super(BasketItemErrorListView, self).get_context_data(**kwargs)
|
||||||
|
context['query'] = self.request.GET.get('q') or ''
|
||||||
|
return context
|
||||||
|
|
||||||
def get_queryset(self):
|
def get_queryset(self):
|
||||||
raw = (
|
raw = (
|
||||||
'SELECT %s FROM lingo_transaction '
|
'SELECT %s FROM lingo_transaction '
|
||||||
|
@ -122,6 +127,11 @@ class BasketItemErrorListView(ListView):
|
||||||
.annotate(transaction_status=RawSQL(raw % 'status', []))
|
.annotate(transaction_status=RawSQL(raw % 'status', []))
|
||||||
.filter(regie__webservice_url='')
|
.filter(regie__webservice_url='')
|
||||||
.order_by())
|
.order_by())
|
||||||
|
|
||||||
|
terms = self.request.GET.get('q')
|
||||||
|
if terms:
|
||||||
|
queryset = queryset.filter(subject__icontains=terms)
|
||||||
|
|
||||||
queryset1 = (
|
queryset1 = (
|
||||||
queryset
|
queryset
|
||||||
.filter(
|
.filter(
|
||||||
|
|
|
@ -12,6 +12,10 @@
|
||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
|
|
||||||
|
<form>
|
||||||
|
<p><input name="q" type="search" value="{{ query }}"> <button>{% trans 'Search' %}</button></p>
|
||||||
|
</form>
|
||||||
|
|
||||||
{% if object_list %}
|
{% if object_list %}
|
||||||
<table class="main">
|
<table class="main">
|
||||||
<thead>
|
<thead>
|
||||||
|
|
|
@ -393,6 +393,41 @@ def test_basketitem_error_list(app, admin_user, payment_backend):
|
||||||
assert '/manage/lingo/?q=%s' % transaction22.bank_transaction_id not in resp.text
|
assert '/manage/lingo/?q=%s' % transaction22.bank_transaction_id not in resp.text
|
||||||
|
|
||||||
|
|
||||||
|
def test_basketitem_error_list_search(app, admin_user, payment_backend):
|
||||||
|
regie = Regie.objects.create(
|
||||||
|
label='test-regie', slug='test-regie', payment_backend=payment_backend)
|
||||||
|
user = User.objects.create_user('dimebag', 'dime@bag.pan', 'pwd')
|
||||||
|
|
||||||
|
item = BasketItem.objects.create(
|
||||||
|
user=user,
|
||||||
|
regie=regie,
|
||||||
|
subject='item 1',
|
||||||
|
source_url='http://example.net/1',
|
||||||
|
amount=1)
|
||||||
|
transaction = Transaction.objects.create(
|
||||||
|
status=eopayment.ERROR,
|
||||||
|
order_id='order id 1',
|
||||||
|
bank_transaction_id='bank_id_1',
|
||||||
|
amount=1)
|
||||||
|
transaction.items.add(item)
|
||||||
|
|
||||||
|
app = login(app)
|
||||||
|
resp = app.get('/manage/lingo/payments/error/', status=200)
|
||||||
|
assert list(resp.context['object_list']) == [item]
|
||||||
|
|
||||||
|
resp.form['q'] = 'item 42'
|
||||||
|
resp = resp.form.submit()
|
||||||
|
assert list(resp.context['object_list']) == []
|
||||||
|
|
||||||
|
resp.form['q'] = 'item 1'
|
||||||
|
resp = resp.form.submit()
|
||||||
|
assert list(resp.context['object_list']) == [item]
|
||||||
|
|
||||||
|
resp.form['q'] = 'item'
|
||||||
|
resp = resp.form.submit()
|
||||||
|
assert list(resp.context['object_list']) == [item]
|
||||||
|
|
||||||
|
|
||||||
def test_configure_tipi_cell(app, admin_user):
|
def test_configure_tipi_cell(app, admin_user):
|
||||||
page = Page(title='tipi', slug='tipi', template_name='standard')
|
page = Page(title='tipi', slug='tipi', template_name='standard')
|
||||||
page.save()
|
page.save()
|
||||||
|
|
Loading…
Reference in New Issue