Esempio n. 1
0
def friends_birthdays(request):
    """return a list of friends birthdays"""
    list_birthdays = []
    friends = get_list_related_users(user=request.user, mutual=False)
    start = request.GET['start']
    start = datetime.date.fromtimestamp(int(start))
    end = request.GET['end']
    end = datetime.date.fromtimestamp(int(end))
    
    for friend in friends:
        profile = friend.get_profile()
        birth_date = profile.birthday
        if birth_date:
            if (start.month == 12 and end.month == 2):
                birth_date = birth_date.replace(year = end.year)
            else :
                birth_date = birth_date.replace(year = start.year)
            if (birth_date >= start and birth_date <= end):                
                birthday = {               
                       'title' : _("%s\'s birthday") % friend.username,
                       'allDay' : True,
                       'color' : '#a2168b',
                       'start' : datetime.datetime.combine(birth_date, datetime.time()).strftime('%Y-%m-%dT%H:%M:%S'),               
                       'url' : profile.get_absolute_url(),               
                       }
                list_birthdays.append(birthday)
    
    if not list_birthdays:
        list_birthdays = None
    json_cals = simplejson.dumps(list_birthdays, ensure_ascii=False)        
    return HttpResponse(json_cals, content_type='application/javascript; charset=utf-8')
Esempio n. 2
0
def list_random_followers(request, username=None, template_name="friends/random_friends.html"):
    if username is None:
        user = request.user   
    else:
        user = User.objects.get(username=username)   
    followers = get_list_related_users(user=user, mutual=False, random=True)    
    return render_to_response(template_name, {
        "list_friends" : followers,
    }, context_instance=RequestContext(request))
Esempio n. 3
0
def list_random_friends(request, username=None, template_name="friends/random_friends.html"):
    if username is None:
        user = request.user   
    else:
        user = User.objects.get(username=username)   
    friends = get_list_related_users(user=user, random=True)
    return render_to_response(template_name, {
        "list_friends" : friends,
    }, context_instance=RequestContext(request))
Esempio n. 4
0
def list_followers(request, username=None, template_name="friends/list_friends.html"):
    if username is None:
        user = request.user   
    else:
        user = User.objects.get(username=username)   
    followers = get_list_related_users(user=user, mutual=False)
    return render_to_response(template_name, {
        "list_friends" : followers,
        "class" : "a.a_followers",
        "user_profile" : user,
        "type" : "Followers",
    }, context_instance=RequestContext(request))
Esempio n. 5
0
def list_friends(request, username=None, template_name="friends/list_friends.html"):
    if username is None:
        user = request.user   
    else:
        user = User.objects.get(username=username)   
    friends = get_list_related_users(user=user)
    return render_to_response(template_name, {
        "list_friends" : friends,
        "class"  : "a.a_friends",
        "user_profile" : user,
        "type" : "Friends",
    }, context_instance=RequestContext(request))
Esempio n. 6
0
def commun_followed(request, username, public_profile_field=None,
                   template_name='friends/list_friends.html',
                   extra_context=None):
    first_user = request.user
    second_user = User.objects.get(username=username)
    followed_for_first = get_list_related_users(user=first_user, mutual=False, direction='from')
    commun_followed = []
    for u in followed_for_first:
        if Friendship.objects.is_followed(u, second_user):            
            commun_followed.append(u)
            
    return render_to_response(template_name, {
        "list_friends" : commun_followed,
    }, context_instance=RequestContext(request))
Esempio n. 7
0
def commun_friends(request, username, public_profile_field=None,
                   template_name='friends/list_friends.html',
                   extra_context=None):
    first_user = request.user
    second_user = User.objects.get(username=username)
    friends_for_first = get_list_related_users(user=first_user)
    commun_friends = []
    for u in friends_for_first:
        if Friendship.objects.are_friends(second_user, u):            
            commun_friends.append(u)
            
    return render_to_response(template_name, {
        "list_friends" : commun_friends,
    }, context_instance=RequestContext(request))
Esempio n. 8
0
def list_random_followed(request,
                         username=None,
                         template_name="friends/random_friends.html"):
    if username is None:
        user = request.user
    else:
        user = User.objects.get(username=username)
    followed = get_list_related_users(user=user,
                                      mutual=False,
                                      direction='from',
                                      random=True)
    return render_to_response(template_name, {
        "list_friends": followed,
    },
                              context_instance=RequestContext(request))
Esempio n. 9
0
def list_followed(request,
                  username=None,
                  template_name="friends/list_friends.html"):
    if username is None:
        user = request.user
    else:
        user = User.objects.get(username=username)
    followed = get_list_related_users(user=user,
                                      mutual=False,
                                      direction='from')
    return render_to_response(template_name, {
        "list_friends": followed,
        "class": "a.a_following",
        "user_profile": user,
        "type": "Following",
    },
                              context_instance=RequestContext(request))
Esempio n. 10
0
def commun_followed(request,
                    username,
                    public_profile_field=None,
                    template_name='friends/list_friends.html',
                    extra_context=None):
    first_user = request.user
    second_user = User.objects.get(username=username)
    followed_for_first = get_list_related_users(user=first_user,
                                                mutual=False,
                                                direction='from')
    commun_followed = []
    for u in followed_for_first:
        if Friendship.objects.is_followed(u, second_user):
            commun_followed.append(u)

    return render_to_response(template_name, {
        "list_friends": commun_followed,
    },
                              context_instance=RequestContext(request))