-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: display errors * feat: display and auto invisible errors * test: coverage more code * test: coverage more code
- Loading branch information
Showing
12 changed files
with
287 additions
and
53 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,4 +1,4 @@ | ||
Django | ||
Django>=4.2 | ||
djangorestframework | ||
django-cors-headers | ||
django-filter | ||
|
36 changes: 36 additions & 0 deletions
36
task/migrations/0011_alter_task_shared_id_alter_task_shared_link_and_more.py
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 |
---|---|---|
@@ -0,0 +1,36 @@ | ||
# Generated by Django 4.1.7 on 2023-07-23 17:27 | ||
from django.db import migrations | ||
from django.db import models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
("task", "0010_alter_task_full_download_now"), | ||
] | ||
|
||
operations = [ | ||
migrations.AlterField( | ||
model_name="task", | ||
name="shared_id", | ||
field=models.CharField(blank=True, default="", max_length=50), | ||
), | ||
migrations.AlterField( | ||
model_name="task", | ||
name="shared_link", | ||
field=models.CharField( | ||
help_text="Link, with or without password", | ||
max_length=100, | ||
), | ||
), | ||
migrations.AlterField( | ||
model_name="task", | ||
name="shared_password", | ||
field=models.CharField( | ||
blank=True, | ||
help_text="Password, if not included in the shared link", | ||
max_length=4, | ||
null=True, | ||
), | ||
), | ||
] |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,33 @@ | ||
from django import forms | ||
|
||
from task.models import Task | ||
from task.utils import parse_shared_link | ||
|
||
|
||
class TaskForm(forms.ModelForm): | ||
class NewTaskForm(forms.ModelForm): | ||
class Meta: | ||
model = Task | ||
fields = ["shared_link", "shared_password", "full_download_now"] | ||
fields = ["shared_link", "shared_id", "shared_password", "full_download_now"] | ||
widgets = { | ||
"shared_link": forms.TextInput(attrs={"class": "form-control"}), | ||
"shared_password": forms.TextInput(attrs={"class": "form-control"}), | ||
"shared_link": forms.TextInput( | ||
attrs={"class": "input input-bordered w-full max-w-xxs"}, | ||
), | ||
"shared_password": forms.TextInput( | ||
attrs={"class": "input input-bordered w-full max-w-xxs"}, | ||
), | ||
"full_download_now": forms.TextInput(attrs={"class": "form-control"}), | ||
} | ||
|
||
def clean(self): | ||
cleaned_data = super().clean() | ||
shared_link = cleaned_data.get("shared_link") | ||
if not shared_link: | ||
return cleaned_data | ||
try: | ||
link = parse_shared_link(shared_link) | ||
except ValueError as e: | ||
self.add_error("shared_link", str(e)) | ||
return cleaned_data | ||
cleaned_data["shared_id"] = link["id"] | ||
if not cleaned_data["shared_password"] and link["password"]: | ||
cleaned_data["shared_password"] = link["password"] |
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 |
---|---|---|
|
@@ -7,14 +7,19 @@ | |
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.3/css/all.min.css" integrity="sha384-zMEydMdp5mC+i11DwQRMHxzvFhmCbjZtR+KrIUQRc1uJJCq7NTXDSHVLozUvqPEB" crossorigin="anonymous"> | ||
<script src="https://cdn.tailwindcss.com"></script> | ||
{% load static %} | ||
<script src="{% static 'js/htmx/htmx.min.js' %}" defer></script> | ||
<script src="{% static 'js/htmx/debug.js' %}" defer></script> | ||
{% comment %} | ||
<script src="{% static 'js/htmx/htmx.min.js' %}" defer></script> | ||
<script src="{% static 'js/htmx/debug.js' %}" defer></script> | ||
{% endcomment %} | ||
<script src="https://unpkg.com/htmx.org"></script> | ||
<script src="https://unpkg.com/htmx.org/dist/ext/debug.js"></script> | ||
<script src="https://unpkg.com/htmx.org/dist/ext/response-targets.js"></script> | ||
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/full.css" rel="stylesheet" type="text/css" /> | ||
<script src="https://cdn.tailwindcss.com"></script> | ||
</head> | ||
|
||
<body class="bg-gray-100 dark:bg-black dark:text-gray-500"> | ||
<div class="container mx-auto p-4"> | ||
<body hx-ext="debug" class="bg-gray-100 dark:bg-black dark:text-gray-500"> | ||
<div hx-ext="response-targets" class="container mx-auto p-4"> | ||
<!-- content area --> | ||
{% block content %}{% endblock %} | ||
</div> | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<div class="toast toast-top toast-center" | ||
hx-get="{% url 'nothing' %}" | ||
hx-trigger="load delay:5s" | ||
hx-swap="outerHTML" | ||
> | ||
{% if form.non_field_errors %} | ||
<div class="alert alert-error"> | ||
{{ form.non_field_errors }} | ||
</div> | ||
{% endif %} | ||
{% for error in form.shared_link.errors %} | ||
<div class="alert alert-error"> | ||
{{ error|escape }} | ||
</div> | ||
{% endfor %} | ||
{% for error in form.shared_password.errors %} | ||
<div class="alert alert-error"> | ||
{{ error|escape }} | ||
</div> | ||
{% endfor %} | ||
{% for error in form.full_download_now.errors %} | ||
<div class="alert alert-error"> | ||
{{ error|escape }} | ||
</div> | ||
{% endfor %} | ||
</div> |
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
Oops, something went wrong.