def blogger_pins(request, influencer_id): brand = request.visitor["brand"] base_brand = request.visitor["base_brand"] assoc_inf = account_helpers.get_associated_influencer(request.user) plan_name = brand.stripe_plan try: influencers_qs = Influencer.objects.prefetch_related('platform_set') influencer = influencers_qs.get(id=influencer_id) except: raise Http404() if brand: mongo_utils.track_query("brand-clicked-blogger-pins", {'blog_url': influencer.blog_url}, {"user_id": request.visitor["auth_user"].id}) account_helpers.intercom_track_event(request, "brand-clicked-blogger-pins", {'blog_url': influencer.blog_url}) elif assoc_inf: account_helpers.intercom_track_event(request, "blogger-view-pins", {'blog_url': influencer.blog_url}) if request.is_ajax(): data = feeds_helpers.pinterest_feed_json(request, for_influencer=influencer, default_posts="about_pins") data = json.dumps(data, cls=DjangoJSONEncoder) return HttpResponse(data, content_type="application/json") else: influencer = serializers.annotate_influencer(influencer, request=request) context = { 'influencer': influencer, 'page': 'pins', 'selected_tab': 'search_bloggers', 'search_page': True, 'type': 'all', 'selected_tab': 'search', 'sub_page': 'main_search', 'shelf_user': request.visitor["user"], 'debug': settings.DEBUG, 'tag_id': request.GET.get('tag_id'), 'saved_search': request.GET.get('saved_search'), } context.update( search_helpers.prepare_filter_params(context, plan_name=plan_name)) return render(request, 'pages/bloggers/blogger_pins.html', context)
def blogger_posts_sponsored(request, influencer_id): mongo_utils.track_visit(request) brand = request.visitor["brand"] base_brand = request.visitor["base_brand"] assoc_inf = account_helpers.get_associated_influencer(request.user) try: influencers_qs = Influencer.objects.prefetch_related('platform_set') influencer = influencers_qs.get(id=influencer_id) except: raise Http404() if not brand and assoc_inf != influencer: return HttpResponseForbidden() if brand: mongo_utils.track_query("brand-clicked-blogger-sponsored-posts", {'blog_url': influencer.blog_url}, {"user_id": request.visitor["auth_user"].id}) account_helpers.intercom_track_event( request, "brand-clicked-blogger-sponsored-posts", {'blog_url': influencer.blog_url}) elif assoc_inf: account_helpers.intercom_track_event(request, "blogger-view-sponsored-posts", {'blog_url': influencer.blog_url}) if request.is_ajax(): data = feeds_helpers.collab_feed_json(request, for_influencer=influencer, default_posts="about") data = json.dumps(data, cls=DjangoJSONEncoder) return HttpResponse(data, content_type="application/json") else: influencer = serializers.annotate_influencer(influencer, request=request) return render( request, 'pages/bloggers/blogger_posts_sponsored.html', { 'influencer': influencer, 'page': 'posts_sponsored', 'selected_tab': 'search_bloggers', 'search_page': True, })
def blogger_items(request, influencer_id): brand = request.visitor["brand"] base_brand = request.visitor["base_brand"] assoc_inf = account_helpers.get_associated_influencer(request.user) try: influencer = Influencer.objects influencer = influencer.prefetch_related('platform_set') influencer = influencer.get(id=influencer_id) except: raise Http404() if brand: mongo_utils.track_query("brand-clicked-blogger-products", {'blog_url': influencer.blog_url}, {"user_id": request.visitor["auth_user"].id}) account_helpers.intercom_track_event(request, "brand-clicked-blogger-products", {'blog_url': influencer.blog_url}) elif assoc_inf: account_helpers.intercom_track_event(request, "blogger-view-products", {'blog_url': influencer.blog_url}) if request.is_ajax() or request.GET.get('debug'): data = feeds_helpers.product_feed_json(request, for_influencer=influencer) data = json.dumps(data, cls=DjangoJSONEncoder) if request.GET.get('debug'): return HttpResponse("<body></body>") return HttpResponse(data, content_type="application/json") else: influencer = serializers.annotate_influencer(influencer, request=request) return render( request, 'pages/bloggers/blogger_items.html', { 'influencer': influencer, 'page': 'items', 'selected_tab': 'search_bloggers', 'search_page': True, })
def blogger_generic_posts(request, section, influencer_id, **kwargs): mongo_utils.track_visit(request) brand = request.visitor["brand"] base_brand = request.visitor["base_brand"] # parameters show_filters = False and brand.stripe_plan # get influencer from db try: influencers_qs = Influencer.objects.prefetch_related('platform_set') influencer = influencers_qs.get(id=influencer_id) except: raise Http404() # track events if brand: mongo_utils.track_query("brand-clicked-blogger-posts", {'blog_url': influencer.blog_url}, {"user_id": request.visitor["auth_user"].id}) account_helpers.intercom_track_event(request, "brand-clicked-blogger-posts", {'blog_url': influencer.blog_url}) elif account_helpers.get_associated_influencer(request.user): account_helpers.intercom_track_event(request, "blogger-view-posts", {'blog_url': influencer.blog_url}) influencer = serializers.annotate_influencer(influencer, request=request) context = { 'influencer': influencer, 'page': normalize_posts_section_name(section), 'selected_tab': 'search_bloggers', 'search_page': True, 'show_filters': show_filters, 'for_influencer': influencer.id, # 'posts_section': section, 'initial_search_mode': normalize_posts_section_name(section), 'init_brand': kwargs.get('brand_domain'), 'type': 'all', 'selected_tab': 'search', 'sub_page': 'main_search', 'shelf_user': request.visitor["user"], 'debug': settings.DEBUG, 'tag_id': request.GET.get('tag_id'), 'saved_search': request.GET.get('saved_search'), 'sections': get_sections( include_all_section=kwargs.get('brand_domain') is not None), 'blogger_page': True, } if show_filters: context.update( search_helpers.prepare_filter_params(context, plan_name=brand.stripe_plan)) return render(request, 'pages/bloggers/blogger_generic_posts.html', context)
def blogger_about(request, influencer_id): mongo_utils.track_visit(request) mongo_utils.influencer_profile_viewed(influencer_id) try: influencers_qs = Influencer.objects.prefetch_related('platform_set') influencer = influencers_qs.get(id=influencer_id) except: raise Http404() profile = influencer.shelf_user and influencer.shelf_user.userprofile or None if influencer.blacklisted: from debra.account_views import access_locked_page return access_locked_page(request, "Access is locked by administration.") assoc_inf = account_helpers.get_associated_influencer(request.user) if assoc_inf == influencer: profile_owner = True add_email = True else: profile_owner = False brand = request.visitor["brand"] base_brand = request.visitor["base_brand"] influencer_data = search_helpers.get_influencer_json( influencer, include_photos=True, long_post_content=True, request=request) try: influencer_data['profile']['items_list'] = influencer_data['profile'][ 'items'] except KeyError: pass influender_profile_id = influencer_data.get("profile", {}).get("id", None) add_email = False if base_brand and base_brand.is_subscribed: if base_brand.stripe_plan in STRIPE_EMAIL_PLANS: add_email = True if base_brand.stripe_plan in STRIPE_COLLECTION_PLANS: influencer = Influencer.objects.get(id=influencer_id) influencer_data["can_favorite"] = True influencer_data["is_favoriting"] = brand.influencer_groups.filter( influencers_mapping__influencer__id=influencer_id).exists() else: influencer_data["can_favorite"] = False if add_email: influencer_data["email"] = False emails = influencer.email if emails: splited = emails.split() if splited: influencer_data["email"] = splited[0] if brand: mongo_utils.track_query("brand-clicked-blogger-about", {'blog_url': influencer.blog_url}, {"user_id": request.visitor["auth_user"].id}) account_helpers.intercom_track_event(request, "brand-clicked-blogger-about", {'blog_url': influencer.blog_url}) elif assoc_inf: account_helpers.intercom_track_event(request, "blogger-view-about", {'blog_url': influencer.blog_url}) influencer = serializers.annotate_influencer(influencer, request=request) return render( request, 'pages/bloggers/blogger_about.html', { 'influencer': influencer, 'page': 'about', 'posts': json.dumps(influencer_data.get("posts"), cls=DjangoJSONEncoder), 'influencer_data': influencer_data, 'style_tags': profile and profile.style_tags and profile.style_tags.split(","), 'relfashion_stats': json.dumps(influencer_data.get("relfashion_stats"), cls=DjangoJSONEncoder), 'category_stats': json.dumps(influencer_data.get("category_stats"), cls=DjangoJSONEncoder), 'popularity_stats': json.dumps(influencer_data.get("popularity_stats"), cls=DjangoJSONEncoder), 'popularity_sums': json.dumps(influencer_data.get("popularity_sums"), cls=DjangoJSONEncoder), 'STRIPE_PLAN_STARTUP': STRIPE_PLAN_STARTUP, 'STRIPE_PLAN_BASIC': STRIPE_PLAN_BASIC, 'STRIPE_EMAIL_PLANS': STRIPE_EMAIL_PLANS, 'COLLABORATION_TYPES': InfluencerCollaborations.COLLABORATION_TYPES, 'profile_owner': profile_owner, 'selected_tab': 'search_bloggers', 'search_page': True, 'sections': get_sections(), 'blogger_page': True, })