From: Jeremy Kerr
Date: Tue, 23 Sep 2008 10:52:53 +0000 (+1000)
Subject: [views] Restructure profile view, simplify bundle access
X-Git-Url: https://git.ozlabs.org/?a=commitdiff_plain;h=750c03f854ace16cd013c189369aa0cf9d3bdd9d;p=patchwork
[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
---
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 0000000..466e3bb
Binary files /dev/null and b/htdocs/images/16-em-cross.png differ
diff --git a/htdocs/images/16-em-down.png b/htdocs/images/16-em-down.png
new file mode 100644
index 0000000..50ac318
Binary files /dev/null and b/htdocs/images/16-em-down.png differ
diff --git a/htdocs/js/confirm.js b/htdocs/js/confirm.js
new file mode 100644
index 0000000..cbc91b3
--- /dev/null
+++ b/htdocs/js/confirm.js
@@ -0,0 +1,5 @@
+function confirm_delete(type, name)
+{
+ return confirm("Are you sure you want to delete the " + type +
+ " '" + name + "'?");
+}
diff --git a/templates/base.html b/templates/base.html
index b9b359f..896b939 100644
--- a/templates/base.html
+++ b/templates/base.html
@@ -21,11 +21,12 @@
{{ 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 %}
+
+
+ Name |
+ Project |
+ Public Link |
+ Patches
+ | Download |
+ Delete |
+
+{% for bundle in bundles %}
+
+ {{ bundle.name }} |
+ {{ bundle.project.linkname }} |
+
+ {% if bundle.public %}
+ {{ bundle.public_url }}
+ {% endif %}
+ |
+ {{ bundle.n_patches }} |
+  |
+
+
+ |
+
+
+{% endfor %}
+
+{% 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 %}
-
-
- Bundle name |
- Patches
- | Public Link |
-
-{% for bundle in bundles %}
-
- {{ bundle.name }} |
- {{ bundle.n_patches }} |
-
- {% if bundle.public %}
- {{ bundle.public_url }}
- {% endif %}
- |
-
-{% endfor %}
-
-{% 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
+
+
+
+
+
{% endblock %}