diff --git a/opentech/apply/projects/admin.py b/opentech/apply/projects/admin.py new file mode 100644 index 0000000000000000000000000000000000000000..711563188a21bdd91c2e29ea110956626a556f9e --- /dev/null +++ b/opentech/apply/projects/admin.py @@ -0,0 +1,17 @@ +from wagtail.contrib.modeladmin.options import ModelAdmin, ModelAdminGroup + +from .models import DocumentCategory + + +class DocumentCategoryAdmin(ModelAdmin): + model = DocumentCategory + menu_icon = 'doc-full' + list_display = ('name', 'recommended_minimum',) + + +class ManageAdminGoup(ModelAdminGroup): + menu_label = 'Manage' + menu_icon = 'folder-open-inverse' + items = ( + DocumentCategoryAdmin, + ) diff --git a/opentech/apply/projects/migrations/0009_documentcategory.py b/opentech/apply/projects/migrations/0009_documentcategory.py new file mode 100644 index 0000000000000000000000000000000000000000..6925bcfa68c739c81951cf8a1bc8a21111caeb44 --- /dev/null +++ b/opentech/apply/projects/migrations/0009_documentcategory.py @@ -0,0 +1,25 @@ +# Generated by Django 2.0.13 on 2019-08-06 22:08 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('application_projects', '0008_add_value_validator'), + ] + + operations = [ + migrations.CreateModel( + name='DocumentCategory', + fields=[ + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('name', models.CharField(max_length=254)), + ('recommended_minimum', models.PositiveIntegerField()), + ], + options={ + 'ordering': ('name',), + 'verbose_name_plural': 'Document Categories', + }, + ), + ] diff --git a/opentech/apply/projects/models.py b/opentech/apply/projects/models.py index fbe5e4e110e6d8f8b5e5aec65d518dbb73361164..7d8364d0776b5a4df465124a350589cf113326b4 100644 --- a/opentech/apply/projects/models.py +++ b/opentech/apply/projects/models.py @@ -78,3 +78,15 @@ class Project(models.Model): def get_absolute_url(self): return reverse('apply:projects:detail', args=[self.id]) + + +class DocumentCategory(models.Model): + name = models.CharField(max_length=254) + recommended_minimum = models.PositiveIntegerField() + + def __str__(self): + return self.name + + class Meta: + ordering = ('name',) + verbose_name_plural = 'Document Categories' diff --git a/opentech/apply/projects/templates/application_projects/includes/supporting_documents.html b/opentech/apply/projects/templates/application_projects/includes/supporting_documents.html index beea493b85f422fef026d094065c4c5fea940c8d..4fb310d0785409468273bdc59fef32226ce0c43a 100644 --- a/opentech/apply/projects/templates/application_projects/includes/supporting_documents.html +++ b/opentech/apply/projects/templates/application_projects/includes/supporting_documents.html @@ -41,7 +41,18 @@ <div class="docs-block__row-inner"> <a data-fancybox data-src="#upload-supporting-doc" class="docs-block__link" href="#">Upload new</a> </div> - <p class="docs-block__info-text">Every project requires a XXXXXX and XXXXXX to be uploaded</p> + {% if remaining_document_categories %} + <div class="docs-block__info-text"> + <p> + Every project should include the following documents: + </p> + <ul> + {% for category in remaining_document_categories %} + <li>{{ category.name }} ({{ category.recommended_minimum }})</li> + {% endfor %} + </ul> + </div> + {% endif %} <!-- Example document list <ul class="docs-block__document-list"> <li class="docs-block__document"> diff --git a/opentech/apply/projects/views.py b/opentech/apply/projects/views.py index 07b525ebe07f5d4a4054229ab7d62f9a45136bdc..63e88bc5d182d3a1773cab7b9f94e68337f25e11 100644 --- a/opentech/apply/projects/views.py +++ b/opentech/apply/projects/views.py @@ -10,7 +10,7 @@ from opentech.apply.utils.views import (DelegateableView, DelegatedViewMixin, ViewDispatcher) from .forms import ProjectEditForm, UpdateProjectLeadForm -from .models import Project +from .models import Project, DocumentCategory @method_decorator(staff_required, name='dispatch') @@ -44,6 +44,12 @@ class AdminProjectDetailView(ActivityContextMixin, DelegateableView, DetailView) model = Project template_name_suffix = '_admin_detail' + def get_context_data(self, **kwargs): + return super().get_context_data( + remaining_document_categories=DocumentCategory.objects.all(), + **kwargs, + ) + class ApplicantProjectDetailView(DetailView): model = Project diff --git a/opentech/apply/projects/wagtail_hooks.py b/opentech/apply/projects/wagtail_hooks.py new file mode 100644 index 0000000000000000000000000000000000000000..b33974ab8c280ff6e53c4268739dda3350746c3b --- /dev/null +++ b/opentech/apply/projects/wagtail_hooks.py @@ -0,0 +1,6 @@ +from wagtail.contrib.modeladmin.options import modeladmin_register + +from .admin import ManageAdminGoup + + +modeladmin_register(ManageAdminGoup)