# 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/wagtaillinks/forms.py
# class ExternalLinkForm(forms.ModelForm):
#     """
#     Form class for external link models.
#     """
#     class Meta(object):
#         model   = Link
#         fields  = ('title', 'external_url', 'tags')
# 
# Path: wagtailplus/wagtaillinks/forms.py
# class EmailLinkForm(forms.ModelForm):
#     """
#     Form class for email link models.
#     """
#     class Meta(object):
#         model   = Link
#         fields  = ('title', 'email', 'tags')
# 
# Path: wagtailplus/wagtaillinks/models.py
# class Link(BaseLink):
#     """
#     Concrete implementation of link.
#     """
#     pass


import json
from wagtail.wagtailadmin.modal_workflow import render_modal_workflow
from wagtail.wagtailsearch.backends import get_search_backends
from wagtailplus.views import chooser
from ..forms import ExternalLinkForm
from ..forms import EmailLinkForm
from ..models import Link

        :rtype: dict.
        """
        return {'link_type': Link.LINK_TYPE_EXTERNAL}

class EmailLinkChooseView(LinkChooseView):
    """
    Email link chooser view.
    """
    form_class          = EmailLinkForm
    chooser_template    = 'wagtaillinks/chooser/email-chooser.html'

    def get_queryset(self):
        """
        Returns queryset limited to external links.

        :rtype: django.db.models.query.QuerySet.
        """
        queryset    = super(EmailLinkChooseView, self).get_queryset()
        queryset    = queryset.filter(link_type=Link.LINK_TYPE_EMAIL)

        return queryset

    def get_search_filters(self):
        """
        Returns dictionary of search filters.

        :rtype: dict.
        """
        return {'link_type': Link.LINK_TYPE_EMAIL}


# 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/wagtaillinks/forms.py
# class ExternalLinkForm(forms.ModelForm):
#     """
#     Form class for external link models.
#     """
#     class Meta(object):
#         model   = Link
#         fields  = ('title', 'external_url', 'tags')
# 
# Path: wagtailplus/wagtaillinks/forms.py
# class EmailLinkForm(forms.ModelForm):
#     """
#     Form class for email link models.
#     """
#     class Meta(object):
#         model   = Link
#         fields  = ('title', 'email', 'tags')
# 
# Path: wagtailplus/wagtaillinks/models.py
# class Link(BaseLink):
#     """
#     Concrete implementation of link.
#     """
#     pass


# Path: wagtailplus/wagtaillinks/views/choosers.py
import json
from wagtail.wagtailadmin.modal_workflow import render_modal_workflow
from wagtail.wagtailsearch.backends import get_search_backends
from wagtailplus.views import chooser
from ..forms import ExternalLinkForm
from ..forms import EmailLinkForm
from ..models import Link

        :rtype: dict.
        """
        return {'link_type': Link.LINK_TYPE_EXTERNAL}

class EmailLinkChooseView(LinkChooseView):
    """
    Email link chooser view.
    """
    form_class          = EmailLinkForm
    chooser_template    = 'wagtaillinks/chooser/email-chooser.html'

    def get_queryset(self):
        """
        Returns queryset limited to external links.

        :rtype: django.db.models.query.QuerySet.
        """
        queryset    = super(EmailLinkChooseView, self).get_queryset()
        queryset    = queryset.filter(link_type=Link.LINK_TYPE_EMAIL)

        return queryset

    def get_search_filters(self):
        """
        Returns dictionary of search filters.

        :rtype: dict.
        """
        return {'link_type': Link.LINK_TYPE_EMAIL}


class CreateAndEmbedLinkView(chooser.CreateView):
