# Path: crudbuilder/abstract.py
# class BaseCrudBuilder(with_metaclass(MetaCrudRegister)):
#     model = None
#     inlineformset = None
# 
# Path: crudbuilder/formset.py
# class BaseInlineFormset(object):
#     extra = 3
#     can_delete = True
#     inline_model = None
#     parent_model = None
#     exclude = []
#     fields = None
#     formfield_callback = None
#     fk_name = None
#     formset_class = None
#     child_form = None
# 
#     def construct_formset(self):
#         """
#         Returns an instance of the inline formset
#         """
#         if not self.inline_model or not self.parent_model:
#             msg = "Parent and Inline models are required in {}".format(self.__class__.__name__)
#             raise NotModelException(msg)
# 
#         return inlineformset_factory(
#             self.parent_model,
#             self.inline_model,
#             **self.get_factory_kwargs())
# 
#     def get_factory_kwargs(self):
#         """
#         Returns the keyword arguments for calling the formset factory
#         """
#         kwargs = {}
#         kwargs.update({
#             'can_delete': self.can_delete,
#             'extra': self.extra,
#             'exclude': self.exclude,
#             'fields': self.fields,
#             'formfield_callback': self.formfield_callback,
#             'fk_name': self.fk_name,
#         })
#         if self.formset_class:
#             kwargs['formset'] = self.formset_class
# 
#         if self.child_form:
#             kwargs['form'] = self.child_form
#         return kwargs


from crudbuilder.abstract import BaseCrudBuilder
from crudbuilder.formset import BaseInlineFormset
from example.models import Person, PersonEmployment
from example.tables import CustomPersonTable
from example.forms import (
    PersonEmployementCreateForm,
    PersonEmployementUpdateForm
)
    tables2_css_class = "table table-bordered table-condensed"
    tables2_pagination = 10  # default is 10
    modelform_excludes = ['created_by', 'updated_by']
    login_required = True
    permission_required = True
    # custom_table2 = CustomPersonTable

    # detailview_excludes = ['img']
    # inlineformset = PersonEmploymentInlineFormset

    # custom_templates = {
    #     'list': 'yourtemplates/template.html'
    # }

    # permissions = {
    #     'list': 'example.person_list',
    #     'create': 'example.person_create'
    # }

    # @classmethod
    # def custom_queryset(cls, request, **kwargs):
    #     return cls.model.objects.filter(created_by=request.user)


class AnotherPersonCrud(BaseCrudBuilder):
    model = Person
    tables2_css_class = "table table-bordered table-condensed"
    custom_postfix_url = 'another-person-crud'  # /appname/<custom_postfix_url>



# Path: crudbuilder/abstract.py
# class BaseCrudBuilder(with_metaclass(MetaCrudRegister)):
#     model = None
#     inlineformset = None
# 
# Path: crudbuilder/formset.py
# class BaseInlineFormset(object):
#     extra = 3
#     can_delete = True
#     inline_model = None
#     parent_model = None
#     exclude = []
#     fields = None
#     formfield_callback = None
#     fk_name = None
#     formset_class = None
#     child_form = None
# 
#     def construct_formset(self):
#         """
#         Returns an instance of the inline formset
#         """
#         if not self.inline_model or not self.parent_model:
#             msg = "Parent and Inline models are required in {}".format(self.__class__.__name__)
#             raise NotModelException(msg)
# 
#         return inlineformset_factory(
#             self.parent_model,
#             self.inline_model,
#             **self.get_factory_kwargs())
# 
#     def get_factory_kwargs(self):
#         """
#         Returns the keyword arguments for calling the formset factory
#         """
#         kwargs = {}
#         kwargs.update({
#             'can_delete': self.can_delete,
#             'extra': self.extra,
#             'exclude': self.exclude,
#             'fields': self.fields,
#             'formfield_callback': self.formfield_callback,
#             'fk_name': self.fk_name,
#         })
#         if self.formset_class:
#             kwargs['formset'] = self.formset_class
# 
#         if self.child_form:
#             kwargs['form'] = self.child_form
#         return kwargs


# Path: example/example/crud.py
from crudbuilder.abstract import BaseCrudBuilder
from crudbuilder.formset import BaseInlineFormset
from example.models import Person, PersonEmployment
from example.tables import CustomPersonTable
from example.forms import (
    PersonEmployementCreateForm,
    PersonEmployementUpdateForm
)

    tables2_css_class = "table table-bordered table-condensed"
    tables2_pagination = 10  # default is 10
    modelform_excludes = ['created_by', 'updated_by']
    login_required = True
    permission_required = True
    # custom_table2 = CustomPersonTable

    # detailview_excludes = ['img']
    # inlineformset = PersonEmploymentInlineFormset

    # custom_templates = {
    #     'list': 'yourtemplates/template.html'
    # }

    # permissions = {
    #     'list': 'example.person_list',
    #     'create': 'example.person_create'
    # }

    # @classmethod
    # def custom_queryset(cls, request, **kwargs):
    #     return cls.model.objects.filter(created_by=request.user)


class AnotherPersonCrud(BaseCrudBuilder):
    model = Person
    tables2_css_class = "table table-bordered table-condensed"
    custom_postfix_url = 'another-person-crud'  # /appname/<custom_postfix_url>



class PersonEmploymentCrud(BaseCrudBuilder):