Bug#754413: add a description field to keywords
Raphael Hertzog wrote:
> On Wed, 30 Dec 2015, Christophe Siraut wrote:
> > Please review branch people/tobald/subscriptions on alioth.
>
> Thanks, merged. I guess showing the description in the modal
> popup was waiting the end of the other discussion...
Yes, I have not enough javascript science nor will to do this properly,
with tests and so on, welcome if someone else wants to step in! Here is
a WIP patch.
Christophe
>From 69d5dba249ae6e9523403c1cb07ce3e0cac35536 Mon Sep 17 00:00:00 2001
From: Christophe Siraut <tobald@debian.org>
Date: Thu, 7 Jan 2016 13:41:53 +0100
Subject: [PATCH] Show keywords descriptions in modal windows.
---
distro_tracker/accounts/static/accounts/js/profile.js | 11 +++++++----
distro_tracker/core/static/css/style.css | 5 +++++
distro_tracker/core/views.py | 3 ++-
3 files changed, 14 insertions(+), 5 deletions(-)
diff --git a/distro_tracker/accounts/static/accounts/js/profile.js b/distro_tracker/accounts/static/accounts/js/profile.js
index e288c74..fc901c6 100644
--- a/distro_tracker/accounts/static/accounts/js/profile.js
+++ b/distro_tracker/accounts/static/accounts/js/profile.js
@@ -61,14 +61,17 @@ $(function() {
$.get(all_keywords_url).done(function(keywords) {
$.each(keywords, function(index, keyword) {
+ var word = keyword[0];
+ var description = keyword[1];
var checked = (
- subscription_has_keywords.indexOf(keyword) != -1 ?
+ subscription_has_keywords.indexOf(word) != -1 ?
' checked ' :
'');
html += (
- '<div class="checkbox"><label>' +
- '<input class="keyword-choice" type="checkbox" ' + checked + 'value="' + keyword + '"> ' + keyword +
- '</label></div>');
+ '<div>' +
+ '<input id="' + word + '" class="keyword-choice" type="checkbox" ' + checked + 'value="' + word + '"> ' +
+ '<label for="' + word + '">' + word + ' : ' + '<small>' + description + '</small></label>' +
+ '</div>');
});
$('#choose-keywords-list').html(html);
diff --git a/distro_tracker/core/static/css/style.css b/distro_tracker/core/static/css/style.css
index 7087910..3689ec7 100644
--- a/distro_tracker/core/static/css/style.css
+++ b/distro_tracker/core/static/css/style.css
@@ -289,3 +289,8 @@ ul.inline > li {
label {
cursor: pointer;
}
+
+.keyword-choice {
+ position: relative;
+ margin-left: 0;
+}
diff --git a/distro_tracker/core/views.py b/distro_tracker/core/views.py
index be0b2c5..c2f58c3 100644
--- a/distro_tracker/core/views.py
+++ b/distro_tracker/core/views.py
@@ -240,7 +240,8 @@ def legacy_rss_redirect(request, package_hash, package_name):
class KeywordsView(View):
def get(self, request):
return render_to_json_response([
- keyword.name for keyword in Keyword.objects.order_by('name').all()
+ (keyword.name, keyword.description)
+ for keyword in Keyword.objects.order_by('name').all()
])
--
2.6.4
Reply to: