From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) by finch.gentoo.org (Postfix) with ESMTP id C4F0613800E for ; Thu, 2 Aug 2012 22:45:31 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 9673CE0803; Thu, 2 Aug 2012 22:44:49 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) by pigeon.gentoo.org (Postfix) with ESMTP id 4B716E080C for ; Thu, 2 Aug 2012 22:44:49 +0000 (UTC) Received: from hornbill.gentoo.org (hornbill.gentoo.org [94.100.119.163]) (using TLSv1 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 640DA1B402D for ; Thu, 2 Aug 2012 22:44:48 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by hornbill.gentoo.org (Postfix) with ESMTP id 1B474E5443 for ; Thu, 2 Aug 2012 22:44:46 +0000 (UTC) From: "Slava Bacherikov" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Slava Bacherikov" Message-ID: <1343911770.4b711746de61ce9d808d265a55aad129675ba64f.bacher09@gentoo> Subject: [gentoo-commits] proj/gentoo-packages:master commit in: gpackages/apps/packages/, gpackages/apps/packages/templatetags/, ... X-VCS-Repository: proj/gentoo-packages X-VCS-Files: gpackages/apps/packages/forms.py gpackages/apps/packages/templatetags/packages.py gpackages/apps/packages/views.py gpackages/templates/arch_choice.html gpackages/templates/arch_choice_modal.html X-VCS-Directories: gpackages/apps/packages/ gpackages/apps/packages/templatetags/ gpackages/templates/ X-VCS-Committer: bacher09 X-VCS-Committer-Name: Slava Bacherikov X-VCS-Revision: 4b711746de61ce9d808d265a55aad129675ba64f X-VCS-Branch: master Date: Thu, 2 Aug 2012 22:44:46 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Archives-Salt: 19f175f5-b843-4a85-8a15-ddd0a42bbbd2 X-Archives-Hash: 3e93e356db71fdea0506c35120c20546 commit: 4b711746de61ce9d808d265a55aad129675ba64f Author: Slava Bacherikov bacher09 org> AuthorDate: Thu Aug 2 12:49:30 2012 +0000 Commit: Slava Bacherikov bacherikov org ua> CommitDate: Thu Aug 2 12:49:30 2012 +0000 URL: http://git.overlays.gentoo.org/gitweb/?p=proj/gentoo-packages.git;a=commit;h=4b711746 Success url in arches choice will be current page --- gpackages/apps/packages/forms.py | 1 + gpackages/apps/packages/templatetags/packages.py | 4 ++-- gpackages/apps/packages/views.py | 9 +++++++++ gpackages/templates/arch_choice.html | 1 + gpackages/templates/arch_choice_modal.html | 1 + 5 files changed, 14 insertions(+), 2 deletions(-) diff --git a/gpackages/apps/packages/forms.py b/gpackages/apps/packages/forms.py index d63751a..3bc07df 100644 --- a/gpackages/apps/packages/forms.py +++ b/gpackages/apps/packages/forms.py @@ -13,6 +13,7 @@ class ArchChoiceForm(forms.Form): widget = DivCheckboxSelectMultiple, #widget = forms.CheckboxSelectMultiple(attrs = {'class': 'inline checkbox'}), choices = arches) + next = forms.CharField(widget = forms.HiddenInput, initial = '/') def get_all_choices(): repos = RepositoryModel.objects.all().order_by('name'). \ diff --git a/gpackages/apps/packages/templatetags/packages.py b/gpackages/apps/packages/templatetags/packages.py index 5f3f966..77e0f65 100644 --- a/gpackages/apps/packages/templatetags/packages.py +++ b/gpackages/apps/packages/templatetags/packages.py @@ -66,8 +66,8 @@ def arch_choice_modal(context): request = context['request'] arches_s = request.session.get('arches') arches_s = arches_s or arches - return {'form': ArchChoiceForm(initial = {'arches': arches_s}), - 'arches': arches_s} + initial = {'arches': arches_s, 'next' : request.path} + return {'form': ArchChoiceForm(initial = initial), 'arches': arches_s} @register.inclusion_tag('filtering_modal.html', takes_context = True) def filtering_modal(context): diff --git a/gpackages/apps/packages/views.py b/gpackages/apps/packages/views.py index b6ddb97..4a5d509 100644 --- a/gpackages/apps/packages/views.py +++ b/gpackages/apps/packages/views.py @@ -219,15 +219,24 @@ class ArchChoiceView(ContextView, ArchesViewMixin, FormView): extra_context = {'page_name': 'Select arches', 'default_arches': arches} + def __init__(self, *args, **kwargs): + super(ArchChoiceView, self).__init__(*args, **kwargs) + self.next_url = None + def get_initial(self): arches = self.get_arches() return {'arches': arches } + def get_success_url(self): + val = super(ArchChoiceView, self).get_success_url() + return self.next_url or val + def form_valid(self, form): arches = sorted(form.cleaned_data['arches']) # Maybe save it to cookies ? # arches_str = ','.join(arches) self.request.session['arches'] = arches + self.next_url = form.cleaned_data['next'] return super(ArchChoiceView, self).form_valid(form) class FilteringView(FormView): diff --git a/gpackages/templates/arch_choice.html b/gpackages/templates/arch_choice.html index d55c96e..1fc8403 100644 --- a/gpackages/templates/arch_choice.html +++ b/gpackages/templates/arch_choice.html @@ -15,6 +15,7 @@
{% csrf_token %} +{{ form.next }}
{% if form.arches.errors %} diff --git a/gpackages/templates/arch_choice_modal.html b/gpackages/templates/arch_choice_modal.html index 0f236ee..2785415 100644 --- a/gpackages/templates/arch_choice_modal.html +++ b/gpackages/templates/arch_choice_modal.html @@ -18,6 +18,7 @@
{% csrf_token %} + {{ form.next }}