-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix routing logic to how 404 instead of 403 on bad urls
- Refactor routing to separate recipe and handle routes from static file serving. - Enhance the `RecipePageNotFound` exception to use HTTP 404 status code. - Update `serve_static_file` function to improve handling of paths without extensions. - Ensure static files are served when 404 or 405 exceptions occur instead of a catch-all route - Improve error handling in URL shortener to raise `HTTPException` instead of returning a response. - Extend `HandleAdmin` to include user search fields, read-only fields, and list filters.
- Loading branch information
Showing
5 changed files
with
54 additions
and
46 deletions.
There are no files selected for viewing
This file contains 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 |
---|---|---|
@@ -1,8 +1,17 @@ | ||
from django.contrib import admin | ||
|
||
from app_users.admin import AppUserAdmin | ||
from .models import Handle | ||
|
||
|
||
@admin.register(Handle) | ||
class HandleAdmin(admin.ModelAdmin): | ||
search_fields = ["name", "redirect_url"] | ||
search_fields = ["name", "redirect_url"] + [ | ||
f"user__{field}" for field in AppUserAdmin.search_fields | ||
] | ||
readonly_fields = ["user", "created_at", "updated_at"] | ||
|
||
list_filter = [ | ||
("user", admin.EmptyFieldListFilter), | ||
("redirect_url", admin.EmptyFieldListFilter), | ||
] |
This file contains 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 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 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 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