From 993318734e739c060144ec693c6c9b6c7c40a7a9 Mon Sep 17 00:00:00 2001 From: hugsy Date: Mon, 3 Jul 2023 16:59:57 -0700 Subject: [PATCH 1/2] using storage for Team model too --- ctfhub/models.py | 10 ++++++++-- ctfhub_project/settings.py | 10 +--------- 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/ctfhub/models.py b/ctfhub/models.py index 0c76954..1d23a31 100644 --- a/ctfhub/models.py +++ b/ctfhub/models.py @@ -51,7 +51,6 @@ EXCALIDRAW_ROOM_ID_REGEX, EXCALIDRAW_ROOM_KEY_REGEX, EXCALIDRAW_URL, - HEDGEDOC_URL, IMAGE_URL, JITSI_URL, USERS_FILE_PATH, @@ -86,7 +85,14 @@ class Team(TimeStampedModel): youtube_url = models.URLField(blank=True) blog_url = models.URLField(blank=True) api_key = models.CharField(max_length=128, default=get_random_string_128) - avatar = models.ImageField(blank=True, upload_to=USERS_FILE_PATH) + avatar = models.ImageField( + null=True, + upload_to=USERS_FILE_PATH, + storage=get_named_storage("MEDIA"), + validators=[ + challenge_file_max_size_validator, + ], + ) ctftime_id = models.IntegerField(default=0, blank=True, null=True) # diff --git a/ctfhub_project/settings.py b/ctfhub_project/settings.py index 6bd3036..ac421d0 100644 --- a/ctfhub_project/settings.py +++ b/ctfhub_project/settings.py @@ -131,18 +131,10 @@ def get_boolean(key: str) -> bool: }, ] - -# Internationalization -# https://docs.djangoproject.com/en/3.1/topics/i18n/ - LANGUAGE_CODE = "en-us" TIME_ZONE = "UTC" USE_I18N = True -USE_TZ = True - - -# Static files (CSS, JavaScript, Images) -# https://docs.djangoproject.com/en/3.1/howto/static-files/ +USE_TZ = False STATIC_URL = "/static/" STATICFILES_DIRS = [ From 073430cf9c6dc1d5f64cce1bf687d66c6abff459 Mon Sep 17 00:00:00 2001 From: crazy hugsy Date: Mon, 3 Jul 2023 19:42:45 -0700 Subject: [PATCH 2/2] Team avatar can be blank --- ctfhub/models.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ctfhub/models.py b/ctfhub/models.py index 1d23a31..b70fad1 100644 --- a/ctfhub/models.py +++ b/ctfhub/models.py @@ -86,7 +86,7 @@ class Team(TimeStampedModel): blog_url = models.URLField(blank=True) api_key = models.CharField(max_length=128, default=get_random_string_128) avatar = models.ImageField( - null=True, + blank=True, upload_to=USERS_FILE_PATH, storage=get_named_storage("MEDIA"), validators=[