Permalink
Browse files

Show mobile statistics on mobile version (bug 662818)

  • Loading branch information...
1 parent 622ba5e commit 642b4189f5cee13a585e64630297406ddd47669a @tofumatt tofumatt committed Jun 10, 2011
View
@@ -68,14 +68,20 @@ def platforms_block(context, platforms, total, defaults=None):
@register.function
@jinja2.contextfunction
def manufacturer_block(context, manufacturers, total, defaults=None):
- tpl = 'dashboard/manufacturers.html'
+ if not getattr(context['request'], 'mobile_site', False):
+ tpl = 'dashboard/manufacturers.html'
+ else:
+ tpl = 'dashboard/mobile/manufacturers.html'
return render_template(tpl, new_context(**locals()))
@register.function
@jinja2.contextfunction
def device_block(context, devices, total, defaults=None):
- tpl = 'dashboard/devices.html'
+ if not getattr(context['request'], 'mobile_site', False):
+ tpl = 'dashboard/devices.html'
+ else:
+ tpl = 'dashboard/mobile/devices.html'
return render_template(tpl, new_context(**locals()))
@@ -55,6 +55,13 @@
{{ platforms_block(platforms, opinion_count) }}
+ {% if product.short == 'mobile' %}
+ {{ manufacturer_block(manufacturers, total,
+ defaults=defaults) }}
+
+ {{ device_block(devices, total, defaults=defaults) }}
+ {% endif %}
+
{{ locales_block(locales, opinion_count) }}
</div>
@@ -0,0 +1,27 @@
+{% macro device_item(device, count=0, selected=False) %}
+<li class="bar filter">
+ <input id="device_{{ device }}" name="device"
+ value="{{ device or 'Unknown' }}"
+ {{ 'disabled' if defaults['manufacturer'] and not device }}
+ type="checkbox" {{ 'checked' if selected else '' }} />
+ <label for="device_{{ device }}" class="{{ 'selected' if selected else '' }}" data-value="{{ count }}">
+ {{ device or _('Unknown') }}
+ </label>
+</li>
+{% endmacro %}
+
+{% if devices %}
+<div class="block collapsible filter-group" id="filter_device">
+ {{ filter_box_toggle(_('Devices')) }}
+
+ <ul class="collapsee filters bars" data-total="{{ total }}">
+ {% if defaults['device'] %}
+ {{ device_item(defaults['device'], selected=True) }}
+ {% else %}
+ {% for item in devices[:15] %}
+ {{ device_item(item.device, item.count) }}
+ {% endfor %}
+ {% endif %}
+ </ul>
+</div>
+{% endif %}
@@ -0,0 +1,28 @@
+{% macro brand_item(manufacturer, count=0, selected=False) %}
+<li class="bar filter">
+ <input id="brand_{{ manufacturer|slugify }}" name="manufacturer"
+ value="{{ manufacturer or 'Unknown' }}"
+ type="checkbox" {{ 'checked' if selected else '' }} />
+ <label for="brand_{{ manufacturer|slugify }}"
+ class="{{ 'selected' if selected else '' }}"
+ data-value="{{ count }}">
+ {{ manufacturer or _('Unknown') }}
+ </label>
+</li>
+{% endmacro %}
+
+{% if manufacturers %}
+<div class="block collapsible filter-group" id="filter_manufacturer">
+ {{ filter_box_toggle(_('Manufacturer')) }}
+
+ <ul class="collapsee filters bars" data-total="{{ total }}">
+ {% if defaults['manufacturer'] %}
+ {{ brand_item(defaults['manufacturer'], selected=True) }}
+ {% else %}
+ {% for item in manufacturers %}
+ {{ brand_item(item.manufacturer, item.count) }}
+ {% endfor %}
+ {% endif %}
+ </ul>
+</div>
+{% endif %}
View
@@ -42,7 +42,7 @@ def test_beta_pagination_link(self):
pag_link = doc('.pager a.next')
eq_(len(pag_link), 1)
assert pag_link.attr('href').endswith(
- '?product=firefox&version=%s' % (
+ '?product=firefox&version=%s' % (input.FIREFOX.default_version or
input.LATEST_BETAS[input.FIREFOX]))
@@ -95,7 +95,8 @@ def test_manufacturer_block(self):
item.count = 50
item.manufacturer = "RySny"
ms = [item]
- r = render('{{ manufacturer_block(ms, 100) }}', dict(ms=ms))
+ r = render('{{ manufacturer_block(ms, 100) }}', dict(ms=ms,
+ request=''))
doc = pq(r)
eq_(doc('input').attr('id'), 'brand_RySny')
@@ -104,7 +105,7 @@ def test_device_block(self):
item.count = 50
item.device = "TacoTruck"
ms = [item]
- r = render('{{ device_block(ms, 100) }}', dict(ms=ms))
+ r = render('{{ device_block(ms, 100) }}', dict(ms=ms, request=''))
doc = pq(r)
eq_(doc('input').attr('id'), 'device_TacoTruck')
View
@@ -46,8 +46,8 @@ def dashboard(request):
try:
c = Client()
search_opts = dict(product=prod.short, version=version)
- c.query('', meta=('type', 'locale', 'platform', 'day_sentiment'),
- **search_opts)
+ c.query('', meta=('type', 'locale', 'manufacturer', 'device',
+ 'day_sentiment'), **search_opts)
metas = c.meta
daily = c.meta.get('day_sentiment', {})
chart_data = dict(series=[
@@ -69,6 +69,8 @@ def dashboard(request):
'sentiments': get_sentiment(metas.get('type', [])),
'locales': metas.get('locale'),
'platforms': metas.get('platform'),
+ 'devices': metas.get('device'),
+ 'manufacturers': metas.get('manufacturer'),
# 'sites': sites,
'version': version,
'versions': VERSION_CHOICES[prod],
@@ -77,6 +77,13 @@
{{ platforms_block(demo.platform, opinion_count, defaults=defaults) }}
+ {% if product.short == 'mobile' %}
+ {{ manufacturer_block(demo.manufacturer, total,
+ defaults=defaults) }}
+
+ {{ device_block(demo.device, total, defaults=defaults) }}
+ {% endif %}
+
{{ locales_block(demo.locale, opinion_count, defaults=defaults) }}
</div>
@@ -292,7 +292,7 @@ a {
.section .group .cell:last-child {
border-bottom: 0;
}
-.section h2 {
+.section h2, .section .filter-group h3 {
background: -moz-linear-gradient(top, #f0f0f0, #dadada);
background: -webkit-gradient(linear, 0 top, 0 bottom, from(#f0f0f0), to(#dadada));
background: linear-gradient(top, #f0f0f0, #dadada);
@@ -339,7 +339,7 @@ a {
display: block;
}
-.filter-group h2 a {
+.filter-group h2 a, .filter-group h3 a {
color: #000;
display: block;
}

0 comments on commit 642b418

Please sign in to comment.