Renamed category to detail

This commit is contained in:
Oskar Hahn 2012-10-24 12:30:45 +02:00
parent 56b9e831c8
commit 57d591fee8
6 changed files with 31 additions and 31 deletions

View File

@ -433,8 +433,8 @@ class AssignmentPDF(PDFView):
candidate_string = candidate.clean_name
if candidate in elected_candidates:
candidate_string = "* " + candidate_string
if candidate.category:
candidate_string += "\n(%s)" % candidate.category
if candidate.name_suffix:
candidate_string += "\n(%s)" % candidate.name_suffix
row.append(candidate_string)
for vote in poll_list:
if vote == None:
@ -594,7 +594,7 @@ class AssignmentPollPDF(PDFView):
cell.append(Paragraph(circle + candidate.clean_name,
stylesheet['Ballot_option_name']))
if candidate.name_suffix:
cell.append(Paragraph("(%s)" % candidate.category,
cell.append(Paragraph("(%s)" % candidate.name_suffix,
stylesheet['Ballot_option_group_right']))
else:
cell.append(Paragraph(" ",

View File

@ -27,7 +27,7 @@ class UserCreateForm(forms.ModelForm, CssClassMixin):
class Meta:
model = User
fields = ('first_name', 'last_name', 'is_active', 'groups', 'category',
fields = ('first_name', 'last_name', 'is_active', 'groups', 'detail',
'gender', 'type', 'committee', 'comment', 'default_password')
@ -35,7 +35,7 @@ class UserUpdateForm(UserCreateForm):
class Meta:
model = User
fields = ('username', 'first_name', 'last_name', 'is_active', 'groups',
'category', 'gender', 'type', 'committee', 'comment',
'detail', 'gender', 'type', 'committee', 'comment',
'default_password')

View File

@ -37,8 +37,8 @@ class User(DjangoUser, PersonMixin, Person):
)
django_user = models.OneToOneField(DjangoUser, editable=False, parent_link=True)
category = models.CharField(
max_length=100, null=True, blank=True, verbose_name=_("Category"),
detail = models.CharField(
max_length=100, blank=True, default='', verbose_name=_("Detail"),
help_text=_('Will be shown behind the name.'))
gender = models.CharField(
max_length=50, choices=GENDER_CHOICES, blank=True,
@ -47,13 +47,13 @@ class User(DjangoUser, PersonMixin, Person):
max_length=100, choices=TYPE_CHOICES, blank=True,
verbose_name=_("Typ"), help_text=_('Only for filter the userlist.'))
committee = models.CharField(
max_length=100, null=True, blank=True, verbose_name=_("Committee"),
max_length=100, blank=True, default='', verbose_name=_("Committee"),
help_text=_('Only for filter the userlist.'))
comment = models.TextField(
null=True, blank=True, verbose_name=_('Comment'),
blank=True, default='', verbose_name=_('Comment'),
help_text=_('Only for notes.'))
default_password = models.CharField(
max_length=100, null=True, blank=True,
max_length=100, blank=True, default='',
verbose_name=_("Default password"))
@property
@ -61,10 +61,10 @@ class User(DjangoUser, PersonMixin, Person):
return self.get_full_name() or self.username
def get_name_suffix(self):
return self.category
return self.detail
def set_name_suffix(self, value):
self.category = value
self.detail = value
name_suffix = property(get_name_suffix, set_name_suffix)

View File

@ -26,11 +26,11 @@
<option value="female"{% if 'female' in sortfilter.gender %} selected{% endif %}>{% trans "Female" %}</option>
<option value=""{% if '' in sortfilter.gender %} selected{% endif %}>{% trans "Not specified" %}</option>
</select>
<select class="default-input" name="category" onchange="document.forms['filter'].submit()">
<option value="---">-- {% trans "Category" %} --</option>
{% for category in categories %}
<option value="{{ category }}"{% if category in sortfilter.category %} selected{% endif %}>
{{ category }}</option>
<select class="default-input" name="detail" onchange="document.forms['filter'].submit()">
<option value="---">-- {% trans "Detail" %} --</option>
{% for detail in details %}
<option value="{{ detail }}"{% if detail in sortfilter.detail %} selected{% endif %}>
{{ detail }}</option>
{% endfor %}
</select>
<select class="default-input" name="type" onchange="document.forms['filter'].submit()">
@ -65,7 +65,7 @@
<tr>
<th><a href="?sort=first_name&reverse={% if 'first_name' in sortfilter.sort and 'reverse' not in sortfilter %}1{% else %}---{%endif%}">{% trans "First Name" %}</a></th>
<th><a href="?sort=last_name&reverse={% if 'last_name' in sortfilter.sort and 'reverse' not in sortfilter %}1{% else %}---{%endif%}">{% trans "Last Name" %}</a></th>
<th><a href="?sort=category&reverse={% if 'category' in sortfilter.sort and 'reverse' not in sortfilter %}1{% else %}---{%endif%}">{% trans "Category" %}</a></th>
<th><a href="?sort=detail&reverse={% if 'detail' in sortfilter.sort and 'reverse' not in sortfilter %}1{% else %}---{%endif%}">{% trans "Detail" %}</a></th>
<th><a href="?sort=type&reverse={% if 'type' in sortfilter.sort and 'reverse' not in sortfilter %}1{% else %}---{%endif%}">{% trans "Type" %}</a></th>
<th><a href="?sort=committee&reverse={% if 'committee' in sortfilter.sort and 'reverse' not in sortfilter %}1{% else %}---{%endif%}">{% trans "Committee" %}</a></th>
{% if perms.participant.can_manage_participant %}
@ -78,7 +78,7 @@
<tr class="{% cycle '' 'odd' %}">
<td>{{ user.first_name }}</td>
<td>{{ user.last_name }}</td>
<td>{{ user.category }}</td>
<td>{{ user.detail }}</td>
<td>{{ user.get_type_display }}</td>
<td>{{ user.committee }}</td>
{% if perms.participant.can_manage_participant %}

View File

@ -35,12 +35,12 @@ class UserTest(TestCase):
self.assertEqual(self.django_user1, self.user1.django_user)
def test_repr(self):
self.assertEqual(unicode(self.user1), u'Max Mustermann')
self.assertEqual(unicode(self.user1), 'Max Mustermann')
def test_name_surfix(self):
self.user1.category = u'München'
self.user1.detail = 'München'
self.user1.save()
self.assertEqual(unicode(self.user1), u'Max Mustermann (München)')
self.assertEqual(unicode(self.user1), 'Max Mustermann (München)')
def test_reset_password(self):
self.assertIsInstance(self.user1.default_password, basestring)

View File

@ -66,8 +66,8 @@ class Overview(ListView):
except KeyError:
sortfilter = {}
for value in [u'gender', u'category', u'type', u'committee', u'status',
u'sort', u'reverse']:
for value in ['gender', 'detail', 'type', 'committee', 'status',
'sort', 'reverse']:
if value in self.request.REQUEST:
if self.request.REQUEST[value] == '---':
try:
@ -80,8 +80,8 @@ class Overview(ListView):
query = User.objects
if 'gender' in sortfilter:
query = query.filter(gender__iexact=sortfilter['gender'][0])
if 'category' in sortfilter:
query = query.filter(category__iexact=sortfilter['category'][0])
if 'detail' in sortfilter:
query = query.filter(detail__iexact=sortfilter['detail'][0])
if 'type' in sortfilter:
query = query.filter(type__iexact=sortfilter['type'][0])
if 'committee' in sortfilter:
@ -92,7 +92,7 @@ class Overview(ListView):
if sortfilter['sort'][0] in ['first_name', 'last_name', 'last_login']:
query = query.order_by(sortfilter['sort'][0])
elif (sortfilter['sort'][0] in
['category', 'type', 'committee', 'comment']):
['detail', 'type', 'committee', 'comment']):
query = query.order_by(
'%s' % sortfilter['sort'][0])
else:
@ -118,8 +118,8 @@ class Overview(ListView):
percent = 0
# list of all existing categories
categories = [p['category'] for p in User.objects.values('category')
.exclude(category='').distinct()]
details = [p['detail'] for p in User.objects.values('detail')
.exclude(detail='').distinct()]
# list of all existing committees
committees = [p['committee'] for p in User.objects.values('committee')
@ -127,7 +127,7 @@ class Overview(ListView):
context.update({
'allusers': all_users,
'percent': round(percent, 1),
'categories': categories,
'details': details,
'committees': committees,
'cookie': ['participant_sortfilter', urlencode(decodedict(self.sortfilter),
doseq=True)],
@ -223,7 +223,7 @@ class ParticipantsListPDF(PDFView):
counter,
Paragraph(user.last_name, stylesheet['Tablecell']),
Paragraph(user.first_name, stylesheet['Tablecell']),
Paragraph(user.category, stylesheet['Tablecell']),
Paragraph(user.detail, stylesheet['Tablecell']),
Paragraph(user.type, stylesheet['Tablecell']),
Paragraph(user.committee, stylesheet['Tablecell'])])
t = LongTable(data, style=[