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

Add detail view and snippet for rendering seat plans

parent 100a6d03
No related branches found
No related tags found
1 merge request!2Views
......@@ -8,7 +8,7 @@ class SeatingPlanTable(tables.Table):
class Meta:
attrs = {"class": "highlight"}
name = tables.LinkColumn("edit_seating_plan", accessor=A("pk"), args=[A("id")])
name = tables.LinkColumn("seating_plan", accessor=A("pk"), args=[A("id")])
edit = tables.LinkColumn(
"edit_seating_plan",
args=[A("id")],
......
......@@ -4,7 +4,13 @@
{% load material_form i18n any_js static %}
{% block browser_title %}{% blocktrans %}Edit seating plan{% endblocktrans %}{% endblock %}
{% block page_title %}{% blocktrans %}Edit seating plan{% endblocktrans %}{% endblock %}
{% block page_title %}
<a href="{% url "seating_plans" %}"
class="btn-flat primary-color-text waves-light waves-effect">
<i class="material-icons left">chevron_left</i> {% trans "Back" %}
</a>
{% blocktrans %}Edit seating plan{% endblocktrans %}
{% endblock %}
{% block extra_head %}
{{ form.media.css }}
......
<div class="row card grey lighten-4 seats">
<div class="card-content">
<div class="seat-grid">
{% for x, x_items in seating_plan.get_all_seats.build_grid.items %}
<div class="seat-grid-col">
{% for y, seat in x_items.items %}
<div class="seat-grid-cell">
{% if seat %}
{% include "stoelindeling/partials/seat.html" with seat=seat %}
{% endif %}
</div>
{% endfor %}
</div>
{% endfor %}
</div>
</div>
</div>
{# -*- engine:django -*- #}
{% extends "core/base.html" %}
{% load material_form i18n any_js %}
{% load i18n static %}
{% block browser_title %}{% blocktrans %}Edit seating plan{% endblocktrans %}{% endblock %}
{% block page_title %}{% blocktrans %}Edit seating plan{% endblocktrans %}{% endblock %}
{% block browser_title %}{% blocktrans %}Seating plan{% endblocktrans %}{% endblock %}
{% block page_title %}
<a href="{% url "seating_plans" %}"
class="btn-flat primary-color-text waves-light waves-effect">
<i class="material-icons left">chevron_left</i> {% trans "Back" %}
</a>
{% blocktrans with plan=object %}Seating plan: {{ plan }}{% endblocktrans %}
{% endblock %}
{% block extra_head %}
{{ form.media.css }}
{% include_css "select2-materialize" %}
<link rel="stylesheet" href="{% static "css/stoelindeling/seating_plan.css" %}">
{% endblock %}
{% block content %}
<form method="post">
{% csrf_token %}
{% form form=form %}{% endform %}
{% include "core/partials/save_button.html" %}
</form>
{% include_js "select2-materialize" %}
{{ form.media.js }}
<a class="btn waves-effect waves-light orange margin-bottom" href="{% url "edit_seating_plan" object.pk %}">
<i class="material-icons left iconify" data-icon="mdi:pencil-outline"></i>
{% trans "Edit" %}
</a>
<a class="btn waves-effect waves-light red margin-bottom" href="{% url "delete_seating_plan" object.pk %}">
<i class="material-icons left iconify" data-icon="mdi:delete-outline"></i>
{% trans "Delete" %}
</a>
{% include "stoelindeling/seating_plan/render.html" with seating_plan=object %}
{% endblock %}
......@@ -9,6 +9,11 @@ urlpatterns = [
views.SeatingPlanCreateView.as_view(),
name="create_seating_plan",
),
path(
"seating_plans/<int:pk>/",
views.SeatingPlanDetailView.as_view(),
name="seating_plan",
),
path(
"seating_plans/<int:pk>/edit/",
views.SeatingPlanEditView.as_view(),
......
......@@ -4,6 +4,7 @@ from django.urls import reverse_lazy
from django.utils.decorators import method_decorator
from django.utils.translation import gettext as _
from django.views.decorators.cache import never_cache
from django.views.generic import DetailView
from django_tables2 import SingleTableView
from reversion.views import RevisionMixin
......@@ -25,6 +26,14 @@ class SeatingPlanListView(PermissionRequiredMixin, SingleTableView):
template_name = "stoelindeling/seating_plan/list.html"
class SeatingPlanDetailView(PermissionRequiredMixin, DetailView):
"""Table of all seating plans."""
model = SeatingPlan
permission_required = "stoelindeling.view_seatingplan_rule"
template_name = "stoelindeling/seating_plan/view.html"
@method_decorator(never_cache, name="dispatch")
class SeatingPlanCreateView(PermissionRequiredMixin, AdvancedCreateView):
"""Create view for seating plans."""
......
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