diff --git a/src/bepasty/config.py b/src/bepasty/config.py index 2bd8c42..5ef441d 100644 --- a/src/bepasty/config.py +++ b/src/bepasty/config.py @@ -87,6 +87,12 @@ class Config: #: Filesystem storage path STORAGE_FILESYSTEM_DIRECTORY = '/tmp/' + #: Default lifetime for uploads + #: Supported units: + #: 'MINUTES', 'HOURS', 'DAYS', 'WEEKS', 'MONTHS', 'YEARS', 'FOREVER' + DEFAULT_MAXLIFE_VALUE = 1 + DEFAULT_MAXLIFE_UNIT = 'MONTHS' + #: server secret key needed for safe session cookies. #: you must set a very long, very random, very secret string here, #: otherwise bepasty will not work (and crash when trying to log in)! diff --git a/src/bepasty/utils/date_funcs.py b/src/bepasty/utils/date_funcs.py index 4577389..af925da 100644 --- a/src/bepasty/utils/date_funcs.py +++ b/src/bepasty/utils/date_funcs.py @@ -7,9 +7,14 @@ def get_maxlife(data, underscore): unit_key = 'maxlife_unit' if underscore else 'maxlife-unit' - unit_default = 'MONTHS' + unit_default = current_app.config['DEFAULT_MAXLIFE_UNIT'] + if unit_default == None: + unit_default = 'MONTHS' unit = data.get(unit_key, unit_default).upper() value_key = 'maxlife_value' if underscore else 'maxlife-value' + value_default = current_app.config['DEFAULT_MAXLIFE_VALUE'] + if value_default == None: + value_default = 'MONTHS' value_default = '1' try: value = int(data.get(value_key, value_default))