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

Archive option for meta categories and other options

parent 5d2438e6
No related branches found
No related tags found
No related merge requests found
...@@ -19,6 +19,10 @@ class MetaCategoryButtonHelper(ButtonHelper): ...@@ -19,6 +19,10 @@ class MetaCategoryButtonHelper(ButtonHelper):
def add_child_button(self, pk, child_verbose_name, **kwargs): 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 category."""
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( classnames = self.prepare_classnames(
start=self.edit_button_classnames + ['icon', 'icon-plus'], start=self.edit_button_classnames + ['icon', 'icon-plus'],
add=kwargs.get('classnames_add'), add=kwargs.get('classnames_add'),
......
# Generated by Django 2.0.13 on 2019-07-09 11:14
from django.db import migrations, models
import wagtail.core.fields
class Migration(migrations.Migration):
dependencies = [
('categories', '0002_metacategory'),
]
operations = [
migrations.AddField(
model_name='metacategory',
name='available_to_applications',
field=models.BooleanField(default=True, help_text='Make available for applications'),
),
migrations.AddField(
model_name='metacategory',
name='filter_on_dashboard',
field=models.BooleanField(default=True, help_text='Make available to filter on dashboard'),
),
migrations.AddField(
model_name='metacategory',
name='help_text',
field=wagtail.core.fields.RichTextField(blank=True),
),
migrations.AddField(
model_name='metacategory',
name='is_archived',
field=models.BooleanField(default=False, verbose_name='Archived'),
),
]
...@@ -2,14 +2,17 @@ from django import forms ...@@ -2,14 +2,17 @@ from django import forms
from django.core.exceptions import PermissionDenied from django.core.exceptions import PermissionDenied
from django.db import models from django.db import models
from django.template.loader import render_to_string from django.template.loader import render_to_string
from django.utils.translation import ugettext_lazy as _
from modelcluster.fields import ParentalKey from modelcluster.fields import ParentalKey
from modelcluster.models import ClusterableModel from modelcluster.models import ClusterableModel
from wagtail.admin.edit_handlers import ( from wagtail.admin.edit_handlers import (
FieldPanel, FieldPanel,
InlinePanel, InlinePanel,
MultiFieldPanel,
) )
from wagtail.admin.forms import WagtailAdminModelForm from wagtail.admin.forms import WagtailAdminModelForm
from wagtail.core.fields import RichTextField
from wagtail.core.models import Orderable from wagtail.core.models import Orderable
from wagtail.search import index from wagtail.search import index
...@@ -48,6 +51,15 @@ class MetaCategory(index.Indexed, MP_Node): ...@@ -48,6 +51,15 @@ class MetaCategory(index.Indexed, MP_Node):
name = models.CharField( name = models.CharField(
max_length=50, unique=True, help_text='Keep the name short, ideally one word.' 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 = RichTextField(features=[
'h2', 'h3', 'bold', 'italic', 'link', 'hr', 'ol', 'ul'], blank=True)
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'
)
# node tree specific fields and attributes # node tree specific fields and attributes
node_order_index = models.IntegerField(blank=True, default=0, editable=False) node_order_index = models.IntegerField(blank=True, default=0, editable=False)
...@@ -59,6 +71,15 @@ class MetaCategory(index.Indexed, MP_Node): ...@@ -59,6 +71,15 @@ class MetaCategory(index.Indexed, MP_Node):
panels = [ panels = [
FieldPanel('parent'), FieldPanel('parent'),
FieldPanel('name'), FieldPanel('name'),
FieldPanel('is_archived'),
MultiFieldPanel(
[
FieldPanel('help_text'),
FieldPanel('filter_on_dashboard'),
FieldPanel('available_to_applications'),
],
heading="Options",
),
] ]
def get_as_listing_header(self): def get_as_listing_header(self):
...@@ -70,6 +91,7 @@ class MetaCategory(index.Indexed, MP_Node): ...@@ -70,6 +91,7 @@ class MetaCategory(index.Indexed, MP_Node):
'depth_minus_1': depth - 1, 'depth_minus_1': depth - 1,
'is_root': self.is_root(), 'is_root': self.is_root(),
'name': self.name, 'name': self.name,
'is_archived': self.is_archived,
} }
) )
return rendered return rendered
......
...@@ -4,6 +4,10 @@ ...@@ -4,6 +4,10 @@
<span> <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> <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> <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> </span>
{% endif %} {% endif %}
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