diff --git a/.djlintrc b/.djlintrc new file mode 100644 index 0000000..b895850 --- /dev/null +++ b/.djlintrc @@ -0,0 +1,6 @@ +{ + "max_line_length": "180", + "max_blank_lines": 1, + "profile": "django" +} + diff --git a/.github/workflows/ruff.yml b/.github/workflows/ruff.yml new file mode 100644 index 0000000..326977c --- /dev/null +++ b/.github/workflows/ruff.yml @@ -0,0 +1,10 @@ +name: Ruff +on: [ push, pull_request ] +jobs: + ruff: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: chartboost/ruff-action@v1 + with: + path: './cardie' diff --git a/.gitignore b/.gitignore index 72dcb08..2107c8b 100644 --- a/.gitignore +++ b/.gitignore @@ -2,4 +2,5 @@ cardie/db.sqlite3 __pycache__ django.log -.env \ No newline at end of file +.env +.ruff_cache diff --git a/.vscode/extensions.json b/.vscode/extensions.json new file mode 100644 index 0000000..3ff560f --- /dev/null +++ b/.vscode/extensions.json @@ -0,0 +1,5 @@ +{ + "recommendations": [ + "charliermarsh.ruff" + ] +} diff --git a/.vscode/tasks.json b/.vscode/tasks.json index 681f74c..bf1348e 100755 --- a/.vscode/tasks.json +++ b/.vscode/tasks.json @@ -64,6 +64,16 @@ "panel": "new" }, "problemMatcher": [] + }, + { + "label": "Format Django templats with djlint", + "type": "shell", + "command": "source .venv/bin/activate && djlint cardie --reformat", + "presentation": { + "reveal": "always", + "panel": "new" + }, + "problemMatcher": [] } ] } \ No newline at end of file diff --git a/README.md b/README.md index 8b0ca97..e166104 100644 --- a/README.md +++ b/README.md @@ -65,6 +65,7 @@ Activate the virtual environment using the command for your system (Linux is use ```bash source ./.venv/bin/activate pip install -r requirements.txt +pip install -r requirements-dev.txt ``` Copy the `.env.example` file to a new file called `.env`. @@ -98,6 +99,19 @@ Set the following global environment variables: - `DEBUG` -> `False` - `DATABASE_URL` -> `${db.DATABASE_URL}` (This works on DigitalOcean, this may not work on every hosting provider) +## Development +### djlint +This project uses `djlint` to lint the templates. You can run this using the following command +```bash +djlint cardie --reformat +``` +### ruff +This project uses [`ruff`](https://docs.astral.sh/ruff/) to lint and format the code. +You can run the following command to lint and format the code. +```bash +ruff check cardie --fix +``` +For VS Code users, you can install the `ruff` extension to get linting and formatting on save. ## Contributing Please see [CONTRIBUTING.md](CONTRIBUTING.md) for instructions on how you can contribute to Cardie diff --git a/cardie/authentication/admin.py b/cardie/authentication/admin.py index 8c38f3f..b97a94f 100644 --- a/cardie/authentication/admin.py +++ b/cardie/authentication/admin.py @@ -1,3 +1,2 @@ -from django.contrib import admin # Register your models here. diff --git a/cardie/authentication/tests.py b/cardie/authentication/tests.py index 7ce503c..4929020 100644 --- a/cardie/authentication/tests.py +++ b/cardie/authentication/tests.py @@ -1,3 +1,2 @@ -from django.test import TestCase # Create your tests here. diff --git a/cardie/authentication/views.py b/cardie/authentication/views.py index e8568dd..7dfcf6f 100644 --- a/cardie/authentication/views.py +++ b/cardie/authentication/views.py @@ -1,4 +1,4 @@ -from django.shortcuts import render, HttpResponse +from django.shortcuts import HttpResponse from django.contrib.auth.hashers import make_password, check_password from authentication.models import User diff --git a/cardie/main/management/commands/cleartempcards.py b/cardie/main/management/commands/cleartempcards.py index 327e4d6..809a92f 100644 --- a/cardie/main/management/commands/cleartempcards.py +++ b/cardie/main/management/commands/cleartempcards.py @@ -1,4 +1,4 @@ -from django.core.management.base import BaseCommand, CommandError +from django.core.management.base import BaseCommand from main.models import TempCard from django.utils import timezone import datetime diff --git a/cardie/main/migrations/0010_migrate_card_v0_to_v1.py b/cardie/main/migrations/0010_migrate_card_v0_to_v1.py index 129d14e..d03937a 100644 --- a/cardie/main/migrations/0010_migrate_card_v0_to_v1.py +++ b/cardie/main/migrations/0010_migrate_card_v0_to_v1.py @@ -1,7 +1,6 @@ # Generated by Django 5.0.3 on 2024-09-09 23:31 from django.db import migrations -import json def migrate_json_data(apps, schema_editor): Card = apps.get_model('main', 'Card') diff --git a/cardie/main/models.py b/cardie/main/models.py index a5e5c2c..a90cc97 100644 --- a/cardie/main/models.py +++ b/cardie/main/models.py @@ -1,4 +1,3 @@ -from colorfield.fields import ColorField from django.db import models from authentication.models import User import uuid diff --git a/cardie/main/templates/authentication.html b/cardie/main/templates/authentication.html index 1706352..c8468e0 100644 --- a/cardie/main/templates/authentication.html +++ b/cardie/main/templates/authentication.html @@ -1,56 +1,85 @@ {% extends "base.html" %} - {% load static %} - {% block head_title %}Authentication{% endblock %} {% block stylesheets %} - - - + + {% endblock %} - {% block body %}