fix rendering

This commit is contained in:
bkfox 2024-04-27 21:36:24 +02:00
parent 8f1ec9cbc1
commit 919cb06da8
7 changed files with 33 additions and 6 deletions

View File

@ -6,6 +6,14 @@
{% block content-container %} {% block content-container %}
<div class="container"> <div class="container">
{% if user.is_superuser %}
<div class="message is-info mt-3">
<div class="message-body">
{% translate "Group and editors' changes will be visible only after page reload." %}
</div>
</div>
{% endif %}
<table class="table is-stripped is-fullwidth"> <table class="table is-stripped is-fullwidth">
<thead> <thead>
<td>{% trans "User" %}</td> <td>{% trans "User" %}</td>
@ -24,7 +32,7 @@
</td> </td>
<td> <td>
{% for p in obj.programs %} {% for p in obj.programs %}
<a href="{% url "program-edit" p.pk %}">{{ p.title }}</a> <a href="{{ p.get_absolute_url }}">{{ p.title }}</a>
{% if not forloop.last %} {% if not forloop.last %}
<br/> <br/>
{% endif %} {% endif %}

View File

@ -23,7 +23,7 @@
</a-many-to-many-edit> </a-many-to-many-edit>
</template> </template>
<template #footer="{item, close}"> <template #footer="{item, close}">
<button type="button" class="button" @click="$refs['group-users'].save(); close()"> <button type="button" class="button" @click="$refs['user-groups'].save(); close()">
Save Save
</button> </button>
</template> </template>

View File

@ -12,7 +12,15 @@
class="button secondary" class="button secondary"
@click="$refs['group-users-modal'].open({id: {{ object.editors_group_id }}, name: '{{ object.editors_group.name }}' })">{% translate "Editors" %}</button> @click="$refs['group-users-modal'].open({id: {{ object.editors_group_id }}, name: '{{ object.editors_group.name }}' })">{% translate "Editors" %}</button>
{% include "./dashboard/widgets/group_users.html" %}
{{ block.super }} {{ block.super }}
{% endif %} {% endif %}
{% endblock %} {% endblock %}
{% block main %}
{{ block.super }}
{% if object and object.pk and request.user.is_superuser %}
{% include "./dashboard/widgets/group_users.html" %}
{% endif %}
{% endblock %}

View File

@ -1,7 +1,6 @@
{% load aircox i18n %} {% load aircox i18n %}
{% block user-actions-container %}
{% has_obj_perm page page.program.change_permission_codename simple=True as can_edit %}
{% block user-actions-container %}
{% if user.is_authenticated %} {% if user.is_authenticated %}
{{ object.get_status_display }} {{ object.get_status_display }}
@ -30,4 +29,5 @@
{% endif %} {% endif %}
{% endwith %} {% endwith %}
{% endif %} {% endif %}
{% endblock %} {% endblock %}

View File

@ -19,6 +19,9 @@ __all__ = (
class EpisodeDetailView(PageDetailView): class EpisodeDetailView(PageDetailView):
model = Episode model = Episode
def can_edit(self, obj):
return permissions.program.can(self.request.user, "update", obj)
def get_context_data(self, **kwargs): def get_context_data(self, **kwargs):
if "tracks" not in kwargs: if "tracks" not in kwargs:
kwargs["tracks"] = self.object.track_set.order_by("position") kwargs["tracks"] = self.object.track_set.order_by("position")

View File

@ -98,7 +98,7 @@ class BasePageListView(AttachedToMixin, BasePageMixin, ParentMixin, BaseView, Li
class BasePageDetailView(BasePageMixin, BaseView, DetailView): class BasePageDetailView(BasePageMixin, BaseView, DetailView):
"""Base view class for BasePage.""" """Base view class for BasePage."""
template_name = "aircox/basepage_detail.html" template_name = "aircox/public.html"
context_object_name = "page" context_object_name = "page"
def get_context_data(self, **kwargs): def get_context_data(self, **kwargs):
@ -162,6 +162,10 @@ class PageDetailView(BasePageDetailView):
template_name = None template_name = None
context_object_name = "page" context_object_name = "page"
def can_edit(self, object):
"""Return True if user can edit current page."""
return False
def get_template_names(self): def get_template_names(self):
return super().get_template_names() + ["aircox/page_detail.html"] return super().get_template_names() + ["aircox/page_detail.html"]
@ -181,6 +185,7 @@ class PageDetailView(BasePageDetailView):
if related: if related:
related = related[: self.related_count] related = related[: self.related_count]
kwargs["related_objects"] = related kwargs["related_objects"] = related
kwargs["can_edit"] = self.can_edit(self.object)
return super().get_context_data(**kwargs) return super().get_context_data(**kwargs)
def get_comment_form(self): def get_comment_form(self):

View File

@ -19,6 +19,9 @@ __all__ = (
class ProgramDetailView(page.PageDetailView): class ProgramDetailView(page.PageDetailView):
model = models.Program model = models.Program
def can_edit(self, obj):
return permissions.program.can(self.request.user, "update", obj)
def get_related_queryset(self): def get_related_queryset(self):
queryset = ( queryset = (
self.get_queryset() self.get_queryset()