Esempio n. 1
0
def test_spuds(request):
    template_data = {}
    if is_fan(request.current_role):
        stream = SpudsController(request.current_role).get_spud_stream(
        ) + SpudsController.GetSpudsForFan(request.current_role.entity)
        # shuffle(stream)
        template_data['spuds'] = stream
        return render(request, 'spudderspuds/pages/test_spuds.html',
                      template_data)
Esempio n. 2
0
def fan_profile_view(request, page_id):
    return redirect('/fan')
    page = get_object_or_404(FanPage, pk=page_id)
    fan_role = RoleFan(page)
    krowdio_response = get_following(fan_role)
    template_data = {
        'page':
        page,
        'role':
        fan_role,
        'fan_spuds':
        SpudsController.GetSpudsForFan(page),
        'base_url':
        'spudderspuds/base.html',
        'following_teams':
        krowdio_users_to_links(request.can_edit, fan_role,
                               krowdio_response['data'],
                               EntityController.ENTITY_TEAM),
        'following_fans':
        krowdio_users_to_links(request.can_edit, fan_role,
                               krowdio_response['data'],
                               RoleController.ENTITY_FAN)
    }
    if request.can_edit:
        template_data[
            'following_teams_title'] = "<img src='/static/img/spudderspuds/button-teams-tiny.png' /> Teams You Follow"
        template_data[
            'following_fans_title'] = "<img src='/static/img/spudderspuds/button-fans-tiny.png' /> Fans You Follow"
    else:
        template_data[
            'following_teams_title'] = "<img src='/static/img/spudderspuds/button-teams-tiny.png' /> Teams %s Follows" % page.name
        template_data[
            'following_fans_title'] = "<img src='/static/img/spudderspuds/button-fans-tiny.png' /> Fans %s Follows" % page.name

    template_data['fan_nav_active'] = 'profile'
    template_data['challenges'] = {
        'created': [
            _format_challenge('created', c) for c in Challenge.objects.filter(
                creator_entity_id=fan_role.entity.id,
                creator_entity_type=RoleController.ENTITY_FAN)
        ],
        'waiting': [
            _format_challenge('waiting', c)
            for c in ChallengeParticipation.objects.filter(
                participating_entity_id=fan_role.entity.id,
                participating_entity_type=RoleController.ENTITY_FAN,
                state=ChallengeParticipation.PRE_ACCEPTED_STATE).
            select_related('challenge')
        ]
    }
    return render(request, 'spudderspuds/fans/pages/fan_page_view.html',
                  template_data)
Esempio n. 3
0
def affiliate_splash(request, affiliate_url_name):
    """
    Gives affiliate splash page
    :param request: any request
    :param affiliate_url_name: any string without the \ character,
        formatted to lowercase for URL matching
    :return: an affiliate's splash page, or a 404 error if not a valid
        affiliate URL
    """
    if affiliate_url_name:
        affiliate_url_name = affiliate_url_name.lower()
    if affiliate_url_name and affiliate_url_name == 'nays' and feature_is_enabled(
            'nays_survey'):
        return _nays_survey(request)

    try:
        aff = Affiliate.objects.get(url_name=affiliate_url_name)
    except Affiliate.DoesNotExist:
        raise Http404
    else:
        template_data = {
            'find_teams': TeamPage.objects.filter(affiliate=aff)[:10],
            'find_fans': FanPage.objects.filter(affiliate=aff)[:10],
            'find_clubs': Club.objects.filter(affiliate=aff)[:10],
            'affiliate': aff
        }
        if is_fan(request.current_role):
            spud_stream = SpudsController(
                request.current_role).get_spud_stream()
            fan_spuds = SpudsController.GetSpudsForFan(
                request.current_role.entity)
            stream = SpudsController.MergeSpudLists(spud_stream, fan_spuds)
            template_data['spuds'] = stream
            krowdio_response = get_following(request.current_role)
            template_data['teams'] = krowdio_users_to_links(
                request.can_edit, request.current_role,
                krowdio_response['data'], EntityController.ENTITY_TEAM)
            template_data['fans'] = krowdio_users_to_links(
                request.can_edit, request.current_role,
                krowdio_response['data'], RoleController.ENTITY_FAN)
            template_data['fan_nav_active'] = "explore"
        return render(request, 'spudderaffiliates/pages/landing_page.html',
                      template_data)
Esempio n. 4
0
def landing_page(request):
    template_data = {
        'find_teams': TeamPage.objects.all()[:10],
        'find_fans': FanPage.objects.all()[:10],
        'find_venues': Venue.objects.all()[:10]
    }
    if is_fan(request.current_role):
        spud_stream = SpudsController(request.current_role).get_spud_stream()
        fan_spuds = SpudsController.GetSpudsForFan(request.current_role.entity)
        stream = SpudsController.MergeSpudLists(spud_stream, fan_spuds)
        template_data['spuds'] = stream

        entity = {
            'id': request.current_role.entity.id,
            'type': request.current_role.entity_type
        }

        participating_challenges = ChallengeParticipation.objects.filter(
            participating_entity_id=entity['id'],
            participating_entity_type=entity['type'])
        template_data['challenge_participations'] = participating_challenges
        template_data['state_engine_states'] = _StateEngineStates
        template_data['my_challenges'] = Challenge.objects.filter(
            creator_entity_id=request.current_role.entity.id,
            creator_entity_type=request.current_role.entity_type)

        # participating_ids = [c.challenge.id for c in participating_challenges]
        #
        # template_data['challenges'] = [_format_challenge('dash participating', c, entity)
        #                                for c in participating_challenges] + \
        #                               [_format_challenge('dash created', c, participating_ids)
        #                                for c in Challenge.objects.filter(creator_entity_id=entity['id'],
        #                                                                  creator_entity_type=entity['type'])]
        #
        template_data['fan_nav_active'] = "explore"
    return render(request, 'spudderspuds/pages/landing_page.html',
                  template_data)