From: "Slava Bacherikov" <slava@bacherikov.org.ua>
To: gentoo-commits@lists.gentoo.org
Subject: [gentoo-commits] proj/gentoo-packages:master commit in: gpackages/apps/packages/, gpackages/apps/packages/templatetags/, ...
Date: Tue, 31 Jul 2012 14:22:52 +0000 (UTC) [thread overview]
Message-ID: <1343737442.945c8a65ae75bb0a206d17adcddf35aa9ab9eb17.bacher09@gentoo> (raw)
commit: 945c8a65ae75bb0a206d17adcddf35aa9ab9eb17
Author: Slava Bacherikov <slava <AT> bacher09 <DOT> org>
AuthorDate: Tue Jul 31 12:24:02 2012 +0000
Commit: Slava Bacherikov <slava <AT> bacherikov <DOT> org <DOT> ua>
CommitDate: Tue Jul 31 12:24:02 2012 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/gentoo-packages.git;a=commit;h=945c8a65
Cache data in package view
---
gpackages/apps/packages/models.py | 12 ++++++++++++
gpackages/apps/packages/templatetags/packages.py | 9 ++++++++-
gpackages/templates/package.html | 2 +-
3 files changed, 21 insertions(+), 2 deletions(-)
diff --git a/gpackages/apps/packages/models.py b/gpackages/apps/packages/models.py
index 7207ad9..5cf2b03 100644
--- a/gpackages/apps/packages/models.py
+++ b/gpackages/apps/packages/models.py
@@ -16,6 +16,9 @@ from package_info.validators import validate_url, validate_email, \
from package_info.parse_cp import VersionParse
from django.utils.html import urlize, linebreaks
+from package_info.generic_metadata.changelog_highlight import changelog_highlight
+from django.utils.safestring import mark_safe
+from django.core.cache import cache
def simple_markup(value):
@@ -456,6 +459,15 @@ class PackageModel(StatsModel, AbstractDateTimeModel):
def short_description(self):
return self.latest_ebuild.description
+ @property
+ def highlighted_changelog(self):
+ key = 'changelog_package_' + str(self.pk)
+ c = cache.get(key)
+ if c is None:
+ c = mark_safe(changelog_highlight(self.changelog))
+ cache.set(key, c)
+ return c
+
def init_by_package(self, package, category = None, virtual_package = None):
#self.name = package.name
self.update_info(package)
diff --git a/gpackages/apps/packages/templatetags/packages.py b/gpackages/apps/packages/templatetags/packages.py
index 5f0f3f0..820daaf 100644
--- a/gpackages/apps/packages/templatetags/packages.py
+++ b/gpackages/apps/packages/templatetags/packages.py
@@ -82,7 +82,14 @@ def filtering_modal(context):
form = FilteringForm(initial = initial)
return {'form': form }
-@register.inclusion_tag('packages_use_flag.html')
+def use_flag_table_key(package):
+ if package.latest_ebuild:
+ return 'use_flag_table_ebuild' + str(package.latest_ebuild.pk)
+ else:
+ return 'use_flag_table_package' + str(package.pk)
+
+@inclusion_cached_tag('packages_use_flag.html', register, use_flag_table_key,
+ time_zone = False)
def use_flag_table(package):
if package.latest_ebuild:
use_flags = package.latest_ebuild.use_flags_with_descr()
diff --git a/gpackages/templates/package.html b/gpackages/templates/package.html
index 2b6760c..00f1191 100644
--- a/gpackages/templates/package.html
+++ b/gpackages/templates/package.html
@@ -11,7 +11,7 @@
</ul>
<div class="tab-content">
<div class="tab-pane active" id="tab1">
- {{ package.changelog|changelog_highlight }}
+ {{ package.highlighted_changelog }}
</div>
<div class="tab-pane" id="tab2">
{% use_flag_table package %}
next reply other threads:[~2012-07-31 14:23 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-07-31 14:22 Slava Bacherikov [this message]
-- strict thread matches above, loose matches on Subject: below --
2012-08-02 22:44 [gentoo-commits] proj/gentoo-packages:master commit in: gpackages/apps/packages/, gpackages/apps/packages/templatetags/, Slava Bacherikov
2012-07-31 14:22 Slava Bacherikov
2012-07-30 23:30 Slava Bacherikov
2012-07-18 23:03 Slava Bacherikov
2012-06-28 23:59 Slava Bacherikov
2012-06-27 22:52 Slava Bacherikov
2012-06-15 23:28 Slava Bacherikov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1343737442.945c8a65ae75bb0a206d17adcddf35aa9ab9eb17.bacher09@gentoo \
--to=slava@bacherikov.org.ua \
--cc=gentoo-commits@lists.gentoo.org \
--cc=gentoo-dev@lists.gentoo.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox