Compare commits

...

3 Commits

15 changed files with 297 additions and 155 deletions

View File

@ -3,7 +3,7 @@ default_language_version:
exclude: ^.*\b(migrations)\b.*$
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
rev: v4.5.0
hooks:
- id: check-ast
- id: check-merge-conflict
@ -16,13 +16,13 @@ repos:
- id: end-of-file-fixer
- id: trailing-whitespace
- repo: https://github.com/charliermarsh/ruff-pre-commit
rev: 'v0.0.292'
rev: 'v0.1.11'
hooks:
- id: ruff
args:
- --fix
- repo: https://github.com/asottile/reorder_python_imports
rev: v3.11.0
rev: v3.12.0
hooks:
- id: reorder-python-imports
args:
@ -30,7 +30,7 @@ repos:
- --application-directories=.:src
exclude: migrations/
- repo: https://github.com/asottile/pyupgrade
rev: v3.13.0
rev: v3.15.0
hooks:
- id: pyupgrade
args:
@ -51,10 +51,10 @@ repos:
hooks:
- id: add-trailing-comma
- repo: https://github.com/hadialqattan/pycln
rev: v2.2.2
rev: v2.4.0
hooks:
- id: pycln
- repo: https://github.com/psf/black
rev: 23.9.1
rev: 23.12.1
hooks:
- id: black

105
pyproject.toml Normal file
View File

@ -0,0 +1,105 @@
[build-system]
requires = ["hatchling", "hatch-vcs"]
build-backend = "hatchling.build"
[project]
name = "membersystem"
description = ''
readme = "README.md"
requires-python = ">=3.11"
keywords = []
authors = [
{ name = "Víðir Valberg Guðmundsson", email = "valberg@orn.li" },
]
dependencies = [
"Django==5.0.1",
"django-money==3.4.1",
"django-allauth==0.60.0",
"psycopg[binary]==3.1.16",
"environs[django]==10.0.0",
"uvicorn==0.25.0",
"whitenoise==6.6.0",
"django-zen-queries==2.1.0",
"django-registries==0.0.3",
]
dynamic = ["version"]
[tool.hatch.version]
source = "vcs"
[tool.hatch.envs.default]
dependencies = [
"coverage[toml]==7.3.0",
"pytest==7.2.2",
"pytest-cov",
"pytest-django==4.5.2",
"mypy==1.1.1",
"django-stubs==1.16.0",
"pip-tools==7.3.0",
"django-debug-toolbar==4.2.0",
"django-browser-reload==1.7.0",
"model-bakery==1.17.0",
]
[[tool.hatch.envs.tests.matrix]]
python = ["3.12"]
django = ["4.2", "5.0"]
[tool.hatch.envs.tests.overrides]
matrix.django.dependencies = [
{ value = "django~={matrix:django}" },
]
matrix.python.dependencies = [
{ value = "typing_extensions==4.5.0", if = ["3.10"]},
]
[tool.hatch.envs.default.scripts]
cov = "pytest --cov-report=term-missing --cov-config=pyproject.toml --cov=src --cov=tests --cov=append {args}"
no-cov = "cov --no-cov {args}"
typecheck = "mypy --config-file=pyproject.toml ."
requirements = "pip-compile --output-file requirements/base.txt pyproject.toml"
server = "./src/manage.py runserver"
migrate = "./src/manage.py migrate"
makemigrations = "./src/manage.py makemigrations"
createsuperuser = "./src/manage.py createsuperuser"
shell = "./src/manage.py shell"
[tool.pytest.ini_options]
DJANGO_SETTINGS_MODULE="tests.settings"
addopts = "--reuse-db"
norecursedirs = "build dist docs .eggs/* *.egg-info htmlcov .git"
python_files = "test*.py"
testpaths = "tests"
pythonpath = ". tests"
[tool.coverage.run]
branch = true
parallel = true
[tool.coverage.report]
exclude_lines = [
"no cov",
"if __name__ == .__main__.:",
"if TYPE_CHECKING:",
]
[tool.mypy]
mypy_path = "src/"
exclude = [
"venv/",
"dist/",
"docs/",
]
namespace_packages = false
show_error_codes = true
strict = true
warn_unreachable = true
follow_imports = "normal"
#plugins = ["mypy_django_plugin.main"]
[tool.django-stubs]
#django_settings_module = "tests.settings"
[[tool.mypy.overrides]]
module = "tests.*"
allow_untyped_defs = true

