<s> from __future__ import unicode_literals <EOL> try : <EOL> from html . parser import HTMLParser <EOL> except ImportError : <EOL> from HTMLParser import HTMLParser <EOL> from django . forms import widgets <EOL> from django . utils . translation import ungettext_lazy , ugettext_lazy as _ <EOL> from django . utils . text import Truncator <EOL> from django . utils . html import format_html <EOL> from django . forms . models import ModelForm <EOL> from django . forms . fields import IntegerField <EOL> from cms . plugin_pool import plugin_pool <EOL> from cmsplugin_cascade . forms import ManageChildrenFormMixin <EOL> from cmsplugin_cascade . fields import PartialFormField <EOL> from cmsplugin_cascade . mixins import TransparentMixin <EOL> from cmsplugin_cascade . widgets import NumberInputWidget <EOL> from . plugin_base import BootstrapPluginBase <EOL> from . panel import panel_heading_sizes , PanelTypeRenderer <EOL> class AccordionForm ( ManageChildrenFormMixin , ModelForm ) : <EOL> num_children = IntegerField ( min_value = <NUM_LIT:1> , initial = <NUM_LIT:1> , <EOL> widget = NumberInputWidget ( attrs = { '<STR_LIT:size>' : '<STR_LIT:3>' , '<STR_LIT>' : '<STR_LIT>' } ) , <EOL> label = _ ( "<STR_LIT>" ) , <EOL> help_text = _ ( "<STR_LIT>" ) ) <EOL> class BootstrapAccordionPlugin ( TransparentMixin , BootstrapPluginBase ) : <EOL> name = _ ( "<STR_LIT>" ) <EOL> form = AccordionForm <EOL> default_css_class = '<STR_LIT>' <EOL> require_parent = True <EOL> parent_classes = ( '<STR_LIT>' , ) <EOL> allow_children = True <EOL> child_classes = None <EOL> render_template = '<STR_LIT>' <EOL> fields = ( '<STR_LIT>' , '<STR_LIT>' , ) <EOL> glossary_fields = ( <EOL> PartialFormField ( '<STR_LIT>' , <EOL> widgets . CheckboxInput ( ) , <EOL> label = _ ( "<STR_LIT>" ) , <EOL> initial = True , <EOL> help_text = _ ( "<STR_LIT>" ) <EOL> ) , <EOL> PartialFormField ( '<STR_LIT>' , <EOL> widgets . CheckboxInput ( ) , <EOL> label = _ ( "<STR_LIT>" ) , <EOL> initial = True , <EOL> help_text = _ ( "<STR_LIT>" ) <EOL> ) , <EOL> ) <EOL> @ classmethod <EOL> def get_identifier ( cls , obj ) : <EOL> identifier = super ( BootstrapAccordionPlugin , cls ) . get_identifier ( obj ) <EOL> num_cols = obj . get_children ( ) . count ( ) <EOL> content = ungettext_lazy ( '<STR_LIT>' , '<STR_LIT>' , num_cols ) . format ( num_cols ) <EOL> return format_html ( '<STR_LIT>' , identifier , content ) <EOL> def save_model ( self , request , obj , form , change ) : <EOL> wanted_children = int ( form . cleaned_data . get ( '<STR_LIT>' ) ) <EOL> super ( BootstrapAccordionPlugin , self ) . save_model ( request , obj , form , change ) <EOL> self . extend_children ( obj , wanted_children , BootstrapAccordionPanelPlugin ) <EOL> plugin_pool . register_plugin ( BootstrapAccordionPlugin ) <EOL> class BootstrapAccordionPanelPlugin ( TransparentMixin , BootstrapPluginBase ) : <EOL> name = _ ( "<STR_LIT>" ) <EOL> default_css_class = '<STR_LIT>' <EOL> parent_classes = ( '<STR_LIT>' , ) <EOL> require_parent = True <EOL> alien_child_classes = True <EOL> glossary_fields = ( <EOL> PartialFormField ( '<STR_LIT>' , <EOL> PanelTypeRenderer . get_widget ( ) , <EOL> label = _ ( "<STR_LIT>" ) , <EOL> help_text = _ ( "<STR_LIT>" ) <EOL> ) , <EOL> PartialFormField ( '<STR_LIT>' , <EOL> widgets . Select ( choices = panel_heading_sizes ) , <EOL> initial = '<STR_LIT>' , <EOL> label = _ ( "<STR_LIT>" ) <EOL> ) , <EOL> PartialFormField ( '<STR_LIT>' , <EOL> widgets . TextInput ( attrs = { '<STR_LIT:size>' : <NUM_LIT> } ) , <EOL> label = _ ( "<STR_LIT>" ) <EOL> ) , <EOL> ) <EOL> class Media : <EOL> css = { '<STR_LIT:all>' : ( '<STR_LIT>' , '<STR_LIT>' , ) } <EOL> @ classmethod <EOL> def get_identifier ( cls , obj ) : <EOL> identifier = super ( BootstrapAccordionPanelPlugin , cls ) . get_identifier ( obj ) <EOL> panel_title = HTMLParser ( ) . unescape ( obj . glossary . get ( '<STR_LIT>' , '<STR_LIT>' ) ) <EOL> panel_title = Truncator ( panel_title ) . words ( <NUM_LIT:3> , truncate = '<STR_LIT>' ) <EOL> return format_html ( '<STR_LIT>' , identifier , panel_title ) <EOL> plugin_pool . register_plugin ( BootstrapAccordionPanelPlugin ) </s>
