damned-lies r1499 - in trunk: . stats templates
- From: claudep svn gnome org
- To: svn-commits-list gnome org
- Subject: damned-lies r1499 - in trunk: . stats templates
- Date: Mon, 16 Mar 2009 21:34:17 +0000 (UTC)
Author: claudep
Date: Mon Mar 16 21:34:17 2009
New Revision: 1499
URL: http://svn.gnome.org/viewvc/damned-lies?rev=1499&view=rev
Log:
2009-03-16 Claude Paroz <claude 2xlibre net>
* stats/forms.py:
* stats/views.py:
* templates/module_edit_branches.html: Instead of using a 'delete'
checkbox to delete a category, use the empty value of the release popup to
signify 'delete'. Probably more intuitive, as old delete checkbox could be
interpreted as the branch deletion.
Fixes bug #575541.
Modified:
trunk/ChangeLog
trunk/stats/forms.py
trunk/stats/views.py
trunk/templates/module_edit_branches.html
Modified: trunk/stats/forms.py
==============================================================================
--- trunk/stats/forms.py (original)
+++ trunk/stats/forms.py Mon Mar 16 21:34:17 2009
@@ -4,6 +4,7 @@
class ReleaseField(forms.ModelChoiceField):
def __init__(self, *args, **kwargs):
super(ReleaseField, self).__init__(*args, **kwargs)
+ self.required = False
if 'initial' in kwargs:
self.is_branch = True
@@ -11,21 +12,29 @@
def __init__(self, module, *args, **kwargs):
super(ModuleBranchForm, self).__init__(*args, **kwargs)
self.branch_fields = []
- for branch in module.branch_set.all():
- for cat in branch.category_set.order_by('name', 'release__name'):
- self.fields[str(cat.id)] = ReleaseField(queryset=Release.objects.all(),
- label=branch.name,
- initial=cat.release.pk)
- self.fields[str(cat.id)+'_cat'] = forms.ChoiceField(choices=CATEGORY_CHOICES,
+ for branch in module.get_branches():
+ categs = branch.category_set.order_by('name', 'release__name')
+ if len(categs):
+ for cat in categs:
+ self.fields[str(cat.id)] = ReleaseField(queryset=Release.objects.all(),
+ label=branch.name,
+ initial=cat.release.pk)
+ self.fields[str(cat.id)+'_cat'] = forms.ChoiceField(choices=CATEGORY_CHOICES,
+ initial=cat.name)
+ self.branch_fields.append((str(cat.id), str(cat.id)+'_cat'))
+ else:
+ # Branch is not linked to any release
+ self.fields[branch.name] = ReleaseField(queryset=Release.objects.all(),
+ label=branch.name)
+ self.fields[branch.name+'_cat'] = forms.ChoiceField(choices=CATEGORY_CHOICES,
initial=cat.name)
- self.fields[str(cat.id)+'_del'] = forms.BooleanField(required=False)
- self.branch_fields.append((str(cat.id), str(cat.id)+'_cat', str(cat.id)+'_del'))
+ self.branch_fields.append((branch.name, branch.name+'_cat'))
self.fields['new_branch'] = forms.CharField(required=False)
self.fields['new_branch_release'] = ReleaseField(queryset=Release.objects.all(), required=False)
self.fields['new_branch_category'] = forms.ChoiceField(choices=CATEGORY_CHOICES)
def get_branches(self):
- for rel_field, cat_field, del_field in self.branch_fields:
- yield (self[rel_field], self[cat_field], self[del_field])
+ for rel_field, cat_field in self.branch_fields:
+ yield (self[rel_field], self[cat_field])
Modified: trunk/stats/views.py
==============================================================================
--- trunk/stats/views.py (original)
+++ trunk/stats/views.py Mon Mar 16 21:34:17 2009
@@ -63,7 +63,7 @@
for key, field in form.fields.items():
if not getattr(field, 'is_branch', False):
continue
- if form.cleaned_data[key+'_del']:
+ if form.fields[key].initial and not form.cleaned_data[key]:
# Delete category
Category.objects.get(pk=key).delete()
updated = True
Modified: trunk/templates/module_edit_branches.html
==============================================================================
--- trunk/templates/module_edit_branches.html (original)
+++ trunk/templates/module_edit_branches.html Mon Mar 16 21:34:17 2009
@@ -15,8 +15,8 @@
<form action="#" method="POST">
<table>
<tr><th>Branch</th><th>Release</th><th>Category</th></tr>
-{% for field1, field2, field3 in form.get_branches %}
- <tr><td>{{ field1.label }}</td><td>{{ field1 }}</td><td>{{ field2 }}</td><td>{{ field3 }} <i>delete?</i></td></tr>
+{% for field1, field2 in form.get_branches %}
+ <tr><td>{{ field1.label }}</td><td>{{ field1 }}</td><td>{{ field2 }}</td></tr>
{% endfor %}
<tr><td>{{ form.new_branch }}</td><td>{{ form.new_branch_release }}</td><td>{{ form.new_branch_category }}</td></tr>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]