예제 #1
0
def manage_player_unset(request, player_id, task_id):
    player = get_object_or_404(SpecialQuestUser, id=player_id)
    task = get_object_or_404(SpecialQuestTask, id=task_id)

    if task in player.done_tasks.all():
        player.done_tasks.remove(task)
        scoring.unset(player, SpecialQuestGame, 'specialquest-passed', external_id=task.id)
        signal_msg = ugettext_noop('completed special quest {task_name}')
        arguments = dict(task_name=task.name)
        from wouso.interface.activity.models import Activity
        Activity.delete(SpecialQuestGame.get_instance(), player, player, signal_msg, arguments)

    return HttpResponseRedirect(reverse('specialquest_manage', args=(player.id,)))
예제 #2
0
파일: cpanel.py 프로젝트: alexef/wouso-1
def manage_player_unset(request, player_id, task_id):
    player = get_object_or_404(SpecialQuestUser, id=player_id)
    task = get_object_or_404(SpecialQuestTask, id=task_id)

    if task in player.done_tasks.all():
        player.done_tasks.remove(task)
        scoring.unset(player, SpecialQuestGame, 'specialquest-passed', external_id=task.id)
        signal_msg = ugettext_noop('completed special quest {task_name}')
        arguments = dict(task_name=task.name)
        from wouso.interface.activity.models import Activity
        Activity.delete(SpecialQuestGame.get_instance(), player, player, signal_msg, arguments)

    return HttpResponseRedirect(reverse('specialquest_manage', args=(player.id,)))
예제 #3
0
def player_group(request, id, page=u'1'):
    group = get_object_or_404(PlayerGroup, pk=id)

    top_users = group.players.all().order_by('-points')
    subgroups = group.children
    if group.parent:
        sistergroups = NewHistory.get_children_top(group.parent, PlayerGroup)
    else:
        sistergroups = None
    history = GroupHistory(group)

    for g in group.sisters:
        g.top = GroupHistory(g)

    activity_list = Activity.get_group_activiy(group)
    paginator = Paginator(activity_list, 10)
    try:
        activity = paginator.page(page)
    except (EmptyPage, InvalidPage):
        activity = paginator.page(paginator.num_pages)

    return render_to_response('profile/group.html', {
        'group': group,
        'top_users': top_users,
        'subgroups': subgroups,
        'sistergroups': sistergroups,
        'top': history,
        'activity': activity,
    },
                              context_instance=RequestContext(request))
예제 #4
0
def player_race(request, race_id):
    race = get_object_or_404(Race, pk=race_id)

    top_users = race.player_set.order_by('-points')
    activity_qs = Activity.get_race_activity(race)
    paginator = Paginator(activity_qs, 20)
    activity = paginator.page(1)

    # get top position
    races = list(Race.objects.filter(can_play=True))
    races.sort(key=lambda a: a.points, reverse=True)
    if race in races:
        top_rank = races.index(race) + 1
    else:
        top_rank = '-'

    groups = NewHistory.get_children_top(race, PlayerGroup)

    # Get levels
    levels = []
    for i, limit in enumerate(God.get_level_limits()):
        level = God.get_race_level(level_no=i + 1, race=race)
        level.limit = limit
        levels.append(level)

    return render_to_response('profile/race.html', {
        'race': race,
        'children': groups,
        'top_users': top_users,
        'top_rank': top_rank,
        'top': ObjectHistory(),
        'activity': activity,
        'levels': levels
    },
                              context_instance=RequestContext(request))
예제 #5
0
    def read(self, request, group_id, type=None):
        try:
            group = PlayerGroup.objects.get(pk=group_id)
        except PlayerGroup.DoesNotExist:
            return rc.NOT_FOUND

        gh = GroupHistory(group)
        fp, q = get_fullpath(request)

        if type is None:  # General information
            return {
                'id': group.id,
                'name': group.name,
                'points': group.live_points,
                'members': group.players.count(),
                'rank': gh.position,
                'activity': '%sactivity/%s' % (fp, q),
                'evolution': '%sevolution/%s' % (fp, q),
            }
        elif type == 'activity':
            qs = Activity.get_group_activiy(group)
            return [
                dict(user_from=unicode(a.user_from),
                     user_to=unicode(a.user_to),
                     message=a.message,
                     date=a.timestamp) for a in qs
            ]
        elif type == 'evolution':
            return gh.week_evolution()
