-
Notifications
You must be signed in to change notification settings - Fork 2
feat: Map screenshots / images #29
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
Merged
Merged
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
cd7b0ee
feat: Map screenshots / images
alexlambson c56a030
- Add map image serializer
alexlambson 44db2f9
- Start work on reusable file upload view
alexlambson afa2e17
- oops forgot to commit these
alexlambson a567b9b
- fix logger type
alexlambson f6387a5
- fix crashing with postgres 18
alexlambson 69f0742
- tests for uploads
alexlambson b55faa6
- Test file type checks
alexlambson 114cac2
- verify file type earlier on
alexlambson 2102b74
- fix legacy uploads for system user validation
alexlambson 050e0ce
- fix docker for real
alexlambson 255d69f
- fix docker permissions. The custom user was causing issues
alexlambson e40e131
- test moderator notes
alexlambson 1e88aa2
- Make kirovy exception handler more generic
alexlambson 4b314ae
Adds a way to delete images
alexlambson 8bf1b21
- Push changes from last night. Just switch to image field.
alexlambson File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -15,11 +15,13 @@ http { | |
| alias /usr/share/nginx/html/static/; # The nginx container's mounted volume. | ||
| expires 30d; | ||
| add_header Cache-Control public; | ||
| include /etc/nginx/mime.types; | ||
|
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. needed to serve files |
||
| } | ||
|
|
||
| # Serve user uploaded files | ||
| location /silo/ { | ||
| alias /usr/share/nginx/html/silo/; # The container's mounted volume. | ||
| include /etc/nginx/mime.types; | ||
| } | ||
|
|
||
| # Proxy requests to the Django app running in gunicorn | ||
|
|
@@ -29,6 +31,7 @@ http { | |
| proxy_set_header X-Real-IP $remote_addr; | ||
| proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; | ||
| proxy_set_header X-Forwarded-Proto $scheme; | ||
| proxy_redirect off; | ||
| } | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,58 @@ | ||
| # API Errors in API class helpers | ||
|
|
||
| Returning errors in the helper functions of your API endpoint can be annoying. | ||
| To avoid that annoyance, just raise one of the [view exceptions](kirovy/exceptions/view_exceptions.py) | ||
| or write your own that subclasses `KirovyValidationError`. | ||
|
|
||
| **Example where you annoy yourself with bubbling returns:** | ||
|
|
||
| ```python | ||
| class MyView(APIView): | ||
| ... | ||
| def helper(self, request: KirovyRequest) -> MyObject | KirovyResponse: | ||
| object_id = request.data.get("id") | ||
| if not object_id: | ||
| return KirovyResponse( | ||
| status=status.HTTP_400_BAD_REQUEST, | ||
| data=ErrorResponseData( | ||
| message="Must specify id", | ||
| code=api_codes.FileUploadApiCodes.MISSING_FOREIGN_ID, | ||
| additional={"expected_field": "id"} | ||
| ) | ||
| ) | ||
|
|
||
| object = get_object_or_404(self.file_parent_class.objects, id=object_id) | ||
| self.check_object_permissions(request, object) | ||
|
|
||
| return object | ||
|
|
||
| def post(self, request: KirovyRequest, format=None) -> KirovyResponse: | ||
| object = self.helper(request) | ||
| if isinstance(object, KirovyResponse): | ||
| return object | ||
| ... | ||
| ``` | ||
|
|
||
| **Example where you just raise the exception:** | ||
|
|
||
| ```python | ||
| class MyView(APIView): | ||
| ... | ||
| def helper(self, request: KirovyRequest) -> MyObject: | ||
| object_id = request.data.get("id") | ||
| if not object_id: | ||
| raise KirovyValidationError( | ||
| detail="Must specify id", | ||
| code=api_codes.FileUploadApiCodes.MISSING_FOREIGN_ID, | ||
| additional={"expected_field": "id"} | ||
| ) | ||
|
|
||
| object = get_object_or_404(self.file_parent_class.objects, id=object_id) | ||
| self.check_object_permissions(request, object) | ||
|
|
||
| return object | ||
|
|
||
| def post(self, request: KirovyRequest, format=None) -> KirovyResponse: | ||
| object = self.helper(request) | ||
| ... | ||
| ``` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was causing issues on machines where the user ID of the host didn't match