from deliverycenters.models import DeliveryCenter, DeliveryCenterGroup, \
    ODTatMatrix
from django.contrib import admin
from deliverycenters.models import State, City
from deliverycenters.forms import AdminCenterForm
from deliverycenters.models import State, City, Serviceability,\
    AttributeCodes, CenterMapper
from bitfield import BitField
from deliverycenters.forms import ServiceabilityForm, CenterMapperForm
from bitfield.forms import BitFieldCheckboxSelectMultiple
from backend.admin import ReplicaModelAdmin


class CenterGroupAdmin(ReplicaModelAdmin):
    list_display = ('name', )
    search_fields = ('name', )


class CenterGroupInline(admin.TabularInline):
    model = DeliveryCenter.group.through
    extra = 1


class CenterAdmin(ReplicaModelAdmin):

    class Meta:
        model = DeliveryCenter

    list_display = ('name', 'city', 'state', 'region', 'code', 'p_center')
    search_fields = ('name', )
    list_editable = ('city',)
    list_filter = ('city__state', 'city__state__region')
    formfield_overrides = {
        BitField: {'widget': BitFieldCheckboxSelectMultiple},
    }
    prepopulated_fields = {"slug": ("name",)}
    exclude = ('code', 'is_processing_center', 'is_dispatch_center', 'is_hub',)
    change_form_template = "admin_search_support.html"
    form = AdminCenterForm


class StateAdmin(ReplicaModelAdmin):

    class Meta:
        model = State
        exclude = ('id',)
    list_display = ('name', 'region')
    search_fields = ('name', )
    list_filter = ('region',)


class CityAdmin(ReplicaModelAdmin):

    class Meta:
        model = City
        fields = ('name', 'state__name', 'tier')
        exclude = ('id',)
        list_display = ('name', 'state')
        search_fields = ('name', 'state__name')
        list_filter = ('state', 'state__region')


class ODTatMatrixAdmin(admin.ModelAdmin):
    list_display = ('origin', 'destination',
                    'forward_surface_cutoff', 'forward_surface_tat',
                    'forward_express_cutoff', 'forward_express_tat',
                    'return_cutoff','return_tat',
                    'dto_cutoff','dto_tat' )
    search_fields = ('origin__name', 'destination__name')
    list_filter = ('origin__name', 'destination__name')

    class Meta:
        model = ODTatMatrix

    def save_model(self, request, obj, form, change):
        obj.user = request.user
        obj.save()

class ServiceabilityAdmin(admin.ModelAdmin):

    class Meta:
        model = Serviceability
        exclude = ('id',)
    form = ServiceabilityForm
    list_display = ('pincode', 'locality')
    search_fields = ('pincode', )
    list_filter = ('pincode', 'locality', )

class AttributeAdmin(ReplicaModelAdmin):

    class Meta:
        model = AttributeCodes
    list_display = ('amt_intra', 'amt_inter', )
    search_fields = ('amt_intra', 'amt_inter', )
    list_filter = ('amt_intra', 'amt_inter', )


class CenterMapperAdmin(admin.ModelAdmin):

    class Meta:
        model = CenterMapper
    form = CenterMapperForm
    list_display = ('serviceability', 'center', )
    search_fields = ('center__name', 'serviceability__pincode')
    list_filter = ('center', )

admin.site.register(DeliveryCenter, CenterAdmin)
admin.site.register(DeliveryCenterGroup, CenterGroupAdmin)
admin.site.register(State, StateAdmin)
admin.site.register(City, CityAdmin)
admin.site.register(ODTatMatrix, ODTatMatrixAdmin)
admin.site.register(Serviceability, ServiceabilityAdmin)
admin.site.register(AttributeCodes, AttributeAdmin)
admin.site.register(CenterMapper, CenterMapperAdmin)

1c9d7d5d5293db3310754ac1909ce3df172ff8de
<mask token>


class StateAdmin(ReplicaModelAdmin):


    class Meta:
        model = State
        exclude = 'id',
    list_display = 'name', 'region'
    search_fields = 'name',
    list_filter = 'region',


class CityAdmin(ReplicaModelAdmin):


    class Meta:
        model = City
        fields = 'name', 'state__name', 'tier'
        exclude = 'id',
        list_display = 'name', 'state'
        search_fields = 'name', 'state__name'
        list_filter = 'state', 'state__region'


class ODTatMatrixAdmin(admin.ModelAdmin):
    list_display = ('origin', 'destination', 'forward_surface_cutoff',
        'forward_surface_tat', 'forward_express_cutoff',
        'forward_express_tat', 'return_cutoff', 'return_tat', 'dto_cutoff',
        'dto_tat')
    search_fields = 'origin__name', 'destination__name'
    list_filter = 'origin__name', 'destination__name'


    class Meta:
        model = ODTatMatrix

    def save_model(self, request, obj, form, change):
        obj.user = request.user
        obj.save()


class ServiceabilityAdmin(admin.ModelAdmin):


    class Meta:
        model = Serviceability
        exclude = 'id',
    form = ServiceabilityForm
    list_display = 'pincode', 'locality'
    search_fields = 'pincode',
    list_filter = 'pincode', 'locality'


class AttributeAdmin(ReplicaModelAdmin):


    class Meta:
        model = AttributeCodes
    list_display = 'amt_intra', 'amt_inter'
    search_fields = 'amt_intra', 'amt_inter'
    list_filter = 'amt_intra', 'amt_inter'


class CenterMapperAdmin(admin.ModelAdmin):


    class Meta:
        model = CenterMapper
    form = CenterMapperForm
    list_display = 'serviceability', 'center'
    search_fields = 'center__name', 'serviceability__pincode'
    list_filter = 'center',


<mask token>

<mask token>


class CenterAdmin(ReplicaModelAdmin):


    class Meta:
        model = DeliveryCenter
    list_display = 'name', 'city', 'state', 'region', 'code', 'p_center'
    search_fields = 'name',
    list_editable = 'city',
    list_filter = 'city__state', 'city__state__region'
    formfield_overrides = {BitField: {'widget': BitFieldCheckboxSelectMultiple}
        }
    prepopulated_fields = {'slug': ('name',)}
    exclude = 'code', 'is_processing_center', 'is_dispatch_center', 'is_hub'
    change_form_template = 'admin_search_support.html'
    form = AdminCenterForm


class StateAdmin(ReplicaModelAdmin):


    class Meta:
        model = State
        exclude = 'id',
    list_display = 'name', 'region'
    search_fields = 'name',
    list_filter = 'region',


class CityAdmin(ReplicaModelAdmin):


    class Meta:
        model = City
        fields = 'name', 'state__name', 'tier'
        exclude = 'id',
        list_display = 'name', 'state'
        search_fields = 'name', 'state__name'
        list_filter = 'state', 'state__region'


class ODTatMatrixAdmin(admin.ModelAdmin):
    list_display = ('origin', 'destination', 'forward_surface_cutoff',
        'forward_surface_tat', 'forward_express_cutoff',
        'forward_express_tat', 'return_cutoff', 'return_tat', 'dto_cutoff',
        'dto_tat')
    search_fields = 'origin__name', 'destination__name'
    list_filter = 'origin__name', 'destination__name'


    class Meta:
        model = ODTatMatrix

    def save_model(self, request, obj, form, change):
        obj.user = request.user
        obj.save()


class ServiceabilityAdmin(admin.ModelAdmin):


    class Meta:
        model = Serviceability
        exclude = 'id',
    form = ServiceabilityForm
    list_display = 'pincode', 'locality'
    search_fields = 'pincode',
    list_filter = 'pincode', 'locality'


class AttributeAdmin(ReplicaModelAdmin):


    class Meta:
        model = AttributeCodes
    list_display = 'amt_intra', 'amt_inter'
    search_fields = 'amt_intra', 'amt_inter'
    list_filter = 'amt_intra', 'amt_inter'


class CenterMapperAdmin(admin.ModelAdmin):


    class Meta:
        model = CenterMapper
    form = CenterMapperForm
    list_display = 'serviceability', 'center'
    search_fields = 'center__name', 'serviceability__pincode'
    list_filter = 'center',


<mask token>

<mask token>


class CenterGroupInline(admin.TabularInline):
    <mask token>
    <mask token>


