Browse Source

Plna podpora "statickych stranek" (vcetne '/') - flatpages

remotes/origin/feincms deploy-prod-2015-05-27-01-11-gavento
Tomas Gavenciak 10 years ago
parent
commit
e5f95d5bda
  1. 24
      mamweb/admin.py
  2. 4
      mamweb/settings_common.py
  3. 8
      mamweb/templates/base.html
  4. 11
      mamweb/templates/flatpages/default.html
  5. 8
      mamweb/templates/home.html
  6. 5
      mamweb/urls.py

24
mamweb/admin.py

@ -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)

4
mamweb/settings_common.py

@ -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',
) )

8
mamweb/templates/base.html

@ -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

@ -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 %}

8
mamweb/templates/home.html

@ -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 %}

5
mamweb/urls.py

@ -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…
Cancel
Save