Skip to content
Snippets Groups Projects
Commit f8210830 authored by Tor-Einar Skog's avatar Tor-Einar Skog
Browse files

Reorganizing admin. Adding more illustrations that can be uploaded to an info page.

Changed breadcrumb navigation
parent 851dbca3
No related branches found
No related tags found
No related merge requests found
# #
# Copyright (c) 2014 NIBIO <http://www.nibio.no/>. # Copyright (c) 2015 NIBIO <http://www.nibio.no/>.
# #
# This file is part of VIPSWeb. # This file is part of VIPSWeb.
# VIPSWeb is free software: you can redistribute it and/or modify # VIPSWeb is free software: you can redistribute it and/or modify
...@@ -16,12 +16,22 @@ ...@@ -16,12 +16,22 @@
# along with VIPSWeb. If not, see <http://www.nibio.no/licenses/>. # along with VIPSWeb. If not, see <http://www.nibio.no/licenses/>.
# #
from django.contrib import admin from django.contrib import admin
from information.models import Information, InformationLocale from django.forms import Textarea
from information.models import Information, InformationLocale, InformationIllustration
from django.db import models
from tinymce.widgets import TinyMCE
from tinymce import models as tinymce_models
# Register your models here. # Register your models here.
class InformationLocaleInline(admin.TabularInline): class InformationLocaleInline(admin.StackedInline):
extra = 1
model = InformationLocale model = InformationLocale
formfield_overrides = {
#models.TextField: {'widget': Textarea(attrs={'rows':4, 'cols':40})},
tinymce_models.HTMLField: {'widget':TinyMCE(attrs={'cols': 120, 'rows': 30})}
}
fields = ['language_code', 'headline', 'lead_paragraph', 'body'] fields = ['language_code', 'headline', 'lead_paragraph', 'body']
""" """
...@@ -33,8 +43,15 @@ class InformationLocaleInline(admin.TabularInline): ...@@ -33,8 +43,15 @@ class InformationLocaleInline(admin.TabularInline):
return field return field
""" """
class InformationIllustrationInline(admin.TabularInline):
extra = 1
model = InformationIllustration
class InformationAdmin(admin.ModelAdmin): class InformationAdmin(admin.ModelAdmin):
inlines = [ inlines = [
InformationIllustrationInline,
InformationLocaleInline, InformationLocaleInline,
] ]
admin.site.register(Information, InformationAdmin) admin.site.register(Information, InformationAdmin)
\ No newline at end of file
No preview for this file type
...@@ -8,7 +8,7 @@ msgid "" ...@@ -8,7 +8,7 @@ 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: 2015-02-13 13:36+0100\n" "POT-Creation-Date: 2015-11-13 13:56+0100\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\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"
...@@ -18,6 +18,34 @@ msgstr "" ...@@ -18,6 +18,34 @@ msgstr ""
"Content-Transfer-Encoding: 8bit\n" "Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n" "Plural-Forms: nplurals=2; plural=(n != 1);\n"
#: models.py:13
msgid "Parent information"
msgstr ""
#: models.py:14
msgid "Main illustration"
msgstr ""
#: models.py:18
msgid "Illustration"
msgstr ""
#: models.py:22
msgid "Headline"
msgstr ""
#: models.py:23
msgid "Lead paragraph"
msgstr ""
#: models.py:24
msgid "Body text"
msgstr ""
#: models.py:25
msgid "Language code"
msgstr ""
#: templates/information/index.html:3 templates/information/index.html.py:5 #: templates/information/index.html:3 templates/information/index.html.py:5
msgid "Information" msgid "Information"
msgstr "" msgstr ""
......
No preview for this file type
...@@ -7,7 +7,7 @@ msgid "" ...@@ -7,7 +7,7 @@ msgid ""
msgstr "" msgstr ""
"Project-Id-Version: \n" "Project-Id-Version: \n"
"Report-Msgid-Bugs-To: \n" "Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2015-02-13 13:36+0100\n" "POT-Creation-Date: 2015-11-13 13:56+0100\n"
"PO-Revision-Date: 2015-02-13 11:13+0100\n" "PO-Revision-Date: 2015-02-13 11:13+0100\n"
"Last-Translator: \n" "Last-Translator: \n"
"Language-Team: \n" "Language-Team: \n"
...@@ -15,11 +15,43 @@ msgstr "" ...@@ -15,11 +15,43 @@ msgstr ""
"MIME-Version: 1.0\n" "MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n" "Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n" "Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=3; plural=(n%10==1 && n%100!=11 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2);\n" "Plural-Forms: nplurals=3; plural=(n%10==1 && n%100!=11 ? 0 : n%10>=2 && n"
"%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2);\n"
"X-Generator: Poedit 1.7.4\n" "X-Generator: Poedit 1.7.4\n"
#: templates/information/index.html:3 #: models.py:13
#: templates/information/index.html.py:5 #, fuzzy
#| msgid "Information"
msgid "Parent information"
msgstr "Informacija"
#: models.py:14
msgid "Main illustration"
msgstr ""
#: models.py:18
#, fuzzy
#| msgid "Information"
msgid "Illustration"
msgstr "Informacija"
#: models.py:22
msgid "Headline"
msgstr ""
#: models.py:23
msgid "Lead paragraph"
msgstr ""
#: models.py:24
msgid "Body text"
msgstr ""
#: models.py:25
msgid "Language code"
msgstr ""
#: templates/information/index.html:3 templates/information/index.html.py:5
msgid "Information" msgid "Information"
msgstr "Informacija" msgstr "Informacija"
...@@ -27,6 +59,6 @@ msgstr "Informacija" ...@@ -27,6 +59,6 @@ msgstr "Informacija"
msgid "" msgid ""
"You haven't added any information pages yet. Please do so in the " "You haven't added any information pages yet. Please do so in the "
"administration GUI." "administration GUI."
msgstr "Niste dodali nikakve informacijske stranice još uvjek. Molimo Vas da to " msgstr ""
"Niste dodali nikakve informacijske stranice još uvjek. Molimo Vas da to "
"učinite u administrativnom GUI." "učinite u administrativnom GUI."
No preview for this file type
...@@ -8,7 +8,7 @@ msgid "" ...@@ -8,7 +8,7 @@ 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: 2015-02-13 13:36+0100\n" "POT-Creation-Date: 2015-11-13 13:56+0100\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\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"
...@@ -18,7 +18,36 @@ msgstr "" ...@@ -18,7 +18,36 @@ msgstr ""
"Content-Transfer-Encoding: 8bit\n" "Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n" "Plural-Forms: nplurals=2; plural=(n != 1);\n"
#: templates/information/index.html:3 templates/information/index.html.py:5 #: models.py:13
msgid "Parent information"
msgstr "Informasjon"
#: models.py:14
msgid "Main illustration"
msgstr "Hovedillustrasjon"
#: models.py:18
msgid "Illustration"
msgstr "Hovedillustrasjon"
#: models.py:22
msgid "Headline"
msgstr "Overskrift"
#: models.py:23
msgid "Lead paragraph"
msgstr "Ingress"
#: models.py:24
msgid "Body text"
msgstr "Brødtekst"
#: models.py:25
msgid "Language code"
msgstr "Språkkode"
#: templates/information/index.html:3
#: templates/information/index.html.py:5
msgid "Information" msgid "Information"
msgstr "Informasjon" msgstr "Informasjon"
...@@ -26,6 +55,6 @@ msgstr "Informasjon" ...@@ -26,6 +55,6 @@ msgstr "Informasjon"
msgid "" msgid ""
"You haven't added any information pages yet. Please do so in the " "You haven't added any information pages yet. Please do so in the "
"administration GUI." "administration GUI."
msgstr "" msgstr "Du har ikke lagt til noen informasjonssider ennå. Vennligst gjør dette via "
"Du har ikke lagt til noen informasjonssider ennå. Vennligst gjør dette via "
"administrasjonsgrensesnittet." "administrasjonsgrensesnittet."
from django.utils.translation import ugettext as _
from django.db import models from django.db import models
from tinymce import models as tinymce_models from tinymce import models as tinymce_models
from django.conf import settings from django.conf import settings
from django.utils import translation from django.utils import translation
#from tinymce.widgets import TinyMCE
# Create your models here. # Create your models here.
class Information(models.Model): class Information(models.Model):
def __unicode__(self): def __unicode__(self):
return InformationLocale.get_heading_with_fallback(self.id) return InformationLocale.get_heading_with_fallback(self.id)
parent_information = models.ForeignKey('self', blank=True, null=True, related_name='children') parent_information = models.ForeignKey('self', blank=True, null=True, related_name='children', verbose_name=_("Parent information"))
illustration = models.ImageField(upload_to='images/information', blank=True) main_illustration = models.ImageField(upload_to='images/information', blank=True, verbose_name=_("Main illustration") )
class InformationIllustration(models.Model):
information = models.ForeignKey(Information)
illustration = models.ImageField(upload_to='images/information', blank=True, verbose_name=_("Illustration"))
class InformationLocale(models.Model): class InformationLocale(models.Model):
information = models.ForeignKey(Information) information = models.ForeignKey(Information)
headline = models.CharField(max_length=200) headline = models.CharField(max_length=200, verbose_name=_("Headline"))
lead_paragraph = models.TextField() lead_paragraph = models.TextField(verbose_name=_("Lead paragraph"))
body = tinymce_models.HTMLField() body = tinymce_models.HTMLField(verbose_name=_("Body text"))
language_code = models.CharField(max_length=2) language_code = models.CharField(max_length=2, verbose_name=_("Language code"))
@staticmethod @staticmethod
def get_information_locale_with_fallback(information_id, language_code=translation.get_language()): def get_information_locale_with_fallback(information_id, language_code=translation.get_language()):
......
...@@ -4,17 +4,19 @@ ...@@ -4,17 +4,19 @@
{% block content %} {% block content %}
<ol class="breadcrumb"> <ol class="breadcrumb">
{% for crumb in breadcrumb reversed %} {% for crumb in breadcrumb reversed %}
{% if not crumb.active %}
<li><a href="{% url 'information:detail' crumb.id %}">{{ crumb.title }}</a></li> {% if crumb.children_locales %}
{% else %}
{% if children_locales %}
<li class="dropdown"> <li class="dropdown">
{% if crumb.active %}
<span class="active">{{ crumb.title }}</span>
{% else %}
<a href="{% url 'information:detail' crumb.id %}">{{ crumb.title }}</a>
{% endif %}
<a class="dropdown-toggle" role="button" id="crumbDropdown" data-toggle="dropdown" aria-expanded="true"> <a class="dropdown-toggle" role="button" id="crumbDropdown" data-toggle="dropdown" aria-expanded="true">
{{ crumb.title }}
<span class="caret"></span> <span class="caret"></span>
</a> </a>
<ul class="dropdown-menu" role="menu" aria-labelledby="crumbDropdown"> <ul class="dropdown-menu" role="menu" aria-labelledby="crumbDropdown">
{% for child in children_locales %} {% for child in crumb.children_locales %}
<li role="presentation"><a role="menuitem" tabindex="-1" href="{% url 'information:detail' child.information.pk %}">{{ child.headline }}</a></li> <li role="presentation"><a role="menuitem" tabindex="-1" href="{% url 'information:detail' child.information.pk %}">{{ child.headline }}</a></li>
{% endfor %} {% endfor %}
</ul> </ul>
...@@ -22,12 +24,12 @@ ...@@ -22,12 +24,12 @@
{% else %} {% else %}
<li class="active">{{ crumb.title }}</li> <li class="active">{{ crumb.title }}</li>
{% endif %} {% endif %}
{% endif %}
{% endfor %} {% endfor %}
</ol> </ol>
{% if information_locale.information.illustration %} {% if information_locale.information.main_illustration %}
<div class="messages_illustration"><img src="{{settings.MEDIA_URL}}{{information_locale.information.illustration}}" class="img-responsive"/></div> <div class="messages_illustration"><img src="{{settings.MEDIA_URL}}{{information_locale.information.main_illustration}}" class="img-responsive"/></div>
{% endif %} {% endif %}
<h1>{{information_locale.headline}}</h1> <h1>{{information_locale.headline}}</h1>
<p class="lead">{{information_locale.lead_paragraph}}</p> <p class="lead">{{information_locale.lead_paragraph}}</p>
......
...@@ -33,16 +33,16 @@ def index(request): ...@@ -33,16 +33,16 @@ def index(request):
def detail(request, information_id): def detail(request, information_id):
information_locale = InformationLocale.get_information_locale_with_fallback(information_id) information_locale = InformationLocale.get_information_locale_with_fallback(information_id)
# Is there a parent? # Is there a parent?
parent_information = information_locale.information.parent_information #parent_information = information_locale.information.parent_information
# We get all the children too # We get all the children too
children_locales = [] #children_locales = []
for child in information_locale.information.children.all(): #for child in information_locale.information.children.all():
children_locales.append(InformationLocale.get_information_locale_with_fallback(child.pk)) # children_locales.append(InformationLocale.get_information_locale_with_fallback(child.pk))
context = { context = {
'information_locale' : information_locale, 'information_locale' : information_locale,
'parent_information' : parent_information, #'parent_information' : parent_information,
'children_locales':children_locales, #'children_locales':children_locales,
'breadcrumb': get_breadcrumb(information_locale.information) 'breadcrumb': get_breadcrumb(information_locale.information)
} }
return render(request, 'information/detail.html', context) return render(request, 'information/detail.html', context)
...@@ -52,10 +52,14 @@ def get_breadcrumb(information): ...@@ -52,10 +52,14 @@ def get_breadcrumb(information):
breadcrumb = []#[] breadcrumb = []#[]
while information != None: while information != None:
information_locale = InformationLocale.get_information_locale_with_fallback(information.pk) information_locale = InformationLocale.get_information_locale_with_fallback(information.pk)
children_locales = []
for child in information_locale.information.children.all():
children_locales.append(InformationLocale.get_information_locale_with_fallback(child.pk))
breadcrumb.append({ breadcrumb.append({
"id":information_locale.information.pk, "id":information_locale.information.pk,
"title":information_locale.headline, "title":information_locale.headline,
"active" : information.pk == active_id "active" : information.pk == active_id,
"children_locales" : children_locales
}) })
information = information.parent_information information = information.parent_information
return breadcrumb return breadcrumb
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment