Beispiel #1
0
 def __init__(self, f, request, params, model, model_admin, *args,
              **kwargs):
     ChoicesFilterSpec.__init__(self, f, request, params, model,
                                model_admin, *args, **kwargs)
     self.lookup_kwarg = 'product__category_now__name'
     self.lookup_val = request.GET.get(self.lookup_kwarg)
     coupon_qs = Categories.objects.all().order_by('-parent', '-name')
     self.lookup_choices = coupon_qs.values_list('name', flat=True)
Beispiel #2
0
    def __init__(self, f, request, params, model, model_admin):
        ChoicesFilterSpec.__init__(self, f, request, params, model, model_admin)
        self.lookup_kwarg = self.my_lookup_kwarg
        # get the current filter value from GET (we will use it to know
        # which filter item is selected)
        self.lookup_val = request.GET.get(self.lookup_kwarg)

        # Prepare the list of unique, country name, ordered alphabetically
        self.lookup_choices = self.prepare_choices()
Beispiel #3
0
    def __init__(self, f, request, params, model, model_admin, *args,
                 **kwargs):
        ChoicesFilterSpec.__init__(self, f, request, params, model,
                                   model_admin, *args, **kwargs)
        self.lookup_kwarg = 'coupon__name'
        self.lookup_val = request.GET.get(self.lookup_kwarg)

        coupon_qs = Coupon.objects.all()
        self.lookup_choices = coupon_qs.values_list('name', flat=True)
Beispiel #4
0
    def __init__(self, f, request, params, model, model_admin):
        ChoicesFilterSpec.__init__(self, f, request, params, model, model_admin)

        # The lookup string that will be added to the queryset
        # by this filter
        self.lookup_kwarg = 'country__name_en'
        # get the current filter value from GET (we will use it to know
        # which filter item is selected)
        self.lookup_val = request.GET.get(self.lookup_kwarg)

        # Prepare the list of unique, country name, ordered alphabetically
        country_qs = Country.objects.filter(added_by = request.user)
        self.lookup_choices = country_qs.values_list('name_en', flat = True)
Beispiel #5
0
 def __init__(
     self, f, request, params, model, model_admin, field_path = None
 ):
     ChoicesFilterSpec.__init__(
         self, f, request, params, model, model_admin, field_path
     )
     self.lookup_kwarg = 'status'
     # usually, lookup_vals are extracted from request.GET. But we have
     # intentionally removed ``status`` from GET before.
     # (Have a look at ``django_monitor.admin.MonitorAdmin.queryset`` to
     # know why). So we'll apply regex over the url:
     import re
     status_matches = re.findall(
         r'status=(?P<status>%s)' % '|'.join(STATUS_DICT.keys()),
         request.get_full_path()
     )
     self.lookup_val = status_matches[0] if status_matches else None
     self.lookup_choices = STATUS_DICT.keys()