mirror of
https://github.com/mediacms-io/mediacms.git
synced 2025-07-23 00:28:04 +00:00
push
This commit is contained in:
@ -68,14 +68,19 @@ class MediaMetadataForm(forms.ModelForm):
|
||||
self.helper.form_method = 'post'
|
||||
self.helper.form_enctype = "multipart/form-data"
|
||||
self.helper.form_show_errors = False
|
||||
self.helper.layout = Layout(
|
||||
|
||||
layout_fields = [
|
||||
CustomField('title'),
|
||||
CustomField('new_tags'),
|
||||
CustomField('add_date'),
|
||||
CustomField('description'),
|
||||
CustomField('uploaded_poster'),
|
||||
CustomField('enable_comments'),
|
||||
)
|
||||
]
|
||||
if self.instance.media_type != "image":
|
||||
layout_fields.append(CustomField('uploaded_poster'))
|
||||
|
||||
self.helper.layout = Layout(*layout_fields)
|
||||
|
||||
|
||||
if self.instance.media_type == "video":
|
||||
self.helper.layout.append(CustomField('thumbnail_time'))
|
||||
|
@ -14,6 +14,7 @@ from rest_framework.parsers import (
|
||||
JSONParser,
|
||||
MultiPartParser,
|
||||
)
|
||||
|
||||
from rest_framework.response import Response
|
||||
from rest_framework.settings import api_settings
|
||||
from rest_framework.views import APIView
|
||||
@ -175,7 +176,7 @@ class MediaBulkUserActions(APIView):
|
||||
|
||||
@swagger_auto_schema(
|
||||
manual_parameters=[
|
||||
openapi.Parameter(name='media_ids', in_=openapi.IN_FORM, type=openapi.TYPE_ARRAY, items=openapi.Items(type=openapi.TYPE_INTEGER), required=True, description="List of media IDs"),
|
||||
openapi.Parameter(name='media_ids', in_=openapi.IN_FORM, type=openapi.TYPE_ARRAY, items=openapi.Items(type=openapi.TYPE_STRING), required=True, description="List of media IDs"),
|
||||
openapi.Parameter(
|
||||
name='action',
|
||||
in_=openapi.IN_FORM,
|
||||
@ -234,7 +235,7 @@ class MediaBulkUserActions(APIView):
|
||||
return Response({"detail": "action is required"}, status=status.HTTP_400_BAD_REQUEST)
|
||||
|
||||
# Get media objects owned by the user
|
||||
media = Media.objects.filter(user=request.user, id__in=media_ids)
|
||||
media = Media.objects.filter(user=request.user, friendly_token__in=media_ids)
|
||||
|
||||
if not media:
|
||||
return Response({"detail": "No matching media found"}, status=status.HTTP_400_BAD_REQUEST)
|
||||
|
@ -1,6 +1,7 @@
|
||||
from django.conf import settings
|
||||
from django.contrib.auth.decorators import login_required
|
||||
from django.core.mail import EmailMessage
|
||||
from django.db.models import Q
|
||||
from django.http import HttpResponseRedirect
|
||||
from django.shortcuts import render
|
||||
from drf_yasg import openapi as openapi
|
||||
@ -193,6 +194,7 @@ class UserList(APIView):
|
||||
@swagger_auto_schema(
|
||||
manual_parameters=[
|
||||
openapi.Parameter(name='page', type=openapi.TYPE_INTEGER, in_=openapi.IN_QUERY, description='Page number'),
|
||||
openapi.Parameter(name='name', type=openapi.TYPE_STRING, in_=openapi.IN_QUERY, description='Search by name or username'),
|
||||
],
|
||||
tags=['Users'],
|
||||
operation_summary='List users',
|
||||
@ -202,9 +204,12 @@ class UserList(APIView):
|
||||
pagination_class = api_settings.DEFAULT_PAGINATION_CLASS
|
||||
paginator = pagination_class()
|
||||
users = User.objects.filter()
|
||||
location = request.GET.get("location", "").strip()
|
||||
if location:
|
||||
users = users.filter(location=location)
|
||||
|
||||
name = request.GET.get("name", "").strip()
|
||||
if name:
|
||||
users = users.filter(
|
||||
Q(name__icontains=name) | Q(username__icontains=name)
|
||||
)
|
||||
|
||||
page = paginator.paginate_queryset(users, request)
|
||||
|
||||
|
Reference in New Issue
Block a user