def formfield_for_foreignkey(self, db_field, request, **kwargs): if db_field.name == 'type': kwargs['queryset'] = JobTypeDao.visible_types() kwargs = formfield_for_coordinator( request, db_field.name, 'type', 'juntagrico.is_area_admin', JobTypeDao.visible_types_by_coordinator, **kwargs) return super().formfield_for_foreignkey(db_field, request, **kwargs)
def formfield_for_foreignkey(self, db_field, request, **kwargs): if db_field.name == 'type': kwargs['queryset'] = JobTypeDao.visible_types() kwargs = formfield_for_coordinator(request, db_field.name, 'type', 'juntagrico.is_area_admin', JobTypeDao.visible_types_by_coordinator, **kwargs) # show jobtype even if invisible to be able to edit and save this job with the same type # HACK: get instance via url argument instance_pk = request.resolver_match.kwargs.get('object_id') if instance_pk is not None: kwargs['queryset'] |= JobType.objects.filter(recuringjob__pk=instance_pk) kwargs['queryset'] = kwargs['queryset'].distinct() return super().formfield_for_foreignkey(db_field, request, **kwargs)
def formfield_for_foreignkey(self, db_field, request, **kwargs): kwargs = formfield_for_coordinator(request, db_field.name, 'job', 'juntagrico.is_area_admin', JobDao.ids_for_area_by_contact) return super().formfield_for_foreignkey(db_field, request, **kwargs)
def formfield_for_foreignkey(self, db_field, request, **kwargs): kwargs = formfield_for_coordinator(request, 'type', 'juntagrico.is_area_admin', JobTypeDao.types_by_coordinator) return super().formfield_for_foreignkey(db_field, request, **kwargs)
def formfield_for_foreignkey(self, db_field, request, **kwargs): kwargs = formfield_for_coordinator( request, db_field.name, 'activityarea', 'juntagrico.is_area_admin', ActivityAreaDao.areas_by_coordinator) return super().formfield_for_foreignkey(db_field, request, **kwargs)