diff --git a/wouso/core/scoring/sm.py b/wouso/core/scoring/sm.py
index 2308484e..d42aa540 100644
--- a/wouso/core/scoring/sm.py
+++ b/wouso/core/scoring/sm.py
@@ -145,16 +145,13 @@ def update_points(player, game):
if level == player.level_no:
return
+ arguments = dict(level=level)
if level < player.level_no:
action_msg = 'level-downgrade'
signal_msg = ugettext_noop("downgraded to level {level}")
- signals.addActivity.send(sender=None, user_from=player,
- user_to=player, message=signal_msg,
- arguments=dict(level=level),
- game=game, action=action_msg)
- else:
+ this_game = game
+ else:
action_msg = 'level-upgrade'
- arguments = dict(level=level)
# Check if the user has previously reached this level
if level > player.max_level:
# Update the maximum reached level
@@ -168,17 +165,19 @@ def update_points(player, game):
else:
# The user should not receive additional gold
signal_msg = ugettext_noop("upgraded back to level {level}")
+ this_game = None
+
+ signals.addActivity.send(sender=None, user_from=player,
+ user_to=player, message=signal_msg,
+ arguments=dict(level=level),
+ game=game, action=action_msg)
- signals.addActivity.send(sender=None, user_from=player,
- user_to=player, message=signal_msg,
- arguments=arguments, game=None,
- action=action_msg)
player.level_no = level
player.save()
def score_simple(player, coin, amount, game=None, formula=None,
- external_id=None, percents=100):
+ external_id=None, percents=100 ):
""" Give amount of coin to the player.
"""
if not isinstance(game, Game) and game is not None:
@@ -252,8 +251,7 @@ def sync_user(player):
""" Synchronise user points with database
"""
coin = Coin.get('points')
- result = History.objects.filter(user=player.user,coin=coin).aggregate(total=models.Sum('amount'))
- points = result['total'] if result['total'] is not None else 0
+ points = real_points(player)
if player.points != points and not player.magic.has_modifier('top-disguise'):
logging.debug('%s had %d instead of %d points' % (player, player.points, points))
player.points = points
diff --git a/wouso/interface/apps/magic/views.py b/wouso/interface/apps/magic/views.py
index 26dff2b1..edd1d53f 100644
--- a/wouso/interface/apps/magic/views.py
+++ b/wouso/interface/apps/magic/views.py
@@ -34,6 +34,7 @@ def get_context_data(self, **kwargs):
# Disable exchange for real
exchange_disabled = BoolSetting.get('disable-Bazaar-Exchange').get_value()
+
try:
rate = scoring.calculate('gold-points-rate', gold=1)['points']
rate2 = round(1/scoring.calculate('points-gold-rate', points=1)['gold'])
@@ -65,9 +66,7 @@ def bazaar_exchange(request):
player = request.user.get_profile()
message, error = '', ''
- if BoolSetting.get('disable-Bazaar-Exchange').get_value():
- error = _("Exchange is disabled")
- elif request.method == 'POST':
+ if request.method == 'POST':
try:
points = float(request.POST.get('points', 0))
gold = round(float(request.POST.get('gold', 0)))
diff --git a/wouso/interface/tests.py b/wouso/interface/tests.py
index 062cffab..cd173105 100644
--- a/wouso/interface/tests.py
+++ b/wouso/interface/tests.py
@@ -24,15 +24,6 @@ def test_online_player(self):
self.assertTrue(player.user.username in str(last10_div))
- def test_online_player(self):
- player = self._get_player()
- self.client.login(username=player.user.username, password='test')
- response = self.client.get('/hub/')
- soup = BeautifulSoup(response.content, "html.parser")
- last10_div = soup.find_all(class_="widget")[0]
-
- self.assertTrue(player.user.username in str(last10_div))
-
def test_profile_page(self):
admin = self._get_superuser()
self._client_superuser()
diff --git a/wouso/resources/templates/magic/bazaar.html b/wouso/resources/templates/magic/bazaar.html
index 92d36ac2..e69de29b 100644
--- a/wouso/resources/templates/magic/bazaar.html
+++ b/wouso/resources/templates/magic/bazaar.html
@@ -1,155 +0,0 @@
-{% extends 'interface/section_base.html' %}
-{% load i18n %}
-{% load artifacts %}
-{% load user %}
-
-{% block title %}{% trans 'Magic' %}{% endblock %}
-{% block sectiontitle %}{% trans 'Magic' %}{% endblock %}
-
-{% block scripts %}
-
-
-{% endblock %}
-
-{% block sectioncontent %}
-
-
-
-
-
-
-
- {% for s in spells %}
- {% if s.available %}
-
-
-
- {% artifact s %}{{ s.title }}
- {{ s.description }}
-
- |
-
- {% if s.due_days == 1 %}
- {% trans '1 day' %}
- {% else %}
- {% if s.due_days > 1 %}
- {{ s.due_days }} {% trans 'days' %}
- {% endif %}
- {% endif %}
- |
-
- {% coin_amount s.price 'gold' %}
- |
-
- {% if user.get_profile.level_no >= s.level_required %}
- {% trans 'Buy' %}
- {% else %}
- {% blocktrans with s.level_required as level %}Level {{level}} required{% endblocktrans %}
- {% endif %}
- |
-
- {% spell_stock player s %}
- |
-
-
- {% endif %}
- {% empty %}
- {% trans 'Nothing' %}.
- {% endfor %}
-
-
-
- {% if not exchange_disabled %}
-
-
-
{{ rate_text }}
-
{% trans 'Exchange points for gold or gold for points' %}
-
-
-
-
- {% endif %}
-
-
-
-
- {% include 'activity/stream.html' %}
- {% include 'activity/stream_pagination.html' %}
-
-
-
-
-
-
{% trans 'Available' %}
- {% if theowner.magic.spell_amounts.all %}
-
- {% trans 'Spell' %} |
- {% trans 'Amount' %} |
-
- {% for s in theowner.magic.spell_amounts.all %}
- {% artifact s.spell %} {{ s.spell.title }} |
- {% spell_stock theowner s.spell %} |
-
- {% endfor %}
-
- {% else %}
- {% trans 'None.' %}
- {% endif %}
-
- {% if theowner.magic.spells.all %}
-
{% trans 'Active on me' %}
-
- {% trans 'Spell' %} |
- {% trans 'Source' %} |
- {% trans 'Until' %} |
-
- {% for s in theowner.magic.spells.all %}
-
- {% artifact s.spell %} {{ s.spell.title }} |
- {% player_simple s.source %} |
- {{ s.due }} |
-
- {% endfor %}
-
- {% endif %}
-
- {% if theowner.magic.spells_cast.all %}
-
{% trans 'Cast by me' %}
-
- {% trans 'Spell' %} |
- {% trans 'Target' %} |
- {% trans 'Until' %} |
-
- {% for s in theowner.magic.spells_cast.all %}
-
- {% artifact s.spell %} {{ s.spell.title }} |
- {% player_simple s.player %} |
- {{ s.due }} |
-
- {% endfor %}
-
- {% endif %}
-
-
-{% endblock %}
-
-