Example #1
0
    def test_user_points(self):
        coin = Coin.add('points')
        player = self._get_player()

        scoring.score_simple(player, 'points', 10)

        up = History.user_points(player.user)
        self.assertTrue(up.has_key('wouso'))
        self.assertTrue(up['wouso'].has_key(coin))
        self.assertEqual(up['wouso'][coin], 10)
Example #2
0
    def test_user_points(self):
        coin = Coin.add('points')
        player = self._get_player()

        scoring.score_simple(player, 'points', 10)

        up = History.user_points(player.user)
        self.assertTrue(up.has_key('wouso'))
        self.assertTrue(up['wouso'].has_key(coin))
        self.assertEqual(up['wouso'][coin], 10)
Example #3
0
    def test_user_points(self):
        coin = Coin.add("points")
        player = self._get_player()

        scoring.score_simple(player, "points", 10)

        up = History.user_points(player.user)
        self.assertTrue(up.has_key("wouso"))
        self.assertTrue(up["wouso"].has_key(coin))
        self.assertEqual(up["wouso"][coin], 10)
Example #4
0
def user_profile(request, id, page=u'1'):
    try:
        profile = Player.objects.get(id=id)
    except Player.DoesNotExist:
        raise Http404

    # TODO: parca exista o functie in core pentru gravatar
    avatar = "http://www.gravatar.com/avatar/%s.jpg?d=monsterid"\
        % md5(profile.user.email).hexdigest()
    activity_list = Activity.get_player_activity(profile)

    top_user = profile.get_extension(TopUser)
    #top_user.topgroups = list(profile.groups.all())
    #for g in top_user.topgroups:
    #    g.week_evolution = top_user.week_evolution(relative_to=g)
    #    g.position = TopHistory.get_user_position(top_user, relative_to=g)
    history = History.user_points(profile)
    paginator = Paginator(activity_list, 10)

    try:
        activity = paginator.page(page)
    except (EmptyPage, InvalidPage):
        activity = paginator.page(paginator.num_pages)

    profile_actions = ''
    profile_superuser_actions = ''
    for g in get_games():
        profile_actions += g.get_profile_actions(request, profile)
        profile_superuser_actions += g.get_profile_superuser_actions(request, profile)

        # some hackish introspection
        if hasattr(g, 'user_model'):
            model = getattr(g, 'user_model')
            setattr(profile, model.__name__.lower(), profile.get_extension(model))
    #Fix to show succes message from report user form
    if 'report_msg' in request.session:
        message = request.session['report_msg']
        del request.session['report_msg']
    else:
        message=''

    return render_to_response('profile/profile.html',
                              {'profile': profile,
                               'avatar': avatar,
                               'activity': activity,
                               'top': top_user,
                               'scoring': history,
                               'profile_actions': profile_actions,
                               'profile_superuser_actions': profile_superuser_actions,
                               'message': message, },
                              context_instance=RequestContext(request))
Example #5
0
def user_profile(request, id, page=u'1'):
    try:
        profile = Player.objects.get(id=id)
    except Player.DoesNotExist:
        raise Http404

    avatar = "http://www.gravatar.com/avatar/%s.jpg?d=monsterid"\
        % md5(profile.user.email).hexdigest()
    activity_list = Activity.objects.\
        filter(Q(user_to=id) | Q(user_from=id)).order_by('-timestamp')

    top_user = profile.get_extension(TopUser)
    top_user.topgroups = list(profile.groups.all().order_by('-gclass'))
    for g in top_user.topgroups:
        g.week_evolution = top_user.week_evolution(relative_to=g)
        g.position = TopHistory.get_user_position(top_user, relative_to=g)
    history = History.user_points(profile)
    paginator = Paginator(activity_list, 10)

    try:
        activity = paginator.page(page)
    except (EmptyPage, InvalidPage):
        activity = paginator.page(paginator.num_pages)

    profile_actions = ''
    profile_superuser_actions = ''
    for g in get_games():
        profile_actions += g.get_profile_actions(request, profile)
        profile_superuser_actions += g.get_profile_superuser_actions(
            request, profile)

        # some hackish introspection
        if hasattr(g, 'user_model'):
            model = getattr(g, 'user_model')
            setattr(profile, model.__name__.lower(),
                    profile.get_extension(model))

    return render_to_response(
        'profile/profile.html', {
            'profile': profile,
            'avatar': avatar,
            'activity': activity,
            'top': top_user,
            'scoring': history,
            'profile_actions': profile_actions,
            'profile_superuser_actions': profile_superuser_actions,
        },
        context_instance=RequestContext(request))
