diff --git a/aircox/templates/aircox/dashboard/user_list.html b/aircox/templates/aircox/dashboard/user_list.html index 8bc79f5..ba7faf0 100644 --- a/aircox/templates/aircox/dashboard/user_list.html +++ b/aircox/templates/aircox/dashboard/user_list.html @@ -6,6 +6,14 @@ {% block content-container %}
{% trans "User" %} | @@ -24,7 +32,7 @@
{% for p in obj.programs %}
- {{ p.title }}
+ {{ p.title }}
{% if not forloop.last %}
{% endif %} diff --git a/aircox/templates/aircox/dashboard/widgets/user_groups.html b/aircox/templates/aircox/dashboard/widgets/user_groups.html index e4a87a0..4835d14 100644 --- a/aircox/templates/aircox/dashboard/widgets/user_groups.html +++ b/aircox/templates/aircox/dashboard/widgets/user_groups.html @@ -23,7 +23,7 @@ - diff --git a/aircox/templates/aircox/program_form.html b/aircox/templates/aircox/program_form.html index a36fe44..bcb0c00 100644 --- a/aircox/templates/aircox/program_form.html +++ b/aircox/templates/aircox/program_form.html @@ -12,7 +12,15 @@ class="button secondary" @click="$refs['group-users-modal'].open({id: {{ object.editors_group_id }}, name: '{{ object.editors_group.name }}' })">{% translate "Editors" %} -{% include "./dashboard/widgets/group_users.html" %} {{ block.super }} {% endif %} {% endblock %} + +{% block main %} +{{ block.super }} + +{% if object and object.pk and request.user.is_superuser %} +{% include "./dashboard/widgets/group_users.html" %} +{% endif %} + +{% endblock %} diff --git a/aircox/templates/aircox/widgets/page_actions.html b/aircox/templates/aircox/widgets/page_actions.html index fd07f4e..6b5a22e 100644 --- a/aircox/templates/aircox/widgets/page_actions.html +++ b/aircox/templates/aircox/widgets/page_actions.html @@ -1,7 +1,6 @@ {% 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 %} {{ object.get_status_display }} @@ -30,4 +29,5 @@ {% endif %} {% endwith %} {% endif %} + {% endblock %} diff --git a/aircox/views/episode.py b/aircox/views/episode.py index 871ba98..bbe0be6 100644 --- a/aircox/views/episode.py +++ b/aircox/views/episode.py @@ -19,6 +19,9 @@ __all__ = ( class EpisodeDetailView(PageDetailView): model = Episode + def can_edit(self, obj): + return permissions.program.can(self.request.user, "update", obj) + def get_context_data(self, **kwargs): if "tracks" not in kwargs: kwargs["tracks"] = self.object.track_set.order_by("position") diff --git a/aircox/views/page.py b/aircox/views/page.py index de804d6..9e68ff8 100644 --- a/aircox/views/page.py +++ b/aircox/views/page.py @@ -98,7 +98,7 @@ class BasePageListView(AttachedToMixin, BasePageMixin, ParentMixin, BaseView, Li class BasePageDetailView(BasePageMixin, BaseView, DetailView): """Base view class for BasePage.""" - template_name = "aircox/basepage_detail.html" + template_name = "aircox/public.html" context_object_name = "page" def get_context_data(self, **kwargs): @@ -162,6 +162,10 @@ class PageDetailView(BasePageDetailView): template_name = None context_object_name = "page" + def can_edit(self, object): + """Return True if user can edit current page.""" + return False + def get_template_names(self): return super().get_template_names() + ["aircox/page_detail.html"] @@ -181,6 +185,7 @@ class PageDetailView(BasePageDetailView): if related: related = related[: self.related_count] kwargs["related_objects"] = related + kwargs["can_edit"] = self.can_edit(self.object) return super().get_context_data(**kwargs) def get_comment_form(self): diff --git a/aircox/views/program.py b/aircox/views/program.py index 0da995b..5b8882e 100644 --- a/aircox/views/program.py +++ b/aircox/views/program.py @@ -19,6 +19,9 @@ __all__ = ( class ProgramDetailView(page.PageDetailView): model = models.Program + def can_edit(self, obj): + return permissions.program.can(self.request.user, "update", obj) + def get_related_queryset(self): queryset = ( self.get_queryset() |