public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
From: "Slava Bacherikov" <slava@bacherikov.org.ua>
To: gentoo-commits@lists.gentoo.org
Subject: [gentoo-commits] proj/gentoo-packages:master commit in: gpackages/apps/packages/, gpackages/apps/packages/templatetags/, ...
Date: Thu,  2 Aug 2012 22:44:46 +0000 (UTC)	[thread overview]
Message-ID: <1343911770.4b711746de61ce9d808d265a55aad129675ba64f.bacher09@gentoo> (raw)

commit:     4b711746de61ce9d808d265a55aad129675ba64f
Author:     Slava Bacherikov <slava <AT> bacher09 <DOT> org>
AuthorDate: Thu Aug  2 12:49:30 2012 +0000
Commit:     Slava Bacherikov <slava <AT> bacherikov <DOT> org <DOT> 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 @@
 </script>
 <div class="arches">
 <form action="./" method="post" enctype="multipart/form-data">{% csrf_token %}
+{{ form.next }}
 <fieldset>
     <div class="control-group">
         {% 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 @@
     </div>
     <form action="{% url 'archchoice' %}" method="post" enctype="multipart/form-data">
     {% csrf_token %}
+    {{ form.next }}
     <div class="arches modal-body">
         <fieldset>
             {{ form.arches }}


             reply	other threads:[~2012-08-02 22:45 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-08-02 22:44 Slava Bacherikov [this message]
  -- strict thread matches above, loose matches on Subject: below --
2012-07-31 14:22 [gentoo-commits] proj/gentoo-packages:master commit in: gpackages/apps/packages/, gpackages/apps/packages/templatetags/, Slava Bacherikov
2012-07-31 14:22 Slava Bacherikov
2012-07-30 23:30 Slava Bacherikov
2012-07-18 23:03 Slava Bacherikov
2012-06-28 23:59 Slava Bacherikov
2012-06-27 22:52 Slava Bacherikov
2012-06-15 23:28 Slava Bacherikov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1343911770.4b711746de61ce9d808d265a55aad129675ba64f.bacher09@gentoo \
    --to=slava@bacherikov.org.ua \
    --cc=gentoo-commits@lists.gentoo.org \
    --cc=gentoo-dev@lists.gentoo.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox