This commit is contained in:
parent
770c1c81b6
commit
d2e58d396f
|
@ -23,7 +23,7 @@ def get_subscription_periods(member: Member | None = None) -> list[SubscriptionP
|
||||||
period=OuterRef("pk"),
|
period=OuterRef("pk"),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
)
|
).filter(membership_exists=True)
|
||||||
|
|
||||||
return list(subscription_periods)
|
return list(subscription_periods)
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,6 @@
|
||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
|
|
||||||
|
|
||||||
<h1>
|
<h1>
|
||||||
{{ member.username }}
|
{{ member.username }}
|
||||||
</h1>
|
</h1>
|
||||||
|
@ -12,6 +11,7 @@
|
||||||
|
|
||||||
<h3>{% trans "Membership" %}</h3>
|
<h3>{% trans "Membership" %}</h3>
|
||||||
|
|
||||||
|
{% if subscription_periods %}
|
||||||
<table class="table">
|
<table class="table">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
|
@ -32,8 +32,8 @@
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
|
{% else %}
|
||||||
|
{% trans "No memberships" %}
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
|
@ -1,13 +1,13 @@
|
||||||
from django.contrib.auth.decorators import login_required
|
from django.contrib.auth.decorators import login_required
|
||||||
from django.contrib.auth.decorators import permission_required
|
from django.contrib.auth.decorators import permission_required
|
||||||
from django.utils.translation import gettext_lazy as _
|
from django.utils.translation import gettext_lazy as _
|
||||||
from zen_queries import render
|
|
||||||
|
|
||||||
from .permissions import ADMINISTRATE_MEMBERS
|
from .permissions import ADMINISTRATE_MEMBERS
|
||||||
from .selectors import get_member
|
from .selectors import get_member
|
||||||
from .selectors import get_members
|
from .selectors import get_members
|
||||||
from .selectors import get_memberships
|
from .selectors import get_memberships
|
||||||
from .selectors import get_subscription_periods
|
from .selectors import get_subscription_periods
|
||||||
|
from utils.view_utils import render
|
||||||
from utils.view_utils import render_list
|
from utils.view_utils import render_list
|
||||||
from utils.view_utils import RowAction
|
from utils.view_utils import RowAction
|
||||||
|
|
||||||
|
|
|
@ -1,5 +0,0 @@
|
||||||
from django.contrib.sites.shortcuts import get_current_site
|
|
||||||
|
|
||||||
|
|
||||||
def current_site(request):
|
|
||||||
return {"site": get_current_site(request)}
|
|
|
@ -81,7 +81,6 @@ TEMPLATES = [
|
||||||
"django.template.context_processors.request",
|
"django.template.context_processors.request",
|
||||||
"django.contrib.auth.context_processors.auth",
|
"django.contrib.auth.context_processors.auth",
|
||||||
"django.contrib.messages.context_processors.messages",
|
"django.contrib.messages.context_processors.messages",
|
||||||
"project.context_processors.current_site",
|
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
|
@ -1,14 +1,16 @@
|
||||||
import contextlib
|
import contextlib
|
||||||
from dataclasses import dataclass
|
from dataclasses import dataclass
|
||||||
|
from typing import Any
|
||||||
|
|
||||||
|
from django.contrib.sites.shortcuts import get_current_site
|
||||||
from django.core.exceptions import FieldError
|
from django.core.exceptions import FieldError
|
||||||
from django.core.paginator import Paginator
|
from django.core.paginator import Paginator
|
||||||
from django.db.models import Model
|
from django.db.models import Model
|
||||||
from django.http import HttpRequest
|
from django.http import HttpRequest
|
||||||
from django.http import HttpResponse
|
from django.http import HttpResponse
|
||||||
from django.shortcuts import render
|
|
||||||
from django.urls import reverse
|
from django.urls import reverse
|
||||||
from zen_queries import queries_disabled
|
from zen_queries import queries_disabled
|
||||||
|
from zen_queries import render as zen_queries_render
|
||||||
|
|
||||||
|
|
||||||
@dataclass
|
@dataclass
|
||||||
|
@ -98,3 +100,20 @@ def render_list(
|
||||||
template_name="utils/list.html",
|
template_name="utils/list.html",
|
||||||
context=context,
|
context=context,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def base_context(request: HttpRequest) -> dict[str, Any]:
|
||||||
|
"""
|
||||||
|
Return a base context for all views.
|
||||||
|
"""
|
||||||
|
return {"site": get_current_site(request)}
|
||||||
|
|
||||||
|
|
||||||
|
def render(request, template_name, context=None):
|
||||||
|
"""
|
||||||
|
Render a template with a base context.
|
||||||
|
"""
|
||||||
|
if context is None:
|
||||||
|
context = {}
|
||||||
|
context = base_context(request) | context
|
||||||
|
return zen_queries_render(request, template_name, context)
|
||||||
|
|
Loading…
Reference in a new issue