From: Jan Szejko Date: Tue, 4 Apr 2017 14:02:22 +0000 (+0200) Subject: add tag for entry url X-Git-Tag: 0.7.0 X-Git-Url: https://git.mdrn.pl/django-migdal.git/commitdiff_plain/05d1be6e85dc92e7be6aebb8b62221480c10540e?ds=sidebyside add tag for entry url --- diff --git a/migdal/templatetags/migdal_tags.py b/migdal/templatetags/migdal_tags.py index f370f97..9c2609c 100644 --- a/migdal/templatetags/migdal_tags.py +++ b/migdal/templatetags/migdal_tags.py @@ -2,11 +2,12 @@ # This file is part of PrawoKultury, licensed under GNU Affero GPLv3 or later. # Copyright © Fundacja Nowoczesna Polska. See NOTICE for more information. # +from django.shortcuts import get_object_or_404 from django_comments_xtd.models import XtdComment import django_comments as comments from django import template from migdal import app_settings -from migdal.models import Category +from migdal.models import Category, Entry register = template.Library() @@ -73,3 +74,9 @@ def entry_comment_form(entry): 'form': comments.get_form()(entry), 'next': entry.get_absolute_url(), } + + +@register.simple_tag +def entry_url(slug, lang='pl'): + entry = get_object_or_404(Entry, **{'slug_%s' % lang: slug}) + return entry.get_absolute_url() diff --git a/setup.py b/setup.py index 2d56d19..32df780 100755 --- a/setup.py +++ b/setup.py @@ -23,9 +23,11 @@ def whole_trees(package_dir, paths): setup( name='django-migdal', - version='0.6.4', + version='0.7.0', author='Radek Czajka', author_email='radoslaw.czajka@nowoczesnapolska.org.pl', + maintainer='Jan Szejko', + maintainer_email='jan.szejko@nowoczesnapolska.org.pl', url='', packages=find_packages(), package_data={'migdal': whole_trees('migdal', ['templates', 'locale'])},