diff options
| author | Étienne Loks <etienne.loks@iggdrasil.net> | 2019-06-27 19:33:35 +0200 | 
|---|---|---|
| committer | Étienne Loks <etienne.loks@iggdrasil.net> | 2019-06-27 19:33:35 +0200 | 
| commit | 13bfe02ca67ec54df5895202fbee8a809a6b7245 (patch) | |
| tree | ad8e0d5d2805f6a920f7db95f4c0c6dd7ed4a220 /ishtar_common/views.py | |
| parent | 76a22721b7875bebd4b76992d7a0b351553b622e (diff) | |
| download | Ishtar-13bfe02ca67ec54df5895202fbee8a809a6b7245.tar.bz2 Ishtar-13bfe02ca67ec54df5895202fbee8a809a6b7245.zip | |
Merge: better layout - fix max page
Diffstat (limited to 'ishtar_common/views.py')
| -rw-r--r-- | ishtar_common/views.py | 11 | 
1 files changed, 8 insertions, 3 deletions
| diff --git a/ishtar_common/views.py b/ishtar_common/views.py index bb68f6044..8b4d212a7 100644 --- a/ishtar_common/views.py +++ b/ishtar_common/views.py @@ -883,6 +883,7 @@ def reset_wizards(request):              module.views.reset_wizards(request)      return redirect(reverse('start')) +  ITEM_PER_PAGE = 20 @@ -896,15 +897,19 @@ def merge_action(model, form, key):              model.merge_candidate.through, form=form,              formset=forms.MergeFormSet, extra=0)          q = model.merge_candidate.through.objects +        count = q.count() +        max_page = count // ITEM_PER_PAGE +        if count % ITEM_PER_PAGE != 0: +            max_page += 1          context = {'current_url': current_url,                     'current_page': page, -                   'max_page': q.count() / ITEM_PER_PAGE} -        if page < context["max_page"]: +                   'max_page': max_page} +        if page < max_page:              context['next_page'] = page + 1          if page > 1:              context['previous_page'] = page - 1 -        item_nb = page * ITEM_PER_PAGE +        item_nb = (page - 1) * ITEM_PER_PAGE          item_nb_1 = item_nb + ITEM_PER_PAGE          from_key = 'from_' + key          to_key = 'to_' + key | 
