diff --git a/opentech/apply/categories/migrations/0003_archive_and_other_fields_meta_categories.py b/opentech/apply/categories/migrations/0003_archive_and_other_fields_for_meta_categories.py similarity index 81% rename from opentech/apply/categories/migrations/0003_archive_and_other_fields_meta_categories.py rename to opentech/apply/categories/migrations/0003_archive_and_other_fields_for_meta_categories.py index c8bda155c1af8d7d9eb30d00d67a0488970386a5..9bf56cd45740bbc4117fdcd05455e92586cf0468 100644 --- a/opentech/apply/categories/migrations/0003_archive_and_other_fields_meta_categories.py +++ b/opentech/apply/categories/migrations/0003_archive_and_other_fields_for_meta_categories.py @@ -1,4 +1,4 @@ -# Generated by Django 2.0.13 on 2019-07-09 11:14 +# Generated by Django 2.0.13 on 2019-07-16 06:01 from django.db import migrations, models import wagtail.core.fields @@ -13,8 +13,8 @@ class Migration(migrations.Migration): operations = [ migrations.AddField( model_name='metacategory', - name='available_to_applications', - field=models.BooleanField(default=True, help_text='Make available for applications'), + name='available_to_applicants', + field=models.BooleanField(default=False, help_text='Make available to applicants'), ), migrations.AddField( model_name='metacategory', diff --git a/opentech/apply/categories/models.py b/opentech/apply/categories/models.py index e9f32927493e43e8dd78e8e77fe85b827e45f833..7310eec04d10b71659f7105dd628500e49405bb3 100644 --- a/opentech/apply/categories/models.py +++ b/opentech/apply/categories/models.py @@ -57,8 +57,8 @@ class MetaCategory(index.Indexed, MP_Node): filter_on_dashboard = models.BooleanField( default=True, help_text='Make available to filter on dashboard' ) - available_to_applications = models.BooleanField( - default=True, help_text='Make available for applications' + available_to_applicants = models.BooleanField( + default=False, help_text='Make available to applicants' ) # node tree specific fields and attributes @@ -71,12 +71,12 @@ class MetaCategory(index.Indexed, MP_Node): panels = [ FieldPanel('parent'), FieldPanel('name'), - FieldPanel('is_archived'), MultiFieldPanel( [ + FieldPanel('is_archived'), FieldPanel('help_text'), FieldPanel('filter_on_dashboard'), - FieldPanel('available_to_applications'), + FieldPanel('available_to_applicants'), ], heading="Options", ), @@ -155,6 +155,14 @@ class MetaCategoryForm(WagtailAdminModelForm): elif instance.id: self.fields['parent'].initial = instance.get_parent() + def clean_parent(self): + parent = self.cleaned_data['parent'] + + if 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']