# Path: wagtailplus/views/chooser.py
# def get_model_permission(permission, model):
#     def get_context_data(self, **kwargs):
#     def get_form_class(self):
#     def get_search_filters(self):
#     def get_template_names(self):
#     def render_to_response(self, context, **response_kwargs):
#     def form_invalid(self, form):
#     def form_valid(self, form):
#     def get_context_data(self, **kwargs):
#     def render_to_response(self, context, **response_kwargs):
#     def render_to_response(self, context, **response_kwargs):
#     def form_valid(self, form):
#     def get_context_data(self, **kwargs):
#     def render_to_response(self, context, **response_kwargs):
# class ChooseView(ListView):
# class CreateView(_CreateView):
# class ChosenView(DetailView):
# class UpdateView(_UpdateView):
# 
# Path: wagtailplus/views/crud.py
# class IndexView(ListView):
# class BaseFormView(FormView):
#         class BaseChooserObjectList(BaseObjectList):
# class CreateView(BaseFormView, _CreateView):
# class UpdateView(BaseFormView, _UpdateView):
# class DeleteView(_DeleteView):
#     def get(self, request, *args, **kwargs):
#     def get_context_data(self, **kwargs):
#     def get_template_names(self):
#     def form_invalid(self, form):
#     def form_valid(self, form):
#     def get_context_data(self, **kwargs):
#     def get_edit_handler_class(self):
#             def render_missing_fields(self):
#         def ChooserObjectList(children):
#     def get_form_class(self):
#     def delete(self, request, *args, **kwargs):
# 
# Path: wagtailplus/wagtailcontacts/forms.py
# class ContactForm(forms.ModelForm):
#     required_css_class = 'required'
# 
#     class Meta(object):
#         model   = Contact
#         fields  = ('name', 'website', 'email', 'telephone', 'tags')
# 
# Path: wagtailplus/wagtailcontacts/models.py
# class Contact(models.Model, TagSearchable):
#     """
#     Basic contact.
#     """
#     created_at  = models.DateTimeField(auto_now_add=True)
#     name        = models.CharField(_(u'Name'), max_length=100, db_index=True, help_text=_(u'Enter a name for this contact'))
#     website     = models.URLField(_(u'Website'), null=True, blank=True, help_text=_(u'Enter an optional website for this contact'))
#     email       = models.EmailField(_(u'Email'), null=True, blank=True, help_text=_(u'Enter an optional email address for this contact'))
#     telephone   = PhoneNumberField(_(u'Telephone'), null=True, blank=True, help_text=_(u'Enter an optional telephone number for this contact'))
#     address     = models.ForeignKey('wagtailaddresses.Address', null=True, blank=True, on_delete=models.SET_NULL, related_name='+', help_text=_(u'Select an optional address for this contact'))
#     image       = models.ForeignKey('wagtailimages.Image', null=True, blank=True, on_delete=models.SET_NULL, related_name='+', help_text=_(u'Select an optional image for this contact'))
#     tags        = TaggableManager(verbose_name=_(u'Tags'), blank=True, help_text=None)
# 
#     class Meta(object):
#         verbose_name        = _(u'Contact')
#         verbose_name_plural = _(u'Contacts')
#         ordering            = ('name',)
#         unique_together     = (('name', 'website'), ('name', 'email'))
# 
#     # Make address searchable.
#     search_fields = [
#         index.SearchField('name', partial_match=True, boost=10),
#         index.SearchField('get_tags', partial_match=True, boost=10),
#         index.SearchField('website'),
#         index.SearchField('email'),
#         index.SearchField('telephone'),
#     ]
# 
#     def __str__(self):
#         """
#         Returns contact name.
# 
#         :rtype: str.
#         """
#         return '{0}'.format(self.name)
# 
#     @classmethod
#     def get_edit_handler(cls):
#         """
#         Returns edit handler instance.
# 
#         :rtype: wagtail.wagtailadmin.edit_handlers.ObjectList.
#         """
#         return ObjectList(cls.content_panels)


