text: ### $Id: admin.py,v 1.8 2017/12/04 08:16:37 muntaza Exp $
  
  from django.contrib import admin
  from umum.models import Provinsi, Kabupaten, LokasiBidang, SKPD, SUBSKPD, KodeBarang, HakTanah, SatuanBarang, KeadaanBarang, SKPenghapusan, MutasiBerkurang, JenisPemanfaatan, AsalUsul, Tahun, GolonganBarang, Tanah, KontrakTanah, PenghapusanTanah, TanahPenghapusan, PemanfaatanTanah, TanahPemanfaatan, HargaTanah
  
  #### Tanah
  from umum.models import TanahDisdikKantor, HargaTanahDisdikKantor
  from umum.admin import HargaTanahInline, TanahAdmin, KontrakTanahAdmin, HargaTanahAdmin
  
  from umum.admin import GedungBangunanInline
  
  
  
  #### Gedung Bangunan
  from gedungbangunan.models import StatusTingkat, StatusBeton, KontrakGedungBangunan, HargaGedungBangunan, GedungBangunan, PenghapusanGedungBangunan, PemanfaatanGedungBangunan, TahunBerkurangGedungBangunan, Ruangan
  
  from gedungbangunan.models import GedungBangunanPemanfaatan, GedungBangunanPenghapusan, GedungBangunanRuangan
  
  from gedungbangunan.models import GedungBangunanDisdikKantor, HargaGedungBangunanDisdikKantor, GedungBangunanRuanganDisdikKantor
  
  from gedungbangunan.admin import HargaGedungBangunanInline, GedungBangunanAdmin, KontrakGedungBangunanAdmin, HargaGedungBangunanAdmin, RuanganInline, GedungBangunanRuanganAdmin
  
  
  
  #### Peralatan Mesin
  from peralatanmesin.models import KontrakPeralatanMesin, HargaPeralatanMesin, PeralatanMesin, PenghapusanPeralatanMesin, PemanfaatanPeralatanMesin, TahunBerkurangPeralatanMesin
  
  
  #untuk menampung inline
  from peralatanmesin.models import PeralatanMesinPemanfaatan, PeralatanMesinPenghapusan
  
  from peralatanmesin.models import PeralatanMesinDisdikKantor, HargaPeralatanMesinDisdikKantor
  
  from peralatanmesin.admin import HargaPeralatanMesinInline, PeralatanMesinAdmin, KontrakPeralatanMesinAdmin, HargaPeralatanMesinAdmin
  
  
  
  
  #### Class Tanah
  class GedungBangunanDisdikKantorInline(GedungBangunanInline):
      model = GedungBangunanDisdikKantor
  
  
  
  class HargaTanahDisdikKantorInline(HargaTanahInline):
      model = HargaTanahDisdikKantor
  
      def formfield_for_foreignkey(self, db_field, request, **kwargs):
          if db_field.name == "id_kontrak":
              kwargs["queryset"] = KontrakTanah.objects.filter(id_skpd__exact=7)
          return super(HargaTanahDisdikKantorInline, self).formfield_for_foreignkey(db_field, request, **kwargs)
  
  
  
  class TanahDisdikKantorAdmin(TanahAdmin):
      inlines = [HargaTanahDisdikKantorInline]
  
  
      def formfield_for_foreignkey(self, db_field, request, **kwargs):
  	if db_field.name == "id_sub_skpd":
              qs_id_sub_skpd=range(43,48)
              kwargs["queryset"] = SUBSKPD.objects.filter(id__in=qs_id_sub_skpd)
          return super(TanahDisdikKantorAdmin, self).formfield_for_foreignkey(db_field, request, **kwargs)
  
      def get_queryset(self, request):
          qs_id_sub_skpd=range(43,48)
          return self.model.objects.filter(id_sub_skpd__in=qs_id_sub_skpd).filter(id_mutasi_berkurang__exact=5)
  
  
  
  class HargaTanahDisdikKantorAdmin(HargaTanahAdmin):
  
      def get_queryset(self, request):
          qs_id_sub_skpd=range(43,48)
          tanah_qs = Tanah.objects.filter(id_sub_skpd__in=qs_id_sub_skpd)
          return self.model.objects.filter(id_tanah__in=tanah_qs)
  
  
  
  ### Register Tanah DisdikKantor
  admin.site.register(TanahDisdikKantor, TanahDisdikKantorAdmin)
  admin.site.register(HargaTanahDisdikKantor, HargaTanahDisdikKantorAdmin)
  
  
  
  
  
  #### Class Gedung dan Bangunan
  class HargaGedungBangunanDisdikKantorInline(HargaGedungBangunanInline):
      model = HargaGedungBangunanDisdikKantor
  
      def formfield_for_foreignkey(self, db_field, request, **kwargs):
          if db_field.name == "id_kontrak_gedung_bangunan":
              kwargs["queryset"] = KontrakGedungBangunan.objects.filter(id_skpd__exact=7)
          return super(HargaGedungBangunanDisdikKantorInline, self).formfield_for_foreignkey(db_field, request, **kwargs)
  
  
  
  class GedungBangunanDisdikKantorAdmin(GedungBangunanAdmin):
      inlines = [HargaGedungBangunanDisdikKantorInline]
  
      def formfield_for_foreignkey(self, db_field, request, **kwargs):
  	if db_field.name == "id_sub_skpd":
              qs_id_sub_skpd=range(43,48)
              kwargs["queryset"] = SUBSKPD.objects.filter(id__in=qs_id_sub_skpd)
          return super(GedungBangunanDisdikKantorAdmin, self).formfield_for_foreignkey(db_field, request, **kwargs)
  
      def get_queryset(self, request):
          qs_id_sub_skpd=range(43,48)
          return self.model.objects.filter(id_sub_skpd__in=qs_id_sub_skpd).filter(id_golongan_barang__exact=3).filter(id_mutasi_berkurang__exact=5)
  
  
  
  class GedungBangunanRuanganDisdikKantorAdmin(GedungBangunanRuanganAdmin):
  
      def get_queryset(self, request):
          qs_id_sub_skpd=range(43,48)
          return self.model.objects.filter(id_sub_skpd__in=qs_id_sub_skpd).filter(id_golongan_barang__exact=3).filter(id_mutasi_berkurang__exact=5)
  
  
  
  class HargaGedungBangunanDisdikKantorAdmin(HargaGedungBangunanAdmin):
  
      def get_queryset(self, request):
          qs_id_sub_skpd=range(43,48)
          gedung_bangunan_qs = GedungBangunan.objects.filter(id_sub_skpd__in=qs_id_sub_skpd)
          return self.model.objects.filter(id_gedung_bangunan__in=gedung_bangunan_qs)
  
  
  
  ###Register GedungBangunan DisdikKantor
  admin.site.register(GedungBangunanDisdikKantor, GedungBangunanDisdikKantorAdmin)
  admin.site.register(GedungBangunanRuanganDisdikKantor, GedungBangunanRuanganDisdikKantorAdmin)
  admin.site.register(HargaGedungBangunanDisdikKantor, HargaGedungBangunanDisdikKantorAdmin)
  
  
  
  
  #### Class Peralatan Mesin
  class HargaPeralatanMesinDisdikKantorInline(HargaPeralatanMesinInline):
      model = HargaPeralatanMesinDisdikKantor
  
      def formfield_for_foreignkey(self, db_field, request, **kwargs):
          if db_field.name == "id_kontrak_peralatan_mesin":
              kwargs["queryset"] = KontrakPeralatanMesin.objects.filter(id_skpd__exact=7)
          return super(HargaPeralatanMesinDisdikKantorInline, self).formfield_for_foreignkey(db_field, request, **kwargs)
  
  
  
  class PeralatanMesinDisdikKantorAdmin(PeralatanMesinAdmin):
      inlines = [HargaPeralatanMesinDisdikKantorInline]
  
      def formfield_for_foreignkey(self, db_field, request, **kwargs):
          if db_field.name == "id_sub_skpd":
              qs_id_sub_skpd=range(43,48)
              kwargs["queryset"] = SUBSKPD.objects.filter(id__in=qs_id_sub_skpd)
          if db_field.name == "id_ruangan":
              qs_id_sub_skpd=range(43,48)
              kwargs["queryset"] = Ruangan.objects.filter(id_gedung_bangunan__id_sub_skpd__in=qs_id_sub_skpd)
          return super(PeralatanMesinDisdikKantorAdmin, self).formfield_for_foreignkey(db_field, request, **kwargs)
  
      def get_queryset(self, request):
          qs_id_sub_skpd=range(43,48)
          return self.model.objects.filter(id_sub_skpd__in=qs_id_sub_skpd).filter(id_mutasi_berkurang__exact=5)
  
  
  
  class HargaPeralatanMesinDisdikKantorAdmin(HargaPeralatanMesinAdmin):
  
      def get_queryset(self, request):
          qs_id_sub_skpd=range(43,48)
          peralatan_mesin_qs = PeralatanMesin.objects.filter(id_sub_skpd__in=qs_id_sub_skpd)
          return self.model.objects.filter(id_peralatan_mesin__in=peralatan_mesin_qs)
  
  
  
  ###Register PeralatanMesin DisdikKantor
  admin.site.register(PeralatanMesinDisdikKantor, PeralatanMesinDisdikKantorAdmin)
  admin.site.register(HargaPeralatanMesinDisdikKantor, HargaPeralatanMesinDisdikKantorAdmin)
  
  
  
  
  
  
  #### Jalan, Irigasi, dan Jaringan
  from jalanirigasijaringan.models import KontrakJalanIrigasiJaringan, HargaJalanIrigasiJaringan, JalanIrigasiJaringan, PenghapusanJalanIrigasiJaringan, PemanfaatanJalanIrigasiJaringan, TahunBerkurangJalanIrigasiJaringan
  
  from jalanirigasijaringan.models import JalanIrigasiJaringanPemanfaatan, JalanIrigasiJaringanPenghapusan
  
  from jalanirigasijaringan.models import JalanIrigasiJaringanDisdikKantor,  HargaJalanIrigasiJaringanDisdikKantor
  
  from jalanirigasijaringan.admin import HargaJalanIrigasiJaringanInline, JalanIrigasiJaringanAdmin, KontrakJalanIrigasiJaringanAdmin, HargaJalanIrigasiJaringanAdmin
  
  
  
  
  #### Class Jalan, Irigasi dan Jaringan
  
  
  class HargaJalanIrigasiJaringanDisdikKantorInline(HargaJalanIrigasiJaringanInline):
      model = HargaJalanIrigasiJaringanDisdikKantor
  
      def formfield_for_foreignkey(self, db_field, request, **kwargs):
          if db_field.name == "id_kontrak_jalan_irigasi_jaringan":
              kwargs["queryset"] = KontrakJalanIrigasiJaringan.objects.filter(id_skpd__exact=7)
          return super(HargaJalanIrigasiJaringanDisdikKantorInline, self).formfield_for_foreignkey(db_field, request, **kwargs)
  
  
  
  class JalanIrigasiJaringanDisdikKantorAdmin(JalanIrigasiJaringanAdmin):
      inlines = [HargaJalanIrigasiJaringanDisdikKantorInline]
  
      def formfield_for_foreignkey(self, db_field, request, **kwargs):
          if db_field.name == "id_sub_skpd":
              qs_id_sub_skpd=range(43,48)
              kwargs["queryset"] = SUBSKPD.objects.filter(id__in=qs_id_sub_skpd)
          return super(JalanIrigasiJaringanDisdikKantorAdmin, self).formfield_for_foreignkey(db_field, request, **kwargs)
  
      def get_queryset(self, request):
          qs_id_sub_skpd=range(43,48)
          return self.model.objects.filter(id_sub_skpd__in=qs_id_sub_skpd).filter(id_golongan_barang__exact=4).filter(id_mutasi_berkurang__exact=5)
  
  
  
  class HargaJalanIrigasiJaringanDisdikKantorAdmin(HargaJalanIrigasiJaringanAdmin):
  
      def get_queryset(self, request):
          qs_id_sub_skpd=range(43,48)
          jalan_irigasi_jaringan_qs = JalanIrigasiJaringan.objects.filter(id_sub_skpd__in=qs_id_sub_skpd)
          return self.model.objects.filter(id_jalan_irigasi_jaringan__in=jalan_irigasi_jaringan_qs)
  
  
  
  ###Register JalanIrigasiJaringan DisdikKantor
  admin.site.register(JalanIrigasiJaringanDisdikKantor, JalanIrigasiJaringanDisdikKantorAdmin)
  admin.site.register(HargaJalanIrigasiJaringanDisdikKantor, HargaJalanIrigasiJaringanDisdikKantorAdmin)
  
  
  
  
  #### Aset Tetap Lainnya
  from atl.models import KontrakATL, HargaATL, ATL, PenghapusanATL, PemanfaatanATL, TahunBerkurangATL, TahunBerkurangUsulHapusATL
  
  from atl.models import ATLPemanfaatan, ATLPenghapusan
  
  from atl.models import ATLDisdikKantor, HargaATLDisdikKantor
  
  from atl.admin import HargaATLInline, ATLAdmin, KontrakATLAdmin, HargaATLAdmin
  
  
  
  
  #### Class Aset Tetap Lainnya
  class HargaATLDisdikKantorInline(HargaATLInline):
      model = HargaATLDisdikKantor
  
      def formfield_for_foreignkey(self, db_field, request, **kwargs):
          if db_field.name == "id_kontrak_atl":
              kwargs["queryset"] = KontrakATL.objects.filter(id_skpd__exact=7)
          return super(HargaATLDisdikKantorInline, self).formfield_for_foreignkey(db_field, request, **kwargs)
  
  
  
  class ATLDisdikKantorAdmin(ATLAdmin):
      inlines = [HargaATLDisdikKantorInline]
  
      def formfield_for_foreignkey(self, db_field, request, **kwargs):
          if db_field.name == "id_sub_skpd":
              qs_id_sub_skpd=range(43,48)
              kwargs["queryset"] = SUBSKPD.objects.filter(id__in=qs_id_sub_skpd)
          if db_field.name == "id_ruangan":
              qs_id_sub_skpd=range(43,48)
              kwargs["queryset"] = Ruangan.objects.filter(id_gedung_bangunan__id_sub_skpd__in=qs_id_sub_skpd)
          return super(ATLDisdikKantorAdmin, self).formfield_for_foreignkey(db_field, request, **kwargs)
  
      def get_queryset(self, request):
          qs_id_sub_skpd=range(43,48)
          return self.model.objects.filter(id_sub_skpd__in=qs_id_sub_skpd).filter(id_mutasi_berkurang__exact=5)
  
  
  
  class HargaATLDisdikKantorAdmin(HargaATLAdmin):
  
      def get_queryset(self, request):
          qs_id_sub_skpd=range(43,48)
          atl_qs = ATL.objects.filter(id_sub_skpd__in=qs_id_sub_skpd)
          return self.model.objects.filter(id_atl__in=atl_qs)
  
  
  
  ###Register ATL DisdikKantor
  admin.site.register(ATLDisdikKantor, ATLDisdikKantorAdmin)
  admin.site.register(HargaATLDisdikKantor, HargaATLDisdikKantorAdmin)
  