% 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 = \
(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/$',
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
'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)
/* bundles */
table.bundlelist {
+ margin-top: 2em;
+ margin-bottom: 4em;
+ margin-left: auto;
+ margin-right: auto;
border: thin solid black;
}
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%;
+}
--- /dev/null
+function confirm_delete(type, name)
+{
+ return confirm("Are you sure you want to delete the " + type +
+ " '" + name + "'?");
+}
<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/>
--- /dev/null
+{% 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 %}
{% 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
</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">
</tr>
</table>
</form>
+</div>
+
+</div>
+
+<p style="clear: both"></p>
{% endblock %}