Skip to content
Snippets Groups Projects
Verified Commit 691131e7 authored by Jonathan Weth's avatar Jonathan Weth :keyboard:
Browse files

Add view for editing posters

parent a6400c89
No related branches found
No related tags found
1 merge request!14Resolve "Not mensa-specific"
Pipeline #22074 passed
# Generated by Django 3.2.5 on 2021-07-14 10:49
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
('resint', '0003_group_in_unique_constraint'),
]
operations = [
migrations.AlterModelOptions(
name='postergroup',
options={'permissions': [('view_poster_of_group', 'Can view all posters of this group'), ('upload_poster_to_group', 'Can upload new posters to this group'), ('change_poster_to_group', 'Can change all posters of this group'), ('delete_poster_of_group', 'Can delete all posters of this group')], 'verbose_name': 'Poster group', 'verbose_name_plural': 'Poster groups'},
),
]
......@@ -44,6 +44,7 @@ class PosterGroup(ExtensibleModel):
permissions = [
("view_poster_of_group", _("Can view all posters of this group")),
("upload_poster_to_group", _("Can upload new posters to this group")),
("change_poster_to_group", _("Can change all posters of this group")),
("delete_poster_of_group", _("Can delete all posters of this group")),
]
......
{% extends 'core/base.html' %}
{% load material_form i18n %}
{% block page_title %}
{% trans "Edit poster" %}
{% endblock %}
{% block browser_title %}
{% trans "Edit poster" %}
{% endblock %}
{% block content %}
<form method="post" enctype="multipart/form-data">
{% csrf_token %}
{% form form=form %}{% endform %}
{% include "core/partials/save_button.html" %}
</form>
{% endblock %}
......@@ -3,6 +3,7 @@ from django.urls import path
from .views import (
PosterCurrentView,
PosterDeleteView,
PosterEditView,
PosterGroupCreateView,
PosterGroupDeleteView,
PosterGroupEditView,
......@@ -14,6 +15,7 @@ from .views import (
urlpatterns = [
path("", PosterListView.as_view(), name="poster_index"),
path("upload/", PosterUploadView.as_view(), name="poster_upload"),
path("<int:pk>/edit/", PosterEditView.as_view(), name="poster_edit"),
path("<int:pk>/delete/", PosterDeleteView.as_view(), name="poster_delete"),
path("<str:slug>.pdf", PosterCurrentView.as_view(), name="poster_show_current"),
path("groups/", PosterGroupListView.as_view(), name="poster_group_list"),
......
......@@ -98,6 +98,23 @@ class PosterUploadView(PermissionRequiredMixin, AdvancedCreateView):
form_class = PosterUploadForm
permission_required = "resint.upload_poster_rule"
def get_form_kwargs(self) -> Dict[str, Any]:
return {"request": self.request}
class PosterEditView(PermissionRequiredMixin, AdvancedEditView):
"""Edit an uploaded poster."""
model = Poster
success_url = reverse_lazy("poster_index")
template_name = "resint/poster/edit.html"
success_message = _("The poster has been changed.")
form_class = PosterUploadForm
permission_required = "resint.edit_poster_rule"
def get_form_kwargs(self) -> Dict[str, Any]:
return {"request": self.request}
class PosterDeleteView(PermissionRequiredMixin, AdvancedDeleteView):
"""Delete an uploaded poster."""
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment