Example #1
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)
Example #2
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)
Example #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)
Example #4
0
 def check_following_page(self, request):
     followers = get_following(request.current_role)
     following = False
     if followers['totalItems'] > 0:
         for user in followers['data']:
             try:
                 item = KrowdIOStorage.objects.get(krowdio_user_id=user['_id'])
                 path = str(request.path)
                 if re.match('/venues/view/\d+', path) and item.venue:
                     if str(item.venue.id) == str.split(path, '/')[-1]:
                         following = True
                 elif re.match('/fan/\d+/*$', path) and item.role_type == 'fan':
                     if str(item.role_id) == str.split(path, '/')[-1]:
                         following = True
                 elif re.match('/team/\d+', path) and item.team:
                     if str(item.team.id) == str.split(path, '/')[-1]:
                         following = True
             except KrowdIOStorage.DoesNotExist:
                 pass
     request.following = following
Example #5
0
 def check_following_page(self, request):
     followers = get_following(request.current_role)
     following = False
     if followers['totalItems'] > 0:
         for user in followers['data']:
             try:
                 item = KrowdIOStorage.objects.get(
                     krowdio_user_id=user['_id'])
                 path = str(request.path)
                 if re.match('/venues/view/\d+', path) and item.venue:
                     if str(item.venue.id) == str.split(path, '/')[-1]:
                         following = True
                 elif re.match('/fan/\d+/*$',
                               path) and item.role_type == 'fan':
                     if str(item.role_id) == str.split(path, '/')[-1]:
                         following = True
                 elif re.match('/team/\d+', path) and item.team:
                     if str(item.team.id) == str.split(path, '/')[-1]:
                         following = True
             except KrowdIOStorage.DoesNotExist:
                 pass
     request.following = following
Example #6
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)