Bug#771604: tracker.debian.org: short description contains long description
> So I'm keeping the bug but repurposing it to add the long description back
> as a tooltip.
Here is a patchset implementing half of this feature, I have not
yet figured out how to feed the long description in the tracker.
Cheers,
Christophe
>From 5b4ee0ae53a55f2705a5ee02ebb7890cc124c856 Mon Sep 17 00:00:00 2001
From: Christophe Siraut <d@tobald.eu.org>
Date: Tue, 2 Dec 2014 12:37:02 +0100
Subject: [PATCH 4/6] core/tests: Add long description as a tooltip on top of
the short description (1/3)
---
distro_tracker/core/tests/tests_views.py | 13 ++++++++++++-
1 file changed, 12 insertions(+), 1 deletion(-)
diff --git a/distro_tracker/core/tests/tests_views.py b/distro_tracker/core/tests/tests_views.py
index 735d6a3..d869182 100644
--- a/distro_tracker/core/tests/tests_views.py
+++ b/distro_tracker/core/tests/tests_views.py
@@ -44,7 +44,8 @@ class PackageViewTest(TestCase):
self.bin_pkg = BinaryPackage.objects.create(
binary_package_name=self.binary_package,
source_package=self.src_pkg,
- short_description='a useful package')
+ short_description='a useful package',
+ long_description='an exiting and useful package, it makes the world a better place')
self.src_pkg.binary_packages = [self.binary_package]
self.src_pkg.save()
self.bin_pkg.save()
@@ -195,6 +196,16 @@ class PackageViewTest(TestCase):
self.assertIn('a useful package', response_content)
+ def test_long_description(self):
+ """
+ Tests that the short description is displayed.
+ """
+ url = self.get_package_url(self.package.name)
+ response = self.client.get(url)
+ response_content = response.content.decode('utf-8')
+
+ self.assertIn('the world a better place', response_content)
+
def test_page_does_not_contain_None(self):
"""
Ensure Python's None never ends up displayed on the web page.
--
2.1.3
>From 0742da43080c237f4001c958dc62adcf6da65366 Mon Sep 17 00:00:00 2001
From: Christophe Siraut <d@tobald.eu.org>
Date: Tue, 2 Dec 2014 12:37:30 +0100
Subject: [PATCH 5/6] core/models: Add long description as a tooltip on top of
the short description (2/3)
---
distro_tracker/core/models.py | 20 ++++++++++++++++++++
1 file changed, 20 insertions(+)
diff --git a/distro_tracker/core/models.py b/distro_tracker/core/models.py
index aded24e..2106540 100644
--- a/distro_tracker/core/models.py
+++ b/distro_tracker/core/models.py
@@ -472,6 +472,26 @@ class SourcePackageName(PackageName):
return ''
+ def long_description(self):
+ """
+ Returns the most recent long description for a source package. If there
+ is a binary package whose name matches the source package, its
+ description will be used. If not, the long description for the first
+ binary package will be used.
+ """
+ if not self.main_version:
+ return ''
+
+ binary_packages = self.main_version.binarypackage_set.all()
+
+ for pkg in binary_packages:
+ if pkg.binary_package_name.name == self.name:
+ return pkg.long_description
+
+ if len(binary_packages) == 1:
+ return binary_packages[0].long_description
+
+ return ''
def get_web_package(package_name):
"""
--
2.1.3
>From 779365b63bdb397951f5bbe59197c501a6f6ca0e Mon Sep 17 00:00:00 2001
From: Christophe Siraut <d@tobald.eu.org>
Date: Tue, 2 Dec 2014 12:37:52 +0100
Subject: [PATCH 6/6] core/templates: Add long description as a tooltip on top
of the short description (3/3)
---
distro_tracker/core/templates/core/package.html | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/distro_tracker/core/templates/core/package.html b/distro_tracker/core/templates/core/package.html
index 672f7d7..78d31b9 100644
--- a/distro_tracker/core/templates/core/package.html
+++ b/distro_tracker/core/templates/core/package.html
@@ -16,7 +16,7 @@
</div>
<div class="span6 col col-lg-6 text-center">
<h1>{{ package }}</h1>
- <h4>{{ package.short_description }}{% if not package.short_description %} {% endif %}</h4>
+ <h4 title="{{ package.long_description }}">{{ package.short_description }}{% if not package.short_description %} {% endif %}</h4>
</div>
<div class="span3 col col-lg-3">
{% include 'core/package-search-form.html' %}
--
2.1.3
Reply to: