type hinting

This commit is contained in:
Laura Klünder 2017-07-14 15:32:14 +02:00
parent e264df3bf3
commit e847ce9fe6
2 changed files with 20 additions and 1 deletions

View file

@ -0,0 +1,17 @@
{% load bootstrap3 %}
{% load i18n %}
{% include 'editor/fragment_levels.html' %}
<h3>{{ space.title }}</h3>
<p>
<a class="btn btn-default btn-xs" accesskey="e" href="{% url 'editor.spaces.edit' level=space.level.pk pk=space.pk %}">
{% trans 'Space' as model_title %}
<i class="glyphicon glyphicon-pencil"></i> {% blocktrans %}Edit {{ model_title }}{% endblocktrans %}
</a>
</p>
<p>
<a href="{% url 'editor.spaces.list' level=space.level.pk %}">&laquo; {% trans 'back to overview' %}</a>
</p>
{% bootstrap_messages %}
{% include 'editor/fragment_child_models.html' %}

View file

@ -1,7 +1,9 @@
import typing
from contextlib import suppress
from django.contrib import messages
from django.core.exceptions import FieldDoesNotExist, ObjectDoesNotExist
from django.db import models
from django.shortcuts import get_object_or_404, redirect, render
from django.urls import reverse
from django.utils.translation import ugettext_lazy as _
@ -9,7 +11,7 @@ from django.utils.translation import ugettext_lazy as _
from c3nav.editor.views.base import sidebar_view
def child_model(request, model, kwargs=None, parent=None):
def child_model(request, model: typing.Union[str, models.Model], kwargs=None, parent=None):
model = request.changeset.wrap_model(model)
related_name = model._meta.default_related_name
if parent is not None: