mirror of
https://github.com/django-helpdesk/django-helpdesk.git
synced 2025-05-29 22:19:05 +02:00
Allow selection of all items on custom "list" fields. Fixes GH-23.
This commit is contained in:
parent
c9e68a05a7
commit
b42026ec33
@ -8,6 +8,7 @@ forms.py - Definitions of newforms-based forms for creating and maintaining
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
|
from StringIO import StringIO
|
||||||
|
|
||||||
from django import forms
|
from django import forms
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
@ -119,10 +120,7 @@ class TicketForm(forms.Form):
|
|||||||
instanceargs['max_digits'] = field.max_length
|
instanceargs['max_digits'] = field.max_length
|
||||||
elif field.data_type == 'list':
|
elif field.data_type == 'list':
|
||||||
fieldclass = forms.ChoiceField
|
fieldclass = forms.ChoiceField
|
||||||
choices = []
|
instanceargs['choices'] = field.choices_as_array
|
||||||
for line in field.list_values.split("\n"):
|
|
||||||
choices.append((line, line))
|
|
||||||
instanceargs['choices'] = choices
|
|
||||||
elif field.data_type == 'boolean':
|
elif field.data_type == 'boolean':
|
||||||
fieldclass = forms.BooleanField
|
fieldclass = forms.BooleanField
|
||||||
elif field.data_type == 'date':
|
elif field.data_type == 'date':
|
||||||
|
@ -1169,6 +1169,14 @@ class CustomField(models.Model):
|
|||||||
null=True,
|
null=True,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
def _choices_as_array(self):
|
||||||
|
from StringIO import StringIO
|
||||||
|
valuebuffer = StringIO(self.list_values)
|
||||||
|
choices = [[item.strip(), item.strip()] for item in valuebuffer.readlines()]
|
||||||
|
valuebuffer.close()
|
||||||
|
return choices
|
||||||
|
choices_as_array = property(_choices_as_array)
|
||||||
|
|
||||||
required = models.BooleanField(
|
required = models.BooleanField(
|
||||||
_('Required?'),
|
_('Required?'),
|
||||||
help_text=_('Does the user have to enter a value for this field?'),
|
help_text=_('Does the user have to enter a value for this field?'),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user