From 26c0fb454e45d920c5da0e7238d7f83d838fe74c Mon Sep 17 00:00:00 2001 From: Todd Dembrey <todd.dembrey@torchbox.com> Date: Tue, 7 Aug 2018 11:48:48 +0100 Subject: [PATCH] Create the duration block --- opentech/apply/funds/blocks.py | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/opentech/apply/funds/blocks.py b/opentech/apply/funds/blocks.py index 416234725..58d994469 100644 --- a/opentech/apply/funds/blocks.py +++ b/opentech/apply/funds/blocks.py @@ -15,6 +15,9 @@ class TitleBlock(ApplicationMustIncludeFieldBlock): name = 'title' description = 'The title of the project' + class Meta: + icon = 'tag' + class ValueBlock(ApplicationMustIncludeFieldBlock): name = 'value' @@ -50,6 +53,37 @@ class FullNameBlock(ApplicationMustIncludeFieldBlock): icon = 'user' +class DurationBlock(ApplicationMustIncludeFieldBlock): + name = 'duration' + description = 'Duration' + + DURATION_OPTIONS = { + 1: "1 month", + 2: "2 months", + 3: "3 months", + 4: "4 months", + 5: "5 months", + 6: "6 months", + 7: "7 months", + 8: "8 months", + 9: "9 months", + 10: "10 months", + 11: "11 months", + 12: "12 months", + 18: "18 months", + 24: "24 months", + } + field_class = forms.ChoiceField + + def get_field_kwargs(self, *args, **kwargs): + field_kwargs = super().get_field_kwargs(*args, **kwargs) + field_kwargs['choices'] = self.DURATION_OPTIONS.items() + return field_kwargs + + class Meta: + icon = 'date' + + class ApplicationCustomFormFieldsBlock(CustomFormFieldsBlock, FormFieldsBlock): category = CategoryQuestionBlock(group=_('Custom')) required_blocks = ApplicationMustIncludeFieldBlock.__subclasses__() -- GitLab