Example #6
0
def user_profile(request, id, page=u'1'):
    if int(id) == request.user.get_profile().id:
        profile = request.user.get_profile()
    else:
        profile = get_object_or_404(Player, id=id)

    activity_list = Activity.get_player_activity(profile)

    top_user = profile.get_extension(TopUser)
    #top_user.topgroups = list(profile.groups.all())
    #for g in top_user.topgroups:
    #    g.week_evolution = top_user.week_evolution(relative_to=g)
    #    g.position = TopHistory.get_user_position(top_user, relative_to=g)
    history = History.user_points(profile)
    paginator = Paginator(activity_list, 10)

    try:
        activity = paginator.page(page)
    except (EmptyPage, InvalidPage):
        activity = paginator.page(paginator.num_pages)

    profile_actions = ''
    profile_superuser_actions = ''
    for g in get_games():
        profile_actions += g.get_profile_actions(request, profile)
        profile_superuser_actions += g.get_profile_superuser_actions(request, profile)

        # some hackish introspection
        if hasattr(g, 'user_model'):
            model = getattr(g, 'user_model')
            setattr(profile, model.__name__.lower(), profile.get_extension(model))
    #Fix to show succes message from report user form
    if 'report_msg' in request.session:
        message = request.session['report_msg']
        del request.session['report_msg']
    else:
        message=''

    return render_to_response('profile/profile.html',
                              {'profile': profile,
                               'activity': activity,
                               'top': top_user,
                               'scoring': history,
                               'profile_actions': profile_actions,
                               'profile_superuser_actions': profile_superuser_actions,
                               'message': message, },
                              context_instance=RequestContext(request))
Example #7
0
def user_profile(request, id, page=u'1'):
    profile = get_object_or_404(Player, id=id)

    activity_list = Activity.get_player_activity(profile)

    top_user = profile.get_extension(TopUser)
    history = History.user_points(profile.user)
    paginator = Paginator(activity_list, 10)

    try:
        activity = paginator.page(page)
    except (EmptyPage, InvalidPage):
        activity = paginator.page(paginator.num_pages)

        # some hackish introspection
        if hasattr(g, 'user_model'):
            model = getattr(g, 'user_model')
            setattr(profile, model.__name__.lower(),
                    profile.get_extension(model))
    # Fix to show succes message from report user form
    if 'report_msg' in request.session:
        message = request.session['report_msg']
        del request.session['report_msg']
    else:
        message = ''

    challenge_launched_recently = Challenge.exist_last_day(
        date.today(), request.user.get_profile(), profile)
    specialquest_button = SpecialQuestGame.get_specialquest_user_button(
        request, profile)
    config_disable_magic = BoolSetting.get(
        'setting-magic').get_value() is False

    return render_to_response('profile/profile.html', {
        'profile': profile,
        'activity': activity,
        'top': top_user,
        'scoring': history,
        'challenge_launched_recently': challenge_launched_recently,
        'specialquest_button': specialquest_button,
        'config_disable_magic': config_disable_magic,
        'message': message
    },
                              context_instance=RequestContext(request))
