Plna podpora "statickych stranek" (vcetne '/') - flatpages
This commit is contained in:
parent
181fce9df5
commit
e5f95d5bda
6 changed files with 52 additions and 8 deletions
24
mamweb/admin.py
Normal file
24
mamweb/admin.py
Normal file
|
@ -0,0 +1,24 @@
|
||||||
|
from django.contrib import admin
|
||||||
|
from django.contrib.flatpages.models import FlatPage
|
||||||
|
|
||||||
|
# Note: we are renaming the original Admin and Form as we import them!
|
||||||
|
from django.contrib.flatpages.admin import FlatPageAdmin as FlatPageAdminOld
|
||||||
|
from django.contrib.flatpages.admin import FlatpageForm as FlatpageFormOld
|
||||||
|
|
||||||
|
from django import forms
|
||||||
|
from ckeditor.widgets import CKEditorWidget
|
||||||
|
|
||||||
|
class FlatpageForm(FlatpageFormOld):
|
||||||
|
content = forms.CharField(widget=CKEditorWidget())
|
||||||
|
class Meta:
|
||||||
|
model = FlatPage # this is not automatically inherited from FlatpageFormOld
|
||||||
|
exclude = []
|
||||||
|
|
||||||
|
|
||||||
|
class FlatPageAdmin(FlatPageAdminOld):
|
||||||
|
form = FlatpageForm
|
||||||
|
|
||||||
|
|
||||||
|
# We have to unregister the normal admin, and then reregister ours
|
||||||
|
admin.site.unregister(FlatPage)
|
||||||
|
admin.site.register(FlatPage, FlatPageAdmin)
|
|
@ -64,6 +64,7 @@ MIDDLEWARE_CLASSES = (
|
||||||
'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
|
'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
|
||||||
'django.contrib.messages.middleware.MessageMiddleware',
|
'django.contrib.messages.middleware.MessageMiddleware',
|
||||||
'django.middleware.clickjacking.XFrameOptionsMiddleware',
|
'django.middleware.clickjacking.XFrameOptionsMiddleware',
|
||||||
|
'django.contrib.flatpages.middleware.FlatpageFallbackMiddleware',
|
||||||
)
|
)
|
||||||
|
|
||||||
TEMPLATE_CONTEXT_PROCESSORS = (
|
TEMPLATE_CONTEXT_PROCESSORS = (
|
||||||
|
@ -104,6 +105,8 @@ INSTALLED_APPS = (
|
||||||
'threadedcomments',
|
'threadedcomments',
|
||||||
'django_comments',
|
'django_comments',
|
||||||
|
|
||||||
|
'django.contrib.flatpages',
|
||||||
|
|
||||||
# MaMweb
|
# MaMweb
|
||||||
'mamweb',
|
'mamweb',
|
||||||
'seminar',
|
'seminar',
|
||||||
|
@ -117,7 +120,6 @@ INSTALLED_APPS = (
|
||||||
# 'admin_tools.menu',
|
# 'admin_tools.menu',
|
||||||
# 'admin_tools.dashboard',
|
# 'admin_tools.dashboard',
|
||||||
'flat',
|
'flat',
|
||||||
|
|
||||||
'django.contrib.admin',
|
'django.contrib.admin',
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -21,8 +21,12 @@
|
||||||
<!-- TODO: only on org login -->
|
<!-- TODO: only on org login -->
|
||||||
<div class="login-bar" style='background: #F80;'>
|
<div class="login-bar" style='background: #F80;'>
|
||||||
{% if view.object %}
|
{% if view.object %}
|
||||||
Objekt {{ view.object }}: {{ view.object }}
|
Objekt {{ view.object }}: {{ view.object }}
|
||||||
{% if view.object.admin_url %}<a href='{{ view.object.admin_url }}'>[admin]</a>{% endif %}
|
{% if view.object.admin_url %}<a href='{{ view.object.admin_url }}'>[admin]</a>{% endif %}
|
||||||
|
{% endif %}
|
||||||
|
{% if flatpage %}
|
||||||
|
Stránka <tt>{{ flatpage.url }}</tt> ({{ flatpage.title }})
|
||||||
|
<a href='{% url 'admin:flatpages_flatpage_change' flatpage.id %}'>[admin]</a>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
<div class="container">
|
<div class="container">
|
||||||
|
|
11
mamweb/templates/flatpages/default.html
Normal file
11
mamweb/templates/flatpages/default.html
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
{% extends "base.html" %}
|
||||||
|
|
||||||
|
{% block title %}{{ flatpage.title }}{% endblock title %}
|
||||||
|
|
||||||
|
{% block content %}
|
||||||
|
<h2>{{ flatpage.title }}</h2>
|
||||||
|
<div>
|
||||||
|
{{ flatpage.content }}
|
||||||
|
</div>
|
||||||
|
{% endblock content %}
|
||||||
|
|
|
@ -1,9 +1,13 @@
|
||||||
{% extends "base.html" %}
|
{% extends "base.html" %}
|
||||||
|
|
||||||
|
{% block title %}{{ flatpage.title }}{% endblock title %}
|
||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
<div>
|
<div>Toto je stránka podle šablony "home.html"</div>
|
||||||
<h2>Vítejte na testwebu MaM!</h2>
|
|
||||||
<p><a href='{% url 'admin:index' %}'>Administrátorské rozhraní</a> (admin/admin)
|
<p><a href='{% url 'admin:index' %}'>Administrátorské rozhraní</a> (admin/admin)
|
||||||
|
<h2>{{ flatpage.title }}</h2>
|
||||||
|
<div>
|
||||||
|
{{ flatpage.content }}
|
||||||
</div>
|
</div>
|
||||||
{% endblock content %}
|
{% endblock content %}
|
||||||
|
|
||||||
|
|
|
@ -19,9 +19,8 @@ urlpatterns = i18n_patterns('',
|
||||||
url(r'^comments_dj/', include('django_comments.urls')),
|
url(r'^comments_dj/', include('django_comments.urls')),
|
||||||
url(r'^comments_fl/', include('fluent_comments.urls')),
|
url(r'^comments_fl/', include('fluent_comments.urls')),
|
||||||
|
|
||||||
# Obsah
|
# Obsah - flatpages
|
||||||
url(r'^$', TemplateView.as_view(template_name='home.html'), name='home'),
|
url(r'^', include('django.contrib.flatpages.urls')), # Pozor: musi byt posledni
|
||||||
|
|
||||||
)
|
)
|
||||||
|
|
||||||
# This is only needed when using runserver.
|
# This is only needed when using runserver.
|
||||||
|
|
Loading…
Reference in a new issue