class CenterAdmin(ReplicaModelAdmin):


    class Meta:
        model = DeliveryCenter
    list_display = 'name', 'city', 'state', 'region', 'code', 'p_center'
    search_fields = 'name',
    list_editable = 'city',
    list_filter = 'city__state', 'city__state__region'
    formfield_overrides = {BitField: {'widget': BitFieldCheckboxSelectMultiple}
        }
    prepopulated_fields = {'slug': ('name',)}
    exclude = 'code', 'is_processing_center', 'is_dispatch_center', 'is_hub'
    change_form_template = 'admin_search_support.html'
    form = AdminCenterForm


class StateAdmin(ReplicaModelAdmin):


    class Meta:
        model = State
        exclude = 'id',
    list_display = 'name', 'region'
    search_fields = 'name',
    list_filter = 'region',


class CityAdmin(ReplicaModelAdmin):


    class Meta:
        model = City
        fields = 'name', 'state__name', 'tier'
        exclude = 'id',
        list_display = 'name', 'state'
        search_fields = 'name', 'state__name'
        list_filter = 'state', 'state__region'


class ODTatMatrixAdmin(admin.ModelAdmin):
    list_display = ('origin', 'destination', 'forward_surface_cutoff',
        'forward_surface_tat', 'forward_express_cutoff',
        'forward_express_tat', 'return_cutoff', 'return_tat', 'dto_cutoff',
        'dto_tat')
    search_fields = 'origin__name', 'destination__name'
    list_filter = 'origin__name', 'destination__name'


    class Meta:
        model = ODTatMatrix

    def save_model(self, request, obj, form, change):
        obj.user = request.user
        obj.save()


class ServiceabilityAdmin(admin.ModelAdmin):


    class Meta:
        model = Serviceability
        exclude = 'id',
    form = ServiceabilityForm
    list_display = 'pincode', 'locality'
    search_fields = 'pincode',
    list_filter = 'pincode', 'locality'


class AttributeAdmin(ReplicaModelAdmin):


    class Meta:
        model = AttributeCodes
    list_display = 'amt_intra', 'amt_inter'
    search_fields = 'amt_intra', 'amt_inter'
    list_filter = 'amt_intra', 'amt_inter'


class CenterMapperAdmin(admin.ModelAdmin):


    class Meta:
        model = CenterMapper
    form = CenterMapperForm
    list_display = 'serviceability', 'center'
    search_fields = 'center__name', 'serviceability__pincode'
    list_filter = 'center',


<mask token>

<mask token>


class CenterGroupInline(admin.TabularInline):
    model = DeliveryCenter.group.through
    extra = 1


class CenterAdmin(ReplicaModelAdmin):


    class Meta:
        model = DeliveryCenter
    list_display = 'name', 'city', 'state', 'region', 'code', 'p_center'
    search_fields = 'name',
    list_editable = 'city',
    list_filter = 'city__state', 'city__state__region'
    formfield_overrides = {BitField: {'widget': BitFieldCheckboxSelectMultiple}
        }
    prepopulated_fields = {'slug': ('name',)}
    exclude = 'code', 'is_processing_center', 'is_dispatch_center', 'is_hub'
    change_form_template = 'admin_search_support.html'
    form = AdminCenterForm


class StateAdmin(ReplicaModelAdmin):


    class Meta:
        model = State
        exclude = 'id',
    list_display = 'name', 'region'
    search_fields = 'name',
    list_filter = 'region',


class CityAdmin(ReplicaModelAdmin):


    class Meta:
        model = City
        fields = 'name', 'state__name', 'tier'
        exclude = 'id',
        list_display = 'name', 'state'
        search_fields = 'name', 'state__name'
        list_filter = 'state', 'state__region'


class ODTatMatrixAdmin(admin.ModelAdmin):
    list_display = ('origin', 'destination', 'forward_surface_cutoff',
        'forward_surface_tat', 'forward_express_cutoff',
        'forward_express_tat', 'return_cutoff', 'return_tat', 'dto_cutoff',
        'dto_tat')
    search_fields = 'origin__name', 'destination__name'
    list_filter = 'origin__name', 'destination__name'


    class Meta:
        model = ODTatMatrix

    def save_model(self, request, obj, form, change):
        obj.user = request.user
        obj.save()


class ServiceabilityAdmin(admin.ModelAdmin):


    class Meta:
        model = Serviceability
        exclude = 'id',
    form = ServiceabilityForm
    list_display = 'pincode', 'locality'
    search_fields = 'pincode',
    list_filter = 'pincode', 'locality'