View File

@ -1,8 +1,8 @@
Django==4.2.5
django-money==3.3.0
django-allauth==0.57.0
psycopg[binary]==3.1.12
environs[django]==9.5
uvicorn==0.23.2
whitenoise==6.5.0
Django==5.0.1
django-money==3.4.1
django-allauth==0.60.0
psycopg[binary]==3.1.16
environs[django]==10.0.0
uvicorn==0.25.0
whitenoise==6.6.0
django-zen-queries==2.1.0

View File

@ -2,89 +2,97 @@
# This file is autogenerated by pip-compile with Python 3.11
# by the following command:
#
# pip-compile --output-file=requirements/base.txt requirements/base.in
# pip-compile --output-file=requirements/base.txt pyproject.toml
#
asgiref==3.7.2
# via django
babel==2.12.1
babel==2.14.0
# via py-moneyed
certifi==2022.9.24
certifi==2023.11.17
# via requests
cffi==1.15.1
cffi==1.16.0
# via cryptography
charset-normalizer==2.1.1
charset-normalizer==3.3.2
# via requests
click==7.1.2
click==8.1.7
# via uvicorn
cryptography==38.0.3
cryptography==41.0.7
# via pyjwt
defusedxml==0.7.1
# via python3-openid
dj-database-url==1.0.0
dj-database-url==2.1.0
# via environs
dj-email-url==1.0.6
# via environs
django==4.2.5
django==5.0.1
# via
# -r requirements/base.in
# dj-database-url
# django-allauth
# django-money
# django-registries
# django-zen-queries
django-allauth==0.57.0
# via -r requirements/base.in
django-cache-url==3.4.2
# membersystem (pyproject.toml)
django-allauth==0.60.0
# via membersystem (pyproject.toml)
django-cache-url==3.4.5
# via environs
django-money==3.3.0
# via -r requirements/base.in
django-money==3.4.1
# via membersystem (pyproject.toml)
django-registries==0.0.3
# via membersystem (pyproject.toml)
django-zen-queries==2.1.0
# via -r requirements/base.in
environs[django]==9.5.0
# via -r requirements/base.in
# via membersystem (pyproject.toml)
environs[django]==10.0.0
# via
# environs
# membersystem (pyproject.toml)
h11==0.14.0
# via uvicorn
idna==3.4
idna==3.6
# via requests
marshmallow==3.19.0
marshmallow==3.20.1
# via environs
oauthlib==3.2.2
# via requests-oauthlib
packaging==21.3
packaging==23.2
# via marshmallow
psycopg[binary]==3.1.12
# via -r requirements/base.in
psycopg-binary==3.1.12
psycopg[binary]==3.1.16
# via
# membersystem (pyproject.toml)
# psycopg
psycopg-binary==3.1.16
# via psycopg
py-moneyed==3.0
# via django-money
pycparser==2.21
# via cffi
pyjwt[crypto]==2.6.0
# via django-allauth
pyparsing==3.0.9
# via packaging
python-dotenv==0.21.0
pyjwt[crypto]==2.8.0
# via
# django-allauth
# pyjwt
python-dotenv==1.0.0
# via environs
python3-openid==3.2.0
# via django-allauth
requests==2.28.1
requests==2.31.0
# via
# django-allauth
# requests-oauthlib
requests-oauthlib==1.3.1
# via django-allauth
sqlparse==0.4.3
sqlparse==0.4.4
# via django
typing-extensions==4.8.0
typing-extensions==4.9.0
# via
# dj-database-url
# psycopg
# py-moneyed
urllib3==1.26.12
urllib3==2.1.0
# via requests
uvicorn==0.23.2
# via -r requirements/base.in
whitenoise==6.5.0
# via -r requirements/base.in
uvicorn==0.25.0
# via membersystem (pyproject.toml)
whitenoise==6.6.0
# via membersystem (pyproject.toml)
# The following packages are considered to be unsafe in a requirements file:
# setuptools

