From fe16cac52a33bd593bc8916415dc939d32dfb8f3 Mon Sep 17 00:00:00 2001 From: Radek Czajka Date: Mon, 12 Nov 2012 11:49:32 +0100 Subject: [PATCH 1/1] Fix notifications. --- migdal/admin.py | 8 +++++++- migdal/forms.py | 12 ++++++++---- migdal/templates/migdal/entry/entry_detail.html | 2 +- migdal/templates/migdal/mail/manager_new_entry.txt | 2 +- 4 files changed, 17 insertions(+), 7 deletions(-) diff --git a/migdal/admin.py b/migdal/admin.py index 6bdfb59..1a7fdd7 100644 --- a/migdal/admin.py +++ b/migdal/admin.py @@ -19,7 +19,7 @@ class AttachmentInline(admin.TabularInline): def filtered_entry_admin(typ): class EntryAdmin(admin.ModelAdmin): def queryset(self, request): - return self.model.objects.filter(type=typ) + return self.model.objects.filter(type=typ.db) def has_add_permission(self, request): return request.user.has_perm('migdal.add_entry') @@ -30,6 +30,12 @@ def filtered_entry_admin(typ): def has_delete_permission(self, request, obj=None): return request.user.has_perm('migdal.delete_entry') + def formfield_for_dbfield(self, db_field, **kwargs): + field = super(EntryAdmin, self).formfield_for_dbfield(db_field, **kwargs) + if db_field.name == 'categories': + field.widget.attrs['style'] = 'height: 10em' + return field + date_hierarchy = 'date' readonly_fields = ('date', 'changed_at') + \ translated_fields(('published_at',)) diff --git a/migdal/forms.py b/migdal/forms.py index e7d6394..7c93ea8 100644 --- a/migdal/forms.py +++ b/migdal/forms.py @@ -2,13 +2,14 @@ # This file is part of PrawoKultury, licensed under GNU Affero GPLv3 or later. # Copyright © Fundacja Nowoczesna Polska. See NOTICE for more information. # +from django.contrib.sites.models import Site +from django.core.mail import mail_managers from django import forms +from django import template from django.utils.translation import ugettext_lazy as _, get_language +from fnpdjango.utils.text.slughifi import slughifi from migdal.models import Entry from migdal import app_settings -from fnpdjango.utils.text import slughifi -from django.core.mail import mail_managers -from django import template def get_submit_form(*args, **kwargs): @@ -56,6 +57,9 @@ def get_submit_form(*args, **kwargs): mail_managers(u"Nowy wpis", template.loader.get_template( 'migdal/mail/manager_new_entry.txt').render( - template.Context({'object': entry}))) + template.Context({ + 'object': entry, + 'site': Site.objects.get_current(), + }))) return SubmitForm(*args, **kwargs) \ No newline at end of file diff --git a/migdal/templates/migdal/entry/entry_detail.html b/migdal/templates/migdal/entry/entry_detail.html index c19b49b..2e71d35 100644 --- a/migdal/templates/migdal/entry/entry_detail.html +++ b/migdal/templates/migdal/entry/entry_detail.html @@ -6,7 +6,7 @@ {% block "titleextra" %}{{ entry.title }} :: {% endblock %} {% block "ogtitle" %}{{ entry.title }}{% endblock %} {% block "ogtype" %}article{% endblock %} -{% block "ogdescription"%}{{ entry.lead|striptags|truncatewords:10 }}{% endblock %} +{% block "ogdescription"%}{{ entry.lead|striptags|truncatewords:16 }}{% endblock %} {% block "ogimage" %}{% spaceless %} {% if entry.image %} {{ entry.image.url|build_absolute_uri:request }} diff --git a/migdal/templates/migdal/mail/manager_new_entry.txt b/migdal/templates/migdal/mail/manager_new_entry.txt index 59703e2..b468401 100644 --- a/migdal/templates/migdal/mail/manager_new_entry.txt +++ b/migdal/templates/migdal/mail/manager_new_entry.txt @@ -1,5 +1,5 @@ {% load url from future %}W serwisie pojawił się nowy wpis. -http://localhost:8000{% url 'admin:migdal_entry_change' object.pk %} +http://{{ site.domain }}{% url 'admin:migdal_entry_'|add:object.type|add:'_change' object.pk %} Autor: {{ object.author|default_if_none:"" }} E-mail: {{ object.author_email|default_if_none:"" }} -- 2.20.1