forked from data.coop/membersystem
Small adjustments.
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,28 +11,29 @@
|
||||||
|
|
||||||
<h3>{% trans "Membership" %}</h3>
|
<h3>{% trans "Membership" %}</h3>
|
||||||
|
|
||||||
<table class="table">
|
{% if subscription_periods %}
|
||||||
<thead>
|
<table class="table">
|
||||||
<tr>
|
<thead>
|
||||||
<th>{% trans "Start" %}</th>
|
<tr>
|
||||||
<th>{% trans "End" %}</th>
|
<th>{% trans "Start" %}</th>
|
||||||
<th>{% trans "Has membership" %}</th>
|
<th>{% trans "End" %}</th>
|
||||||
<th>{% trans "Actions" %}</th>
|
<th>{% trans "Has membership" %}</th>
|
||||||
</tr>
|
<th>{% trans "Actions" %}</th>
|
||||||
</thead>
|
|
||||||
<tbody>
|
|
||||||
{% for period in subscription_periods %}
|
|
||||||
<tr {% if not period.period.upper %}class="table-active"{% endif %}>
|
|
||||||
<td>{{ period.period.lower }}</td>
|
|
||||||
<td>{{ period.period.upper }}</td>
|
|
||||||
<td>{{ period.membership_exists }}</td>
|
|
||||||
<td></td>
|
|
||||||
</tr>
|
</tr>
|
||||||
{% endfor %}
|
</thead>
|
||||||
</tbody>
|
<tbody>
|
||||||
</table>
|
{% for period in subscription_periods %}
|
||||||
|
<tr {% if not period.period.upper %}class="table-active"{% endif %}>
|
||||||
|
<td>{{ period.period.lower }}</td>
|
||||||
|
<td>{{ period.period.upper }}</td>
|
||||||
|
<td>{{ period.membership_exists }}</td>
|
||||||
|
<td></td>
|
||||||
|
</tr>
|
||||||
|
{% endfor %}
|
||||||
|
</tbody>
|
||||||
|
</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