Skip to content

Commit

Permalink
Merge branch 'main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
artsyjian authored Sep 5, 2024
2 parents e2a1ed4 + e2cfdb7 commit 6bcd746
Show file tree
Hide file tree
Showing 40 changed files with 477 additions and 12 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/deploy_docs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ on:
branches:
- main
paths:
- '/docs/**'
- 'docs/**'
- 'mkdocs.yml'
workflow_dispatch:

Expand Down
19 changes: 19 additions & 0 deletions .github/workflows/django_check.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
on:
push:
branches:
- main
pull_request:

jobs:
ruff:
runs-on: ubuntu-latest
name: Check Django
steps:
- name: "Checkout Repo"
uses: actions/checkout@v4
- name: Check Django
uses: dagger/dagger-for-github@v5
with:
verb: call
args: "linters check-django"
version: "0.12.6"
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,8 @@ local_settings.py
db.sqlite3
db.sqlite3-journal
*.dump
staticfiles
src/staticfiles
src/media

# Flask stuff:
instance/
Expand Down
16 changes: 14 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,17 @@
# Spokane Tech

Home of [SpokaneTech.org](https://SpokaneTech.org), an online hub for Spokane's tech events and groups. It's not just a website; it's a community-driven, open-source initiative aimed at fostering learning and collaboration among aspiring and seasoned tech enthusiasts.
Home of [SpokaneTech.org](https://SpokaneTech.org), an online hub for Spokane's
tech events and groups. It's not just a website; it's a community-driven,
open-source initiative aimed at fostering learning and collaboration among
aspiring and seasoned tech enthusiasts.

Interested in participating? Great! Read on...

Here are a few things you can do to get started.

- Go to the site and explore. It's live at [https://spokanetech.org](https://spokanetech.org).
- Look through the [open issues](https://github.com/SpokaneTech/SpokaneTech_Py/issues) and find one that interests you (issues tagged "good first issue" could be great candidates).
- [Read the docs](https://docs.spokanetech.org/)! In our documentation directory we have design decisions, style guide, contributing guide and more. Feel free to familiarize yourself with these.
- Clone the repo to you machine and run locally, explore the code, break things, fix things, have fun. Step-by-step instructions are in the [CONTRIBUTION doc](https://docs.spokanetech.org/CONTRIBUTING/).
- Have a feature idea or found a bug? Create an issue [here](https://github.com/SpokaneTech/SpokaneTech_Py/issues/new/choose)

Please visit our [docs](https://spokanetech.github.io/SpokaneTech_Py/) to learn how to get started working on SpokaneTech_Py!
10 changes: 9 additions & 1 deletion dagger/src/linters.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from asyncio import CancelledError, TaskGroup

import dagger
from dagger import object_type, function
from dagger import function, object_type


@object_type
Expand All @@ -19,6 +19,13 @@ async def run_linter(self, cmd: list[str]) -> str:
# The ExecError exposes the
raise LinterError(exec_error=e)

@function
async def check_django(self) -> str:
"""
Run Django system checks.
"""
return await self.run_linter(["src/manage.py", "check"])

@function
async def check(self) -> str:
"""
Expand Down Expand Up @@ -68,6 +75,7 @@ async def all(self) -> str:
# Run all the linters
async with TaskGroup() as tg:
tasks = [
tg.create_task(self.check_django()),
tg.create_task(self.check()),
tg.create_task(self.format()),
tg.create_task(self.bandit()),
Expand Down
10 changes: 10 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,14 @@
services:
app:
image: spokanetech:latest
build:
context: .
container_name: app
ports:
- "8000:8000"
env_file:
- .env

worker:
image: spokanetech:latest
build:
Expand Down
19 changes: 19 additions & 0 deletions docs/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ source venv/bin/activate
pip install -r requirements.dev.lock
```

> Note: to add a new dependency see [Adding Dependencies](#adding-dependencies).
`python-dotenv` will automatically load values in the `.env` file when Django's `manage.py` is used. Create a `.env` file from the template (**note: `.env` should never be checked in to source control!**):

```shell
Expand Down Expand Up @@ -132,6 +134,23 @@ Quit the server with CONTROL-C.

</details>

### Adding Dependencies

The lock files are generated using [`uv`](https://github.com/astral-sh/uv);
which is included in the development requirements. To add a file use:

```shell
uv add [--dev] SOME-DEP
uv pip compile pyproject.toml --extra dev -o requirements.dev.lock --prerelease=allow
uv pip compile pyproject.toml -o requirements.lock --prerelease=allow
```

Then make sure to sync the virtual environment with the new lock files.

```shell
uv pip sync requirements.dev.lock
```

### Dagger

[Dagger](https://dagger.io/) is used for continuous integration and
Expand Down
2 changes: 2 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ dependencies = [
"crispy-bootstrap5>=2024.2",
"discord.py>=2.3.2",
"Django>=5.0.1",
"django-allauth[socialaccount]>=64.2.0",
"django-azure-communication-email>=1.1.0",
"django-celery-beat>=2.6.0",
"django-celery-results>=2.5.1",
Expand All @@ -30,6 +31,7 @@ dependencies = [
"python-dotenv>=1.0.1",
"sentry-sdk[celery,django]>=2.1.1",
"sqlparse>=0.4.4",
"pillow>=10.4.0",
]

[project.optional-dependencies]
Expand Down
13 changes: 11 additions & 2 deletions requirements.dev.lock
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ django==5.0.8
# spokanetech (pyproject.toml)
# crispy-bootstrap5
# dj-database-url
# django-allauth
# django-azure-communication-email
# django-celery-beat
# django-celery-results
Expand All @@ -114,6 +115,8 @@ django==5.0.8
# djangorestframework
# model-bakery
# sentry-sdk
django-allauth==64.2.0
# via spokanetech (pyproject.toml)
django-azure-communication-email==1.1.0
# via spokanetech (pyproject.toml)
django-celery-beat==2.6.0
Expand Down Expand Up @@ -239,6 +242,7 @@ pbr==6.1.0
# via stevedore
pillow==10.4.0
# via
# spokanetech (pyproject.toml)
# cairosvg
# mkdocs-material
platformdirs==4.2.2
Expand All @@ -262,7 +266,9 @@ pygments==2.18.0
# mkdocs-material
# rich
pyjwt==2.9.0
# via msal
# via
# django-allauth
# msal
pymdown-extensions==10.9
# via mkdocs-material
pytest==8.3.2
Expand Down Expand Up @@ -301,14 +307,17 @@ regex==2024.7.24
requests==2.32.3
# via
# azure-core
# django-allauth
# eventbrite
# mkdocs-material
# msal
# msrest
# requests-oauthlib
# responses
requests-oauthlib==2.0.0
# via msrest
# via
# django-allauth
# msrest
responses==0.25.3
# via spokanetech (pyproject.toml)
rich==13.8.0
Expand Down
14 changes: 12 additions & 2 deletions requirements.lock
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ django==5.0.8
# spokanetech (pyproject.toml)
# crispy-bootstrap5
# dj-database-url
# django-allauth
# django-azure-communication-email
# django-celery-beat
# django-celery-results
Expand All @@ -95,6 +96,8 @@ django==5.0.8
# django-timezone-field
# djangorestframework
# sentry-sdk
django-allauth==64.2.0
# via spokanetech (pyproject.toml)
django-azure-communication-email==1.1.0
# via spokanetech (pyproject.toml)
django-celery-beat==2.6.0
Expand Down Expand Up @@ -173,6 +176,8 @@ oauthlib==3.2.2
# via requests-oauthlib
packaging==24.1
# via gunicorn
pillow==10.4.0
# via spokanetech (pyproject.toml)
portalocker==2.10.1
# via msal-extensions
prometheus-client==0.20.0
Expand All @@ -186,7 +191,9 @@ psycopg-binary==3.2.1
pycparser==2.22
# via cffi
pyjwt==2.9.0
# via msal
# via
# django-allauth
# msal
python-crontab==3.2.0
# via django-celery-beat
python-dateutil==2.9.0.post0
Expand All @@ -203,12 +210,15 @@ redis==5.1.0b7
requests==2.32.3
# via
# azure-core
# django-allauth
# eventbrite
# msal
# msrest
# requests-oauthlib
requests-oauthlib==2.0.0
# via msrest
# via
# django-allauth
# msrest
sentry-sdk==2.13.0
# via spokanetech (pyproject.toml)
setuptools==72.2.0
Expand Down
16 changes: 15 additions & 1 deletion src/spokanetech/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import environ
import dj_database_url
import sentry_sdk
from django.urls import reverse_lazy


# Build paths inside the project like this: BASE_DIR / 'subdir'.
Expand Down Expand Up @@ -100,6 +101,10 @@
"markdownify.apps.MarkdownifyConfig",
"handyhelpers",
"web",
# django-allauth
"allauth",
"allauth.account",
"allauth.socialaccount",
]

if DEBUG:
Expand All @@ -113,7 +118,7 @@
"django.contrib.auth.middleware.AuthenticationMiddleware",
"django.contrib.messages.middleware.MessageMiddleware",
"django.middleware.clickjacking.XFrameOptionsMiddleware",
"web.middleware.TimezoneMiddleware",
"allauth.account.middleware.AccountMiddleware",
]

if DEBUG:
Expand Down Expand Up @@ -170,6 +175,13 @@
},
]

AUTHENTICATION_BACKENDS = [
"django.contrib.auth.backends.ModelBackend",
"allauth.account.auth_backends.AuthenticationBackend",
]

LOGIN_REDIRECT_URL = reverse_lazy("web:index")


# Internationalization
# https://docs.djangoproject.com/en/5.0/topics/i18n/
Expand Down Expand Up @@ -312,3 +324,5 @@
if USE_AZURE:
EMAIL_BACKEND = "django_azure_communication_email.EmailBackend"
AZURE_COMMUNICATION_CONNECTION_STRING = env.str("AZURE_COMMUNICATION_CONNECTION_STRING")
elif DEBUG:
EMAIL_BACKEND = "django.core.mail.backends.console.EmailBackend"
4 changes: 3 additions & 1 deletion src/spokanetech/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,16 @@
"""

from django.conf import settings
from django.conf.urls.static import static
from django.contrib import admin
from django.urls import include, path

urlpatterns = [
path("admin/", admin.site.urls),
path("handyhelpers/", include("handyhelpers.urls")),
path("accounts/", include("allauth.urls")),
path("", include("web.urls")),
]
] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)


if settings.DEBUG:
Expand Down
11 changes: 11 additions & 0 deletions src/templates/429.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{% extends "allauth/layouts/base.html" %}
{% load allauth %}
{% block head_title %}
Too Many Requests
{% endblock head_title %}
{% block content %}
{% element h1 %}
Too Many Requests
{% endelement %}
<p>You are sending too many requests. Please wait before trying again.</p>
{% endblock content %}
5 changes: 5 additions & 0 deletions src/templates/allauth/elements/alert.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{% load allauth %}
<div class="alert alert-xs {% if attrs.level == "error" %}alert-warning{% else %}alert-info{% endif %}">
{% slot message %}
{% endslot %}
</div>
19 changes: 19 additions & 0 deletions src/templates/allauth/elements/badge.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{% load allauth %}
{% setvar variant %}
{% if "warning" in attrs.tags %}
warning
{% elif "danger" in attrs.tags %}
danger
{% elif "secondary" in attrs.tags %}
secondary
{% elif "success" in attrs.tags %}
success
{% else %}
primary
{% endif %}
{% endsetvar %}
<span {% if attrs.title %}title="{{ attrs.title }}"{% endif %}
class="badge text-bg-{{ variant }}">
{% slot %}
{% endslot %}
</span>
31 changes: 31 additions & 0 deletions src/templates/allauth/elements/button.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
{% load allauth %}
{% comment %} djlint:off {% endcomment %}
<{% if attrs.href %}a href="{{ attrs.href }}"{% else %}button{% endif %}
{% if attrs.form %}form="{{ attrs.form }}"{% endif %}
{% if attrs.id %}id="{{ attrs.id }}"{% endif %}
{% if attrs.name %}name="{{ attrs.name }}"{% endif %}
{% if attrs.type %}type="{{ attrs.type }}"{% endif %}
{% if attrs.value %}value="{{ attrs.value }}"{% endif %}
class="{% block class %}
btn
{% if "link" in attrs.tags %}btn-link
{% else %}
{% if "prominent" in attrs.tags %}btn-lg{% elif "minor" in attrs.tags %}btn-sm{% endif %}
btn-{% if 'outline' in attrs.tags %}outline-{% endif %}{% if "danger" in attrs.tags %}danger{% elif "secondary" in attrs.tags %}secondary{% elif "warning" in attrs.tags %}warning{% else %}primary{% endif %}
{% endif %}{% endblock %}">
{% if "tool" in attrs.tags %}
{% if "delete" in attrs.tags %}
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-trash" viewBox="0 0 16 16">
<path d="M5.5 5.5A.5.5 0 0 1 6 6v6a.5.5 0 0 1-1 0V6a.5.5 0 0 1 .5-.5Zm2.5 0a.5.5 0 0 1 .5.5v6a.5.5 0 0 1-1 0V6a.5.5 0 0 1 .5-.5Zm3 .5a.5.5 0 0 0-1 0v6a.5.5 0 0 0 1 0V6Z"/>
<path d="M14.5 3a1 1 0 0 1-1 1H13v9a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V4h-.5a1 1 0 0 1-1-1V2a1 1 0 0 1 1-1H6a1 1 0 0 1 1-1h2a1 1 0 0 1 1 1h3.5a1 1 0 0 1 1 1v1ZM4.118 4 4 4.059V13a1 1 0 0 0 1 1h6a1 1 0 0 0 1-1V4.059L11.882 4H4.118ZM2.5 3h11V2h-11v1Z"/>
</svg>
{% elif "edit" in attrs.tags %}
<svg xmlns="http://www.w3.org/2000/svg" width="1em" height="1em" viewBox="0 0 16 16"><path fill="currentColor" d="M12.854.146a.5.5 0 0 0-.707 0L10.5 1.793L14.207 5.5l1.647-1.646a.5.5 0 0 0 0-.708zm.646 6.061L9.793 2.5L3.293 9H3.5a.5.5 0 0 1 .5.5v.5h.5a.5.5 0 0 1 .5.5v.5h.5a.5.5 0 0 1 .5.5v.5h.5a.5.5 0 0 1 .5.5v.207zm-7.468 7.468A.5.5 0 0 1 6 13.5V13h-.5a.5.5 0 0 1-.5-.5V12h-.5a.5.5 0 0 1-.5-.5V11h-.5a.5.5 0 0 1-.5-.5V10h-.5a.5.5 0 0 1-.175-.032l-.179.178a.5.5 0 0 0-.11.168l-2 5a.5.5 0 0 0 .65.65l5-2a.5.5 0 0 0 .168-.11z"/></svg>
{% endif %}
{% endif %}

{% if not "tool" in attrs.tags %}
{% slot %}
{% endslot %}
{% endif %}
</{% if attrs.href %}a{% else %}button{% endif %}>
Loading

0 comments on commit 6bcd746

Please sign in to comment.