Merge branch 'devel'

This commit is contained in:
Felipe Martín 2015-08-27 23:55:15 +02:00
commit 0ff5079924
4 changed files with 59 additions and 10 deletions

View File

@ -0,0 +1,19 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import models, migrations
class Migration(migrations.Migration):
dependencies = [
('amiibo', '0019_auto_20150827_1825'),
]
operations = [
migrations.AddField(
model_name='amiiboshop',
name='type',
field=models.CharField(default=b'1', max_length=1, choices=[(b'1', b'Figure'), (b'2', b'Pack')]),
),
]

View File

@ -150,8 +150,17 @@ class AmiiboCard(models.Model):
class AmiiboShop(models.Model):
FIGURE = '1'
PACK = '2'
ITEM_TYPES = (
(FIGURE, 'Figure'),
(PACK, 'Pack'),
)
amiibo = models.ForeignKey(Amiibo, related_name='shops_set')
shop = models.ForeignKey('shop.Shop', related_name='amiibos_set')
type = models.CharField(choices=ITEM_TYPES, default=FIGURE, max_length=1)
url = models.TextField()
item_id = models.CharField(max_length=64)
check_price = models.BooleanField(default=True)
@ -180,6 +189,10 @@ class AmiiboShop(models.Model):
def last_price(self):
return self.price_set.first()
@property
def is_pack(self):
return self.type == self.PACK
def __unicode__(self):
return u'{} in {}'.format(self.amiibo.name, self.shop.name)

View File

@ -5,3 +5,10 @@ $('[data-href]').on('click', function(event) {
// Enable dropdowns
$('.dropdown').dropdown({transition: 'drop', on: 'hover'});
$(function(){
$('[data-component="silbingPopup"]').popup({
inline: true,
position: 'left center'
});
});

View File

@ -58,7 +58,6 @@
<thead>
<tr>
<th>{% trans "Shop" %}</th>
<th class="center aligned">{% trans "Stock" %}</th>
<th class="center aligned">{% trans "Price" %}</th>
</tr>
</thead>
@ -71,18 +70,29 @@
<a href="{{ relation.get_url }}" target="_blank">
<i class="{% if relation.shop.flag_code == 'uk' %}gb{% else %}{{ relation.shop.flag_code }}{% endif %} flag"></i> {{ relation.shop.name }}
</a>
{% if relation.last_price.date %}<em class="float-right">{% trans "Updated " %} <span data-relative="{{ relation.last_price.date.isoformat }}"></span></em>{% endif %}
{% if relation.last_price.date %}
<i class="ui icon info circle float-right" data-component="silbingPopup"></i>
<div class="ui special popup">
<em>{% trans "Updated " %} <span data-relative="{{ relation.last_price.date.isoformat }}"></span></em>
</div>
{% endif %}
{% if relation.is_pack %}
<i class="icon cube float-right" data-component="silbingPopup"></i>
<div class="ui special popup">
{% trans "This is a pack of various items" %}
</div>
{% endif %}
</td>
{% endspaceless %}
<td class="center aligned {{ stock|yesno:'positive,negative' }}" {% if not price %}colspan="2"{% endif %}>
<i class="icon {{ stock|yesno:'checkmark,close' }}"></i>
{{ stock|yesno|capfirst }}
<td class="center aligned {{ stock|yesno:'positive,negative' }}">
{% if stock and price %}
<span data-price="{{ price }}" data-currency="{{ currency }}" data-money>
{{ price }} {{ relation.last_price.currency }}
</span>
{% else %}
{% trans "No stock" %}
{% endif %}
</td>
{% if price %}
<td class="center aligned" data-price="{{ price }}" data-currency="{{ currency }}" data-money>
{{ price }} {{ relation.last_price.currency }}
</td>
{% endif %}
{% endwith %}
</tr>
{% endfor %}