Skip to content
Snippets Groups Projects
Commit 6c5b32e4 authored by Parbhat Puri's avatar Parbhat Puri Committed by Fredrik Jonsson
Browse files

Add validation for archive check to parent and minor updates

parent 362c3483
No related branches found
No related tags found
No related merge requests found
# 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 from django.db import migrations, models
import wagtail.core.fields import wagtail.core.fields
...@@ -13,8 +13,8 @@ class Migration(migrations.Migration): ...@@ -13,8 +13,8 @@ class Migration(migrations.Migration):
operations = [ operations = [
migrations.AddField( migrations.AddField(
model_name='metacategory', model_name='metacategory',
name='available_to_applications', name='available_to_applicants',
field=models.BooleanField(default=True, help_text='Make available for applications'), field=models.BooleanField(default=False, help_text='Make available to applicants'),
), ),
migrations.AddField( migrations.AddField(
model_name='metacategory', model_name='metacategory',
......
...@@ -57,8 +57,8 @@ class MetaCategory(index.Indexed, MP_Node): ...@@ -57,8 +57,8 @@ class MetaCategory(index.Indexed, MP_Node):
filter_on_dashboard = models.BooleanField( filter_on_dashboard = models.BooleanField(
default=True, help_text='Make available to filter on dashboard' default=True, help_text='Make available to filter on dashboard'
) )
available_to_applications = models.BooleanField( available_to_applicants = models.BooleanField(
default=True, help_text='Make available for applications' default=False, help_text='Make available to applicants'
) )
# node tree specific fields and attributes # node tree specific fields and attributes
...@@ -71,12 +71,12 @@ class MetaCategory(index.Indexed, MP_Node): ...@@ -71,12 +71,12 @@ class MetaCategory(index.Indexed, MP_Node):
panels = [ panels = [
FieldPanel('parent'), FieldPanel('parent'),
FieldPanel('name'), FieldPanel('name'),
FieldPanel('is_archived'),
MultiFieldPanel( MultiFieldPanel(
[ [
FieldPanel('is_archived'),
FieldPanel('help_text'), FieldPanel('help_text'),
FieldPanel('filter_on_dashboard'), FieldPanel('filter_on_dashboard'),
FieldPanel('available_to_applications'), FieldPanel('available_to_applicants'),
], ],
heading="Options", heading="Options",
), ),
...@@ -155,6 +155,14 @@ class MetaCategoryForm(WagtailAdminModelForm): ...@@ -155,6 +155,14 @@ class MetaCategoryForm(WagtailAdminModelForm):
elif instance.id: elif instance.id:
self.fields['parent'].initial = instance.get_parent() 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): def save(self, commit=True, *args, **kwargs):
instance = super().save(commit=False, *args, **kwargs) instance = super().save(commit=False, *args, **kwargs)
parent = self.cleaned_data['parent'] parent = self.cleaned_data['parent']
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment