mirror of
https://github.com/mediacms-io/mediacms.git
synced 2025-11-22 06:17:58 -05:00
feat: add fily type and max user media uplod limits
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user