diff --git a/media/img/login-background/autumn-bg.jpg b/media/img/login-background/autumn-bg.jpg new file mode 100644 index 00000000000..9a867b2de8f Binary files /dev/null and b/media/img/login-background/autumn-bg.jpg differ diff --git a/media/img/login-background/spring-bg.jpg b/media/img/login-background/spring-bg.jpg new file mode 100644 index 00000000000..910ff8102df Binary files /dev/null and b/media/img/login-background/spring-bg.jpg differ diff --git a/media/img/login-background/summer-bg.jpg b/media/img/login-background/summer-bg.jpg new file mode 100644 index 00000000000..ed9c04c0d2d Binary files /dev/null and b/media/img/login-background/summer-bg.jpg differ diff --git a/media/img/login-background/winter-bg.jpg b/media/img/login-background/winter-bg.jpg new file mode 100644 index 00000000000..57fda0bff56 Binary files /dev/null and b/media/img/login-background/winter-bg.jpg differ diff --git a/seahub/utils/auth.py b/seahub/utils/auth.py index b2940752f6a..742ca5f1860 100644 --- a/seahub/utils/auth.py +++ b/seahub/utils/auth.py @@ -1,6 +1,7 @@ import os from seahub.settings import LOGIN_BG_IMAGE_PATH, MEDIA_ROOT from seahub.utils import gen_token +from datetime import datetime VIRTUAL_ID_EMAIL_DOMAIN = '@auth.local' @@ -9,11 +10,29 @@ 'bearer' ] +MONTH_SEASON_MAP = { + 1: 'winter', + 2: 'winter', + 3: 'spring', + 4: 'spring', + 5: 'spring', + 6: 'summer', + 7: 'summer', + 8: 'summer', + 9: 'autumn', + 10: 'autumn', + 11: 'autumn', + 12: 'winter' +} def get_login_bg_image_path(): """ Return custom background image path if it exists, otherwise return default background image path. """ - login_bg_image_path = LOGIN_BG_IMAGE_PATH + current_month = datetime.today().month + login_bg_image_path = "img/login-background/%s-bg.jpg" % MONTH_SEASON_MAP.get(current_month) + if not os.path.exists(os.path.join(MEDIA_ROOT, login_bg_image_path)): + login_bg_image_path = LOGIN_BG_IMAGE_PATH + # get path that background image of login page custom_login_bg_image_path = get_custom_login_bg_image_path() if os.path.exists(os.path.join(MEDIA_ROOT, custom_login_bg_image_path)):