Example #1
0
    count = len(user.active_tasks)

    if not count:
        return ''

    return render_to_string('specialquest/sidebar.html', {
        'not_done': count,
        'id': 'specialquest'
    })


register_sidebar_block('specialquest', sidebar_widget)


def header_link(context):
    user = context.get('user', None)
    if not user or not user.is_authenticated() or SpecialQuestGame.disabled():
        return {}
    profile = user.get_profile()
    if profile:
        user = profile.get_extension(SpecialQuestUser)
        count = len(user.active_tasks)
    else:
        count = 0
    url = reverse('wouso.games.specialquest.views.index')

    return dict(link=url, count=count, text=_('Special'))


register_header_link('specialquest', header_link)
Example #2
0
    profile = user.get_profile()
    if profile:
        chall_user = profile.get_extension(ChallengeUser)
        challs = ChallengeGame.get_active(chall_user)
        # remove launched challenges by the user
        challs = [c for c in challs if not (c.status == 'L' and c.user_from.user == chall_user)]
        # remove refused challenges
        challs = [c for c in challs if not c.status == 'R']

        count = len(challs)
    else:
        count = 0
    url = reverse('wouso.games.challenge.views.index')

    return dict(link=url, count=count, text=_('Challenges'))
register_header_link('challenges', header_link)


def sidebar_widget(context):
    user = context.get('user', None)
    if not user or not user.is_authenticated():
        return ''
    chall_user = user.get_profile().get_extension(ChallengeUser)
    challs = ChallengeGame.get_active(chall_user)
    challs = [c for c in challs if c.status == 'A']
    # reduce noise, thanks
    if not challs:
        return ''
    return render_to_string('challenge/sidebar.html', {'challenges': challs,
                            'challenge': ChallengeGame,  'chall_user': chall_user, 'id': 'challenge'})
register_sidebar_block('challenge', sidebar_widget)
Example #3
0
        return render_to_response('messaging/message_one.html',
                                  {'m': message, 'mess_user': me},
                                  context_instance=RequestContext(request))
    raise Http404


@login_required
def delete(request, id):
    message = get_object_or_404(Message, pk=id)
    me = request.user.get_profile().get_extension(MessagingUser)

    if message.sender == me or message.receiver == me:
        message.delete()
    else:
        raise Http404
    go_back = request.META.get('HTTP_REFERER', None)
    if not go_back:
        go_back = reverse('wouso.interface.messaging.views.home')
    return HttpResponseRedirect(go_back)


def header_link(context):
    # TODO refactor this lame thing
    user = context.get('user', None)
    if not user or not user.is_authenticated():
        return dict(text=_('Messages'))
    count = MessageApp.get_unread_for_user(user)
    url = reverse('messaging')
    return dict(link=url, count=count, text=_('Messages'))
register_header_link('messaging', header_link)
Example #4
0
    message = get_object_or_404(Message, pk=id)
    me = request.user.get_profile().get_extension(MessagingUser)

    if message.sender == me or message.receiver == me:
        message.delete()
    else:
        raise Http404
    go_back = request.META.get('HTTP_REFERER', None)
    if not go_back:
        go_back = reverse('wouso.interface.messaging.views.home')
    return HttpResponseRedirect(go_back)


def header_link(context):
    # TODO refactor this lame thing
    user = context.get('user', None)

    if not user or not user.is_authenticated():
        return dict(text=_('Messages'))

    if MessageApp.disabled():
        return ''

    count = MessageApp.get_unread_for_user(user)
    url = reverse('messaging')

    return dict(link=url, count=count, text=_('Messages'))


register_header_link('messaging', header_link)
Example #5
0
        chall_user = profile.get_extension(ChallengeUser)
        challs = ChallengeGame.get_active(chall_user)
        # remove launched challenges by the user
        challs = [c for c in challs if not (c.status == "L" and c.user_from.user == chall_user)]
        # remove refused challenges
        challs = [c for c in challs if not c.status == "R"]

        count = len(challs)
    else:
        count = 0
    url = reverse("wouso.games.challenge.views.index")

    return dict(link=url, count=count, text=_("Challenges"))


register_header_link("challenges", header_link)


def sidebar_widget(context):
    user = context.get("user", None)
    if not user or not user.is_authenticated():
        return ""

    chall_user = user.get_profile().get_extension(ChallengeUser)
    challs = ChallengeGame.get_active(chall_user)
    challs = [c for c in challs if c.status == "A"]
    # reduce noise, thanks
    if not challs:
        return ""
    return render_to_string(
        "challenge/sidebar.html",
Example #6
0
        return ''
    user = user.get_profile().get_extension(SpecialQuestUser)
    count = len(user.active_tasks)

    if not count:
        return ''

    return render_to_string('specialquest/sidebar.html',
                            {'not_done': count})


register_sidebar_block('specialquest', sidebar_widget)


def header_link(context):
    user = context.get('user', None)
    if not user or not user.is_authenticated() or SpecialQuestGame.disabled():
        return {}
    profile = user.get_profile()
    if profile:
        user = profile.get_extension(SpecialQuestUser)
        count = len(user.active_tasks)
    else:
        count = 0
    url = reverse('wouso.games.specialquest.views.index')

    return dict(link=url, count=count, text=_('Special'))


register_header_link('specialquest', header_link)
Example #7
0
        return u"%s casted on %s until %s [%s]" % (self.spell, self.player, self.due, self.source)


class Bazaar(App):
    @classmethod
    def get_header_link(kls, context):
        user = context.get('user', None)
        if kls.disabled() or not user:
            return {}
        url = reverse('bazaar_home')
        player = user.get_profile() if user.is_authenticated() else None
        if player:
            count = PlayerSpellDue.objects.filter(player=player, seen=False).count()
        else:
            count = 0

        return dict(link=url, text=_('Magic'), count=count)

    @classmethod
    def management_task(cls, datetime=lambda: datetime.now(), stdout=sys.stdout):
        spells = PlayerSpellDue.get_expired(datetime)

        stdout.write(" %d expired spells\n" % spells.count())
        for s in spells:
            SpellHistory.expired(s.player, s.spell)

            signals.postExpire.send(sender=None, psdue=s)
            s.delete()

register_header_link('bazaar', Bazaar.get_header_link)
Example #8
0

class Bazaar(App):
    @classmethod
    def get_header_link(kls, context):
        user = context.get("user", None)
        if kls.disabled() or not user:
            return {}
        url = reverse("bazaar_home")
        player = user.get_profile() if user.is_authenticated() else None
        if player:
            count = PlayerSpellDue.objects.filter(player=player, seen=False).count()
        else:
            count = 0

        return dict(link=url, text=_("Magic"), count=count)

    @classmethod
    def management_task(cls, datetime=lambda: datetime.now(), stdout=sys.stdout):
        spells = PlayerSpellDue.get_expired(datetime)

        stdout.write(" %d expired spells\n" % spells.count())
        for s in spells:
            SpellHistory.expired(s.player, s.spell)

            signals.postExpire.send(sender=None, psdue=s)
            s.delete()


register_header_link("bazaar", Bazaar.get_header_link)
Example #9
0
        return u"%s casted on %s until %s [%s]" % (self.spell, self.player, self.due, self.source)


class Bazaar(App):
    @classmethod
    def get_header_link(kls, context):
        user = context.get('user', None)
        if kls.disabled() or not user:
            return {}
        url = reverse('bazaar_home')
        player = user.get_profile() if user.is_authenticated() else None
        if player:
            count = PlayerSpellDue.objects.filter(player=player, seen=False).count()
        else:
            count = 0

        return dict(link=url, text=_('Magic'), count=count)

    @classmethod
    def management_task(cls, datetime=lambda: datetime.now(), stdout=sys.stdout):
        spells = PlayerSpellDue.get_expired(datetime)

        stdout.write(" %d expired spells\n" % spells.count())
        for s in spells:
            SpellHistory.expired(s.player, s.spell)

            signals.postExpire.send(sender=None, psdue=s)
            s.delete()

register_header_link('bazaar', Bazaar.get_header_link)