From 750c03f854ace16cd013c189369aa0cf9d3bdd9d Mon Sep 17 00:00:00 2001 From: Jeremy Kerr Date: Tue, 23 Sep 2008 20:52:53 +1000 Subject: [PATCH] [views] Restructure profile view, simplify bundle access Make bundles more like todo lists - the list itself has its own page, accessible from the top user links. Signed-off-by: Jeremy Kerr --- apps/patchwork/forms.py | 5 +++ apps/patchwork/urls.py | 2 + apps/patchwork/views/bundle.py | 25 ++++++++++- htdocs/css/style.css | 35 +++++++++++++++ htdocs/images/16-em-cross.png | Bin 0 -> 469 bytes htdocs/images/16-em-down.png | Bin 0 -> 400 bytes htdocs/js/confirm.js | 5 +++ templates/base.html | 9 ++-- templates/patchwork/bundles.html | 62 +++++++++++++++++++++++++++ templates/patchwork/profile.html | 71 +++++++++++++++++-------------- 10 files changed, 177 insertions(+), 37 deletions(-) create mode 100644 htdocs/images/16-em-cross.png create mode 100644 htdocs/images/16-em-down.png create mode 100644 htdocs/js/confirm.js create mode 100644 templates/patchwork/bundles.html diff --git a/apps/patchwork/forms.py b/apps/patchwork/forms.py index bc746bd..dc30299 100644 --- a/apps/patchwork/forms.py +++ b/apps/patchwork/forms.py @@ -80,6 +80,11 @@ class CreateBundleForm(forms.ModelForm): % name) return name +class DeleteBundleForm(forms.Form): + name = 'deletebundleform' + form_name = forms.CharField(initial = name, widget = forms.HiddenInput) + bundle_id = forms.IntegerField(widget = forms.HiddenInput) + class DelegateField(forms.ModelChoiceField): def __init__(self, project, *args, **kwargs): queryset = User.objects.filter(userprofile__in = \ diff --git a/apps/patchwork/urls.py b/apps/patchwork/urls.py index c969b29..4352db0 100644 --- a/apps/patchwork/urls.py +++ b/apps/patchwork/urls.py @@ -36,6 +36,8 @@ urlpatterns = patterns('', (r'^user/todo/$', 'patchwork.views.user.todo_lists'), (r'^user/todo/(?P[^/]+)/$', 'patchwork.views.user.todo_list'), + (r'^user/bundles/$', + 'patchwork.views.bundle.bundles'), (r'^user/bundle/(?P[^/]+)/$', 'patchwork.views.bundle.bundle'), (r'^user/bundle/(?P[^/]+)/mbox/$', diff --git a/apps/patchwork/views/bundle.py b/apps/patchwork/views/bundle.py index d8c868e..5f990c4 100644 --- a/apps/patchwork/views/bundle.py +++ b/apps/patchwork/views/bundle.py @@ -25,7 +25,7 @@ from django.http import HttpResponse, HttpResponseRedirect import django.core.urlresolvers from patchwork.models import Patch, Bundle, Project from patchwork.utils import get_patch_ids -from patchwork.forms import BundleForm +from patchwork.forms import BundleForm, DeleteBundleForm from patchwork.views import generic_list from patchwork.filters import DelegateFilter from patchwork.paginator import Paginator @@ -100,6 +100,29 @@ def setbundle(request): 'patchwork.views.bundle.list') ) +@login_required +def bundles(request): + context = PatchworkRequestContext(request) + + if request.method == 'POST': + form_name = request.POST.get('form_name', '') + + if form_name == DeleteBundleForm.name: + form = DeleteBundleForm(request.POST) + if form.is_valid(): + bundle = get_object_or_404(Bundle, + id = form.cleaned_data['bundle_id']) + bundle.delete() + + bundles = Bundle.objects.filter(owner = request.user) + for bundle in bundles: + bundle.delete_form = DeleteBundleForm(auto_id = False, + initial = {'bundle_id': bundle.id}) + + context['bundles'] = bundles + + return render_to_response('patchwork/bundles.html', context) + @login_required def bundle(request, bundle_id): bundle = get_object_or_404(Bundle, id = bundle_id) diff --git a/htdocs/css/style.css b/htdocs/css/style.css index bef9605..a05e877 100644 --- a/htdocs/css/style.css +++ b/htdocs/css/style.css @@ -267,6 +267,10 @@ span.p_mod { color: #0000ff; } /* bundles */ table.bundlelist { + margin-top: 2em; + margin-bottom: 4em; + margin-left: auto; + margin-right: auto; border: thin solid black; } @@ -400,3 +404,34 @@ table.vertical th, table.vertical td { td.numberformat { text-align: right; } + +/* boxes */ +div.box { + border: thin solid gray; + margin: 1em; + padding: 0.5em; +} + +div.box h2 { + background: #786fb4; + color: white; + margin: -0.5em -0.5em 1em; -0.5em; + padding: 0em 0.5em; + font-size: 100%; +} + +div.box table.vertical { + margin-left: auto; + margin-right: auto; +} + +/* columns */ +.leftcol { + float: left; + width: 49%; +} + +.rightcol { + float: right; + width: 49%; +} diff --git a/htdocs/images/16-em-cross.png b/htdocs/images/16-em-cross.png new file mode 100644 index 0000000000000000000000000000000000000000..466e3bbd92b9a8a900f7b038c21e4e3947c2bc5c GIT binary patch literal 469 zcmV;`0V@89P)>CIcf_9n%yDRLhuf8WZeFAG=!Q$$RrHX}(jdlxmK?@s24@Jz)OfDf&@eW)FoB8IS z+08%1@H`KXtf%0``T7jubEoTlzrPum;!AG7yu!RCvg&o&|HI8IQLP5mY{IHmL$Pp* zg;PG-#0WeX*tTEXXaI);a6Uu#dT@tBSmme+o)L<@0`FDkUe&PBC-NN2g%M zii<_4LP5+zCId}|4(QsvbIhFctP7f$u_;U@(DONv%R#T#aF8A{A!HhD5Ii#+<5eN{t;jR!;{~_8Q11RCwBA{Qv(y10{e3#@M-I9bE9# z8)2-bnu)w+gt6T{f=~@W2bGa_3@}qby4sf?!tVlf@a@-MhQI$HY-T1RynqfqeEZGt z=P$$!EX<6g8}RlEi3T7CoUFJA!~3tO27ts)y@Uq~gF7T>P+j0{Ysm2E?RSP}?|(2H zyYrsm=Wj?Lu(L8T2yyc;=xT{D$O&^YY(0D)t_LM}uH1PHHkOeQ2ZpLa224nC-1zYM z8-|y!UNLa7u`qD5GJ|afVGtW629g7*0jb3nhz&pqU|2BJivm-pFs~59*Pjscx!IW+ zzJGqp@cQk0nC1qoUVs|X2vYd#%X{{ user.username }}
- profile :: todo - ({{ user.get_profile.n_todo_patches }})
- logout :: - about + ({{ user.get_profile.n_todo_patches }}) :: + bundles +
+ profile :: + logout {% else %} login
diff --git a/templates/patchwork/bundles.html b/templates/patchwork/bundles.html new file mode 100644 index 0000000..7f87f6f --- /dev/null +++ b/templates/patchwork/bundles.html @@ -0,0 +1,62 @@ +{% extends "base.html" %} + +{% block title %}Bundles{% endblock %} +{% block heading %}Bundles{% endblock %} + +{% block headers %} + +{% endblock %} + +{% block body %} + +{% if bundles %} + + + + + + + + +{% for bundle in bundles %} + + + + + + + + + +{% endfor %} +
NameProjectPublic LinkPatches + DownloadDelete
{{ bundle.name }}{{ bundle.project.linkname }} + {% if bundle.public %} + {{ bundle.public_url }} + {% endif %} + {{ bundle.n_patches }}download +
+ {{ bundle.delete_form.as_p }} + +
+
+{% endif %} + +

Bundles are groups of related patches. You can create bundles by +selecting patches from a project, then using the 'create bundle' form +to give your bundle a name. Each bundle can be public or private; public +bundles are given a persistent URL, based you your username and the name +of the bundle. Private bundles are only visible to you.

+ +{% if not bundles %} +

You have no bundles.

+{% endif %} +{% endblock %} diff --git a/templates/patchwork/profile.html b/templates/patchwork/profile.html index 81005a3..c204183 100644 --- a/templates/patchwork/profile.html +++ b/templates/patchwork/profile.html @@ -22,42 +22,20 @@ Contributor to {% endif %}

-

Todo

+
+
+

Todo

{% if user.get_profile.n_todo_patches %} -

Your todo -list contains {{ user.get_profile.n_todo_patches }} -patch{{ user.get_profile.n_todo_patches|pluralize:"es" }}.

+

Your todo + list contains {{ user.get_profile.n_todo_patches }} + patch{{ user.get_profile.n_todo_patches|pluralize:"es" }}.

{% else %} -

Your todo list contains patches that have been delegated to you. You -have no items in your todo list at present.

-{% endif %} -

Bundles

- -{% if bundles %} - - - - - -{% for bundle in bundles %} - - - - - -{% endfor %} -
Bundle namePatches - Public Link
{{ bundle.name }}{{ bundle.n_patches }} - {% if bundle.public %} - {{ bundle.public_url }} - {% endif %} -
-{% else %} -

no bundles

+

Your todo list contains patches that have been delegated to you. You + have no items in your todo list at present.

{% endif %} +
- +

Linked email addresses

The following email addresses are associated with this patchwork account. Adding alternative addresses allows patchwork to group contributions that @@ -96,7 +74,31 @@ address.

+
+
+ +
+ +
+

Bundles

+{% if bundles %} +

You have the following bundle{{ bundle|length|pluralize }}:

+ +

Visit the bundles + page to manage your bundles.

+{% else %} +

You have no bundles.

+{% endif %} +
+ + +

Settings

@@ -110,5 +112,10 @@ address.

+
+ +
+ +

{% endblock %} -- 2.39.2