Ejemplo n.º 1
0
def get_bookmarks_for_tags(request, tag_id):
	''' Retrieve the bookmarks corresponding to the tag id '''

	email = request.COOKIES.get("email", "")
	auth_token = request.COOKIES.get("auth", "")

	if not is_logged_in(email, auth_token):
		redirect_uri = '/tags/' + tag_id
		return login(request, redirect_uri=redirect_uri)

	redis_obj = Redis()
	bookmark_ids = bookmark_for_tags(redis_obj, int(tag_id))

	bookmark_list = [{} for i in xrange(len(bookmark_ids))]

	for i, bookmark_id in enumerate(bookmark_ids):
		bookmark_info = {}
		bookmark_id = int(bookmark_id)
		bookmark_info['url'] = get_url(redis_obj, bookmark_id)
		bookmark_info['name'] = get_name(redis_obj, bookmark_id)
		bookmark_info['description'] = get_description(redis_obj, bookmark_id)

		bookmark_list[i] = bookmark_info

	return HttpResponse(simplejson.dumps(bookmark_list),mimetype='application/json')

	return Http404()
Ejemplo n.º 2
0
		def wrapper_func(request, *args, **kwargs):
			
			email = request.COOKIES.get("email", "")
			auth_token = request.COOKIES.get("auth", "")

			if not is_logged_in(email, auth_token):
				return login(request, redirect_uri)

			return func(request, *args, **kwargs)
Ejemplo n.º 3
0
def get_relations(request,relation_type,username):
	''' Display the followers or following depending on the request '''

	email = request.COOKIES.get("email", "")
	auth_token = request.COOKIES.get("auth", "")

	if not is_logged_in(email, auth_token):
		return login(request,'/relation/' + relation_type)

	redis_obj = Redis()
	
	try:
		user_id = get_unique_id(redis_obj,username)
		if relation_type == "followers":
			relations = get_followers(redis_obj,user_id)
		elif relation_type == "following":
			relations = get_following(redis_obj,user_id)
		else:
			relations = []
	except:
		relations = []

	return HttpResponse(simplejson.dumps(relations),mimetype='application/json')