View File

@ -1,8 +1,8 @@
-r test.txt
django-browser-reload==1.11.0
django-browser-reload==1.12.1
django-debug-toolbar==4.2.0
django-extensions==3.2.3
django-stubs==1.12.0
ipython==8.6.0
mypy==1.5.1
django-stubs==4.2.7
ipython==8.19.0
mypy==1.8.0

View File

@ -8,33 +8,32 @@ asgiref==3.7.2
# via
# -r requirements/test.txt
# django
asttokens==2.1.0
# django-browser-reload
asttokens==2.4.1
# via stack-data
babel==2.12.1
babel==2.14.0
# via
# -r requirements/test.txt
# py-moneyed
backcall==0.2.0
# via ipython
certifi==2022.9.24
certifi==2023.11.17
# via
# -r requirements/test.txt
# requests
cffi==1.15.1
cffi==1.16.0
# via
# -r requirements/test.txt
# cryptography
charset-normalizer==2.1.1
charset-normalizer==3.3.2
# via
# -r requirements/test.txt
# requests
click==7.1.2
click==8.1.7
# via
# -r requirements/test.txt
# uvicorn
coverage==7.3.1
coverage==7.4.0
# via -r requirements/test.txt
cryptography==38.0.3
cryptography==41.0.7
# via
# -r requirements/test.txt
# pyjwt
@ -44,7 +43,7 @@ defusedxml==0.7.1
# via
# -r requirements/test.txt
# python3-openid
dj-database-url==1.0.0
dj-database-url==2.1.0
# via
# -r requirements/test.txt
# environs
@ -52,7 +51,7 @@ dj-email-url==1.0.6
# via
# -r requirements/test.txt
# environs
django==4.2.5
django==5.0.1
# via
# -r requirements/test.txt
# dj-database-url
@ -64,11 +63,11 @@ django==4.2.5
# django-stubs
# django-stubs-ext
# django-zen-queries
django-allauth==0.57.0
django-allauth==0.60.0
# via -r requirements/test.txt
django-browser-reload==1.11.0
django-browser-reload==1.12.1
# via -r requirements/dev.in
django-cache-url==3.4.2
django-cache-url==3.4.5
# via
# -r requirements/test.txt
# environs
@ -76,65 +75,61 @@ django-debug-toolbar==4.2.0
# via -r requirements/dev.in
django-extensions==3.2.3
# via -r requirements/dev.in
django-money==3.3.0
django-money==3.4.1
# via -r requirements/test.txt
django-stubs==1.12.0
django-stubs==4.2.7
# via -r requirements/dev.in
django-stubs-ext==0.7.0
django-stubs-ext==4.2.7
# via django-stubs
django-zen-queries==2.1.0
# via -r requirements/test.txt
environs[django]==9.5.0
environs[django]==10.0.0
# via -r requirements/test.txt
executing==1.2.0
executing==2.0.1
# via stack-data
h11==0.14.0
# via
# -r requirements/test.txt
# uvicorn
idna==3.4
idna==3.6
# via
# -r requirements/test.txt
# requests
ipython==8.6.0
ipython==8.19.0
# via -r requirements/dev.in
jedi==0.18.1
jedi==0.19.1
# via ipython
lxml==4.9.1
lxml==5.0.1
# via
# -r requirements/test.txt
# unittest-xml-reporting
marshmallow==3.19.0
marshmallow==3.20.1
# via
# -r requirements/test.txt
# environs
matplotlib-inline==0.1.6
# via ipython
mypy==1.5.1
# via
# -r requirements/dev.in
# django-stubs
mypy==1.8.0
# via -r requirements/dev.in
mypy-extensions==1.0.0
# via mypy
oauthlib==3.2.2
# via
# -r requirements/test.txt
# requests-oauthlib
packaging==21.3
packaging==23.2
# via
# -r requirements/test.txt
# marshmallow
parso==0.8.3
# via jedi
pexpect==4.8.0
pexpect==4.9.0
# via ipython
pickleshare==0.7.5
prompt-toolkit==3.0.43
# via ipython
prompt-toolkit==3.0.32
# via ipython
psycopg[binary]==3.1.12
psycopg[binary]==3.1.16
# via -r requirements/test.txt
psycopg-binary==3.1.12
psycopg-binary==3.1.16
# via
# -r requirements/test.txt
# psycopg
@ -150,17 +145,13 @@ pycparser==2.21
# via
# -r requirements/test.txt
# cffi
pygments==2.13.0
pygments==2.17.2
# via ipython
pyjwt[crypto]==2.6.0
pyjwt[crypto]==2.8.0
# via
# -r requirements/test.txt
# django-allauth
pyparsing==3.0.9
# via
# -r requirements/test.txt
# packaging
python-dotenv==0.21.0
python-dotenv==1.0.0
# via
# -r requirements/test.txt
# environs
@ -168,7 +159,7 @@ python3-openid==3.2.0
# via
# -r requirements/test.txt
# django-allauth
requests==2.28.1
requests==2.31.0
# via
# -r requirements/test.txt
# django-allauth
@ -179,28 +170,27 @@ requests-oauthlib==1.3.1
# django-allauth
six==1.16.0
# via asttokens
sqlparse==0.4.3
sqlparse==0.4.4
# via
# -r requirements/test.txt
# django
# django-debug-toolbar
stack-data==0.6.1
stack-data==0.6.3
# via ipython
tblib==2.0.0
tblib==3.0.0
# via -r requirements/test.txt
tomli==2.0.1
# via django-stubs
traitlets==5.5.0
traitlets==5.14.1
# via
# ipython
# matplotlib-inline
types-pytz==2022.6.0.1
types-pytz==2023.3.1.1
# via django-stubs
types-pyyaml==6.0.12.2
types-pyyaml==6.0.12.12
# via django-stubs
typing-extensions==4.8.0
typing-extensions==4.9.0
# via
# -r requirements/test.txt
# dj-database-url
# django-stubs
# django-stubs-ext
# mypy
@ -208,15 +198,15 @@ typing-extensions==4.8.0
# py-moneyed
unittest-xml-reporting==3.2.0
# via -r requirements/test.txt
urllib3==1.26.12
urllib3==2.1.0
# via
# -r requirements/test.txt
# requests
uvicorn==0.23.2
uvicorn==0.25.0
# via -r requirements/test.txt
wcwidth==0.2.5
wcwidth==0.2.13
# via prompt-toolkit
whitenoise==6.5.0
whitenoise==6.6.0
# via -r requirements/test.txt
# The following packages are considered to be unsafe in a requirements file:

View File

@ -1,5 +1,5 @@
-r base.txt
coverage==7.3.1
tblib==2.0.0
coverage==7.4.0
tblib==3.0.0
unittest-xml-reporting==3.2.0

View File

@ -8,29 +8,29 @@ asgiref==3.7.2
# via
# -r requirements/base.txt
# django
babel==2.12.1
babel==2.14.0
# via
# -r requirements/base.txt
# py-moneyed
certifi==2022.9.24
certifi==2023.11.17
# via
# -r requirements/base.txt
# requests
cffi==1.15.1
cffi==1.16.0
# via
# -r requirements/base.txt
# cryptography
charset-normalizer==2.1.1
charset-normalizer==3.3.2
# via
# -r requirements/base.txt
# requests
click==7.1.2
click==8.1.7
# via
# -r requirements/base.txt
# uvicorn
coverage==7.3.1
coverage==7.4.0
# via -r requirements/test.in
cryptography==38.0.3
cryptography==41.0.7
# via
# -r requirements/base.txt
# pyjwt
@ -38,7 +38,7 @@ defusedxml==0.7.1
# via
# -r requirements/base.txt
# python3-openid
dj-database-url==1.0.0
dj-database-url==2.1.0
# via
# -r requirements/base.txt
# environs
@ -46,36 +46,36 @@ dj-email-url==1.0.6
# via
# -r requirements/base.txt
# environs
django==4.2.5
django==5.0.1
# via
# -r requirements/base.txt
# dj-database-url
# django-allauth
# django-money
# django-zen-queries
django-allauth==0.57.0
django-allauth==0.60.0
# via -r requirements/base.txt
django-cache-url==3.4.2
django-cache-url==3.4.5
# via
# -r requirements/base.txt
# environs
django-money==3.3.0
django-money==3.4.1
# via -r requirements/base.txt
django-zen-queries==2.1.0
# via -r requirements/base.txt
environs[django]==9.5.0
environs[django]==10.0.0
# via -r requirements/base.txt
h11==0.14.0
# via
# -r requirements/base.txt
# uvicorn
idna==3.4
idna==3.6
# via
# -r requirements/base.txt
# requests
lxml==4.9.1
lxml==5.0.1
# via unittest-xml-reporting
marshmallow==3.19.0
marshmallow==3.20.1
# via
# -r requirements/base.txt
# environs
@ -83,13 +83,13 @@ oauthlib==3.2.2
# via
# -r requirements/base.txt
# requests-oauthlib
packaging==21.3
packaging==23.2
# via
# -r requirements/base.txt
# marshmallow
psycopg[binary]==3.1.12
psycopg[binary]==3.1.16
# via -r requirements/base.txt
psycopg-binary==3.1.12
psycopg-binary==3.1.16
# via
# -r requirements/base.txt
# psycopg
@ -101,15 +101,11 @@ pycparser==2.21
# via
# -r requirements/base.txt
# cffi
pyjwt[crypto]==2.6.0
pyjwt[crypto]==2.8.0
# via
# -r requirements/base.txt
# django-allauth
pyparsing==3.0.9
# via
# -r requirements/base.txt
# packaging
python-dotenv==0.21.0
python-dotenv==1.0.0
# via
# -r requirements/base.txt
# environs
@ -117,7 +113,7 @@ python3-openid==3.2.0
# via
# -r requirements/base.txt
# django-allauth
requests==2.28.1
requests==2.31.0
# via
# -r requirements/base.txt
# django-allauth
@ -126,26 +122,27 @@ requests-oauthlib==1.3.1
# via
# -r requirements/base.txt
# django-allauth
sqlparse==0.4.3
sqlparse==0.4.4
# via
# -r requirements/base.txt
# django
tblib==2.0.0
tblib==3.0.0
# via -r requirements/test.in
typing-extensions==4.8.0
typing-extensions==4.9.0
# via
# -r requirements/base.txt
# dj-database-url
# psycopg
# py-moneyed
unittest-xml-reporting==3.2.0
# via -r requirements/test.in
urllib3==1.26.12
urllib3==2.1.0
# via
# -r requirements/base.txt
# requests
uvicorn==0.23.2
uvicorn==0.25.0
# via -r requirements/base.txt
whitenoise==6.5.0
whitenoise==6.6.0
# via -r requirements/base.txt
# The following packages are considered to be unsafe in a requirements file:

