diff --git a/opentech/apply/categories/admin.py b/opentech/apply/categories/admin.py index 2eb24d179ee07a77d238c5cb068d6458ab2b1162..0ada958a07ba7abfa88ba19862a6ea52728462b1 100644 --- a/opentech/apply/categories/admin.py +++ b/opentech/apply/categories/admin.py @@ -1,9 +1,9 @@ from django.conf.urls import url from wagtail.contrib.modeladmin.options import ModelAdmin -from .admin_helpers import MetaCategoryButtonHelper -from .admin_views import AddChildMetaCategoryViewClass -from .models import Category, MetaCategory +from .admin_helpers import MetaTermButtonHelper +from .admin_views import AddChildMetaTermViewClass +from .models import Category, MetaTerm class CategoryAdmin(ModelAdmin): @@ -12,8 +12,8 @@ class CategoryAdmin(ModelAdmin): model = Category -class MetaCategoryAdmin(ModelAdmin): - model = MetaCategory +class MetaTermAdmin(ModelAdmin): + model = MetaTerm menu_icon = 'tag' @@ -24,11 +24,11 @@ class MetaCategoryAdmin(ModelAdmin): inspect_view_enabled = True inspect_view_fields = ('name', 'get_parent', 'id') - button_helper_class = MetaCategoryButtonHelper + button_helper_class = MetaTermButtonHelper def add_child_view(self, request, instance_pk): kwargs = {'model_admin': self, 'parent_pk': instance_pk} - view_class = AddChildMetaCategoryViewClass + view_class = AddChildMetaTermViewClass return view_class.as_view(**kwargs)(request) def get_admin_urls_for_registration(self): diff --git a/opentech/apply/categories/admin_helpers.py b/opentech/apply/categories/admin_helpers.py index 9f786fced1de4030624668a1e96c39297d414ba2..6937b6b342ff387d1a9d293d97bd725f87470a36 100644 --- a/opentech/apply/categories/admin_helpers.py +++ b/opentech/apply/categories/admin_helpers.py @@ -3,9 +3,9 @@ from django.contrib.admin.utils import quote from wagtail.contrib.modeladmin.helpers import ButtonHelper -class MetaCategoryButtonHelper(ButtonHelper): +class MetaTermButtonHelper(ButtonHelper): def delete_button(self, pk, *args, **kwargs): - """Ensure that the delete button is not shown for root category.""" + """Ensure that the delete button is not shown for root meta term.""" instance = self.model.objects.get(pk=pk) if instance.is_root(): return @@ -18,7 +18,11 @@ class MetaCategoryButtonHelper(ButtonHelper): return self.finalise_classname(classnames, exclude or []) def add_child_button(self, pk, child_verbose_name, **kwargs): - """Build a add child button, to easily add a child under category.""" + """Build a add child button, to easily add a child under meta term.""" + instance = self.model.objects.get(pk=pk) + if instance.is_archived or instance.get_parent() and instance.get_parent().is_archived: + return + classnames = self.prepare_classnames( start=self.edit_button_classnames + ['icon', 'icon-plus'], add=kwargs.get('classnames_add'), diff --git a/opentech/apply/categories/admin_views.py b/opentech/apply/categories/admin_views.py index 890bccbe451363c024e42286f885067a66515838..98faa64a6489dfcc4e50e8eab0c00a52445faab5 100644 --- a/opentech/apply/categories/admin_views.py +++ b/opentech/apply/categories/admin_views.py @@ -4,7 +4,7 @@ from django.shortcuts import get_object_or_404 from wagtail.contrib.modeladmin.views import CreateView -class AddChildMetaCategoryViewClass(CreateView): +class AddChildMetaTermViewClass(CreateView): """View class that can take an additional URL param for parent id.""" parent_pk = None diff --git a/opentech/apply/categories/migrations/0003_rename_meta_categories_to_meta_terms.py b/opentech/apply/categories/migrations/0003_rename_meta_categories_to_meta_terms.py new file mode 100644 index 0000000000000000000000000000000000000000..ec7168cba720ad3e3e4aa5ff1bfe8b649896e22b --- /dev/null +++ b/opentech/apply/categories/migrations/0003_rename_meta_categories_to_meta_terms.py @@ -0,0 +1,35 @@ +# Generated by Django 2.0.13 on 2019-07-30 07:53 + +from django.db import migrations, models +import wagtail.core.fields +import wagtail.search.index + + +class Migration(migrations.Migration): + + dependencies = [ + ('categories', '0002_metacategory'), + ] + + operations = [ + migrations.CreateModel( + name='MetaTerm', + fields=[ + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('path', models.CharField(max_length=255, unique=True)), + ('depth', models.PositiveIntegerField()), + ('numchild', models.PositiveIntegerField(default=0)), + ('name', models.CharField(help_text='Keep the name short, ideally one word.', max_length=50, unique=True)), + ('is_archived', models.BooleanField(default=False, verbose_name='Archived')), + ('help_text', wagtail.core.fields.RichTextField(blank=True)), + ('filter_on_dashboard', models.BooleanField(default=True, help_text='Make available to filter on dashboard')), + ('available_to_applicants', models.BooleanField(default=False, help_text='Make available to applicants')), + ('node_order_index', models.IntegerField(blank=True, default=0, editable=False)), + ], + options={ + 'verbose_name': 'Meta Term', + 'verbose_name_plural': 'Meta Terms', + }, + bases=(wagtail.search.index.Indexed, models.Model), + ), + ] diff --git a/opentech/apply/categories/migrations/0004_rename_meta_categories_to_meta_terms.py b/opentech/apply/categories/migrations/0004_rename_meta_categories_to_meta_terms.py new file mode 100644 index 0000000000000000000000000000000000000000..75b2953ddc2c0ff94c4d008d2e821e2eaa7b0c9f --- /dev/null +++ b/opentech/apply/categories/migrations/0004_rename_meta_categories_to_meta_terms.py @@ -0,0 +1,17 @@ +# Generated by Django 2.0.13 on 2019-07-30 07:53 + +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ('categories', '0003_rename_meta_categories_to_meta_terms'), + ('funds', '0070_rename_meta_categories_to_meta_terms'), + ] + + operations = [ + migrations.DeleteModel( + name='MetaCategory', + ), + ] diff --git a/opentech/apply/categories/migrations/0005_alter_is_archived_field_on_terms.py b/opentech/apply/categories/migrations/0005_alter_is_archived_field_on_terms.py new file mode 100644 index 0000000000000000000000000000000000000000..5d34f431c5450b403863fde6ea343bd531f57398 --- /dev/null +++ b/opentech/apply/categories/migrations/0005_alter_is_archived_field_on_terms.py @@ -0,0 +1,18 @@ +# Generated by Django 2.1.11 on 2019-09-27 17:22 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('categories', '0004_rename_meta_categories_to_meta_terms'), + ] + + operations = [ + migrations.AlterField( + model_name='metaterm', + name='is_archived', + field=models.BooleanField(default=False, help_text='Archived terms can be viewed but not set on content.', verbose_name='Archived'), + ), + ] diff --git a/opentech/apply/categories/models.py b/opentech/apply/categories/models.py index 09ad45ddc21d2b9b2b864c34bbe606f1ec64068a..a21ec1a12f7227103e40f60527f9164e7c16f452 100644 --- a/opentech/apply/categories/models.py +++ b/opentech/apply/categories/models.py @@ -2,14 +2,17 @@ from django import forms from django.core.exceptions import PermissionDenied from django.db import models from django.template.loader import render_to_string +from django.utils.translation import ugettext_lazy as _ from modelcluster.fields import ParentalKey from modelcluster.models import ClusterableModel from wagtail.admin.edit_handlers import ( FieldPanel, InlinePanel, + MultiFieldPanel, ) from wagtail.admin.forms import WagtailAdminModelForm +from wagtail.core.fields import RichTextField from wagtail.core.models import Orderable from wagtail.search import index @@ -43,11 +46,23 @@ class Category(ClusterableModel): verbose_name_plural = 'Categories' -class MetaCategory(index.Indexed, MP_Node): - """ Hierarchal "Meta" category """ +class MetaTerm(index.Indexed, MP_Node): + """ Hierarchal "Meta" terms """ name = models.CharField( max_length=50, unique=True, help_text='Keep the name short, ideally one word.' ) + is_archived = models.BooleanField( + default=False, verbose_name=_("Archived"), + help_text='Archived terms can be viewed but not set on content.' + ) + filter_on_dashboard = models.BooleanField( + default=True, help_text='Make available to filter on dashboard' + ) + available_to_applicants = models.BooleanField( + default=False, help_text='Make available to applicants' + ) + help_text = RichTextField(features=[ + 'h2', 'h3', 'bold', 'italic', 'link', 'hr', 'ol', 'ul'], blank=True) # node tree specific fields and attributes node_order_index = models.IntegerField(blank=True, default=0, editable=False) @@ -57,19 +72,29 @@ class MetaCategory(index.Indexed, MP_Node): node_order_by = ['node_order_index', 'name'] panels = [ - FieldPanel('parent'), FieldPanel('name'), + FieldPanel('parent'), + MultiFieldPanel( + [ + FieldPanel('is_archived'), + FieldPanel('filter_on_dashboard'), + FieldPanel('available_to_applicants'), + FieldPanel('help_text'), + ], + heading="Options", + ), ] def get_as_listing_header(self): depth = self.get_depth() rendered = render_to_string( - 'categories/admin/includes/meta_category_list_header.html', + 'categories/admin/includes/meta_term_list_header.html', { 'depth': depth, 'depth_minus_1': depth - 1, 'is_root': self.is_root(), 'name': self.name, + 'is_archived': self.is_archived, } ) return rendered @@ -86,13 +111,13 @@ class MetaCategory(index.Indexed, MP_Node): def delete(self): if self.is_root(): - raise PermissionDenied('Cannot delete root Category.') + raise PermissionDenied('Cannot delete root term.') else: super().delete() @classmethod def get_root_descendants(cls): - # Meta categories queryset without Root node + # Meta terms queryset without Root node root_node = cls.get_first_root_node() if root_node: return root_node.get_descendants() @@ -102,20 +127,20 @@ class MetaCategory(index.Indexed, MP_Node): return self.name class Meta: - verbose_name = 'Meta Category' - verbose_name_plural = 'Meta Categories' + verbose_name = 'Meta Term' + verbose_name_plural = 'Meta Terms' -class MetaCategoryChoiceField(forms.ModelChoiceField): +class MetaTermChoiceField(forms.ModelChoiceField): def label_from_instance(self, obj): depth_line = '-' * (obj.get_depth() - 1) return "{} {}".format(depth_line, super().label_from_instance(obj)) -class MetaCategoryForm(WagtailAdminModelForm): - parent = MetaCategoryChoiceField( +class MetaTermForm(WagtailAdminModelForm): + parent = MetaTermChoiceField( required=True, - queryset=MetaCategory.objects.all(), + queryset=MetaTerm.objects.all(), empty_label=None, ) @@ -123,16 +148,24 @@ class MetaCategoryForm(WagtailAdminModelForm): super().__init__(*args, **kwargs) instance = kwargs['instance'] - if instance.is_root() or MetaCategory.objects.count() == 0: + if instance.is_root() or MetaTerm.objects.count() == 0: self.fields['parent'].disabled = True self.fields['parent'].required = False - self.fields['parent'].empty_label = 'N/A - Root Category' + self.fields['parent'].empty_label = 'N/A - Root Term' self.fields['parent'].widget = forms.HiddenInput() - self.fields['name'].label += ' (Root - First category can be named root)' + self.fields['name'].label += ' (Root - First term can be named root)' elif instance.id: self.fields['parent'].initial = instance.get_parent() + def clean_parent(self): + parent = self.cleaned_data['parent'] + + if parent and parent.is_archived: + raise forms.ValidationError('The parent is archived therefore can not add child under it.') + + return parent + def save(self, commit=True, *args, **kwargs): instance = super().save(commit=False, *args, **kwargs) parent = self.cleaned_data['parent'] @@ -141,8 +174,8 @@ class MetaCategoryForm(WagtailAdminModelForm): return instance if instance.id is None: - if MetaCategory.objects.all().count() == 0: - MetaCategory.add_root(instance=instance) + if MetaTerm.objects.all().count() == 0: + MetaTerm.add_root(instance=instance) else: instance = parent.add_child(instance=instance) else: @@ -152,4 +185,4 @@ class MetaCategoryForm(WagtailAdminModelForm): return instance -MetaCategory.base_form_class = MetaCategoryForm +MetaTerm.base_form_class = MetaTermForm diff --git a/opentech/apply/categories/templates/categories/admin/includes/meta_category_list_header.html b/opentech/apply/categories/templates/categories/admin/includes/meta_term_list_header.html similarity index 70% rename from opentech/apply/categories/templates/categories/admin/includes/meta_category_list_header.html rename to opentech/apply/categories/templates/categories/admin/includes/meta_term_list_header.html index b6a816694bcffbec1fc4fb524ce0931a9e111fcb..1c5c2867237c3c2b5462517322c345908639ce9d 100644 --- a/opentech/apply/categories/templates/categories/admin/includes/meta_category_list_header.html +++ b/opentech/apply/categories/templates/categories/admin/includes/meta_term_list_header.html @@ -4,6 +4,10 @@ <span> <span class="inline-block" style="margin-left:{{ depth }}em; font-size:{% if depth is 1 %}90{% elif depth is 2 %}80{% else %}100{% endif %}%;"></span> <i class="icon icon-fa-level-up icon-fa-rotate-90" style="display: inline-block;"></i> - {{ name }} + {% if is_archived %} + <span style="color: LightGray">{{ name }} (archived)</span> + {% else %} + {{ name }} + {% endif %} </span> {% endif %} diff --git a/opentech/apply/funds/admin.py b/opentech/apply/funds/admin.py index fe8a56644834d090aa18b0b8940d0cb31e5539b0..ccecd965741aab3cdcf1d0d7b13e3ebcfd26a080 100644 --- a/opentech/apply/funds/admin.py +++ b/opentech/apply/funds/admin.py @@ -12,7 +12,7 @@ from .admin_helpers import ( RoundFundChooserView, ) from .models import ApplicationForm, FundType, LabType, RequestForPartners, Round, SealedRound -from opentech.apply.categories.admin import CategoryAdmin, MetaCategoryAdmin +from opentech.apply.categories.admin import CategoryAdmin, MetaTermAdmin class BaseRoundAdmin(ModelAdmin): @@ -148,5 +148,5 @@ class ApplyAdminGroup(ModelAdminGroup): CategoryAdmin, ScreeningStatusAdmin, ReviewerRoleAdmin, - MetaCategoryAdmin, + MetaTermAdmin, ) diff --git a/opentech/apply/funds/forms.py b/opentech/apply/funds/forms.py index df7ce6d8a9e0446ae2f674598dc59d17d65d6e06..be01520db4d66f263567a089e061d3fb6a0e418b 100644 --- a/opentech/apply/funds/forms.py +++ b/opentech/apply/funds/forms.py @@ -8,12 +8,12 @@ from django.utils.translation import ugettext_lazy as _ from django.utils.safestring import mark_safe from django_select2.forms import Select2Widget -from opentech.apply.categories.models import MetaCategory +from opentech.apply.categories.models import MetaTerm from opentech.apply.users.models import User from .models import AssignedReviewers, ApplicationSubmission, ReviewerRole from .utils import render_icon -from .widgets import Select2MultiCheckboxesWidget, MetaCategorySelect2Widget +from .widgets import Select2MultiCheckboxesWidget, MetaTermSelect2Widget from .workflow import get_action_mapping @@ -390,14 +390,14 @@ class GroupedModelMultipleChoiceField(forms.ModelMultipleChoiceField): return {'label': super().label_from_instance(obj), 'disabled': not obj.is_leaf()} -class UpdateMetaCategoriesForm(ApplicationSubmissionModelForm): - meta_categories = GroupedModelMultipleChoiceField( +class UpdateMetaTermsForm(ApplicationSubmissionModelForm): + meta_terms = GroupedModelMultipleChoiceField( queryset=None, # updated in init method - widget=MetaCategorySelect2Widget(attrs={'data-placeholder': 'Meta categories'}), - label='Meta categories', + widget=MetaTermSelect2Widget(attrs={'data-placeholder': 'Meta terms'}), + label='Meta terms', choices_groupby='get_parent', required=False, - help_text='Meta categories are hierarchical in nature.', + help_text='Meta terms are hierarchical in nature.', ) class Meta: @@ -407,4 +407,4 @@ class UpdateMetaCategoriesForm(ApplicationSubmissionModelForm): def __init__(self, *args, **kwargs): kwargs.pop('user') super().__init__(*args, **kwargs) - self.fields['meta_categories'].queryset = MetaCategory.get_root_descendants().exclude(depth=2) + self.fields['meta_terms'].queryset = MetaTerm.get_root_descendants().exclude(depth=2) diff --git a/opentech/apply/funds/migrations/0070_rename_meta_categories_to_meta_terms.py b/opentech/apply/funds/migrations/0070_rename_meta_categories_to_meta_terms.py new file mode 100644 index 0000000000000000000000000000000000000000..44e7746dc8814705577a494905af233a797a25cc --- /dev/null +++ b/opentech/apply/funds/migrations/0070_rename_meta_categories_to_meta_terms.py @@ -0,0 +1,23 @@ +# Generated by Django 2.0.13 on 2019-07-30 07:53 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('categories', '0003_rename_meta_categories_to_meta_terms'), + ('funds', '0069_merge_20190905_0403'), + ] + + operations = [ + migrations.RemoveField( + model_name='applicationsubmission', + name='meta_categories', + ), + migrations.AddField( + model_name='applicationsubmission', + name='meta_terms', + field=models.ManyToManyField(blank=True, related_name='submissions', to='categories.MetaTerm'), + ), + ] diff --git a/opentech/apply/funds/models/submissions.py b/opentech/apply/funds/models/submissions.py index a6df3d877f198d8d3b0281429afd3a173aad5ef7..e4bff5ca8d884c201d73acfc070dad5effb181ff 100644 --- a/opentech/apply/funds/models/submissions.py +++ b/opentech/apply/funds/models/submissions.py @@ -32,7 +32,7 @@ from wagtail.core.fields import StreamField from wagtail.contrib.forms.models import AbstractFormSubmission from opentech.apply.activity.messaging import messenger, MESSAGES -from opentech.apply.categories.models import MetaCategory +from opentech.apply.categories.models import MetaTerm from opentech.apply.determinations.models import Determination from opentech.apply.review.models import ReviewOpinion from opentech.apply.review.options import MAYBE, AGREE, DISAGREE @@ -393,8 +393,8 @@ class ApplicationSubmission( limit_choices_to=LIMIT_TO_PARTNERS, blank=True, ) - meta_categories = models.ManyToManyField( - MetaCategory, + meta_terms = models.ManyToManyField( + MetaTerm, related_name='submissions', blank=True, ) @@ -518,7 +518,7 @@ class ApplicationSubmission( raise ValueError('Incorrect State for transition') submission_in_db = ApplicationSubmission.objects.get(id=self.id) - prev_meta_categories = submission_in_db.meta_categories.all() + prev_meta_terms = submission_in_db.meta_terms.all() self.id = None proposal_form = kwargs.get('proposal_form') @@ -528,7 +528,7 @@ class ApplicationSubmission( self.live_revision = None self.draft_revision = None self.save() - self.meta_categories.set(prev_meta_categories) + self.meta_terms.set(prev_meta_terms) submission_in_db.next = self submission_in_db.save() diff --git a/opentech/apply/funds/templates/funds/applicationsubmission_admin_detail.html b/opentech/apply/funds/templates/funds/applicationsubmission_admin_detail.html index e8e3b36fb373cc59d855baa6e7e02a49f9199ac5..4aeff8b6464d151641626801271bb18e06d98b87 100644 --- a/opentech/apply/funds/templates/funds/applicationsubmission_admin_detail.html +++ b/opentech/apply/funds/templates/funds/applicationsubmission_admin_detail.html @@ -25,7 +25,7 @@ {% if PROJECTS_ENABLED %} {% include "funds/includes/create_project_form.html" %} {% endif %} - {% include "funds/includes/update_meta_categories_form.html" %} + {% include "funds/includes/update_meta_terms_form.html" %} {% endblock %} {% block reviews %} @@ -47,8 +47,8 @@ {% include 'funds/includes/screening_status_block.html' %} {% endblock %} -{% block meta_categories %} - {% include 'funds/includes/meta_categories_block.html' %} +{% block meta_terms %} + {% include 'funds/includes/meta_terms_block.html' %} {% endblock %} {% block determination %} diff --git a/opentech/apply/funds/templates/funds/applicationsubmission_detail.html b/opentech/apply/funds/templates/funds/applicationsubmission_detail.html index 7c997b86d74e10ee61053915661e78f5ae7a6f8e..006202f030cefea19cf4251c10cacfb0b30e5eb0 100644 --- a/opentech/apply/funds/templates/funds/applicationsubmission_detail.html +++ b/opentech/apply/funds/templates/funds/applicationsubmission_detail.html @@ -105,10 +105,12 @@ {% include 'determinations/includes/applicant_determination_block.html' with submission=object %} {% endblock %} - {% block screening_status %} - {% endblock %} - {% block meta_categories %} - {% endblock %} + {% if request.user.is_apply_staff %} + {% block screening_status %} + {% endblock %} + {% block meta_terms %} + {% endblock %} + {% endif %} {% block reviews %} {% endblock %} diff --git a/opentech/apply/funds/templates/funds/includes/actions.html b/opentech/apply/funds/templates/funds/includes/actions.html index 0dcfc3d8ab1b46e8b71842c04a74545f8aa037e5..20f84c073537ee2acebafe912800dbe47eef856e 100644 --- a/opentech/apply/funds/templates/funds/includes/actions.html +++ b/opentech/apply/funds/templates/funds/includes/actions.html @@ -27,4 +27,4 @@ <a class="button button--white button--full-width button--bottom-space" href="{% url 'funds:submissions:revisions:list' submission_pk=object.id %}">Revisions</a> -<a data-fancybox data-src="#update-meta-categories" class="button button--white button--full-width button--bottom-space" href="#">Meta Categories</a> +<a data-fancybox data-src="#update-meta-terms" class="button button--white button--full-width button--bottom-space" href="#">Meta Terms</a> diff --git a/opentech/apply/funds/templates/funds/includes/meta_categories_block.html b/opentech/apply/funds/templates/funds/includes/meta_categories_block.html deleted file mode 100644 index 48adf136a2e544bd4096b8437cd1b5bd0dce621d..0000000000000000000000000000000000000000 --- a/opentech/apply/funds/templates/funds/includes/meta_categories_block.html +++ /dev/null @@ -1,10 +0,0 @@ -<div class="sidebar__inner"> - <h5>Meta Categories</h5> - <ul> - {% for meta_category in object.meta_categories.all %} - <li>{{ meta_category.name }}</li> - {% empty %} - None. Meta categories can be added to a submission using Meta categories button at top. - {% endfor %} - </ul> -</div> diff --git a/opentech/apply/funds/templates/funds/includes/meta_terms_block.html b/opentech/apply/funds/templates/funds/includes/meta_terms_block.html new file mode 100644 index 0000000000000000000000000000000000000000..9b8bbf890675b0c6ab33b007b268a4c926338e96 --- /dev/null +++ b/opentech/apply/funds/templates/funds/includes/meta_terms_block.html @@ -0,0 +1,11 @@ +<div class="sidebar__inner"> + <h5>Meta Terms</h5> + <ul> + {% for meta_term in object.meta_terms.all %} + <h6 class="heading--no-margin">{{ meta_term.get_parent }}</h6> + <li>{{ meta_term.name }}</li> + {% empty %} + None. Meta terms can be added to a submission using Meta terms button at top. + {% endfor %} + </ul> +</div> diff --git a/opentech/apply/funds/templates/funds/includes/update_meta_categories_form.html b/opentech/apply/funds/templates/funds/includes/update_meta_categories_form.html deleted file mode 100644 index 44395f61d0657c1e08d0ec59e768e6da4491b7ac..0000000000000000000000000000000000000000 --- a/opentech/apply/funds/templates/funds/includes/update_meta_categories_form.html +++ /dev/null @@ -1,4 +0,0 @@ -<div class="modal" id="update-meta-categories"> - <h4 class="modal__header-bar">Update Meta Categories</h4> - {% include 'funds/includes/delegated_form_base.html' with form=meta_categories_form value='Update' %} -</div> diff --git a/opentech/apply/funds/templates/funds/includes/update_meta_terms_form.html b/opentech/apply/funds/templates/funds/includes/update_meta_terms_form.html new file mode 100644 index 0000000000000000000000000000000000000000..a754d3f17b625b303c1d122fcecee794cf0ba5b3 --- /dev/null +++ b/opentech/apply/funds/templates/funds/includes/update_meta_terms_form.html @@ -0,0 +1,4 @@ +<div class="modal" id="update-meta-terms"> + <h4 class="modal__header-bar">Update Meta Terms</h4> + {% include 'funds/includes/delegated_form_base.html' with form=meta_terms_form value='Update' %} +</div> diff --git a/opentech/apply/funds/views.py b/opentech/apply/funds/views.py index af01e3a39e0e0ad6b51f1d5d86778c65865d9e6c..b134a851bdbef3bdc382ce6d7870e6940c4c44d5 100644 --- a/opentech/apply/funds/views.py +++ b/opentech/apply/funds/views.py @@ -44,7 +44,7 @@ from .forms import ( UpdateReviewersForm, UpdateSubmissionLeadForm, UpdatePartnersForm, - UpdateMetaCategoriesForm, + UpdateMetaTermsForm, ) from .models import ( ApplicationSubmission, @@ -524,10 +524,10 @@ class UpdatePartnersView(DelegatedViewMixin, UpdateView): @method_decorator(staff_required, name='dispatch') -class UpdateMetaCategoriesView(DelegatedViewMixin, UpdateView): +class UpdateMetaTermsView(DelegatedViewMixin, UpdateView): model = ApplicationSubmission - form_class = UpdateMetaCategoriesForm - context_name = 'meta_categories_form' + form_class = UpdateMetaTermsForm + context_name = 'meta_terms_form' class AdminSubmissionDetailView(ReviewContextMixin, ActivityContextMixin, DelegateableView, DetailView): @@ -541,7 +541,7 @@ class AdminSubmissionDetailView(ReviewContextMixin, ActivityContextMixin, Delega UpdateReviewersView, UpdatePartnersView, CreateProjectView, - UpdateMetaCategoriesView, + UpdateMetaTermsView, ] def dispatch(self, request, *args, **kwargs): diff --git a/opentech/apply/funds/widgets.py b/opentech/apply/funds/widgets.py index 4af3d76a77449c16687f19891d9e5705ba988ea2..3c0b8101d2d663114b83bc02c616f970aeb9ce3c 100644 --- a/opentech/apply/funds/widgets.py +++ b/opentech/apply/funds/widgets.py @@ -22,7 +22,7 @@ class Select2MultiCheckboxesWidget(Select2MultipleWidget): return attrs -class MetaCategorySelect2Widget(Select2MultipleWidget): +class MetaTermSelect2Widget(Select2MultipleWidget): def create_option(self, name, value, label, selected, index, subindex=None, attrs=None): disabled = False diff --git a/opentech/apply/projects/templates/application_projects/project_admin_detail.html b/opentech/apply/projects/templates/application_projects/project_admin_detail.html index ffafd3731869879201c6675b6fa2530ac3fe07c9..f7ef7817bc0e9204d9ca7fcca66d2a327c42ea48 100644 --- a/opentech/apply/projects/templates/application_projects/project_admin_detail.html +++ b/opentech/apply/projects/templates/application_projects/project_admin_detail.html @@ -99,6 +99,12 @@ Lead </a> +<!-- <a data-fancybox --> +<!-- data-src="#update-meta-terms" --> +<!-- class="button button--bottom-space button--white button--full-width" --> +<!-- href="#"> --> +<!-- Meta Terms --> +<!-- </a> --> {% endblock %} {% block project_approvals %}