Example #1
0
def instagram_home(request):
    """
    The top twitter profiles, that link to particular users
    """
    me = get_me_from_instagram()

    if(request.GET.get('go_back_to_home')):
        return HttpResponseRedirect(reverse('home'))

    if(request.GET.get('scrape_all_followers')):
        scrape_all_followers()
        return HttpResponseRedirect('instagram_home/')

    if(request.GET.get('refresh_followers')):
        refresh_instagram_followers()
        return HttpResponseRedirect('instagram_home/')

    if(request.GET.get('follow_my_followers')):
        follow_my_instagram_followers()
        return HttpResponseRedirect('instagram_home/')

    if(request.GET.get('refresh_me')):
        me = refresh_and_return_me_from_instagram()
        return HttpResponseRedirect('instagram_home/')

    if(request.GET.get('generate_post')):
        generate_instagram_post()
        return HttpResponseRedirect('instagram_home/')

    template = loader.get_template('integrations/instagram_home.html')
    num_posts = 0
    followers = get_instagram_followers()
    num_followers = len(followers)
    context = {'num_posts': num_posts, 'followers': followers, 'num_followers': num_followers, 'me': me}
    return HttpResponse(template.render(context, request))
Example #2
0
def instagram_person_detail(request, person_username):
    author = None
    for person in InstagramPerson.objects.all():
        if person.username.strip() == person_username.strip():
            author = person

    if(request.GET.get('go_back_to_list')):
        return HttpResponseRedirect('/integrations/instagram_home')

    if(request.GET.get('scrape')):
        scrape_follower(author)
        return HttpResponseRedirect('/integrations/instagram_person_detail/' + person_username)

    if(request.GET.get('generate_post')):
        generate_instagram_post(author)
        return HttpResponseRedirect('/integrations/instagram_person_detail/' + person_username)

    if(request.GET.get('clear_follower_posts')):
        clear_follower_posts(author)
        return HttpResponseRedirect('/integrations/instagram_person_detail/' + person_username)

    posts = InstagramPost.objects.filter(author=author)
    hashtags = InstagramHashtag.objects.filter(original_post__author=author)
    context = RequestContext(request, {
        'person': author,
        'posts': posts,
        'len_posts': len(posts),
        'hashtags': hashtags,
        'len_hashtags': len(hashtags),
    })

    template = loader.get_template('integrations/instagram_person_detail.html')

    return HttpResponse(template.render(context))