mirror of
https://github.com/pretix/pretix.git
synced 2026-05-08 15:44:02 +00:00
Simplify SettingsProxy._unserialize
This commit is contained in:
@@ -46,10 +46,8 @@ class SettingsProxy:
|
|||||||
return value
|
return value
|
||||||
elif value is None:
|
elif value is None:
|
||||||
return None
|
return None
|
||||||
elif as_type == int:
|
elif as_type == int or as_type == float or as_type == decimal.Decimal:
|
||||||
return int(value)
|
return as_type(value)
|
||||||
elif as_type == float:
|
|
||||||
return float(value)
|
|
||||||
elif as_type == dict or as_type == list:
|
elif as_type == dict or as_type == list:
|
||||||
return json.loads(value)
|
return json.loads(value)
|
||||||
elif as_type == bool:
|
elif as_type == bool:
|
||||||
@@ -60,8 +58,6 @@ class SettingsProxy:
|
|||||||
return dateutil.parser.parse(value).date()
|
return dateutil.parser.parse(value).date()
|
||||||
elif as_type == time:
|
elif as_type == time:
|
||||||
return dateutil.parser.parse(value).time()
|
return dateutil.parser.parse(value).time()
|
||||||
elif as_type == decimal.Decimal:
|
|
||||||
return decimal.Decimal(value)
|
|
||||||
elif issubclass(as_type, Versionable):
|
elif issubclass(as_type, Versionable):
|
||||||
return as_type.objects.current.get(identity=value)
|
return as_type.objects.current.get(identity=value)
|
||||||
elif issubclass(as_type, Model):
|
elif issubclass(as_type, Model):
|
||||||
|
|||||||
Reference in New Issue
Block a user