Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement Image Gallery Functionality & Endpoints #3312

Merged
merged 2 commits into from Aug 31, 2023

Conversation

jonasdeluna
Copy link
Member

Implement imagegallery endpoints

@codecov
Copy link

codecov bot commented Apr 18, 2023

Codecov Report

Patch coverage: 94.39% and project coverage change: +0.02% 🎉

Comparison is base (f3ada16) 88.16% compared to head (8379438) 88.19%.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #3312      +/-   ##
==========================================
+ Coverage   88.16%   88.19%   +0.02%     
==========================================
  Files         664      665       +1     
  Lines       20946    21049     +103     
==========================================
+ Hits        18467    18564      +97     
- Misses       2479     2485       +6     
Files Changed Coverage Δ
lego/apps/events/views.py 82.93% <44.44%> (-1.22%) ⬇️
lego/apps/files/views.py 85.71% <92.85%> (+2.95%) ⬆️
lego/api/v1.py 100.00% <100.00%> (ø)
lego/apps/events/serializers/events.py 96.92% <100.00%> (+0.09%) ⬆️
...go/apps/files/migrations/0005_file_save_for_use.py 100.00% <100.00%> (ø)
lego/apps/files/models.py 82.81% <100.00%> (+0.27%) ⬆️
lego/apps/files/serializers.py 100.00% <100.00%> (ø)
lego/apps/files/tests/test_api.py 97.80% <100.00%> (+3.51%) ⬆️

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@jonasdeluna jonasdeluna changed the title Imagegallery newer Implement Image Gallery Functionality & Endpoints Apr 25, 2023
@jonasdeluna jonasdeluna added review-needed Pull requests that need review new-feature Pull requests that introduce or issues that suggest a new feature labels Apr 25, 2023
Copy link
Member

@LudvigHz LudvigHz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Super nice. this looks very good. Just some questions that need addressing and some discussions to be had :)

Also, the naming could be better IMO 😬. (ImageGallery is very vague, and something like CoverImageGallery for the endpoint makes more sense)

lego/apps/events/serializers/events.py Show resolved Hide resolved
lego/apps/events/views.py Show resolved Hide resolved
lego/apps/files/serializers.py Outdated Show resolved Hide resolved
lego/apps/files/views.py Outdated Show resolved Hide resolved
start.sh Outdated Show resolved Hide resolved
lego/apps/files/serializers.py Outdated Show resolved Hide resolved
lego/apps/files/views.py Outdated Show resolved Hide resolved
lego/apps/events/constants.py Outdated Show resolved Hide resolved
@ivarnakken ivarnakken added the changes-requested Pull requests with requested changes label Apr 29, 2023
@jonasdeluna jonasdeluna force-pushed the imagegallery-newer branch 3 times, most recently from 06fb210 to ddb60de Compare May 2, 2023 19:18
@jonasdeluna jonasdeluna requested a review from LudvigHz May 3, 2023 11:16
Copy link
Member

@LudvigHz LudvigHz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Still some permission stuff missing, but then this should be good to go!

Would also be nice if you could add some tests for the endpoints you created here :)
(check different perms, and that the response is correct in each case)

lego/apps/files/views.py Outdated Show resolved Hide resolved
Copy link
Member

@LudvigHz LudvigHz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome with the tests!

Just a few comments to clean things up and this should be good to go :)

lego/apps/files/views.py Outdated Show resolved Hide resolved
lego/apps/files/views.py Outdated Show resolved Hide resolved
lego/apps/files/tests/test_api.py Outdated Show resolved Hide resolved
lego/apps/files/tests/test_api.py Outdated Show resolved Hide resolved
Copy link
Member

@LudvigHz LudvigHz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome!

if self.instance.token != data["token"]:
raise PermissionDenied()
if "save_for_use" not in data:
raise ValidationError()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would be nice to include an error message. but not critical

Comment on lines +62 to +66
if serializer.is_valid(raise_exception=True):
serializer.save()
return Response(data=serializer.data, status=status.HTTP_200_OK)
else:
return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since you have raise_exception in is_valid(), you won't execute the code path in the else block no?

Not an issue though :)

return reverse("api:v1:files-imagegallery", kwargs={"key": key})


class SetSaveForUserTest(BaseAPITestCase):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a super clean and thorough test! Love it!! 💯

@LudvigHz LudvigHz added approved Pull requests that have been approved changes-requested Pull requests with requested changes and removed changes-requested Pull requests with requested changes labels Jul 27, 2023
@jonasdeluna jonasdeluna merged commit ebc60f3 into master Aug 31, 2023
3 checks passed
@jonasdeluna jonasdeluna deleted the imagegallery-newer branch August 31, 2023 20:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Pull requests that have been approved changes-requested Pull requests with requested changes new-feature Pull requests that introduce or issues that suggest a new feature review-needed Pull requests that need review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants