Various small improvements

main
Jaap Joris Vens 2020-03-24 15:32:12 +01:00
rodzic b092c12c99
commit c552f52e46
6 zmienionych plików z 57 dodań i 51 usunięć

Wyświetl plik

@ -8,6 +8,7 @@ example_dir=$(python3 -c 'import os,example;print(os.path.dirname(example.__file
cp -r "$example_dir" "$1" cp -r "$example_dir" "$1"
cp "$example_dir"/../manage.py . cp "$example_dir"/../manage.py .
sed -i "s/example/$1/" manage.py sed -i "s/example/$1/" manage.py
sed -i "s/example/$1/" "$1"/wsgi.py
cat << EOF > .gitignore cat << EOF > .gitignore
*.pyc *.pyc
__pycache__/ __pycache__/

Wyświetl plik

@ -7,8 +7,8 @@ msgid ""
msgstr "" msgstr ""
"Project-Id-Version: PACKAGE VERSION\n" "Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n" "Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2020-02-20 22:46+0100\n" "POT-Creation-Date: 2020-03-24 14:49+0100\n"
"PO-Revision-Date: 2020-02-20 22:48+0100\n" "PO-Revision-Date: 2020-03-24 14:50+0100\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n" "Language-Team: LANGUAGE <LL@li.org>\n"
"Language: \n" "Language: \n"
@ -21,103 +21,95 @@ msgstr ""
msgid "Content Management System" msgid "Content Management System"
msgstr "Content Beheer" msgstr "Content Beheer"
#: forms.py:15 #: forms.py:55
msgid "Delete"
msgstr "Verwijderen"
#: forms.py:112
msgid "Your email address" msgid "Your email address"
msgstr "Uw email adres" msgstr "Uw email adres"
#: forms.py:16 forms.py:17 #: forms.py:113 forms.py:114
msgid "Your message" msgid "Your message"
msgstr "Uw bericht" msgstr "Uw bericht"
#: forms.py:32 #: forms.py:128
#, python-format #, python-format
msgid "Contact form at %(hostname)s." msgid "Contact form at %(hostname)s."
msgstr "%(hostname)s contactformulier" msgstr "%(hostname)s contactformulier"
#: models.py:63 models.py:87 #: models.py:67
msgid "page" msgid "page"
msgstr "pagina" msgstr "pagina"
#: models.py:64 #: models.py:68
msgid "slug" msgid "slug"
msgstr "slug" msgstr "slug"
#: models.py:65 models.py:90 #: models.py:69 models.py:93
msgid "number" msgid "number"
msgstr "nummer" msgstr "nummer"
#: models.py:66 #: models.py:70
msgid "visible in menu" msgid "visible in menu"
msgstr "zichtbaar in het menu" msgstr "zichtbaar in het menu"
#: models.py:70 #: models.py:74
msgid "New page" msgid "New page"
msgstr "Nieuwe pagina" msgstr "Nieuwe pagina"
#: models.py:80 #: models.py:84
msgid "Page" msgid "Page"
msgstr "Pagina" msgstr "Pagina"
#: models.py:81 #: models.py:85
msgid "Pages" msgid "Pages"
msgstr "Paginas" msgstr "Paginas"
#: models.py:88 models.py:110 #: models.py:91 models.py:115
msgid "section" msgid "section"
msgstr "sectie" msgstr "sectie"
#: models.py:89 #: models.py:92
msgid "type" msgid "type"
msgstr "type" msgstr "type"
#: models.py:92 #: models.py:94
msgid "content" msgid "content"
msgstr "inhoud" msgstr "inhoud"
#: models.py:93 #: models.py:95
msgid "image" msgid "image"
msgstr "afbeelding" msgstr "afbeelding"
#: models.py:94 #: models.py:96
msgid "video" msgid "video"
msgstr "video" msgstr "video"
#: models.py:94 #: models.py:96
msgid "Paste a YouTube, Vimeo, or SoundCloud link" msgid "Paste a YouTube, Vimeo, or SoundCloud link"
msgstr "Plak hier een YouTube, Vimeo of SoundCloud link" msgstr "Plak hier een YouTube, Vimeo of SoundCloud link"
#: models.py:95 #: models.py:97
msgid "link" msgid "link"
msgstr "" msgstr "link"
#: models.py:102 #: models.py:107
msgid "New section" msgid "New section"
msgstr "Nieuwe sectie" msgstr "Nieuwe sectie"
#: models.py:104 #: models.py:109
msgid "Untitled" msgid "Untitled"
msgstr "Geen titel" msgstr "Geen titel"
#: models.py:111 #: models.py:116
msgid "sections" msgid "sections"
msgstr "secties" msgstr "secties"
#: templates/cms/base.html:33
msgid "new page"
msgstr "nieuwe pagina"
#: templates/cms/edit.html:4 #: templates/cms/edit.html:4
msgid "Edit" msgid "Edit"
msgstr "Bewerk" msgstr "Bewerk"
#: templates/cms/edit.html:20 #: templates/cms/edit.html:13
msgid "Please correct the error(s) below and save again" msgid "Please correct the error(s) below and save again"
msgstr "Herstel a.u.b. de fout(en) hieronder en sla nogmaals op" msgstr "Herstel a.u.b. de fout(en) hieronder en sla nogmaals op"
#: templates/registration/login.html:14 templates/registration/login.html:18
msgid "Log in"
msgstr "Inloggen"
#: views.py:191
msgid "You cant save a new page without adding any sections!"
msgstr "Voeg minstens één sectie toe!"

Wyświetl plik

@ -1,18 +1,12 @@
{% extends 'base.html' %} {% extends 'base.html' %}
{% load static cms %} {% load cms %}
{% block title %}{{block.super}} - {{page.title}}{% endblock %} {% block title %}{{block.super}} - {{page.title}}{% endblock %}
{% block content %} {% block content %}
{% for section in sections %} {% for section in sections %}
<div id="{{section.title|slugify}}"></div>
{% include_section section %} {% include_section section %}
{% endfor %} {% endfor %}
{% if perms.cms_page.change %} {% editpage '<img src="/static/cms/edit.png">' %}
<div class="edit">
<a href="{% if page.slug %}{% url 'cms:updatepage' page.slug %}{% else %}{% url 'cms:updatepage' %}{% endif %}"><img src="{% static 'cms/edit.png' %}"></a>
</div>
{% endif %}
{% endblock %} {% endblock %}

Wyświetl plik

@ -25,13 +25,30 @@ def eval(context, expr):
return mark_safe(md(result, extensions=MARKDOWN_EXTENSIONS)) return mark_safe(md(result, extensions=MARKDOWN_EXTENSIONS))
@register.simple_tag(takes_context=True) @register.simple_tag(takes_context=True)
def edit(context): def editsection(context, inner):
'''Renders a simple link to edit the current section''' '''Renders a simple link to edit the current section'''
if context['request'].user.has_perms('cms_section_change'): section = context['section']
slug = context['section'].page.slug user = context['request'].user
number = context['section'].number app_label = section._meta.app_label
url = reverse('cms:updatesection', args=[slug, number]) if slug else reverse('cms:updatesection', args=[number]) model_name = section._meta.model_name
return mark_safe(f'<a class="edit" href="{url}">{_("edit")}</a>') if user.has_perms(f'{app_label}_{model_name}_change'):
slug = section.page.slug
number = section.number
url = reverse('cms:updatesection', args=[slug, number]) if slug else reverse('cms:updatesection', args=[number])
return mark_safe(f'<a class="edit section" href="{url}">{inner}</a>')
return ''
@register.simple_tag(takes_context=True)
def editpage(context, inner):
'''Renders a simple link to edit the current page'''
page = context['page']
user = context['request'].user
app_label = page._meta.app_label
model_name = page._meta.model_name
if user.has_perms(f'{app_label}_{model_name}_change'):
slug = page.slug
url = reverse('cms:updatepage', args=[slug]) if slug else reverse('cms:updatepage')
return mark_safe(f'<a class="edit page" href="{url}">{inner}</a>')
return '' return ''
@register.tag('include_section') @register.tag('include_section')

Wyświetl plik

@ -48,6 +48,7 @@ if not DEBUG:
INSTALLED_APPS += ['django.contrib.staticfiles'] INSTALLED_APPS += ['django.contrib.staticfiles']
MIDDLEWARE = [ MIDDLEWARE = [
'django.middleware.cache.UpdateCacheMiddleware',
'cms.middleware.SassMiddleware', 'cms.middleware.SassMiddleware',
'django.middleware.security.SecurityMiddleware', 'django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware',
@ -56,6 +57,7 @@ MIDDLEWARE = [
'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware', 'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware', 'django.middleware.clickjacking.XFrameOptionsMiddleware',
'django.middleware.cache.FetchFromCacheMiddleware',
] ]
TEMPLATES = [ TEMPLATES = [

Wyświetl plik

@ -11,6 +11,6 @@ import os
from django.core.wsgi import get_wsgi_application from django.core.wsgi import get_wsgi_application
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'project.settings') os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'example.settings')
application = get_wsgi_application() application = get_wsgi_application()