View File

@ -7,6 +7,7 @@
{% block content %}
<div class="content-view">
<h1>
{{ member.username }}
</h1>
@ -39,5 +40,6 @@
{% else %}
{% trans "No memberships" %}
{% endif %}
</div>
{% endblock %}

View File

@ -70,6 +70,7 @@ def members_admin_detail(request, member_id):
context = {
"member": member,
"subscription_periods": subscription_periods,
"base_path": "admin-members",
}
return render(

View File

@ -8,29 +8,38 @@
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="description" content="">
<title>{% block head_title %}{% endblock %} {{ site.name }}</title>
<link rel="stylesheet" href="{% static "/fonts/inter.css" %}">
<link rel="stylesheet" href="{% static "/css/style.css" %}">
<link rel="stylesheet" href="{% static "fonts/inter.css" %}">
<link rel="stylesheet" href="{% static "css/style.css" %}">
</head>
<body>
<header>
<h1> data.coop membersystem </h1>
<a class="logout" href="{% url "account_logout" %}">Log out</a>
</header
</header>
<main>
<aside>
<div>
<figure></figure>
<h2>{{ user }}</h2>
{% if current_membership %}
<dl>
<dt>Membership</dt>
<dd>{% if current_membership %} Active {% endif %}</dd>
<dd>
Active
</dd>
<dt>Period</dt>
<dd>{% if current_membership %} Until {{ current_period.upper }} <span class="time_remaining">({{ current_period.upper|timeuntil }})</span>{% endif %}</dd>
<dd>
Until {{ current_period.upper }} <span class="time_remaining">({{ current_period.upper|timeuntil }})</span>
</dd>
<dt>Membership type</dt>
<dd>Normal member</dd>
</dl>
{% else %}
Your membership status will be displayed here in the future.
{% endif %}
</div>
</aside>
<nav>
@ -41,11 +50,13 @@
</a>
</li>
{% comment %}
<li>
<a href="/services" class="{% active_path "services" "current" %}">
Services
</a>
</li>
{% endcomment %}
<li>
<a href="{% url "account_email" %}" class="{% active_path "account_email" "current" %}">

View File

@ -7,11 +7,22 @@
{% block content %}
<div class="content-view">
<h2>Welcome {{ user }}!</h2>
<p>
This is the new member area.
</p>
<p>
It is very much under construction.
</p>
{% comment %}
<hr>
<br>
<div class="infobox">
<p>
To get you started we need to verify your email!
To get started we need you to verify your email!
</p>
<button>Verify email</button>
</div>
{% endcomment %}
</div>
{% endblock %}

View File

@ -1,6 +1,12 @@
{% extends "base.html" %}
{% block content %}
<div class="content-view">
Coming soon!
</div>
{% comment %}
<div class="content-view">
<h2>Services you subscribe to</h2>
<div class="services">
@ -52,4 +58,5 @@
</div>
</div>
</div>
{% endcomment %}
{% endblock %}

View File

@ -7,6 +7,8 @@
{% block content %}
<div class="content-view">
<h1>
{{ entity_name_plural|capfirst }} <small class="text-muted">{{ total_count }}</small>
</h1>
@ -48,7 +50,6 @@
</table>
{% if is_paginated %}
<nav>
<ul class="pagination justify-content-center">
{% if not page.has_previous %}
@ -101,8 +102,9 @@
{% endif %}
</ul>
</nav>
{% endif %}
</div>
{% endblock %}

View File

@ -5,9 +5,17 @@ register = template.Library()
@register.simple_tag(takes_context=True)
def active_path(context, path_name, class_name):
def active_path(context, path_name, class_name) -> str | None:
"""Return the given class name if the current path matches the given path name."""
path = reverse(path_name)
request_path = context.get("request").path
if path == request_path or ("basepath" in context and context["basepath"] == path):
# Check if the current path matches the given path name.
is_path = path == request_path
# Check if the current path is a sub-path of the given path name.
is_base_path = "base_path" in context and reverse(context["base_path"]) == path
if is_path or is_base_path:
return class_name