forked from data.coop/membersystem
Fix site context variable with a context processor.
This commit is contained in:
parent
64ba5cc6f4
commit
b9f77251f1
12
Makefile
12
Makefile
|
@ -23,10 +23,10 @@ pre_commit_run_all:
|
|||
venv/bin/pre-commit run --all-files
|
||||
|
||||
makemigrations:
|
||||
${MANAGE_COMMAND} makemigrations ${EXTRA_ARGS}
|
||||
${MANAGE_COMMAND} makemigrations ${ARGS}
|
||||
|
||||
migrate:
|
||||
${MANAGE_COMMAND} migrate ${EXTRA_ARGS}
|
||||
${MANAGE_COMMAND} migrate ${ARGS}
|
||||
|
||||
createsuperuser:
|
||||
${MANAGE_COMMAND} createsuperuser
|
||||
|
@ -35,7 +35,7 @@ shell:
|
|||
${MANAGE_COMMAND} shell
|
||||
|
||||
manage_command:
|
||||
${MANAGE_COMMAND} ${COMMAND}
|
||||
${MANAGE_COMMAND} ${ARGS}
|
||||
|
||||
add_dependency:
|
||||
${DOCKER_RUN} ${DOCKER_CONTAINER_NAME} poetry add --lock ${DEPENDENCY}
|
||||
|
@ -49,14 +49,10 @@ poetry_lock:
|
|||
poetry_command:
|
||||
${DOCKER_RUN} ${DOCKER_CONTAINER_NAME} poetry ${COMMAND}
|
||||
|
||||
build_dev_docker_image: compile_requirements_dev
|
||||
build_dev_docker_image: compile_requirements
|
||||
${DOCKER_COMPOSE} build ${DOCKER_CONTAINER_NAME}
|
||||
|
||||
compile_requirements:
|
||||
./venv/bin/pip-compile --output-file requirements/base.txt requirements/base.in
|
||||
|
||||
compile_requirements_test: compile_requirements
|
||||
./venv/bin/pip-compile --output-file requirements/test.txt requirements/test.in
|
||||
|
||||
compile_requirements_dev: compile_requirements_test
|
||||
./venv/bin/pip-compile --output-file requirements/dev.txt requirements/dev.in
|
||||
|
|
|
@ -8,7 +8,6 @@ from .selectors import get_member
|
|||
from .selectors import get_members
|
||||
from .selectors import get_memberships
|
||||
from .selectors import get_subscription_periods
|
||||
from utils.view_utils import base_view_context
|
||||
from utils.view_utils import render_list
|
||||
from utils.view_utils import RowAction
|
||||
|
||||
|
@ -21,7 +20,7 @@ def membership_overview(request):
|
|||
|
||||
current_period = current_membership.period.period if current_membership else None
|
||||
|
||||
context = base_view_context(request) | {
|
||||
context = {
|
||||
"current_membership": current_membership,
|
||||
"current_period": current_period,
|
||||
"previous_memberships": previous_memberships,
|
||||
|
@ -66,7 +65,7 @@ def members_admin_detail(request, member_id):
|
|||
member = get_member(member_id=member_id)
|
||||
subscription_periods = get_subscription_periods(member=member)
|
||||
|
||||
context = base_view_context(request) | {
|
||||
context = {
|
||||
"member": member,
|
||||
"subscription_periods": subscription_periods,
|
||||
}
|
||||
|
|
5
src/project/context_processors.py
Normal file
5
src/project/context_processors.py
Normal file
|
@ -0,0 +1,5 @@
|
|||
from django.contrib.sites.shortcuts import get_current_site
|
||||
|
||||
|
||||
def current_site(request):
|
||||
return {"site": get_current_site(request)}
|
|
@ -80,6 +80,7 @@ TEMPLATES = [
|
|||
"django.template.context_processors.request",
|
||||
"django.contrib.auth.context_processors.auth",
|
||||
"django.contrib.messages.context_processors.messages",
|
||||
"project.context_processors.current_site",
|
||||
],
|
||||
},
|
||||
},
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
import contextlib
|
||||
from dataclasses import dataclass
|
||||
|
||||
from django.contrib.sites.shortcuts import get_current_site as django_get_current_site
|
||||
from django.core.exceptions import FieldError
|
||||
from django.core.paginator import Paginator
|
||||
from django.db.models import Model
|
||||
|
@ -11,11 +10,6 @@ from django.urls import reverse
|
|||
from zen_queries import render
|
||||
|
||||
|
||||
def base_view_context(request):
|
||||
"""Include the current site in the context."""
|
||||
return {"site": django_get_current_site(request)}
|
||||
|
||||
|
||||
@dataclass
|
||||
class Row:
|
||||
"""
|
||||
|
@ -82,7 +76,7 @@ def render_list(
|
|||
)
|
||||
rows.append(row)
|
||||
|
||||
context = base_view_context(request) | {
|
||||
context = {
|
||||
"rows": rows,
|
||||
"columns": columns,
|
||||
"row_actions": row_actions,
|
||||
|
|
Loading…
Reference in a new issue