class AttributeAdmin(ReplicaModelAdmin):


    class Meta:
        model = AttributeCodes
    list_display = 'amt_intra', 'amt_inter'
    search_fields = 'amt_intra', 'amt_inter'
    list_filter = 'amt_intra', 'amt_inter'


class CenterMapperAdmin(admin.ModelAdmin):


    class Meta:
        model = CenterMapper
    form = CenterMapperForm
    list_display = 'serviceability', 'center'
    search_fields = 'center__name', 'serviceability__pincode'
    list_filter = 'center',


<mask token>

from deliverycenters.models import DeliveryCenter, DeliveryCenterGroup, \
    ODTatMatrix
from django.contrib import admin
from deliverycenters.models import State, City
from deliverycenters.forms import AdminCenterForm
from deliverycenters.models import State, City, Serviceability,\
    AttributeCodes, CenterMapper
from bitfield import BitField
from deliverycenters.forms import ServiceabilityForm, CenterMapperForm
from bitfield.forms import BitFieldCheckboxSelectMultiple
from backend.admin import ReplicaModelAdmin


class CenterGroupAdmin(ReplicaModelAdmin):
    list_display = ('name', )
    search_fields = ('name', )


class CenterGroupInline(admin.TabularInline):
    model = DeliveryCenter.group.through
    extra = 1


class CenterAdmin(ReplicaModelAdmin):

    class Meta:
        model = DeliveryCenter

    list_display = ('name', 'city', 'state', 'region', 'code', 'p_center')
    search_fields = ('name', )
    list_editable = ('city',)
    list_filter = ('city__state', 'city__state__region')
    formfield_overrides = {
        BitField: {'widget': BitFieldCheckboxSelectMultiple},
    }
    prepopulated_fields = {"slug": ("name",)}
    exclude = ('code', 'is_processing_center', 'is_dispatch_center', 'is_hub',)
    change_form_template = "admin_search_support.html"
    form = AdminCenterForm


class StateAdmin(ReplicaModelAdmin):

    class Meta:
        model = State
        exclude = ('id',)
    list_display = ('name', 'region')
    search_fields = ('name', )
    list_filter = ('region',)


class CityAdmin(ReplicaModelAdmin):

    class Meta:
        model = City
        fields = ('name', 'state__name', 'tier')
        exclude = ('id',)
        list_display = ('name', 'state')
        search_fields = ('name', 'state__name')
        list_filter = ('state', 'state__region')


class ODTatMatrixAdmin(admin.ModelAdmin):
    list_display = ('origin', 'destination',
                    'forward_surface_cutoff', 'forward_surface_tat',
                    'forward_express_cutoff', 'forward_express_tat',
                    'return_cutoff','return_tat',
                    'dto_cutoff','dto_tat' )
    search_fields = ('origin__name', 'destination__name')
    list_filter = ('origin__name', 'destination__name')

    class Meta:
        model = ODTatMatrix

    def save_model(self, request, obj, form, change):
        obj.user = request.user
        obj.save()

class ServiceabilityAdmin(admin.ModelAdmin):

    class Meta:
        model = Serviceability
        exclude = ('id',)
    form = ServiceabilityForm
    list_display = ('pincode', 'locality')
    search_fields = ('pincode', )
    list_filter = ('pincode', 'locality', )

class AttributeAdmin(ReplicaModelAdmin):

    class Meta:
        model = AttributeCodes
    list_display = ('amt_intra', 'amt_inter', )
    search_fields = ('amt_intra', 'amt_inter', )
    list_filter = ('amt_intra', 'amt_inter', )


class CenterMapperAdmin(admin.ModelAdmin):

    class Meta:
        model = CenterMapper
    form = CenterMapperForm
    list_display = ('serviceability', 'center', )
    search_fields = ('center__name', 'serviceability__pincode')
    list_filter = ('center', )

admin.site.register(DeliveryCenter, CenterAdmin)
admin.site.register(DeliveryCenterGroup, CenterGroupAdmin)
admin.site.register(State, StateAdmin)
admin.site.register(City, CityAdmin)
admin.site.register(ODTatMatrix, ODTatMatrixAdmin)
admin.site.register(Serviceability, ServiceabilityAdmin)
admin.site.register(AttributeCodes, AttributeAdmin)
admin.site.register(CenterMapper, CenterMapperAdmin)
