manager: basic views to create/list/edit pages

This commit is contained in:
Frédéric Péters 2014-12-07 16:03:47 +01:00
parent a5c9062229
commit 4628509fd4
11 changed files with 138 additions and 2 deletions

View File

@ -0,0 +1,6 @@
{% extends "gadjo/base.html" %}
{% block page-title %}Combo{% endblock %}
{% block site-title %}Combo{% endblock %}
{% block footer %}Combo — Copyright © Entr'ouvert{% endblock %}

View File

@ -0,0 +1,7 @@
{% extends "combo/manager_base.html" %}
{% block content %}
<a href="{% url 'combo-manager-pages-list' %}">Pages</a>
{% endblock %}

View File

@ -0,0 +1,18 @@
{% extends "combo/manager_base.html" %}
{% load i18n %}
{% block content %}
<form method="post" enctype="multipart/form-data">
{% csrf_token %}
{{ form.as_p }}
<div class="buttons">
<button>{% trans "Save" %}</button>
{% if object.id %}
<a class="cancel" href="{{ object.get_absolute_url }}">{% trans 'Cancel' %}</a>
{% else %}
<a class="cancel" href="{% url 'combo-manager-pages-list' %}">{% trans 'Cancel' %}</a>
{% endif %}
</div>
</form>
{% endblock %}

View File

@ -0,0 +1,10 @@
{% extends "combo/manager_base.html" %}
{% load i18n %}
{% block appbar %}
<h2>Page - {{ object.title }}</h2>
{% endblock %}
{% block content %}
{% endblock %}

View File

@ -0,0 +1,13 @@
{% extends "combo/manager_base.html" %}
{% block content %}
<ul>
{% for page in object_list %}
<li><a href="{% url 'combo-manager-page-view' pk=page.id %}">{{ page.title }}</a></li>
{% endfor %}
</ul>
<a href="{% url 'combo-manager-page-add' %}">+</a>
{% endblock %}

28
combo/manager/urls.py Normal file
View File

@ -0,0 +1,28 @@
# combo - content management system
# Copyright (C) 2014 Entr'ouvert
#
# This program is free software: you can redistribute it and/or modify it
# under the terms of the GNU Affero General Public License as published
# by the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
from django.conf.urls import patterns, url, include
from . import views
urlpatterns = patterns('combo.views',
url(r'^$', views.homepage, name='combo-manager-homepage'),
url(r'^pages/$', views.pages_list, name='combo-manager-pages-list'),
url(r'^pages/add/$', views.page_add, name='combo-manager-page-add'),
url(r'^pages/(?P<pk>\w+)/$', views.page_view,
name='combo-manager-page-view'),
)

View File

@ -1,3 +1,46 @@
from django.shortcuts import render
# combo - content management system
# Copyright (C) 2014 Entr'ouvert
#
# This program is free software: you can redistribute it and/or modify it
# under the terms of the GNU Affero General Public License as published
# by the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# Create your views here.
from django.views.generic import TemplateView, DetailView, CreateView, ListView
from combo.data.models import Page
class HomepageView(TemplateView):
template_name = 'combo/manager_home.html'
homepage = HomepageView.as_view()
class PagesListView(ListView):
model = Page
template_name = 'combo/pages_list.html'
pages_list = PagesListView.as_view()
class PageAddView(CreateView):
model = Page
template_name = 'combo/page_add.html'
page_add = PageAddView.as_view()
class PageView(DetailView):
model = Page
template_name = 'combo/page_view.html'
page_view = PageView.as_view()

View File

@ -37,7 +37,9 @@ INSTALLED_APPS = (
'django.contrib.messages',
'django.contrib.staticfiles',
'ckeditor',
'gadjo',
'combo.data',
'combo.manager',
)
MIDDLEWARE_CLASSES = (
@ -49,6 +51,12 @@ MIDDLEWARE_CLASSES = (
'django.middleware.clickjacking.XFrameOptionsMiddleware',
)
# Serve xstatic files, required for gadjo
from django.conf import global_settings
STATICFILES_FINDERS = global_settings.STATICFILES_FINDERS + \
('gadjo.finders.XStaticFinder',)
ROOT_URLCONF = 'combo.urls'
WSGI_APPLICATION = 'combo.wsgi.application'

View File

@ -1,4 +1,5 @@
from django.conf.urls import patterns, include, url
urlpatterns = patterns('',
url(r'^manage/', include('combo.manager.urls')),
)

View File

@ -1,2 +1,3 @@
Django==1.6
django-ckeditor
-e git+http://repos.entrouvert.org/gadjo.git/#egg=gadjo

View File

@ -59,6 +59,7 @@ setup(
],
install_requires=['django == 1.6',
'django-ckeditor',
'gadjo',
],
zip_safe=False,
)