Skip to content

Commit

Permalink
Minor formatting and removing unneeded file
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewtavis committed Mar 2, 2025
1 parent c36a575 commit 10b552f
Show file tree
Hide file tree
Showing 8 changed files with 16 additions and 42 deletions.
11 changes: 0 additions & 11 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,6 @@
],
"eslint.useFlatConfig": true,
"typescript.tsdk": "./frontend/node_modules/typescript/lib",
"cSpell.words": [
"headlessui",
"Nuxt",
"organizationimage",
"viewsets",
"vuedraggable",
"vueuse"
],
// This gets rid of 'Unknown at-rule @apply' messages in VSCode 'Problems' tab. First noticed in MediaImageCarousel.vue.
// Look at tailwind.json for more info.
// https://github.com/tailwindlabs/tailwindcss/discussions/5258#discussioncomment-1979394
"css.customData": [
".vscode/tailwind.json"
],
Expand Down
2 changes: 1 addition & 1 deletion .vscode/tailwind.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,4 @@
]
}
]
}
}
14 changes: 0 additions & 14 deletions backend/communities/organizations/urls.py

This file was deleted.

6 changes: 3 additions & 3 deletions backend/communities/organizations/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -200,8 +200,8 @@ class OrganizationImageViewSet(viewsets.ModelViewSet[Image]):
serializer_class = ImageSerializer

def list(self, request: Request, org_id: UUID) -> Response:
images = self.queryset.filter(
organizationimage__org_id=org_id
).order_by('organizationimage__sequence_index')
images = self.queryset.filter(organizationimage__org_id=org_id).order_by(
"organizationimage__sequence_index"
)
serializer = self.get_serializer(images, many=True)
return Response(serializer.data)
16 changes: 7 additions & 9 deletions backend/content/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,25 +41,22 @@ class Meta:
read_only_fields = ["id", "creation_date"]

def validate(self, data: Dict[str, Union[str, int]]) -> Dict[str, Union[str, int]]:
# Remove string validation since we're getting a file object
# Remove string validation since we're getting a file object.
if "file_object" not in data:
raise serializers.ValidationError("No file was submitted.")

return data

# Using 'Any' type until a more correct type is determined.
def create(self, validated_data: Dict[str, Any]) -> Image:
# Handle file upload properly
file_obj = self.context["request"].FILES.get("file_object")
if file_obj:
if file_obj := self.context["request"].FILES.get("file_object"):
validated_data["file_object"] = file_obj

# Create the image first
# Create the image first.
image = super().create(validated_data)

# Get the organization from the request
organization_id = self.context["request"].data.get("organization_id")
if organization_id:
# Create OrganizationImage with next sequence index
if organization_id := self.context["request"].data.get("organization_id"):
# Create OrganizationImage with next sequence index.
from communities.organizations.models import OrganizationImage

next_index = OrganizationImage.objects.filter(
Expand All @@ -68,6 +65,7 @@ def create(self, validated_data: Dict[str, Any]) -> Image:
OrganizationImage.objects.create(
org_id=organization_id, image=image, sequence_index=next_index
)

return image


Expand Down
4 changes: 3 additions & 1 deletion backend/content/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -312,9 +312,11 @@ class ImageViewSet(viewsets.ModelViewSet[Image]):
def create(self, request: Request, *args: Any, **kwargs: Any) -> Response:
serializer = self.get_serializer(
data=request.data,
context={"request": request}, # Pass request to serializer
context={"request": request}, # pass request to serializer
)
if serializer.is_valid():
serializer.save()

return Response(serializer.data, status=status.HTTP_201_CREATED)

return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST)
1 change: 0 additions & 1 deletion backend/core/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,6 @@
STATIC_ROOT = BASE_DIR / "static/"
STATIC_URL = "static/"

# After STATIC_URL setting
MEDIA_ROOT = BASE_DIR / "media"
MEDIA_URL = "/media/"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
</swiper-container>
<p
v-if="uploadError"
class="absolute bottom-2 right-12 z-10 rounded bg-white/80 p-1 text-sm text-action-red dark:bg-black/80"
class="absolute bottom-2 right-12 z-10 rounded bg-layer-0/80 p-1 text-sm text-action-red"
>
{{ $t(i18nMap.components.media_image_carousel.upload_error) }}
</p>
Expand All @@ -49,8 +49,8 @@

<script setup lang="ts">
import { register } from "swiper/element/bundle";
import { IconMap } from "~/types/icon-map";
import { useModalHandlers } from "~/composables/useModalHandlers";
import { IconMap } from "~/types/icon-map";

const props = defineProps({
fullscreen: Boolean,
Expand Down

0 comments on commit 10b552f

Please sign in to comment.