Example #8
0
def user_profile(request, id, page=u'1'):
    try:
        profile = Player.objects.get(id=id)
    except Player.DoesNotExist:
        raise Http404

    avatar = "http://www.gravatar.com/avatar/%s.jpg?d=monsterid"\
        % md5(profile.user.email).hexdigest()
    activity_list = Activity.objects.\
        filter(Q(user_to=id) | Q(user_from=id)).order_by('-timestamp')

    top_user = profile.get_extension(TopUser)
    top_user.topgroups = list(profile.groups.all().order_by('-gclass'))
    for g in top_user.topgroups:
        g.week_evolution = top_user.week_evolution(relative_to=g)
        g.position = TopHistory.get_user_position(top_user, relative_to=g)
    history = History.user_points(profile)
    paginator = Paginator(activity_list, 10)

    try:
        activity = paginator.page(page)
    except (EmptyPage, InvalidPage):
        activity = paginator.page(paginator.num_pages)

    profile_actions = ''
    profile_superuser_actions = ''
    for g in get_games():
        profile_actions += g.get_profile_actions(request, profile)
        profile_superuser_actions += g.get_profile_superuser_actions(request, profile)

        # some hackish introspection
        if hasattr(g, 'user_model'):
            model = getattr(g, 'user_model')
            setattr(profile, model.__name__.lower(), profile.get_extension(model))

    return render_to_response('profile/profile.html',
                              {'profile': profile,
                               'avatar': avatar,
                               'activity': activity,
                               'top': top_user,
                               'scoring': history,
                               'profile_actions': profile_actions,
                               'profile_superuser_actions': profile_superuser_actions,},
                              context_instance=RequestContext(request))
Example #9
0
def user_profile(request, id, page=u'1'):
    profile = get_object_or_404(Player, id=id)

    activity_list = Activity.get_player_activity(profile)

    top_user = profile.get_extension(TopUser)
    history = History.user_points(profile.user)
    paginator = Paginator(activity_list, 10)

    try:
        activity = paginator.page(page)
    except (EmptyPage, InvalidPage):
        activity = paginator.page(paginator.num_pages)

    profile_actions = ''
    profile_superuser_actions = ''
    for g in get_games():
        profile_actions += g.get_profile_actions(request, profile)
        profile_superuser_actions += g.get_profile_superuser_actions(
            request, profile)

        # some hackish introspection
        if hasattr(g, 'user_model'):
            model = getattr(g, 'user_model')
            setattr(profile, model.__name__.lower(),
                    profile.get_extension(model))
    #Fix to show succes message from report user form
    if 'report_msg' in request.session:
        message = request.session['report_msg']
        del request.session['report_msg']
    else:
        message = ''

    return render_to_response('profile/profile.html', {
        'profile': profile,
        'activity': activity,
        'top': top_user,
        'scoring': history,
        'profile_actions': profile_actions,
        'profile_superuser_actions': profile_superuser_actions,
        'message': message,
    },
                              context_instance=RequestContext(request))
Example #10
0
def user_profile(request, id, page=u'1'):
    profile = get_object_or_404(Player, id=id)

    activity_list = Activity.get_player_activity(profile)

    top_user = profile.get_extension(TopUser)
    history = History.user_points(profile.user)
    paginator = Paginator(activity_list, 10)

    try:
        activity = paginator.page(page)
    except (EmptyPage, InvalidPage):
        activity = paginator.page(paginator.num_pages)

        # some hackish introspection
        if hasattr(g, 'user_model'):
            model = getattr(g, 'user_model')
            setattr(profile, model.__name__.lower(), profile.get_extension(model))
    #Fix to show succes message from report user form
    if 'report_msg' in request.session:
        message = request.session['report_msg']
        del request.session['report_msg']
    else:
        message=''

    challenge_launched_recently = Challenge.exist_last_day(date.today(),
                                        request.user.get_profile(), profile)
    specialquest_button = SpecialQuestGame.get_specialquest_user_button(request, profile)
    config_disable_magic = BoolSetting.get('setting-magic').get_value() is False

    return render_to_response('profile/profile.html',
                              {'profile': profile,
                               'activity': activity,
                               'top': top_user,
                               'scoring': history,
                               'challenge_launched_recently': challenge_launched_recently,
                               'specialquest_button': specialquest_button,
                               'config_disable_magic': config_disable_magic,
                               'message': message},
                              context_instance=RequestContext(request))