mirror of
https://github.com/pacnpal/thrillwiki_django_no_react.git
synced 2025-12-22 22:51:09 -05:00
feat: Refactor rides app with unique constraints, mixins, and enhanced documentation
- Added migration to convert unique_together constraints to UniqueConstraint for RideModel. - Introduced RideFormMixin for handling entity suggestions in ride forms. - Created comprehensive code standards documentation outlining formatting, docstring requirements, complexity guidelines, and testing requirements. - Established error handling guidelines with a structured exception hierarchy and best practices for API and view error handling. - Documented view pattern guidelines, emphasizing the use of CBVs, FBVs, and ViewSets with examples. - Implemented a benchmarking script for query performance analysis and optimization. - Developed security documentation detailing measures, configurations, and a security checklist. - Compiled a database optimization guide covering indexing strategies, query optimization patterns, and computed fields.
This commit is contained in:
@@ -1,10 +1,11 @@
|
||||
{% load widget_tweaks %}
|
||||
{% load widget_tweaks safe_html %}
|
||||
{# Security: Icon SVGs are sanitized to prevent XSS. Only trusted SVG elements are allowed. #}
|
||||
|
||||
{% if type == 'button' or type == 'submit' or type == 'reset' %}
|
||||
<button
|
||||
<button
|
||||
type="{{ type|default:'button' }}"
|
||||
{% if id %}id="{{ id }}"{% endif %}
|
||||
class="inline-flex items-center justify-center rounded-md text-sm font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50
|
||||
class="inline-flex items-center justify-center rounded-md text-sm font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50
|
||||
{% if variant == 'destructive' %}bg-destructive text-destructive-foreground hover:bg-destructive/90
|
||||
{% elif variant == 'outline' %}border border-input bg-background hover:bg-accent hover:text-accent-foreground
|
||||
{% elif variant == 'secondary' %}bg-secondary text-secondary-foreground hover:bg-secondary/80
|
||||
@@ -26,7 +27,7 @@
|
||||
{% if x_data %}x-data="{{ x_data }}"{% endif %}
|
||||
{% if x_on_click %}@click="{{ x_on_click }}"{% endif %}>
|
||||
{% if icon %}
|
||||
{{ icon|safe }}
|
||||
{{ icon|sanitize_svg }}
|
||||
{% if label %}<span class="ml-2">{{ label }}</span>{% endif %}
|
||||
{% else %}
|
||||
{{ label|default:content }}
|
||||
@@ -34,9 +35,9 @@
|
||||
{% block button_content %}{% endblock %}
|
||||
</button>
|
||||
{% else %}
|
||||
<a
|
||||
<a
|
||||
href="{{ href }}"
|
||||
class="inline-flex items-center justify-center rounded-md text-sm font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50
|
||||
class="inline-flex items-center justify-center rounded-md text-sm font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50
|
||||
{% if variant == 'destructive' %}bg-destructive text-destructive-foreground hover:bg-destructive/90
|
||||
{% elif variant == 'outline' %}border border-input bg-background hover:bg-accent hover:text-accent-foreground
|
||||
{% elif variant == 'secondary' %}bg-secondary text-secondary-foreground hover:bg-secondary/80
|
||||
@@ -51,7 +52,7 @@
|
||||
{% if x_data %}x-data="{{ x_data }}"{% endif %}
|
||||
{% if x_on_click %}@click="{{ x_on_click }}"{% endif %}>
|
||||
{% if icon %}
|
||||
{{ icon|safe }}
|
||||
{{ icon|sanitize_svg }}
|
||||
{% if label %}<span class="ml-2">{{ label }}</span>{% endif %}
|
||||
{% else %}
|
||||
{{ label|default:content }}
|
||||
|
||||
@@ -1,3 +1,6 @@
|
||||
{% load safe_html %}
|
||||
{# Security: Header, content, and footer are sanitized to prevent XSS. #}
|
||||
|
||||
<div class="border rounded-lg shadow-sm bg-card text-card-foreground">
|
||||
{% if header or title %}
|
||||
<div class="flex flex-col space-y-1.5 p-6">
|
||||
@@ -8,19 +11,19 @@
|
||||
<p class="text-sm text-muted-foreground">{{ description }}</p>
|
||||
{% endif %}
|
||||
{% if header %}
|
||||
{{ header|safe }}
|
||||
{{ header|sanitize }}
|
||||
{% endif %}
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
|
||||
<div class="p-6 pt-0">
|
||||
{{ content|safe }}
|
||||
{{ content|sanitize }}
|
||||
{% block card_content %}{% endblock %}
|
||||
</div>
|
||||
|
||||
|
||||
{% if footer %}
|
||||
<div class="flex items-center p-6 pt-0">
|
||||
{{ footer|safe }}
|
||||
{{ footer|sanitize }}
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
|
||||
@@ -1,3 +1,6 @@
|
||||
{% load safe_html %}
|
||||
{# Security: Dialog content and footer are sanitized to prevent XSS. #}
|
||||
|
||||
<div class="fixed inset-0 z-50 flex items-start justify-center sm:items-center"
|
||||
role="dialog"
|
||||
aria-modal="true"
|
||||
@@ -9,42 +12,42 @@
|
||||
x-transition:leave="transition ease-in duration-100"
|
||||
x-transition:leave-start="opacity-100"
|
||||
x-transition:leave-end="opacity-0">
|
||||
|
||||
|
||||
<!-- Backdrop -->
|
||||
<div class="fixed inset-0 transition-all bg-background/80 backdrop-blur-sm"
|
||||
<div class="fixed inset-0 transition-all bg-background/80 backdrop-blur-sm"
|
||||
@click="open = false; setTimeout(() => $el.closest('[hx-history-elt]').innerHTML = '', 200)"></div>
|
||||
|
||||
|
||||
<!-- Dialog Panel -->
|
||||
<div class="fixed z-50 grid w-full gap-4 p-6 duration-200 border shadow-lg bg-background sm:max-w-lg sm:rounded-lg"
|
||||
x-show="open"
|
||||
x-transition:enter="animate-in fade-in-0 zoom-in-95 slide-in-from-left-1/2 slide-in-from-top-[48%]"
|
||||
x-transition:leave="animate-out fade-out-0 zoom-out-95 slide-out-to-left-1/2 slide-out-to-top-[48%]">
|
||||
|
||||
|
||||
<div class="flex flex-col space-y-1.5 text-center sm:text-left">
|
||||
{% if title %}
|
||||
<h2 class="text-lg font-semibold leading-none tracking-tight">
|
||||
{{ title }}
|
||||
</h2>
|
||||
{% endif %}
|
||||
|
||||
|
||||
{% if description %}
|
||||
<p class="text-sm text-muted-foreground">
|
||||
{{ description }}
|
||||
</p>
|
||||
{% endif %}
|
||||
</div>
|
||||
|
||||
|
||||
<div class="py-4">
|
||||
{{ content|safe }}
|
||||
{{ content|sanitize }}
|
||||
{% block dialog_content %}{% endblock %}
|
||||
</div>
|
||||
|
||||
|
||||
{% if footer %}
|
||||
<div class="flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2">
|
||||
{{ footer|safe }}
|
||||
{{ footer|sanitize }}
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
|
||||
<!-- Close Button -->
|
||||
<button class="absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground"
|
||||
@click="open = false">
|
||||
|
||||
@@ -1,12 +1,15 @@
|
||||
{% load safe_html %}
|
||||
{# Security: Trigger and content are sanitized to allow only safe HTML elements. #}
|
||||
|
||||
<div class="relative inline-block text-left" x-data="{ open: false }" @click.away="open = false">
|
||||
<div @click="open = !open">
|
||||
{% if trigger %}
|
||||
{{ trigger|safe }}
|
||||
{{ trigger|sanitize }}
|
||||
{% else %}
|
||||
<button type="button"
|
||||
class="inline-flex w-full justify-center gap-x-1.5 rounded-md bg-white px-3 py-2 text-sm font-semibold text-gray-900 shadow-sm ring-1 ring-inset ring-gray-300 hover:bg-gray-50"
|
||||
id="menu-button"
|
||||
aria-expanded="true"
|
||||
<button type="button"
|
||||
class="inline-flex w-full justify-center gap-x-1.5 rounded-md bg-white px-3 py-2 text-sm font-semibold text-gray-900 shadow-sm ring-1 ring-inset ring-gray-300 hover:bg-gray-50"
|
||||
id="menu-button"
|
||||
aria-expanded="true"
|
||||
aria-haspopup="true">
|
||||
{{ label|default:"Options" }}
|
||||
<svg class="w-5 h-5 -mr-1 text-gray-400" viewBox="0 0 20 20" fill="currentColor" aria-hidden="true">
|
||||
@@ -29,7 +32,7 @@
|
||||
aria-labelledby="menu-button"
|
||||
tabindex="-1">
|
||||
<div class="py-1" role="none">
|
||||
{{ content|safe }}
|
||||
{{ content|sanitize }}
|
||||
{% block dropdown_content %}{% endblock %}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user