mirror of
https://github.com/pacnpal/thrillwiki_django_no_react.git
synced 2025-12-21 23:31:07 -05:00
initial geodjango implementation
This commit is contained in:
@@ -75,16 +75,19 @@ def upload_photo(request):
|
||||
{"error": "You do not have permission to upload photos"}, status=403
|
||||
)
|
||||
|
||||
# Determine if the photo should be auto-approved
|
||||
is_approved = request.user.is_superuser or request.user.is_staff or request.user.groups.filter(name='Moderators').exists()
|
||||
|
||||
# Create the photo
|
||||
photo = Photo.objects.create(
|
||||
image=request.FILES["image"],
|
||||
content_type=content_type,
|
||||
object_id=obj.id,
|
||||
uploaded_by=request.user, # Add the user who uploaded the photo
|
||||
# Set as primary if it's the first photo
|
||||
is_primary=not Photo.objects.filter(
|
||||
content_type=content_type, object_id=obj.id
|
||||
).exists(),
|
||||
is_approved=is_approved # Auto-approve if the user is a moderator, admin, or superuser
|
||||
)
|
||||
|
||||
return JsonResponse(
|
||||
@@ -93,6 +96,7 @@ def upload_photo(request):
|
||||
"url": photo.image.url,
|
||||
"caption": photo.caption,
|
||||
"is_primary": photo.is_primary,
|
||||
"is_approved": photo.is_approved,
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user