from django.conf.urls import url
from django.contrib.auth.decorators import permission_required
from wagtailplus.views import chooser
from wagtailplus.views import crud
from .forms import ContactForm
from .models import Contact

        permission_required('wagtailcontacts.change_contact')(crud.UpdateView.as_view(
            model=Contact,
            template_name='wagtailcontacts/contacts/edit.html',
            success_url='wagtailcontacts_index'
        )),
        name='wagtailcontacts_edit_contact'
    ),
    url(
        r'^delete/(?P<pk>\d+)/$',
        permission_required('wagtailcontacts.delete_contact')(crud.DeleteView.as_view(
            model=Contact,
            template_name='wagtailcontacts/contacts/confirm_delete.html',
            success_url='wagtailcontacts_index'
        )),
        name='wagtailcontacts_delete_contact'
    ),
    # Contact chooser URLs.
    url(
        r'^chooser/$',
        chooser.ChooseView.as_view(
            model=Contact,
            chooser_template='wagtailcontacts/chooser/chooser.html',
            results_template='wagtailcontacts/chooser/results.html',
            chooser_javascript='wagtailcontacts/chooser/chooser.js',
            form_class=ContactForm
        ),
        name='wagtailcontacts_contact_chooser'
    ),
    url(
        r'^chooser/create/$',

# Path: wagtailplus/views/chooser.py
# def get_model_permission(permission, model):
#     def get_context_data(self, **kwargs):
#     def get_form_class(self):
#     def get_search_filters(self):
#     def get_template_names(self):
#     def render_to_response(self, context, **response_kwargs):
#     def form_invalid(self, form):
#     def form_valid(self, form):
#     def get_context_data(self, **kwargs):
#     def render_to_response(self, context, **response_kwargs):
#     def render_to_response(self, context, **response_kwargs):
#     def form_valid(self, form):
#     def get_context_data(self, **kwargs):
#     def render_to_response(self, context, **response_kwargs):
# class ChooseView(ListView):
# class CreateView(_CreateView):
# class ChosenView(DetailView):
# class UpdateView(_UpdateView):
# 
# Path: wagtailplus/views/crud.py
# class IndexView(ListView):
# class BaseFormView(FormView):
#         class BaseChooserObjectList(BaseObjectList):
# class CreateView(BaseFormView, _CreateView):
# class UpdateView(BaseFormView, _UpdateView):
# class DeleteView(_DeleteView):
#     def get(self, request, *args, **kwargs):
#     def get_context_data(self, **kwargs):
#     def get_template_names(self):
#     def form_invalid(self, form):
#     def form_valid(self, form):
#     def get_context_data(self, **kwargs):
#     def get_edit_handler_class(self):
#             def render_missing_fields(self):
#         def ChooserObjectList(children):
#     def get_form_class(self):
#     def delete(self, request, *args, **kwargs):
# 
# Path: wagtailplus/wagtailcontacts/forms.py
# class ContactForm(forms.ModelForm):
#     required_css_class = 'required'
# 
#     class Meta(object):
#         model   = Contact
#         fields  = ('name', 'website', 'email', 'telephone', 'tags')
# 
# Path: wagtailplus/wagtailcontacts/models.py
# class Contact(models.Model, TagSearchable):
#     """
#     Basic contact.
#     """
#     created_at  = models.DateTimeField(auto_now_add=True)
#     name        = models.CharField(_(u'Name'), max_length=100, db_index=True, help_text=_(u'Enter a name for this contact'))
#     website     = models.URLField(_(u'Website'), null=True, blank=True, help_text=_(u'Enter an optional website for this contact'))
#     email       = models.EmailField(_(u'Email'), null=True, blank=True, help_text=_(u'Enter an optional email address for this contact'))
#     telephone   = PhoneNumberField(_(u'Telephone'), null=True, blank=True, help_text=_(u'Enter an optional telephone number for this contact'))
#     address     = models.ForeignKey('wagtailaddresses.Address', null=True, blank=True, on_delete=models.SET_NULL, related_name='+', help_text=_(u'Select an optional address for this contact'))
#     image       = models.ForeignKey('wagtailimages.Image', null=True, blank=True, on_delete=models.SET_NULL, related_name='+', help_text=_(u'Select an optional image for this contact'))
#     tags        = TaggableManager(verbose_name=_(u'Tags'), blank=True, help_text=None)
# 
#     class Meta(object):
#         verbose_name        = _(u'Contact')
#         verbose_name_plural = _(u'Contacts')
#         ordering            = ('name',)
#         unique_together     = (('name', 'website'), ('name', 'email'))
# 
#     # Make address searchable.
#     search_fields = [
#         index.SearchField('name', partial_match=True, boost=10),
#         index.SearchField('get_tags', partial_match=True, boost=10),
#         index.SearchField('website'),
#         index.SearchField('email'),
#         index.SearchField('telephone'),
#     ]
# 
#     def __str__(self):
#         """
#         Returns contact name.
# 
#         :rtype: str.
#         """
#         return '{0}'.format(self.name)
# 
#     @classmethod
#     def get_edit_handler(cls):
#         """
#         Returns edit handler instance.
# 
#         :rtype: wagtail.wagtailadmin.edit_handlers.ObjectList.
#         """
#         return ObjectList(cls.content_panels)


# Path: wagtailplus/wagtailcontacts/admin_urls.py
from django.conf.urls import url
from django.contrib.auth.decorators import permission_required
from wagtailplus.views import chooser
from wagtailplus.views import crud
from .forms import ContactForm
from .models import Contact

        permission_required('wagtailcontacts.change_contact')(crud.UpdateView.as_view(
            model=Contact,
            template_name='wagtailcontacts/contacts/edit.html',
            success_url='wagtailcontacts_index'
        )),
        name='wagtailcontacts_edit_contact'
    ),
    url(
        r'^delete/(?P<pk>\d+)/$',
        permission_required('wagtailcontacts.delete_contact')(crud.DeleteView.as_view(
            model=Contact,
            template_name='wagtailcontacts/contacts/confirm_delete.html',
            success_url='wagtailcontacts_index'
        )),
        name='wagtailcontacts_delete_contact'
    ),
    # Contact chooser URLs.
    url(
        r'^chooser/$',
        chooser.ChooseView.as_view(
            model=Contact,
            chooser_template='wagtailcontacts/chooser/chooser.html',
            results_template='wagtailcontacts/chooser/results.html',
            chooser_javascript='wagtailcontacts/chooser/chooser.js',
            form_class=ContactForm
        ),
        name='wagtailcontacts_contact_chooser'
    ),
    url(
        r'^chooser/create/$',

        chooser.CreateView.as_view(
