diff --git a/opentech/apply/dashboard/templates/dashboard/dashboard.html b/opentech/apply/dashboard/templates/dashboard/dashboard.html index bdfa001e58e82e47558dfa692d70a6f3fbddb08a..d95e40df80bacbbec4ca7897cf668a9f6634556b 100644 --- a/opentech/apply/dashboard/templates/dashboard/dashboard.html +++ b/opentech/apply/dashboard/templates/dashboard/dashboard.html @@ -7,7 +7,7 @@ {% for submission in applicationsubmission_list %} <tr> <td> - {{ submission }} + {{ submission.title }} </td> </tr> {% empty %} diff --git a/opentech/apply/funds/blocks.py b/opentech/apply/funds/blocks.py index cbe885a8cef4937fae55a412ecb4db14fdd95d07..f07a94967ef29d66999e5ed9c0675815c8eddb3a 100644 --- a/opentech/apply/funds/blocks.py +++ b/opentech/apply/funds/blocks.py @@ -26,15 +26,14 @@ class CustomFormFieldsBlock(FormFieldsBlock): else: error_dict = dict() - required_block_names = [block.name for block in MustIncludeFieldBlock.__subclasses__()] block_types = [block.block_type for block in value] - missing = set(required_block_names) - set(block_types) + missing = set(REQUIRED_BLOCK_NAMES) - set(block_types) counted_types = Counter(block_types) duplicates = [ name for name, count in counted_types.items() - if name in required_block_names and count > 1 + if name in REQUIRED_BLOCK_NAMES and count > 1 ] all_errors = list() @@ -75,6 +74,7 @@ class MustIncludeStatic(StaticBlock): def render_form(self, *args, **kwargs): errors = kwargs.pop('errors') if errors: + # Pretend the error is a readonly input so that we get nice formatting error_message= '<div class="error"><input readonly placeholder="{}"></div>'.format(errors[0]) else: error_message = '' @@ -98,3 +98,6 @@ class TitleBlock(MustIncludeFieldBlock): class ValueBlock(MustIncludeFieldBlock): name = 'value' description = 'The value of the project' + + +REQUIRED_BLOCK_NAMES = [block.name for block in MustIncludeFieldBlock.__subclasses__()] diff --git a/opentech/apply/funds/models.py b/opentech/apply/funds/models.py index 64cf0ccc52930587df15998eb4e503d3a87fb131..cbedf7486caef4692c8a6628031663c3896dea28 100644 --- a/opentech/apply/funds/models.py +++ b/opentech/apply/funds/models.py @@ -21,7 +21,7 @@ from wagtail.wagtailforms.models import AbstractFormSubmission from opentech.apply.stream_forms.models import AbstractStreamForm -from .blocks import CustomFormFieldsBlock +from .blocks import CustomFormFieldsBlock, REQUIRED_BLOCK_NAMES from .forms import WorkflowFormAdminForm from .workflow import SingleStage, DoubleStage @@ -189,4 +189,8 @@ class Round(AbstractStreamForm): class ApplicationSubmission(AbstractFormSubmission): - pass + def __getattr__(self, item): + # fall back to values defined on the data + if item in REQUIRED_BLOCK_NAMES: + return self.get_data()[item] + return super().__getattr__(item)