From a7ce0cda0cec4d2066edaa49e58a4ddb6ba75ed0 Mon Sep 17 00:00:00 2001 From: Mikel Emaldi Date: Fri, 20 Jan 2017 12:11:29 +0100 Subject: [PATCH] A quick-fix to allow migrating the database. Untested --- labman_ud/entities/publications/forms.py | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/labman_ud/entities/publications/forms.py b/labman_ud/entities/publications/forms.py index 3997475..0786bad 100644 --- a/labman_ud/entities/publications/forms.py +++ b/labman_ud/entities/publications/forms.py @@ -4,12 +4,6 @@ from entities.utils.models import Tag from entities.publications.models import Publication -PUBLICATION_TYPES = (()) -types = Publication.objects.all().values_list('child_type', flat=True).order_by('child_type').distinct() -for choice in types: - PUBLICATION_TYPES = PUBLICATION_TYPES + ((choice, choice),) - - class CommaSeparatedStringField(forms.Field): def __init__(self, *args, **kwargs): @@ -57,7 +51,7 @@ class PublicationSearchForm(forms.Form): max_length=2, required=False) publication_types = forms.MultipleChoiceField( - choices=PUBLICATION_TYPES, required=False) + choices=(()), required=False) tags = CommaSeparatedStringField( required=False) @@ -66,6 +60,15 @@ class PublicationSearchForm(forms.Form): editor_field_count = forms.CharField(widget=forms.HiddenInput()) def __init__(self, *args, **kwargs): + + publication_types_tuple = (()) + types = Publication.objects.all().values_list('child_type', flat=True).order_by('child_type').distinct() + for choice in types: + publication_types_tuple = publication_types_tuple + ((choice, choice),) + + self.publication_types = forms.MultipleChoiceField( + choices=publication_types_tuple, required=False) + extra_editor_fields = kwargs.pop('extra_editor', 1) extra_author_fields = kwargs.pop('extra_author', 1)