Beispiel #1
0
    def __init__(self, **kwargs):
        if kwargs.get("initial"):
            self.options = kwargs["initial"]
        else:
            self.options = kwargs

        self.start_date = kwargs.get("start_date", None)
        self.end_date = kwargs.get("end_date", None)
        if self.options.get("date_range"):
            self.start_date, self.end_date = parse_date_range(
                self.options["date_range"])

        if self.options.get("shop"):
            self.shop = Shop.objects.get(pk=self.options["shop"])
        else:
            self.shop = None

        if self.start_date is None:
            self.start_date = make_aware(datetime.min + timedelta(days=1),
                                         get_current_timezone())
        if self.end_date is None:
            self.end_date = make_aware(datetime.max - timedelta(days=1),
                                       get_current_timezone())

        if self.options.get("request"):
            self.request = self.options["request"]

        self.rendered = False
Beispiel #2
0
    def __init__(self, **kwargs):
        if kwargs.get("initial"):
            self.options = kwargs["initial"]
        else:
            self.options = kwargs

        self.start_date = kwargs.get("start_date", None)
        self.end_date = kwargs.get("end_date", None)
        if self.options.get("date_range"):
            self.start_date, self.end_date = parse_date_range(self.options["date_range"])

        if self.options.get("shop"):
            self.shop = Shop.objects.get(pk=self.options["shop"])
        else:
            self.shop = None

        if self.start_date is None:
            self.start_date = make_aware(datetime.min + timedelta(days=1), get_current_timezone())
        if self.end_date is None:
            self.end_date = make_aware(datetime.max - timedelta(days=1), get_current_timezone())

        if self.options.get("request"):
            self.request = self.options["request"]

        self.rendered = False
Beispiel #3
0
 def clean(self):
     data = self.cleaned_data
     if data.get("date_range") == DateRangeChoices.CUSTOM:
         try:
             data["date_range"] = parse_date_range((data["start_date"], data["end_date"]))
         except Exception as exc:
             self.add_error("__all__", force_text(exc))
     return data
Beispiel #4
0
 def clean(self):
     data = self.cleaned_data
     if data.get("date_range") == DateRangeChoices.CUSTOM:
         try:
             data["date_range"] = parse_date_range((data["start_date"], data["end_date"]))
         except Exception as exc:
             self.add_error("__all__", force_text(exc))
     return data
Beispiel #5
0
 def __init__(self, **kwargs):
     if kwargs.get("initial"):
         self.options = kwargs["initial"]
     else:
         self.options = kwargs
     self.start_date = kwargs.get("start_date", None)
     self.end_date = kwargs.get("end_date", None)
     if self.options.get("date_range"):
         self.start_date, self.end_date = parse_date_range(self.options["date_range"])
     if self.options.get("shop"):
         self.shop = Shop.objects.get(pk=self.options["shop"])
     else:
         self.shop = None
     self.rendered = False
Beispiel #6
0
 def __init__(self, **kwargs):
     if kwargs.get("initial"):
         self.options = kwargs["initial"]
     else:
         self.options = kwargs
     self.start_date = kwargs.get("start_date", None)
     self.end_date = kwargs.get("end_date", None)
     if self.options.get("date_range"):
         self.start_date, self.end_date = parse_date_range(self.options["date_range"])
     if self.options.get("shop"):
         self.shop = Shop.objects.get(pk=self.options["shop"])
     else:
         self.shop = None
     self.rendered = False