Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
7 changes: 3 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -162,9 +162,8 @@ cython_debug/

**/settings/secret.py

# Pycharm tailwind autocomplete workaround folder

pyc-autocomplete/

/docker/
**/docker/tailwindcss
**/tailwind/build.css

**/media/
34 changes: 18 additions & 16 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,6 @@ repos:
name: ruff lint
args: [ "--exit-non-zero-on-fix" ]
- id: ruff-format
- repo: https://github.com/crate-ci/typos
rev: codespell-dict-v0.5.0
hooks:
- id: typos
args:
- --exclude
- "static/general/dist/.*"

- repo: https://github.com/executablebooks/mdformat
rev: 0.7.21
Expand All @@ -35,18 +28,27 @@ repos:
types: [markdown]
additional_dependencies:
- mdformat-myst
- repo: https://github.com/biomejs/pre-commit
rev: v0.6.1
hooks:
- id: biome-check
additional_dependencies: ["@biomejs/biome@1.9.2"]

- repo: local
hooks:
- id: rustywind # Remove rustywind once biomejs tailwind sorting is competent: https://github.com/biomejs/biome/issues/1274
name: Tailwind CSS Class sorter
- id: rustywind
name: rustywind Tailwind CSS class linter # The Prettier tailwind plugin doesn't like Django templates
language: node
additional_dependencies:
- rustywind@latest
entry: rustywind
args: [--write]
types_or: [html]
args: ["--write"]
types_or: ["html"]

- repo: https://github.com/JoC0de/pre-commit-prettier
on: push # Prettier can be slow (5-10s) so only run on push to not be annoying every commit
# We need to run prettier-tailwind and prettier-jinja separately since prettier-jinja overrides tailwind
hooks:
- id: prettier-jinja
name: Prettier + Jinja/DTL 🥳 (push)
language: node
additional_dependencies:
- prettier@3.6.2
- prettier-plugin-jinja-template@2.1.0
entry: prettier
args: ["--write", "--plugin=prettier-plugin-jinja-template"]
5 changes: 5 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Ignore artifacts:
build
coverage
input.css
build.css
1 change: 1 addition & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
20 changes: 0 additions & 20 deletions biome.json

This file was deleted.

2 changes: 1 addition & 1 deletion dev/docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@ ENV UV_LINK_MODE=copy \
UV_PROJECT_ENVIRONMENT="/venv"

RUN apt-get update \
&& apt-get install -y --no-install-recommends libpq-dev \
&& apt-get install -y --no-install-recommends libpq-dev curl \
&& uv sync --frozen \
&& rm -rf /var/lib/apt/lists/* # Reduce image size
2 changes: 1 addition & 1 deletion dev/docker/compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ services:
- watchfiles
- --filter
- python
- "uv run celery -A director worker"
- "uv run celery -A director worker --concurrency=4"
- /director5/manager/director
working_dir: /director5/manager
networks:
Expand Down
10 changes: 9 additions & 1 deletion dev/docker/docker-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,15 @@ if [ "$1" = "django" ]; then
exec uv run python manage.py runserver 0.0.0.0:8080
elif [ "$1" = "tailwind" ]; then
static="manager/director/static/tailwind"
exec dev/tailwind/tailwindcss -i $static/input.css -o $static/build.css --config dev/tailwind/tailwind.config.js --watch --poll
binary="dev/docker/tailwindcss"

if [ ! -f "$binary" ]; then
echo "Tailwind binary not found, downloading..."
curl -L -o "$binary" https://github.com/tailwindlabs/tailwindcss/releases/download/v4.1.11/tailwindcss-linux-x64 # version lock
chmod +x "$binary"
fi

exec "$binary" -i "$static/input.css" -o "$static/build.css" --watch --poll
elif [ "$1" = "fastapi" ]; then
exec uv run fastapi dev orchestrator/main.py --host 0.0.0.0 --port 8080
else
Expand Down
8 changes: 0 additions & 8 deletions dev/tailwind/build-tailwind.sh

This file was deleted.

16 changes: 0 additions & 16 deletions dev/tailwind/enable-pycharm-autocomplete.sh

This file was deleted.

58 changes: 0 additions & 58 deletions dev/tailwind/tailwind.config.js

This file was deleted.

Binary file removed dev/tailwind/tailwindcss
Binary file not shown.
14 changes: 2 additions & 12 deletions manager/director/apps/auth/urls.py
Original file line number Diff line number Diff line change
@@ -1,21 +1,11 @@
from django.conf import settings
from django.contrib.auth.views import LoginView
from django.urls import path

from . import views
from .views import HTMXLoginView

app_name = "auth"

urlpatterns = [
path("login/", views.login_view, name="login"),
path("login/", HTMXLoginView.as_view(), name="login"),
path("logout/", views.logout_view, name="logout"),
]

if settings.DEBUG:
urlpatterns.append(
path(
"password-login/",
LoginView.as_view(template_name="auth/password-login.html"),
name="password_login",
)
)
28 changes: 23 additions & 5 deletions manager/director/apps/auth/views.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,32 @@
from django.conf import settings
from django.contrib.auth import logout
from django.contrib.auth.decorators import login_required
from django.contrib.auth.forms import AuthenticationForm
from django.contrib.auth.views import LoginView
from django.http import HttpRequest, HttpResponse
from django.shortcuts import redirect, render
from django_htmx.http import HttpResponseClientRedirect


def login_view(request: HttpRequest) -> HttpResponse:
if request.user.is_authenticated:
return redirect("sites:index")
return render(request, "auth/login.html", {"debug": settings.DEBUG})
class HTMXLoginView(LoginView):
template_name = "auth/login.html"

def form_valid(self, form: AuthenticationForm):
response = super().form_valid(form)

if self.request.htmx:
return HttpResponseClientRedirect(self.get_redirect_url())

return response

def form_invalid(self, form: AuthenticationForm):
if self.request.htmx:
return render(
self.request,
"auth/login.html.partials/password.html",
self.get_context_data(form=form),
)

return super().form_invalid(form)


@login_required
Expand Down
7 changes: 7 additions & 0 deletions manager/director/apps/sites/consumers/routing.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
from django.urls import path

from director.apps.sites.consumers.site_status import SiteStatusConsumer

websocket_urlpatterns = [
path("sites/<int:site_id>/websocket/status", SiteStatusConsumer.as_asgi()),
]
Loading
Loading