diff --git a/requirements.txt b/requirements.txt
index fc38151..0017216 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -1,3 +1,4 @@
Django>=1.7
gadjo
django-select2
+django-ckeditor
diff --git a/setup.py b/setup.py
index 9ba4b56..0c87733 100644
--- a/setup.py
+++ b/setup.py
@@ -100,6 +100,7 @@ setup(
install_requires=['django>=1.7',
'gadjo',
'django-select2',
+ 'django-ckeditor',
],
zip_safe=False,
cmdclass={
diff --git a/welco/kb/__init__.py b/welco/kb/__init__.py
new file mode 100644
index 0000000..e69de29
diff --git a/welco/kb/models.py b/welco/kb/models.py
new file mode 100644
index 0000000..50cc400
--- /dev/null
+++ b/welco/kb/models.py
@@ -0,0 +1,33 @@
+# welco - multichannel request processing
+# Copyright (C) 2015 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 .
+
+from django.core.urlresolvers import reverse
+from django.db import models
+from django.utils.translation import ugettext_lazy as _
+
+from ckeditor.fields import RichTextField
+
+
+class Page(models.Model):
+ title = models.CharField(_('Title'), max_length=200)
+ slug = models.SlugField(_('Slug'))
+ content = RichTextField(_('Text'))
+
+ class Meta:
+ ordering = ['title']
+
+ def get_absolute_url(self):
+ return reverse('kb-page-view', kwargs={'slug': self.slug})
diff --git a/welco/kb/templates/kb/base.html b/welco/kb/templates/kb/base.html
new file mode 100644
index 0000000..ee04560
--- /dev/null
+++ b/welco/kb/templates/kb/base.html
@@ -0,0 +1,13 @@
+{% extends "welco/base.html" %}
+{% load i18n static %}
+
+{% block breadcrumb %}
+{{ block.super }}
+{% trans 'Knowledge Base' %}
+{% endblock %}
+
+{% block extrascripts %}
+{{ block.super }}
+
+
+{% endblock %}
diff --git a/welco/kb/templates/kb/page_confirm_delete.html b/welco/kb/templates/kb/page_confirm_delete.html
new file mode 100644
index 0000000..1d23987
--- /dev/null
+++ b/welco/kb/templates/kb/page_confirm_delete.html
@@ -0,0 +1,17 @@
+{% extends "kb/base.html" %}
+{% load i18n %}
+
+{% block appbar %}
+
{{ view.model.get_verbose_name }}
+{% endblock %}
+
+{% block content %}
+
+{% endblock %}
diff --git a/welco/kb/templates/kb/page_detail.html b/welco/kb/templates/kb/page_detail.html
new file mode 100644
index 0000000..5aa47f1
--- /dev/null
+++ b/welco/kb/templates/kb/page_detail.html
@@ -0,0 +1,14 @@
+{% extends "kb/base.html" %}
+{% load i18n %}
+
+{% block appbar %}
+{% trans 'Knowledge Base' %} - {{ object.title }}
+{% trans 'Delete' %}
+{% trans 'Edit' %}
+{% endblock %}
+
+{% block content %}
+
+{{ object.content|safe }}
+
+{% endblock %}
diff --git a/welco/kb/templates/kb/page_form.html b/welco/kb/templates/kb/page_form.html
new file mode 100644
index 0000000..383903e
--- /dev/null
+++ b/welco/kb/templates/kb/page_form.html
@@ -0,0 +1,26 @@
+{% extends "kb/base.html" %}
+{% load i18n %}
+
+{% block appbar %}
+{% if object.id %}
+{% trans "Edit Page" %}
+{% else %}
+{% trans "New Page" %}
+{% endif %}
+{% endblock %}
+
+{% block content %}
+
+
+{% endblock %}
diff --git a/welco/kb/templates/kb/page_list.html b/welco/kb/templates/kb/page_list.html
new file mode 100644
index 0000000..e4f37b8
--- /dev/null
+++ b/welco/kb/templates/kb/page_list.html
@@ -0,0 +1,28 @@
+{% extends "kb/base.html" %}
+{% load i18n %}
+
+{% block appbar %}
+{% trans 'Knowledge Base' %}
+{% trans 'New' %}
+{% endblock %}
+
+{% block content %}
+
+{% if object_list %}
+
+ {% for page in object_list %}
+
+ {% endfor %}
+
+{% else %}
+
+ {% blocktrans %}
+ The knowledge base is currently empty. Click on the "New" button in the top
+ right corner to add a first page.
+ {% endblocktrans %}
+
+{% endif %}
+
+{% endblock %}
diff --git a/welco/kb/views.py b/welco/kb/views.py
new file mode 100644
index 0000000..2ba9eab
--- /dev/null
+++ b/welco/kb/views.py
@@ -0,0 +1,52 @@
+# welco - multichannel request processing
+# Copyright (C) 2015 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 .
+
+from django.core.urlresolvers import reverse_lazy
+from django.views.generic import (DetailView, CreateView, UpdateView,
+ ListView, DeleteView)
+
+from .models import Page
+
+
+class PageListView(ListView):
+ model = Page
+
+page_list = PageListView.as_view()
+
+
+class PageAddView(CreateView):
+ model = Page
+
+page_add = PageAddView.as_view()
+
+
+class PageEditView(UpdateView):
+ model = Page
+
+page_edit = PageEditView.as_view()
+
+
+class PageDetailView(DetailView):
+ model = Page
+
+page_detail = PageDetailView.as_view()
+
+
+class PageDeleteView(DeleteView):
+ model = Page
+ success_url = reverse_lazy('kb-home')
+
+page_delete = PageDeleteView.as_view()
diff --git a/welco/settings.py b/welco/settings.py
index 8222d0b..57e70ed 100644
--- a/welco/settings.py
+++ b/welco/settings.py
@@ -39,8 +39,10 @@ INSTALLED_APPS = (
'django.contrib.messages',
'django.contrib.staticfiles',
'django_select2',
+ 'ckeditor',
'welco.sources.mail',
'welco.qualif',
+ 'welco.kb',
'gadjo',
)
@@ -102,6 +104,20 @@ TEMPLATE_DIRS = (
os.path.join(BASE_DIR, 'welco', 'templates'),
)
+CKEDITOR_UPLOAD_PATH = 'uploads/'
+
+CKEDITOR_CONFIGS = {
+ 'default': {
+ 'toolbar_Own': [['Source', 'Format', '-', 'Bold', 'Italic'],
+ ['NumberedList', 'BulletedList'],
+ ['JustifyLeft', 'JustifyCenter', 'JustifyRight', 'JustifyBlock'],
+ ['Link', 'Unlink'],
+ ['Image',],
+ ['RemoveFormat',]],
+ 'toolbar': 'Own',
+ },
+}
+
# Authentication settings
try:
import mellon
diff --git a/welco/static/css/style.css b/welco/static/css/style.css
index d3a0fde..6aed542 100644
--- a/welco/static/css/style.css
+++ b/welco/static/css/style.css
@@ -1,15 +1,15 @@
-div#main-content {
+body.welco-home div#main-content {
width: 100%;
border: 0;
padding: 0;
height: calc(100vh - 8em);
}
-div#more-user-links {
+body.welco-home div#more-user-links {
display: none;
}
-div#content {
+body.welco-home div#content {
margin: 0;
padding: 0;
height: 100%;
@@ -119,3 +119,25 @@ div#content .cell.qualif .select2-container,
div#content .cell.qualif select {
width: 98%;
}
+
+div.objects-list > div {
+ border: 1px solid #bcbcbc;
+ border-collapse: collapse;
+ margin-top: -1px;
+}
+
+div.objects-list > div a {
+ padding: 1em 1ex;
+ display: block;
+ border-bottom: none;
+}
+
+div.objects-list > div:hover {
+ background: #ccc;
+}
+
+div.objects-list > div.level-1 {
+ margin-left: 25px;
+}
+
+
diff --git a/welco/templates/welco/base.html b/welco/templates/welco/base.html
index 9ce7cdc..42fbb04 100644
--- a/welco/templates/welco/base.html
+++ b/welco/templates/welco/base.html
@@ -4,9 +4,6 @@
{% block page-title %}Welco{% endblock %}
{% block site-title %}Welco{% endblock %}
-{% block more-user-links %}
-{% endblock %}
-
{% block extrascripts %}
{{ block.super }}
diff --git a/welco/templates/welco/home.html b/welco/templates/welco/home.html
index b197e82..d38d444 100644
--- a/welco/templates/welco/home.html
+++ b/welco/templates/welco/home.html
@@ -1,6 +1,8 @@
{% extends "welco/base.html" %}
{% load i18n %}
+{% block bodyargs %}class="welco-home"{% endblock %}
+
{% block content %}
diff --git a/welco/urls.py b/welco/urls.py
index 11a732a..9812ea1 100644
--- a/welco/urls.py
+++ b/welco/urls.py
@@ -23,9 +23,18 @@ from . import apps
urlpatterns = patterns('',
url(r'^$', 'welco.views.home', name='home'),
url(r'^ajax/qualification$', 'welco.views.qualification', name='qualification'),
+
+ url(r'^kb/$', 'welco.kb.views.page_list', name='kb-home'),
+ url(r'^kb/add/$', 'welco.kb.views.page_add', name='kb-page-add'),
+ url(r'^kb/(?P[\w-]+)/$', 'welco.kb.views.page_detail', name='kb-page-view'),
+ url(r'^kb/(?P[\w-]+)/edit$', 'welco.kb.views.page_edit', name='kb-page-edit'),
+ url(r'^kb/(?P[\w-]+)/delete$', 'welco.kb.views.page_delete', name='kb-page-delete'),
+
url(r'^admin/', include(admin.site.urls)),
url(r'^logout/$', 'welco.views.logout', name='auth_logout'),
url(r'^login/$', 'welco.views.login', name='auth_login'),
+
+ (r'^ckeditor/', include('ckeditor.urls')),
)
if 'mellon' in settings.INSTALLED_APPS: