feat: add fily type and max user media uplod limits

This commit is contained in:
Markos Gogoulos
2025-08-19 11:35:49 +03:00
committed by GitHub
parent e9f862a0ff
commit 8cbeb72dd2
10 changed files with 98 additions and 27 deletions

View File

@@ -401,6 +401,32 @@ def clean_comment(raw_comment):
return cleaned_comment
def user_allowed_to_upload(request):
"""Any custom logic for whether a user is allowed
to upload content lives here
"""
if request.user.is_anonymous:
return False
if is_mediacms_editor(request.user):
return True
# Check if user has reached the maximum number of uploads
if hasattr(settings, 'NUMBER_OF_MEDIA_USER_CAN_UPLOAD'):
if models.Media.objects.filter(user=request.user).count() >= settings.NUMBER_OF_MEDIA_USER_CAN_UPLOAD:
return False
if settings.CAN_ADD_MEDIA == "all":
return True
elif settings.CAN_ADD_MEDIA == "email_verified":
if request.user.email_is_verified:
return True
elif settings.CAN_ADD_MEDIA == "advancedUser":
if request.user.advancedUser:
return True
return False
def kill_ffmpeg_process(filepath):
"""Kill ffmpeg process that is processing a specific file
@@ -606,3 +632,7 @@ def copy_media(media_id):
None
"""
pass
def is_media_allowed_type(media):
return media.media_type in settings.ALLOWED_MEDIA_UPLOAD_TYPES