diff --git a/deploy/pip_packages.txt b/deploy/pip_packages.txt index 7d122c33cef1668f1b7c46ac4e6726f42f8a04b8..96a4c1ceef757ae0dbab59acdf830a23880ff0b6 100644 --- a/deploy/pip_packages.txt +++ b/deploy/pip_packages.txt @@ -26,3 +26,4 @@ selenium==2.34.0 django-dynamic-fixture==1.6.5 django-selenium==0.9.6 django-parsley==0.0.2a0 +Markdown==2.3.1 diff --git a/django/econsensus/custom_flatpages/__init__.py b/django/econsensus/custom_flatpages/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/django/econsensus/custom_flatpages/templatetags/__init__.py b/django/econsensus/custom_flatpages/templatetags/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/django/econsensus/custom_flatpages/templatetags/custom_flatpages.py b/django/econsensus/custom_flatpages/templatetags/custom_flatpages.py new file mode 100644 index 0000000000000000000000000000000000000000..22074d0d4518d7166a65d6fa1601ae877502db5d --- /dev/null +++ b/django/econsensus/custom_flatpages/templatetags/custom_flatpages.py @@ -0,0 +1,47 @@ +from django import template +from django.conf import settings +from django.contrib.flatpages.models import FlatPage + + +register = template.Library() + + +class TopFlatpageNode(template.Node): + def __init__(self, context_name, user): + self.context_name = context_name + self.user = template.Variable(user) + + def render(self, context): + flatpages = FlatPage.objects.filter(sites__id=settings.SITE_ID) + flatpages = flatpages.filter(url__regex=r'^/[^/]+/$') + + user = self.user.resolve(context) + if not user.is_authenticated(): + flatpages = flatpages.filter(registration_required=False) + + context[self.context_name] = flatpages.order_by('url') + return '' + + +@register.tag +def get_topflatpages(parser, token): + """ + Retrieves all top-level flatpage objects available for the current site. + + Syntax:: + + {% get_topflatpages for user as context_name %} + + Example usage:: + + {% get_topflatpages for someuser as flatpages %} + """ + pieces = token.split_contents() + syntax_message = ("%(tag_name)s expects a syntax of %(tag_name)s " + "for user as context_name" % + dict(tag_name=pieces[0])) + if len(pieces) != 5 or pieces[1] != 'for' or pieces[3] != 'as': + raise template.TemplateSyntaxError(syntax_message) + user = pieces[2] + context_name = pieces[4] + return TopFlatpageNode(context_name, user) diff --git a/django/econsensus/econsensus/settings.py b/django/econsensus/econsensus/settings.py index 617d154a03f6a20b366a9c191016132cef7e0864..da74ed0d45a5c53ee1d6f118dad61ef4466835cb 100644 --- a/django/econsensus/econsensus/settings.py +++ b/django/econsensus/econsensus/settings.py @@ -131,6 +131,8 @@ INSTALLED_APPS = ( 'django.contrib.messages', 'django.contrib.staticfiles', 'django.contrib.comments', + 'django.contrib.flatpages', + 'django.contrib.markup', 'south', 'registration', 'notification', @@ -146,6 +148,7 @@ INSTALLED_APPS = ( 'tagging', 'remember_me', 'actionitems', + 'custom_flatpages', ) ACTIONITEMS_ORIGIN_MODEL = 'publicweb.Decision' diff --git a/django/econsensus/econsensus/urls.py b/django/econsensus/econsensus/urls.py index 84bd6a8fd379c0653f76e1039c03ae577684797b..f38bf2f8a0c7f86f5022a04aa3e77ccb21bc1d57 100644 --- a/django/econsensus/econsensus/urls.py +++ b/django/econsensus/econsensus/urls.py @@ -21,6 +21,7 @@ urlpatterns = patterns('', url(r'^comments/', include('django.contrib.comments.urls')), url(r'^organizations/', include('custom_organizations.urls')), url(r'^invitations/', include(invitation_backend().get_urls())), + url(r'^pages/', include('django.contrib.flatpages.urls')), url(r'', include('publicweb.urls')), ) diff --git a/django/econsensus/publicweb/static/css/styles.css b/django/econsensus/publicweb/static/css/styles.css index 8f6c952190e4427e7255104737510bd3dfa5a456..92a9d4418d88b5ff227f28d43889435d53e5a1a9 100644 --- a/django/econsensus/publicweb/static/css/styles.css +++ b/django/econsensus/publicweb/static/css/styles.css @@ -1188,6 +1188,19 @@ div#tags { float: right; } +#footer ul.flatpagelinks li { + float: left; +} + +#footer ul.flatpagelinks li a { + font-size: 1.2em; + padding-right: 0.5em; +} + +#footer ul.flatpagelinks li a:hover { + background-color: #ededed; +} + /* login form */ body.login #header-wrapper, body.login #content-wrapper, body.login #footer-wrapper { @@ -1348,6 +1361,12 @@ p.error404 { margin-bottom : 40px; } +/* Styling of admin-defined pages */ +#flatpage ul { + list-style: disc outside none; + padding-left: 1em; +} + /* Media Queries*/ @media screen and (max-width:800px) { diff --git a/django/econsensus/publicweb/templates/base.html b/django/econsensus/publicweb/templates/base.html index a86c30ca6fa2012705e6fb2cccd3d67f8d304cfd..80f326261916fb7a63a1dc6d0345aabf8a99fa31 100644 --- a/django/econsensus/publicweb/templates/base.html +++ b/django/econsensus/publicweb/templates/base.html @@ -3,6 +3,7 @@ {% load i18n %} {% load org_filters %} {% load guardian_tags %} +{% load custom_flatpages %} {% if organization %} {% get_obj_perms request.user for organization as "organization_permissions" %} @@ -90,6 +91,14 @@ <div id="footer-wrapper"> <div id="footer"> {% block footer_content%}{% endblock %} + {% get_topflatpages for user as flatpages %} + {% for page in flatpages %} + {% if forloop.first %}<ul class="flatpagelinks">{% endif %} + <li> + <a href="{% url 'django.contrib.flatpages.views.flatpage' url=page.url %}">{{ page.title }}</a> + </li> + {% if forloop.last %}</ul>{% endif %} + {% endfor %} <p class="aptivate">{% trans "Econsensus" %} {{ version }} {% trans "is an open source project developed by" %} <a href="http://www.aptivate.org/"><span class="user-org not_translated">Aptivate</span></a></p> </div> </div><!-- footer end --> diff --git a/django/econsensus/publicweb/templates/flatpages/default.html b/django/econsensus/publicweb/templates/flatpages/default.html new file mode 100644 index 0000000000000000000000000000000000000000..1886c5b9e01a817881e97ee9463fb1bc276782f9 --- /dev/null +++ b/django/econsensus/publicweb/templates/flatpages/default.html @@ -0,0 +1,10 @@ +{% extends "base.html" %} +{% load markup %} +{% block title %}{{ flatpage.title }}{% endblock %} +{% block main_content %} + <div id="flatpage"> + {{ flatpage.content|markdown }} + </div> +{% endblock %} + +