Gentoo Archives: gentoo-commits

From: Slava Bacherikov <slava@××××××××××××××.ua>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] proj/gentoo-packages:master commit in: gpackages/apps/packages/, gpackages/static/js/, gpackages/templates/
Date: Sat, 30 Jun 2012 01:39:04
Message-Id: 1341011057.352228c716b23c57f8b0e86e48c809550f5274fb.bacher09@gentoo
1 commit: 352228c716b23c57f8b0e86e48c809550f5274fb
2 Author: Slava Bacherikov <slava <AT> bacher09 <DOT> org>
3 AuthorDate: Fri Jun 29 23:04:17 2012 +0000
4 Commit: Slava Bacherikov <slava <AT> bacherikov <DOT> org <DOT> ua>
5 CommitDate: Fri Jun 29 23:04:17 2012 +0000
6 URL: http://git.overlays.gentoo.org/gitweb/?p=proj/gentoo-packages.git;a=commit;h=352228c7
7
8 Add details to package
9
10 ---
11 gpackages/apps/packages/views.py | 2 +-
12 gpackages/static/js/packages_details.js | 21 ++++++++++++++++
13 gpackages/templates/base.html | 1 +
14 gpackages/templates/package_object.html | 40 ++++++++++++++++++++++++++++++-
15 4 files changed, 62 insertions(+), 2 deletions(-)
16
17 diff --git a/gpackages/apps/packages/views.py b/gpackages/apps/packages/views.py
18 index 5d70510..d04acd3 100644
19 --- a/gpackages/apps/packages/views.py
20 +++ b/gpackages/apps/packages/views.py
21 @@ -81,7 +81,7 @@ class PackagesListsView(MultipleFilterListViewMixin, ContextListView):
22 base_queryset = PackageModel.objects.all(). \
23 select_related('virtual_package',
24 'virtual_package__category'). \
25 - prefetch_related('repository'). \
26 + prefetch_related('repository', 'herds', 'maintainers'). \
27 prefetch_keywords(arches)
28
29 class PackageDetailView(ContextView, DetailView):
30
31 diff --git a/gpackages/static/js/packages_details.js b/gpackages/static/js/packages_details.js
32 new file mode 100644
33 index 0000000..75cb070
34 --- /dev/null
35 +++ b/gpackages/static/js/packages_details.js
36 @@ -0,0 +1,21 @@
37 +!function ($){
38 + $(function() {
39 + $('.package a.trigger').click(function (e){
40 + var self = $(e.target),
41 + details = self.parent().next();
42 + $('.trigger', this).text() == '+'
43 + ? $('.trigger', this).text('-')
44 + : $('.trigger', this).text('+');
45 +
46 + if (details.hasClass('hide')){
47 + details.removeClass('hide');
48 + details.hide();
49 + details.fadeIn(200);
50 + }
51 + else details.fadeToggle(200);
52 +
53 + e.preventDefault();
54 + return false;
55 + });
56 + });
57 +}(window.jQuery);
58
59 diff --git a/gpackages/templates/base.html b/gpackages/templates/base.html
60 index 69d5ff6..74b4797 100644
61 --- a/gpackages/templates/base.html
62 +++ b/gpackages/templates/base.html
63 @@ -160,6 +160,7 @@ Text
64 <script src="{{ STATIC_URL }}js/bootstrap.js"></script>
65 <script src="{{ STATIC_URL }}js/csrf.js"></script>
66 <script src="{{ STATIC_URL }}js/language.js"></script>
67 + <script src="{{ STATIC_URL }}js/packages_details.js"></script>
68 {% endblock body %}
69 </body>
70 </html>
71
72 diff --git a/gpackages/templates/package_object.html b/gpackages/templates/package_object.html
73 index d713d4a..189d9bd 100644
74 --- a/gpackages/templates/package_object.html
75 +++ b/gpackages/templates/package_object.html
76 @@ -1,6 +1,6 @@
77 {% load url from future %}
78 {% load packages %}
79 -<div class="well package-well">
80 +<div class="well package-well package">
81 <div class="package-name">
82 <span><a href="{{ package.get_absolute_url }}">{{ package.cp }}</a>:: {{ package.repository.name }}</span>
83 <span class="package_update_datetime">{{ package.updated_datetime }}</span>
84 @@ -9,4 +9,42 @@
85 <div style="padding-bottom: 10px; margin 10px;">{{ package.description }}</div>
86 {% endif %}
87 {% render_keywords_table package arches %}
88 +
89 + {% with herds=package.herds.all maintainers=package.maintainers.all %}
90 + {% if herds or maintainers %}
91 + <div style="padding-bottom: 10px; padding-top: 0px; margin-top: 0px;">
92 + <a href="#" class="trigger"><span class="trigger">+</span>Details</a>
93 + </div>
94 + <div class="row-fluid details hide">
95 + <table class="table table-striped table-hover">
96 + <colgroup>
97 + <col class="span1">
98 + <col class="span1">
99 + </colgroup>
100 + <tbody>
101 + {% if herds %}
102 + <tr>
103 + <td>Herds:</td>
104 + <td>
105 + {% for herd in herds %}
106 + <a href="{% url 'packages' herd=herd.name %}">{{ herd.name }}</a>{% if not forloop.last %},{% endif %}
107 + {% endfor %}
108 + </td>
109 + </tr>
110 + {% endif %}
111 + {% if maintainers %}
112 + <tr>
113 + <td>Maintainers:</td>
114 + <td>
115 + {% for maintainer in maintainers %}
116 + <a href="{% url 'packages' maintainer=maintainer.pk %}">{{ maintainer.name }}</a>{% if not forloop.last %},{% endif %}
117 + {% endfor %}
118 + </td>
119 + </tr>
120 + {% endif %}
121 + </tbody>
122 + </table>
123 + </div>
124 + {% endif %}
125 + {% endwith %}
126 </div>