]> git.ozlabs.org Git - patchwork/commitdiff
[views] Restructure profile view, simplify bundle access
authorJeremy Kerr <jk@ozlabs.org>
Tue, 23 Sep 2008 10:52:53 +0000 (20:52 +1000)
committerJeremy Kerr <jk@ozlabs.org>
Tue, 23 Sep 2008 10:52:53 +0000 (20:52 +1000)
Make bundles more like todo lists - the list itself has its own page,
accessible from the top user links.

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
apps/patchwork/forms.py
apps/patchwork/urls.py
apps/patchwork/views/bundle.py
htdocs/css/style.css
htdocs/images/16-em-cross.png [new file with mode: 0644]
htdocs/images/16-em-down.png [new file with mode: 0644]
htdocs/js/confirm.js [new file with mode: 0644]
templates/base.html
templates/patchwork/bundles.html [new file with mode: 0644]
templates/patchwork/profile.html

index bc746bd11c580deb3031dbaa1925bf36920d29de..dc30299970ab7f8a976de0e6b593b4c4e9d2ee50 100644 (file)
@@ -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 = \
index c969b2954d356faddf3f665f7f95e69b118e9245..4352db0e0d16a4d5d3552c4d3e07209386c06faa 100644 (file)
@@ -36,6 +36,8 @@ urlpatterns = patterns('',
     (r'^user/todo/$', 'patchwork.views.user.todo_lists'),
     (r'^user/todo/(?P<project_id>[^/]+)/$', 'patchwork.views.user.todo_list'),
 
+    (r'^user/bundles/$',
+        'patchwork.views.bundle.bundles'),
     (r'^user/bundle/(?P<bundle_id>[^/]+)/$',
         'patchwork.views.bundle.bundle'),
     (r'^user/bundle/(?P<bundle_id>[^/]+)/mbox/$',
index d8c868eee64ac5bdc2b8a041ae213de42133c9a7..5f990c44dfe0d1f705370cbd8d8e3a922a623fe4 100644 (file)
@@ -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)
index bef96057199e233b4f1d83499e891aa92ec85c2d..a05e877eaff45922cfb9fffab5e68b1d4fcff56e 100644 (file)
@@ -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 (file)
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 (file)
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 (file)
index 0000000..cbc91b3
--- /dev/null
@@ -0,0 +1,5 @@
+function confirm_delete(type, name)
+{
+       return confirm("Are you sure you want to delete the " + type +
+                       " '" + name + "'?");
+}
index b9b359f2c5c10154ff10258d159c0a60e33009a0..896b93970de93d9d985c5aff66bfe204fef4d3ac 100644 (file)
     <a href="{% url patchwork.views.user.profile %}"
      ><strong>{{ user.username }}</strong></a>
     <br/>
-     <a href="{% url patchwork.views.user.profile %}">profile</a> ::
      <a href="{% url patchwork.views.user.todo_lists %}">todo
-      ({{ user.get_profile.n_todo_patches }})</a><br/>
-     <a href="{% url auth_logout %}">logout</a> ::
-     <a href="{% url patchwork.views.help path="about/" %}">about</a>
+      ({{ user.get_profile.n_todo_patches }})</a> ::
+     <a href="{% url patchwork.views.bundle.bundles %}">bundles</a>
+     <br/>
+     <a href="{% url patchwork.views.user.profile %}">profile</a> ::
+     <a href="{% url auth_logout %}">logout</a>
 {% else %}
      <a href="{% url auth_login %}">login</a>
      <br/>
diff --git a/templates/patchwork/bundles.html b/templates/patchwork/bundles.html
new file mode 100644 (file)
index 0000000..7f87f6f
--- /dev/null
@@ -0,0 +1,62 @@
+{% extends "base.html" %}
+
+{% block title %}Bundles{% endblock %}
+{% block heading %}Bundles{% endblock %}
+
+{% block headers %}
+ <script language="JavaScript" type="text/javascript" src="/js/confirm.js">
+ </script>
+{% endblock %}
+
+{% block body %}
+
+{% if bundles %}
+<table class="bundlelist">
+ <tr>
+  <th>Name</th>
+  <th>Project</th>
+  <th>Public Link</th>
+  <th>Patches</td>
+  <th>Download</th>
+  <th>Delete</th>
+ </tr>
+{% for bundle in bundles %}
+ <tr>
+  <td><a href="{% url patchwork.views.bundle.bundle bundle_id=bundle.id %}"
+   >{{ bundle.name }}</a></td>
+  <td>{{ bundle.project.linkname }}</td>
+  <td>
+   {% if bundle.public %}
+    <a href="{{ bundle.public_url }}">{{ bundle.public_url }}</a>
+   {% endif %}
+  </td>
+  <td style="text-align: right">{{ bundle.n_patches }}</td>
+  <td style="text-align: center;"><a
+   href="{% url patchwork.views.bundle.mbox bundle_id=bundle.id %}"
+   ><img src="/images/16-em-down.png" width="16" height="16" alt="download"
+   title="download"/></a></td>
+  <td style="text-align: center;">
+   <form method="post"
+    onsubmit="return confirm_delete('bundle', '{{bundle.name|escapejs}}');">
+    {{ bundle.delete_form.as_p }}
+    <input type="image"
+     src="/images/16-em-cross.png" width="16" height="16" alt="delete"
+     title="delete" border="0" style="border: none;"/>
+   </form>
+  </td>
+
+ </tr>
+{% endfor %}
+</table>
+{% endif %}
+
+<p>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.</p>
+
+{% if not bundles %}
+<p>You have no bundles.</p>
+{% endif %}
+{% endblock %}
index 81005a36616f165cb476203a74530325899b3ef8..c204183ab923fc1084674b9e54333e1e5da5cf9f 100644 (file)
@@ -22,42 +22,20 @@ Contributor to
 {% endif %}
 </p>
 
-<h2>Todo</h2>
+<div class="leftcol">
+<div class="box">
+ <h2>Todo</h2>
 {% if user.get_profile.n_todo_patches %}
-<p>Your <a href="{% url patchwork.views.user.todo_lists %}">todo
-list</a> contains {{ user.get_profile.n_todo_patches }}
-patch{{ user.get_profile.n_todo_patches|pluralize:"es" }}.</p>
+ <p>Your <a href="{% url patchwork.views.user.todo_lists %}">todo
+  list</a> contains {{ user.get_profile.n_todo_patches }}
+  patch{{ user.get_profile.n_todo_patches|pluralize:"es" }}.</p>
 {% else %}
-<p>Your todo list contains patches that have been delegated to you. You
-have no items in your todo list at present.</p>
-{% endif %}
-<h2>Bundles</h2>
-
-{% if bundles %}
-<table class="bundlelist">
- <tr>
-  <th>Bundle name</th>
-  <th>Patches</td>
-  <th>Public Link</th>
- </tr>
-{% for bundle in bundles %}
- <tr>
-  <td><a href="{% url patchwork.views.bundle.bundle bundle_id=bundle.id %}"
-   >{{ bundle.name }}</a></td>
-  <td style="text-align: right">{{ bundle.n_patches }}</td>
-  <td>
-   {% if bundle.public %}
-    <a href="{{ bundle.public_url }}">{{ bundle.public_url }}</a>
-   {% endif %}
-  </td>
- </tr>
-{% endfor %}
-</table>
-{% else %}
-<p>no bundles</p>
+ <p>Your todo list contains patches that have been delegated to you. You
+  have no items in your todo list at present.</p>
 {% endif %}
+</div>
 
-
+<div class="box">
 <h2>Linked email addresses</h2>
 <p>The following email addresses are associated with this patchwork account.
 Adding alternative addresses allows patchwork to group contributions that
@@ -96,7 +74,31 @@ address.</p>
   </td>
  </tr>
 </table>
+</div>
+</div>
+
+<div class="rightcol">
+
+<div class="box">
+<h2>Bundles</h2>
 
+{% if bundles %}
+<p>You have the following bundle{{ bundle|length|pluralize }}:</p>
+<ul>
+{% for bundle in bundles %}
+ <li><a href="{% url patchwork.views.bundle.bundle bundle_id=bundle.id %}"
+   >{{ bundle.name }}</a></li>
+{% endfor %}
+</ul>
+<p>Visit the <a href="{%url patchwork.views.bundle.bundles %}">bundles
+ page</a> to manage your bundles.</p>
+{% else %}
+<p>You have no bundles.</p>
+{% endif %}
+</div>
+
+
+<div class="box">
 <h2>Settings</h2>
 
 <form method="post">
@@ -110,5 +112,10 @@ address.</p>
   </tr>
  </table>
 </form>
+</div>
+
+</div>
+
+<p style="clear: both"></p>
 
 {% endblock %}