예제 #6
0
파일: views.py 프로젝트: AndreiRO/wouso
def player_race(request, race_id):
    race = get_object_or_404(Race, pk=race_id)

    top_users = race.player_set.order_by('-points')
    activity_qs = Activity.get_race_activity(race)
    paginator = Paginator(activity_qs, 20)
    activity = paginator.page(1)

    # get top position
    races = list(Race.objects.filter(can_play=True))
    races.sort(key=lambda a: a.points, reverse=True)
    if race in races:
        top_rank = races.index(race) + 1
    else:
        top_rank = '-'

    groups = NewHistory.get_children_top(race, PlayerGroup)

    # Get levels
    levels = []
    for i, limit in enumerate(God.LEVEL_LIMITS):
        l = God.get_race_level(level_no=i + 1, race=race)
        l.limit = limit
        levels.append(l)

    return render_to_response('profile/race.html',
                            {'race': race,
                             'children': groups,
                             'top_users': top_users,
                             'top_rank': top_rank,
                             'top': ObjectHistory(),
                             'activity': activity,
                             'levels': levels},
                            context_instance=RequestContext(request)
    )
예제 #7
0
파일: views.py 프로젝트: AndreiRO/wouso
def player_group(request, id, page=u'1'):
    group = get_object_or_404(PlayerGroup, pk=id)

    top_users = group.players.all().order_by('-points')
    subgroups = group.children
    if group.parent:
        sistergroups = NewHistory.get_children_top(group.parent, PlayerGroup)
    else:
        sistergroups = None
    history = GroupHistory(group)

    for g in group.sisters:
        g.top = GroupHistory(g)

    activity_list = Activity.get_group_activiy(group)
    paginator = Paginator(activity_list, 10)
    try:
        activity = paginator.page(page)
    except (EmptyPage, InvalidPage):
        activity = paginator.page(paginator.num_pages)

    return render_to_response('profile/group.html',
                              {'group': group,
                               'top_users': top_users,
                               'subgroups': subgroups,
                               'sistergroups': sistergroups,
                               'top': history,
                               'activity': activity,
                               },
                              context_instance=RequestContext(request))
예제 #8
0
def get_wall(page=u'1'):
    """ Returns activity for main wall, paginated."""
    activity_list = Activity.get_global_activity()
    paginator = Paginator(activity_list, 10)
    try:
        activity = paginator.page(page)
    except (EmptyPage, InvalidPage):
        activity = paginator.page(paginator.num_pages)
    return activity
예제 #9
0
파일: views.py 프로젝트: AndreiRO/wouso
def get_wall(page=u'1'):
    """ Returns activity for main wall, paginated."""
    activity_list = Activity.get_global_activity()
    paginator = Paginator(activity_list, 10)
    try:
        activity = paginator.page(page)
    except (EmptyPage, InvalidPage):
        activity = paginator.page(paginator.num_pages)
    return activity
예제 #10
0
def new_activity_messages(chat_user):
    """
    Return a list of new messages from the activity module, formatted the same as create_message.
    """
    query = Activity.get_global_activity().filter(timestamp__gt=chat_user.last_message_ts)
    msgs = []
    for m in query:
        message = u'<strong>%s</strong> %s' % (m.user_from.nickname, m.message)
        msgs.append(dict(room='global', text=message, time=m.timestamp.strftime("%H:%M"), mess_type='activity'))
    return msgs
예제 #11
0
파일: utils.py 프로젝트: taygun/wouso
def new_activity_messages(chat_user):
    """
    Return a list of new messages from the activity module, formatted the same as create_message.
    """
    query = Activity.get_global_activity().filter(timestamp__gt=chat_user.last_message_ts)
    msgs = []
    for m in query:
        message = u'<strong>%s</strong> %s' % (m.user_from.nickname, m.message)
        msgs.append(dict(room='global', text=message, time=m.timestamp.strftime("%H:%M"), mess_type='activity'))
    return msgs
