Fix failing tests

This commit is contained in:
Raphael Michel
2021-04-23 15:30:02 +02:00
parent 96e31c15e6
commit 8e05d52f42
2 changed files with 6 additions and 3 deletions

View File

@@ -39,8 +39,10 @@ from collections import OrderedDict, namedtuple
from decimal import Decimal from decimal import Decimal
from typing import Tuple from typing import Tuple
import pytz
from defusedcsv import csv from defusedcsv import csv
from django import forms from django import forms
from django.conf import settings
from django.db.models import QuerySet from django.db.models import QuerySet
from django.utils.formats import localize from django.utils.formats import localize
from django.utils.translation import gettext, gettext_lazy as _ from django.utils.translation import gettext, gettext_lazy as _
@@ -72,7 +74,8 @@ class BaseExporter:
if isinstance(event, QuerySet): if isinstance(event, QuerySet):
self.events = event self.events = event
self.event = None self.event = None
self.timezone = self.events.first().timezone e = self.events.first()
self.timezone = e.timezone if e else pytz.timezone(settings.TIME_ZONE)
else: else:
self.events = Event.objects.filter(pk=event.pk) self.events = Event.objects.filter(pk=event.pk)
self.timezone = event.timezone self.timezone = event.timezone

View File

@@ -197,7 +197,7 @@ class CheckinList(LoggedModel):
'product', 'variation', 'now', 'entries_number', 'entries_today', 'entries_days' 'product', 'variation', 'now', 'entries_number', 'entries_today', 'entries_days'
} }
if not rules or not isinstance(rules, dict): if not rules or not isinstance(rules, dict):
return return rules
if len(rules) > 1: if len(rules) > 1:
raise ValidationError(f'Rules should not include dictionaries with more than one key, found: "{rules}".') raise ValidationError(f'Rules should not include dictionaries with more than one key, found: "{rules}".')
@@ -217,7 +217,7 @@ class CheckinList(LoggedModel):
if operator == 'var': if operator == 'var':
if values[0] not in allowed_vars: if values[0] not in allowed_vars:
raise ValidationError(f'Logic variable "{values[0]}" is currently not allowed.') raise ValidationError(f'Logic variable "{values[0]}" is currently not allowed.')
return return rules
if operator in ('or', 'and') and seen_nonbool: if operator in ('or', 'and') and seen_nonbool:
raise ValidationError(f'You cannot use OR/AND logic on a level below a comparison operator.') raise ValidationError(f'You cannot use OR/AND logic on a level below a comparison operator.')