from mediguest_admin.site import mediguest_admin_site from django.contrib import admin from models import ConvictionType, Conviction class ConvictionsInline(admin.TabularInline): model = Conviction extra = 0 mediguest_admin_site.register(ConvictionType) mediguest_admin_site.register(Conviction)
from mediguest_admin.site import mediguest_admin_site from models import GP, HealthProvider mediguest_admin_site.register(GP) mediguest_admin_site.register(HealthProvider)
from mediguest_admin.site import mediguest_admin_site from models import Address mediguest_admin_site.register(Address)
from mediguest_admin.site import mediguest_admin_site from models import ClientNote from django.contrib import admin class ClientNotesInline(admin.TabularInline): model = ClientNote extra = 0 mediguest_admin_site.register(ClientNote)
from mediguest_admin.site import mediguest_admin_site from models import Drug, DrugUnit, DrugFrequency, DrugDose from django.contrib import admin class DrugDosesInline(admin.TabularInline): model = DrugDose extra = 0 mediguest_admin_site.register(Drug) mediguest_admin_site.register(DrugUnit) mediguest_admin_site.register(DrugFrequency) mediguest_admin_site.register(DrugDose)
from mediguest_admin.site import mediguest_admin_site from models import InventoryItemType, InventoryItem from django.contrib import admin class InventoryItemInline(admin.TabularInline): model = InventoryItem extra = 0 mediguest_admin_site.register(InventoryItemType) mediguest_admin_site.register(InventoryItem)
from mediguest_admin.site import mediguest_admin_site from models import RoomType, Room, Booking from inventory.admin import InventoryItemInline from django.forms.models import BaseInlineFormSet from django.contrib import admin class BookingsInline(admin.TabularInline): model = Booking extra = 0 class RoomAdmin(admin.ModelAdmin): inlines = [ InventoryItemInline, ] mediguest_admin_site.register(RoomType) mediguest_admin_site.register(Room, RoomAdmin) mediguest_admin_site.register(Booking)
from mediguest_admin.site import mediguest_admin_site from models import BenefitType, ReceivedBenefit from django.contrib import admin class ReceivedBenefitsInline(admin.TabularInline): model = ReceivedBenefit extra = 0 mediguest_admin_site.register(BenefitType) mediguest_admin_site.register(ReceivedBenefit)
from mediguest_admin.site import mediguest_admin_site from models import RiskAssessment from django.contrib import admin class RiskAssessmentsInline(admin.TabularInline): model = RiskAssessment extra = 0 mediguest_admin_site.register(RiskAssessment)
from mediguest_admin.site import mediguest_admin_site from models import Hospital, HospitalAdmission from django.forms.models import BaseInlineFormSet from django.contrib import admin class HospitalAdmissionsInline(admin.TabularInline): model = HospitalAdmission extra = 0 mediguest_admin_site.register(HospitalAdmission) mediguest_admin_site.register(Hospital)
from mediguest_admin.site import mediguest_admin_site from models import SupportPlanReview from django.contrib import admin class SupportPlanReviewsInline(admin.TabularInline): model = SupportPlanReview extra = 0 mediguest_admin_site.register(SupportPlanReview)
from mediguest_admin.site import mediguest_admin_site from models import Hospital, HospitalAdmission from django.forms.models import BaseInlineFormSet from django.contrib import admin class HospitalAdmissionsInline(admin.TabularInline): model = HospitalAdmission extra = 0 mediguest_admin_site.register(HospitalAdmission) mediguest_admin_site.register(Hospital)
from mediguest_admin.site import mediguest_admin_site from models import SupportPlanReview from django.contrib import admin class SupportPlanReviewsInline(admin.TabularInline): model = SupportPlanReview extra = 0 mediguest_admin_site.register(SupportPlanReview)
from addresses.models import Address from models import Organization, OrganizationMember, Person from mediguest_admin.site import mediguest_admin_site from django.contrib import admin from foreignkeysearch.widgets import ForeignKeySearchForm from foreignkeysearch.handler import BaseHandler class address_SearchHandler(BaseHandler): model = Address class PersonAdmin(admin.ModelAdmin): def formfield_for_dbfield(self, db_field, **kwargs): field = super(PersonAdmin, self).formfield_for_dbfield(db_field, **kwargs) if db_field.name in ('address'): field.widget = ForeignKeySearchForm( db_field=db_field, handler=eval(db_field.name + '_SearchHandler'), ) return field mediguest_admin_site.register(Organization) mediguest_admin_site.register(OrganizationMember) mediguest_admin_site.register(Person, PersonAdmin)
from mediguest_admin.site import mediguest_admin_site from models import RiskAssessment from django.contrib import admin class RiskAssessmentsInline(admin.TabularInline): model = RiskAssessment extra = 0 mediguest_admin_site.register(RiskAssessment)
return super(ServiceChargesInline, self).formfield_for_foreignkey(field, request, **kwargs) class ServiceChargePaymentsInline(admin.TabularInline): model = ServiceChargePayment extra = 0 def get_formset(self, request, obj=None, **kwargs): """ Enable formfield_for_foreign key to be given obj instance """ from django.utils.functional import curry return super(ServiceChargePaymentsInline, self).get_formset(request, obj=obj, formfield_callback=curry(self.formfield_for_foreignkey, request=request, obj=obj) ) def formfield_for_foreignkey(self, field, request, **kwargs): """ Filter only discounts which are currently applicable """ from models import ServiceCharge if field.name == 'service_charge': if kwargs['obj'] is not None: kwargs['queryset'] = ServiceCharge.objects.filter(client=kwargs['obj'].client) del kwargs['obj'] return super(ServiceChargePaymentsInline, self).formfield_for_foreignkey(field, request, **kwargs) mediguest_admin_site.register(ServiceChargeType) mediguest_admin_site.register(ServiceCharge) mediguest_admin_site.register(ServiceChargePayment)
from mediguest_admin.site import mediguest_admin_site from django.contrib import admin from models import ConvictionType, Conviction class ConvictionsInline(admin.TabularInline): model = Conviction extra = 0 mediguest_admin_site.register(ConvictionType) mediguest_admin_site.register(Conviction)
from mediguest_admin.site import mediguest_admin_site from models import Incident from django.contrib import admin class IncidentsInline(admin.TabularInline): model = Incident extra = 0 mediguest_admin_site.register(Incident)
'fields': ( 'national_insurance_no', 'gp', 'assigned_keyworker', 'contact_next_of_kin', 'next_of_kin', 'medical_problems', 'mobility_problems', 'assistance_required', ) }), ('Statistics', { 'fields': ( 'presented_as_homeless', 'ethnic_origin', ) }), ) def formfield_for_dbfield(self, db_field, **kwargs): field = super(ClientAdmin, self).formfield_for_dbfield(db_field, **kwargs) if db_field.name in ('address', 'keyworker', 'gp', 'next_of_kin'): field.widget = ForeignKeySearchForm( db_field=db_field, handler=eval(db_field.name + '_SearchHandler'), ) return field mediguest_admin_site.register(Client, ClientAdmin)
from mediguest_admin.site import mediguest_admin_site from models import RoomType, Room, Booking from inventory.admin import InventoryItemInline from django.forms.models import BaseInlineFormSet from django.contrib import admin class BookingsInline(admin.TabularInline): model = Booking extra = 0 class RoomAdmin(admin.ModelAdmin): inlines = [ InventoryItemInline, ] mediguest_admin_site.register(RoomType) mediguest_admin_site.register(Room, RoomAdmin) mediguest_admin_site.register(Booking)
def get_formset(self, request, obj=None, **kwargs): """ Enable formfield_for_foreign key to be given obj instance """ from django.utils.functional import curry return super(ServiceChargePaymentsInline, self).get_formset( request, obj=obj, formfield_callback=curry(self.formfield_for_foreignkey, request=request, obj=obj)) def formfield_for_foreignkey(self, field, request, **kwargs): """ Filter only discounts which are currently applicable """ from models import ServiceCharge if field.name == 'service_charge': if kwargs['obj'] is not None: kwargs['queryset'] = ServiceCharge.objects.filter( client=kwargs['obj'].client) del kwargs['obj'] return super(ServiceChargePaymentsInline, self).formfield_for_foreignkey(field, request, **kwargs) mediguest_admin_site.register(ServiceChargeType) mediguest_admin_site.register(ServiceCharge) mediguest_admin_site.register(ServiceChargePayment)
from mediguest_admin.site import mediguest_admin_site from models import InventoryItemType, InventoryItem from django.contrib import admin class InventoryItemInline(admin.TabularInline): model = InventoryItem extra = 0 mediguest_admin_site.register(InventoryItemType) mediguest_admin_site.register(InventoryItem)
from mediguest_admin.site import mediguest_admin_site from models import Keyworker, KeyworkSession from django.contrib import admin class KeyworkSessionsInline(admin.TabularInline): model = KeyworkSession extra = 0 mediguest_admin_site.register(Keyworker) mediguest_admin_site.register(KeyworkSession)
from mediguest_admin.site import mediguest_admin_site from models import Religion mediguest_admin_site.register(Religion)