def filter_by_user_and_hcode(user, q, function='convert_hcodereport_table'): functiont = get_function(function) user_labs = get_user_laboratories(user) labs = user_labs.filter(rooms__furniture__shelf__shelfobject__object__h_code__in=q) # 'rooms__furniture__shelf__shelfobject__object__h_code__code' result = labs.annotate( room=F('rooms__name'), furniture=F('rooms__furniture__name'), reactive=F('rooms__furniture__shelf__shelfobject__object__name'), quantity=F('rooms__furniture__shelf__shelfobject__quantity'), unit=F('rooms__furniture__shelf__shelfobject__measurement_unit'), reactive_id=F('rooms__furniture__shelf__shelfobject__object__pk') ).values('name', 'room', 'furniture', 'reactive', 'quantity', 'unit', 'reactive_id') return functiont(result)
def get_queryset(self): query = super().get_queryset().order_by('update_time') self.form = self.form_class(self.request.GET) self.form.is_valid() query = self.filter_period(self.form.cleaned_data['period'], query) if self.form.cleaned_data['precursor']: query = query.filter(precursor=True) if self.form.cleaned_data['all_laboratories']: query = query.filter( laboratory__in=get_user_laboratories(self.request.user)) else: query = query.filter(laboratory=self.lab) if self.form.cleaned_data['resume']: self.myqueryset = query return query
def get_queryset(self): q = self.request.GET.get('search_fil', '') if q == "": q = None return get_user_laboratories(self.request.user, q)
def get_user_labs(context): if 'request' not in context: return [] return get_user_laboratories(context['request'].user)
def get_user_labs(context): if 'request' not in context: return [] return get_user_laboratories(context['request'].user)