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)
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)