예제 #12
0
def all_activity(request):
    """
     Render all public activity, no matter race or game
    """
    page = 1
    activity_list = Activity.get_global_activity(wouso_only=False)
    paginator = Paginator(activity_list, 100)
    try:
        activity = paginator.page(page)
    except (EmptyPage, InvalidPage):
        activity = paginator.page(paginator.num_pages)

    return render_to_response('activity/all.html', {'activity': activity}, context_instance=RequestContext(request))
예제 #13
0
파일: views.py 프로젝트: AndreiRO/wouso
def all_activity(request):
    """
     Render all public activity, no matter race or game
    """
    page = 1
    activity_list = Activity.get_global_activity(wouso_only=False)
    paginator = Paginator(activity_list, 100)
    try:
        activity = paginator.page(page)
    except (EmptyPage, InvalidPage):
        activity = paginator.page(paginator.num_pages)

    return render_to_response('activity/all.html', {'activity': activity}, context_instance=RequestContext(request))
예제 #14
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))
예제 #15
0
파일: views.py 프로젝트: alexef/wouso-1
def player_race(request, race_id):
    race = get_object_or_404(Race, pk=race_id)

    top_users = race.player_set.order_by('-points')
    activity_qs = Activity.get_race_activiy(race)
    paginator = Paginator(activity_qs, 20)
    activity = paginator.page(1)

    return render_to_response('profile/race.html',
                            {'race': race,
                             'top_users': top_users,
                             'activity': activity},
                            context_instance=RequestContext(request)
    )
예제 #16
0
파일: views.py 프로젝트: AndreiRO/wouso
def hub(request):
    if request.user.is_anonymous():
        return anonymous_homepage(request)

    # check first time
    profile = request.user.get_profile()
    activity = Activity.get_player_activity(profile).count()
    if activity < 2:
        # first timer, show povestea
        from wouso.interface.apps.pages.models import StaticPage
        try:
            story = StaticPage.objects.get(slug='poveste')
        except: pass
        else:
            return HttpResponseRedirect(reverse('static_page', args=(story.slug,)))
    return homepage(request)
예제 #17
0
def hub(request):
    if request.user.is_anonymous():
        return anonymous_homepage(request)

    # check first time
    profile = request.user.get_profile()
    activity = Activity.get_player_activity(profile).count()
    if activity < 2:
        # first timer, show povestea
        from wouso.interface.apps.pages.models import StaticPage
        try:
            story = StaticPage.objects.get(slug='poveste')
        except: pass
        else:
            return HttpResponseRedirect(reverse('static_page', args=(story.slug,)))
    return homepage(request)
예제 #18
0
파일: views.py 프로젝트: cvicentiu/wouso
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))
예제 #19
0
파일: views.py 프로젝트: anaion/wouso
def player_race(request, race_id):
    race = get_object_or_404(Race, pk=race_id)

    top_users = race.player_set.order_by('-points')
    activity_qs = Activity.get_race_activity(race)
    paginator = Paginator(activity_qs, 20)
    activity = paginator.page(1)

    groups = NewHistory.get_children_top(race, PlayerGroup)

    return render_to_response('profile/race.html', {
        'race': race,
        'children': groups,
        'top_users': top_users,
        'activity': activity
    },
                              context_instance=RequestContext(request))
예제 #20
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))
예제 #21
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))
예제 #22
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))
예제 #23
0
    def read(self, request, group_id, type=None):
        try:
            group = PlayerGroup.objects.get(pk=group_id)
        except PlayerGroup.DoesNotExist:
            return rc.NOT_FOUND

        gh = GroupHistory(group)
        fp, q = get_fullpath(request)

        if type is None:  # General information
            return {
                'id': group.id,
                'name': group.name,
                'points': group.live_points,
                'members': group.players.count(),
                'rank': gh.position,
                'activity': '%sactivity/%s' % (fp, q),
                'evolution': '%sevolution/%s' % (fp, q)}
        elif type == 'activity':
            qs = Activity.get_group_activiy(group)
            return [dict(user_from=unicode(a.user_from), user_to=unicode(a.user_to), message=a.message, date=a.timestamp) for a in qs]
        elif type == 'evolution':
            return gh.week_evolution()
예제 #24
0
 def ac(self):
     return Activity.get_player_activity(self).count()