diff --git a/information/admin.py b/information/admin.py index 96ca7a73dce223294dbf206f07a7056c95f428db..a62729bb179a295b329746292c60a5bb34516566 100644 --- a/information/admin.py +++ b/information/admin.py @@ -1,5 +1,5 @@ # -# Copyright (c) 2014 NIBIO <http://www.nibio.no/>. +# Copyright (c) 2015 NIBIO <http://www.nibio.no/>. # # This file is part of VIPSWeb. # VIPSWeb is free software: you can redistribute it and/or modify @@ -16,12 +16,22 @@ # along with VIPSWeb. If not, see <http://www.nibio.no/licenses/>. # + 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. -class InformationLocaleInline(admin.TabularInline): +class InformationLocaleInline(admin.StackedInline): + extra = 1 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'] """ @@ -33,8 +43,15 @@ class InformationLocaleInline(admin.TabularInline): return field """ +class InformationIllustrationInline(admin.TabularInline): + extra = 1 + model = InformationIllustration + class InformationAdmin(admin.ModelAdmin): + + inlines = [ + InformationIllustrationInline, InformationLocaleInline, ] admin.site.register(Information, InformationAdmin) \ No newline at end of file diff --git a/information/locale/bg/LC_MESSAGES/django.mo b/information/locale/bg/LC_MESSAGES/django.mo index f6ba2ae55f5d93821584a97dbda11718fe787bfe..dc2d95ede55993a7d6f97a0c78606ad1f5a55ae0 100644 Binary files a/information/locale/bg/LC_MESSAGES/django.mo and b/information/locale/bg/LC_MESSAGES/django.mo differ diff --git a/information/locale/bg/LC_MESSAGES/django.po b/information/locale/bg/LC_MESSAGES/django.po index b0f1278c806b7b3cde918d2dbc8e799047358ace..32c59888e3a8166ef3204bd983246ad5e669cfc9 100644 --- a/information/locale/bg/LC_MESSAGES/django.po +++ b/information/locale/bg/LC_MESSAGES/django.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\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" "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" "Language-Team: LANGUAGE <LL@li.org>\n" @@ -18,6 +18,34 @@ msgstr "" "Content-Transfer-Encoding: 8bit\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 msgid "Information" msgstr "" diff --git a/information/locale/bs/LC_MESSAGES/django.mo b/information/locale/bs/LC_MESSAGES/django.mo index bef41cbf4744454c5004925c47a5fc9c80c3a656..729deb0c674387fd793cd2bd400d50caa209177b 100644 Binary files a/information/locale/bs/LC_MESSAGES/django.mo and b/information/locale/bs/LC_MESSAGES/django.mo differ diff --git a/information/locale/bs/LC_MESSAGES/django.po b/information/locale/bs/LC_MESSAGES/django.po index 2000377ef2f604835fba7c6cd19d43d364065000..310dde5cb2c2428a2e8010e971ee7fc248ad31d1 100644 --- a/information/locale/bs/LC_MESSAGES/django.po +++ b/information/locale/bs/LC_MESSAGES/django.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: \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" "Last-Translator: \n" "Language-Team: \n" @@ -15,11 +15,43 @@ msgstr "" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\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" -#: templates/information/index.html:3 -#: templates/information/index.html.py:5 +#: models.py:13 +#, 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" msgstr "Informacija" @@ -27,6 +59,6 @@ msgstr "Informacija" msgid "" "You haven't added any information pages yet. Please do so in the " "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." - diff --git a/information/locale/nb/LC_MESSAGES/django.mo b/information/locale/nb/LC_MESSAGES/django.mo index 087ec3652ac03002ff32c23e1066f13c1c7d8c07..1ac720ec66e8d2bc1809b1051b2012f012edf897 100644 Binary files a/information/locale/nb/LC_MESSAGES/django.mo and b/information/locale/nb/LC_MESSAGES/django.mo differ diff --git a/information/locale/nb/LC_MESSAGES/django.po b/information/locale/nb/LC_MESSAGES/django.po index 24380e163c35651288051137965b84241abfc51d..0032aa738b078b19579cb78d4ad99b69cddf3514 100644 --- a/information/locale/nb/LC_MESSAGES/django.po +++ b/information/locale/nb/LC_MESSAGES/django.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\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" "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" "Language-Team: LANGUAGE <LL@li.org>\n" @@ -18,7 +18,36 @@ msgstr "" "Content-Transfer-Encoding: 8bit\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" msgstr "Informasjon" @@ -26,6 +55,6 @@ msgstr "Informasjon" msgid "" "You haven't added any information pages yet. Please do so in the " "administration GUI." -msgstr "" -"Du har ikke lagt til noen informasjonssider ennå. Vennligst gjør dette via " +msgstr "Du har ikke lagt til noen informasjonssider ennå. Vennligst gjør dette via " "administrasjonsgrensesnittet." + diff --git a/information/models.py b/information/models.py index c1996eeb939bff257cfa596d9ca392dffb634905..cc90ca5f4342b6fc2c43378b9b568fcc50a66ded 100644 --- a/information/models.py +++ b/information/models.py @@ -1,22 +1,28 @@ +from django.utils.translation import ugettext as _ from django.db import models from tinymce import models as tinymce_models from django.conf import settings from django.utils import translation +#from tinymce.widgets import TinyMCE # Create your models here. class Information(models.Model): def __unicode__(self): return InformationLocale.get_heading_with_fallback(self.id) - parent_information = models.ForeignKey('self', blank=True, null=True, related_name='children') - illustration = models.ImageField(upload_to='images/information', blank=True) - + parent_information = models.ForeignKey('self', blank=True, null=True, related_name='children', verbose_name=_("Parent information")) + 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): information = models.ForeignKey(Information) - headline = models.CharField(max_length=200) - lead_paragraph = models.TextField() - body = tinymce_models.HTMLField() - language_code = models.CharField(max_length=2) + headline = models.CharField(max_length=200, verbose_name=_("Headline")) + lead_paragraph = models.TextField(verbose_name=_("Lead paragraph")) + body = tinymce_models.HTMLField(verbose_name=_("Body text")) + language_code = models.CharField(max_length=2, verbose_name=_("Language code")) @staticmethod def get_information_locale_with_fallback(information_id, language_code=translation.get_language()): diff --git a/information/templates/information/detail.html b/information/templates/information/detail.html index cf990128362b3247dd5ec5d3aa6798bede7d3589..a4d3ea5652bf686d23ab94649e9d60817a1947b2 100644 --- a/information/templates/information/detail.html +++ b/information/templates/information/detail.html @@ -4,17 +4,19 @@ {% block content %} <ol class="breadcrumb"> {% for crumb in breadcrumb reversed %} - {% if not crumb.active %} - <li><a href="{% url 'information:detail' crumb.id %}">{{ crumb.title }}</a></li> - {% else %} - {% if children_locales %} + + {% if crumb.children_locales %} <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"> - {{ crumb.title }} <span class="caret"></span> </a> <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> {% endfor %} </ul> @@ -22,12 +24,12 @@ {% else %} <li class="active">{{ crumb.title }}</li> {% endif %} - {% endif %} + {% endfor %} </ol> -{% if information_locale.information.illustration %} -<div class="messages_illustration"><img src="{{settings.MEDIA_URL}}{{information_locale.information.illustration}}" class="img-responsive"/></div> +{% if information_locale.information.main_illustration %} +<div class="messages_illustration"><img src="{{settings.MEDIA_URL}}{{information_locale.information.main_illustration}}" class="img-responsive"/></div> {% endif %} <h1>{{information_locale.headline}}</h1> <p class="lead">{{information_locale.lead_paragraph}}</p> diff --git a/information/views.py b/information/views.py index 0870a4cab9b35bdc6a975bd9a4bf4c631cbe3d44..9be62ed255983a44b6e7cc6cc44532892ac46217 100644 --- a/information/views.py +++ b/information/views.py @@ -33,16 +33,16 @@ def index(request): def detail(request, information_id): information_locale = InformationLocale.get_information_locale_with_fallback(information_id) # Is there a parent? - parent_information = information_locale.information.parent_information + #parent_information = information_locale.information.parent_information # We get all the children too - children_locales = [] - for child in information_locale.information.children.all(): - children_locales.append(InformationLocale.get_information_locale_with_fallback(child.pk)) + #children_locales = [] + #for child in information_locale.information.children.all(): + # children_locales.append(InformationLocale.get_information_locale_with_fallback(child.pk)) context = { 'information_locale' : information_locale, - 'parent_information' : parent_information, - 'children_locales':children_locales, + #'parent_information' : parent_information, + #'children_locales':children_locales, 'breadcrumb': get_breadcrumb(information_locale.information) } return render(request, 'information/detail.html', context) @@ -52,10 +52,14 @@ def get_breadcrumb(information): breadcrumb = []#[] while information != None: 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({ "id":information_locale.information.pk, "title":information_locale.headline, - "active" : information.pk == active_id + "active" : information.pk == active_id, + "children_locales" : children_locales }) information = information.parent_information return breadcrumb