kopia lustrzana https://github.com/rtts/django-simplecms
rodzic
774e9e7379
commit
045b05a337
|
@ -3,6 +3,7 @@ import swapper
|
|||
from django.db import models
|
||||
from django.urls import reverse
|
||||
from django.forms import TextInput, Select
|
||||
from django.utils.text import slugify
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
from embed_video.fields import EmbedVideoField
|
||||
from polymorphic.models import PolymorphicModel
|
||||
|
@ -101,6 +102,9 @@ class BaseSection(Numbered, PolymorphicModel):
|
|||
def number_with_respect_to(self):
|
||||
return self.page.sections.all()
|
||||
|
||||
def get_absolute_url(self):
|
||||
return self.page.get_absolute_url() + '#' + slugify(self.title)
|
||||
|
||||
def __str__(self):
|
||||
if not self.pk:
|
||||
return str(_('New section'))
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
|
||||
{% block content %}
|
||||
{% for section in sections %}
|
||||
<div id="{{section.title|slugify}}"></div>
|
||||
{% include_section section %}
|
||||
{% endfor %}
|
||||
|
||||
|
|
|
@ -224,7 +224,7 @@ class EditSection(UserPassesTestMixin, edit.ModelFormMixin, base.TemplateRespons
|
|||
if form.is_valid():
|
||||
section = form.save()
|
||||
if section:
|
||||
return HttpResponseRedirect(section.page.get_absolute_url())
|
||||
return HttpResponseRedirect(section.get_absolute_url())
|
||||
elif self.page.sections.exists():
|
||||
return HttpResponseRedirect(self.page.get_absolute_url())
|
||||
else:
|
||||
|
|
Ładowanie…
Reference in New Issue