コード例 #1
0
ファイル: views.py プロジェクト: itamsvtd/FrittieHome
def show_notification(request):
    now = datetime.datetime.now()
    autocomplete_data = get_autocomplete_data(request)
    member_login = get_member_login_object(request)
    current_page = 1
    if 'page' in request.GET:
        current_page = int(request.GET['page'])
    all_notifies = Notify.objects.filter(
        notify_to=member_login).order_by("-date")
    last_page = int(len(all_notifies) / 10) + 1
    notifies = all_notifies[(current_page - 1) * 10:current_page * 10]
    for notify in notifies:
        elapse_time = now - notify.date
        notify.elapse_time = get_elapse_time(int(elapse_time.total_seconds()))
        if notify.status == 'new': notify.status = 'old'
        notify.save()
    new_buzzes = get_new_buzzes(request)
    new_mail = get_new_mail(request)
    new_notify = len(new_buzzes) + len(new_mail)
    return render_to_response("notify_template/page/main_page.html", {
        "autocomplete_data": autocomplete_data,
        "member_login": member_login,
        'current_page': current_page,
        'last_page': last_page,
        "notifies": notifies,
        "new_buzzes": new_buzzes,
        'new_mail': new_mail,
        'new_notify': new_notify
    },
                              context_instance=RequestContext(request))
コード例 #2
0
def show_notification(request):
	now = datetime.datetime.now()
	autocomplete_data =  get_autocomplete_data(request)
	member_login = get_member_login_object(request)
	current_page = 1
	if 'page' in request.GET:
		current_page = int(request.GET['page'])
	all_notifies = Notify.objects.filter(notify_to=member_login).order_by("-date")
	last_page = int(len(all_notifies) / 10) + 1
	notifies = all_notifies[(current_page-1)*10:current_page*10] 
	for notify in notifies:
		elapse_time = now - notify.date
		notify.elapse_time = get_elapse_time(int(elapse_time.total_seconds())) 
		if notify.status == 'new': notify.status = 'old'
		notify.save()
	new_buzzes = get_new_buzzes(request)
	new_mail = get_new_mail(request)
	new_notify = len(new_buzzes) + len(new_mail)
	return render_to_response(
			"notify_template/page/main_page.html",
			{
				"autocomplete_data": autocomplete_data,
				"member_login": member_login,
				'current_page': current_page,
				'last_page': last_page,
				"notifies": notifies,
				"new_buzzes": new_buzzes,
				'new_mail': new_mail,
				'new_notify': new_notify
			},
			context_instance=RequestContext(request)
		)
コード例 #3
0
def member_message(request,username):
	member_chat = get_object_or_404(Member,user=get_object_or_404(User,username=username))
	member_login = get_member_login_object(request)
	messages = get_specific_conversation(request,member_chat)
	if member_chat == member_login or messages == 'redirect': 
		return HttpResponseRedirect('/messages/')

	autocomplete_data = get_autocomplete_data(request)
	friends = member_login.get_friends()
	friends_autocomplete_data = get_friends_autocomplete_data(request,message=True)
	new_buzzes = get_new_buzzes(request)
	new_mail = get_new_mail(request)
	new_notify = len(new_buzzes) + len(new_mail)
	return render_to_response('message_template/page/member_message_page.html',
						{
							'autocomplete_data': autocomplete_data,
							'member_login': member_login,
							'member_chat': member_chat,
							'friends': friends,
							'friends_autocomplete_data': friends_autocomplete_data,
							'new_buzzes': new_buzzes,
							'new_mail': new_mail,
							'new_notify': new_notify,
							'messages': messages
						},
						context_instance=RequestContext(request)
					)
コード例 #4
0
def member_message(request, username):
    member_chat = get_object_or_404(Member,
                                    user=get_object_or_404(User,
                                                           username=username))
    member_login = get_member_login_object(request)
    messages = get_specific_conversation(request, member_chat)
    if member_chat == member_login or messages == 'redirect':
        return HttpResponseRedirect('/messages/')

    autocomplete_data = get_autocomplete_data(request)
    friends = member_login.get_friends()
    friends_autocomplete_data = get_friends_autocomplete_data(request,
                                                              message=True)
    new_buzzes = get_new_buzzes(request)
    new_mail = get_new_mail(request)
    new_notify = len(new_buzzes) + len(new_mail)
    return render_to_response(
        'message_template/page/member_message_page.html', {
            'autocomplete_data': autocomplete_data,
            'member_login': member_login,
            'member_chat': member_chat,
            'friends': friends,
            'friends_autocomplete_data': friends_autocomplete_data,
            'new_buzzes': new_buzzes,
            'new_mail': new_mail,
            'new_notify': new_notify,
            'messages': messages
        },
        context_instance=RequestContext(request))
コード例 #5
0
ファイル: views.py プロジェクト: itamsvtd/FrittieHome
def main_page(request):
	autocomplete_data = get_autocomplete_data(request)
	location_categories = LocationCategory.objects.all()
	member_login = get_member_login_object(request)
	new_buzzes = get_new_buzzes(request)
	new_mail = get_new_mail(request)
	new_notify = len(new_buzzes) + len(new_mail)
	locations = Location.objects.all()
	today_activities = get_today_activity()
	trending_activities = get_trending_activity()
	hot_activities = get_hot_activity()
	return render_to_response(
			"main_template/page/index.html",
			{
				"member_login": member_login,
				'new_notify': new_notify,
				'new_buzzes': new_buzzes,
				'new_mail': new_mail,
				"locations": locations,
				"autocomplete_data": autocomplete_data,
				"location_categories": location_categories,
				"today_activities": today_activities,
				'trending_activities': trending_activities,
				'hot_activities': hot_activities,
			},
			context_instance=RequestContext(request)
		)
コード例 #6
0
ファイル: views.py プロジェクト: itamsvtd/FrittieHome
def show_photo(request,photo_type,object_id,photo_id):
    all_photo = Photo.objects.filter(photo_type=photo_type,object_id=object_id)
    current_photo = get_object_or_404(Photo,pk=photo_id)
    member_login= get_member_login_object(request)
    autocomplete_data = get_autocomplete_data(request)
    new_buzzes = get_new_buzzes(request)
    new_mail = get_new_mail(request)
    new_notify = len(new_buzzes) + len(new_mail)
    return render_to_response('photo_template/page/main_page.html',
                                {
                                    'autocomplete_data': autocomplete_data,
                                    'member_login': member_login,
                                    'current_photo': current_photo,
                                    'all_photo': all_photo,
                                    'new_buzzes': new_buzzes,
                                    'new_mail': new_mail,
                                    'new_notify': new_notify
                                },
                                context_instance = RequestContext(request)
                            )

# def multi_show_uploaded(request, key):
#     """Simple file view helper.
#     Used to show uploaded file directly"""
#     image = get_object_or_404(Photo, key_data=key)
#     url = settings.MEDIA_URL+image.image.name
#     return render_to_response('photo_template/one_image.html', {"multi_single_url":url,})
コード例 #7
0
ファイル: views.py プロジェクト: itamsvtd/FrittieHome
def find_friend(request):
    member_login = get_member_login_object(request)
    autocomplete_data = get_autocomplete_data(request)
    is_import_fb_friend = False
    invite_friends = None
    suggest_friends = None
    facebook_friends = get_facebook_friends(member_login)
    new_buzzes = get_new_buzzes(request)
    new_mail = get_new_mail(request)
    new_notify = len(new_buzzes) + len(new_mail)
    if facebook_friends != None:
        is_import_fb_friend = True
        invite_friends = facebook_friends[1]
        suggest_friends = facebook_friends[0]
    return render_to_response('friend_template/page/main_page.html', {
        "member_login": member_login,
        "autocomplete_data": autocomplete_data,
        'is_import_fb_friend': is_import_fb_friend,
        'invite_friends': invite_friends,
        'suggest_friends': suggest_friends,
        'new_notify': new_notify,
        'new_buzzes': new_buzzes,
        'new_mail': new_mail
    },
                              context_instance=RequestContext(request))
コード例 #8
0
ファイル: views.py プロジェクト: itamsvtd/FrittieHome
def find_friend(request):
	member_login = get_member_login_object(request)
	autocomplete_data = get_autocomplete_data(request)
	is_import_fb_friend = False
	invite_friends = None
	suggest_friends = None
	facebook_friends = get_facebook_friends(member_login)
	new_buzzes = get_new_buzzes(request)
	new_mail = get_new_mail(request)
	new_notify = len(new_buzzes) + len(new_mail)
	if facebook_friends != None:
		is_import_fb_friend = True
		invite_friends = facebook_friends[1]
		suggest_friends = facebook_friends[0]
	return render_to_response('friend_template/page/main_page.html',
							{
								"member_login": member_login,
								"autocomplete_data": autocomplete_data,
								'is_import_fb_friend': is_import_fb_friend,
								'invite_friends': invite_friends,
								'suggest_friends': suggest_friends,
								'new_notify': new_notify,
								'new_buzzes': new_buzzes,
								'new_mail': new_mail
							},
							context_instance=RequestContext(request)
							)
コード例 #9
0
ファイル: views.py プロジェクト: itamsvtd/FrittieHome
def safety(request):
    autocomplete_data = get_autocomplete_data(request)
    member_login = get_member_login_object(request)
    return render_to_response("info_template/page/safety.html", {
        "member_login": member_login,
        'autocomplete_data': autocomplete_data,
    },
                              context_instance=RequestContext(request))
コード例 #10
0
ファイル: views.py プロジェクト: itamsvtd/FrittieHome
def safety(request):
	autocomplete_data = get_autocomplete_data(request)
	member_login = get_member_login_object(request)
    	return render_to_response("info_template/page/safety.html",
    				{
                		"member_login": member_login,
                		'autocomplete_data': autocomplete_data,
            		},
            		context_instance = RequestContext(request)
    			)
コード例 #11
0
def show_feeds(request):
    member_login = get_member_login_object(request)
    autocomplete_data = get_autocomplete_data(request)
    friends = member_login.get_friends()
    friends_activity_stream = get_friend_activity_stream(
        request, 'page_content')[:PAGE_STREAM_LIMIT]
    new_buzzes = get_new_buzzes(request)
    new_mail = get_new_mail(request)
    new_notify = len(new_buzzes) + len(new_mail)
    return render_to_response('feed_template/page/main_page.html', {
        "member_login": member_login,
        "autocomplete_data": autocomplete_data,
        'friends': friends,
        'friends_activity_stream': friends_activity_stream,
        'new_notify': new_notify,
        'new_buzzes': new_buzzes,
        'new_mail': new_mail
    },
                              context_instance=RequestContext(request))
コード例 #12
0
ファイル: views.py プロジェクト: itamsvtd/FrittieHome
def show_feeds(request):
	member_login = get_member_login_object(request)
	autocomplete_data = get_autocomplete_data(request)
	friends = member_login.get_friends()
	friends_activity_stream = get_friend_activity_stream(request,'page_content')[:PAGE_STREAM_LIMIT]
	new_buzzes = get_new_buzzes(request)
	new_mail = get_new_mail(request)
	new_notify = len(new_buzzes) + len(new_mail)
	return render_to_response('feed_template/page/main_page.html',
							{
								"member_login": member_login,
								"autocomplete_data": autocomplete_data,
								'friends': friends,
								'friends_activity_stream':friends_activity_stream,
								'new_notify': new_notify,
								'new_buzzes': new_buzzes,
								'new_mail': new_mail
							},
							context_instance=RequestContext(request)
							)
コード例 #13
0
ファイル: views.py プロジェクト: itamsvtd/FrittieHome
def show_error(request):
	error_type = None
	if error_type in request.GET:
		error_type = request.GET['type']

	autocomplete_data = get_autocomplete_data(request)
	member_login = get_member_login_object
	new_buzzes = get_new_buzzes(request)
	new_mail = get_new_mail(request)
	new_notify = len(new_buzzes) + len(new_mail)
	return render_to_response(
				"error.html",
				{
					"member_login": member_login,
					'error_type': error_type,
					'new_notify': new_notify,
					'new_buzzes': new_buzzes,
					'new_mail': new_mail,
				},
				context_instance=RequestContext(request)
				)
コード例 #14
0
def message_main_view(request):
    autocomplete_data = get_autocomplete_data(request)

    member_login = get_member_login_object(request)
    friends = member_login.get_friends()
    friends_autocomplete_data = get_friends_autocomplete_data(request,
                                                              message=True)
    messages = get_all_conversation(request)
    new_buzzes = get_new_buzzes(request)
    new_mail = get_new_mail(request)
    new_notify = len(new_buzzes) + len(new_mail)
    return render_to_response('message_template/page/main_page.html', {
        'autocomplete_data': autocomplete_data,
        'member_login': member_login,
        'new_buzzes': new_buzzes,
        'new_mail': new_mail,
        'new_notify': new_notify,
        'friends': friends,
        'friends_autocomplete_data': friends_autocomplete_data,
        'messages': messages
    },
                              context_instance=RequestContext(request))
コード例 #15
0
def message_main_view(request):
	autocomplete_data = get_autocomplete_data(request)

	member_login = get_member_login_object(request)
	friends = member_login.get_friends()
	friends_autocomplete_data = get_friends_autocomplete_data(request,message=True)
	messages = get_all_conversation(request)
	new_buzzes = get_new_buzzes(request)
	new_mail = get_new_mail(request)
	new_notify = len(new_buzzes) + len(new_mail)
	return render_to_response('message_template/page/main_page.html',
						{
							'autocomplete_data': autocomplete_data,
							'member_login': member_login,
							'new_buzzes': new_buzzes,
							'new_mail': new_mail,
							'new_notify': new_notify,
							'friends': friends,
							'friends_autocomplete_data': friends_autocomplete_data,
							'messages': messages 
						},
						context_instance=RequestContext(request)
					)
コード例 #16
0
def show_activity(request,activity_id):
    request.session['allow_upload_stream'] = True

    # Autocomplete Data
    autocomplete_data = get_autocomplete_data(request)

    # Activity object
    activity = get_object_or_404(Activity, pk=activity_id)

    # Update activity status, activity comment amount, and activity member join amount
    activity.update_comment_amount()
    activity.update_member_amount()
    update_activity_status(activity)           

    # Activity data  
    activity_photo = Photo.objects.filter(photo_type='activity',object_id=activity.pk)
    activity_user_request = get_user_activity_request(request,activity_id)
    activity_location = activity.location 
    activity_location_photo = Photo.objects.filter(photo_type='location',object_id=activity_location.pk)
    activity_comment = Comment.objects.filter(comment_type='activity',object_id=activity.pk)
    activity_unjoinable = get_activity_unjoinable(request,activity_id) 
    for comment in activity_comment:
        comment.save()

    # User login and his/her friends
    member_login = get_member_login_object(request)
    new_buzzes = get_new_buzzes(request)
    new_mail = get_new_mail(request)
    new_notify = len(new_buzzes) + len(new_mail)
    friends = None
    friends_join = None
    if member_login != None:
        friends = member_login.get_friends()
        friends_join = get_friends_join_activity(friends,activity)

    # Boolean data to define the interaction of the page
    is_user_activity_create = check_user_activity_create(request,activity_id)
    is_user_activity_join = check_user_activity_join(request,activity_id)
    is_activity_seeable = check_activity_seeable(request,activity_id)

    # Return corresponding template based on the boolean data
    # If activity is public, everyone can see it. If it is private
    # only friend of the host can see it.
    template = "activity_template/normal_page/" + activity.activity_type + "_main_page.html"
    if is_activity_seeable == False:
        template = "activity_template/normal_page/authorize_activity_notice.html"    
    if is_user_activity_create:
        template = "activity_template/admin_page/main_page.html"

    return render_to_response(
                            template, 
                            {
                                'autocomplete_data': autocomplete_data,
                                'activity': activity, 
                                'activity_comment': activity_comment,
                                'activity_photo': activity_photo,
                                'activity_user_request':activity_user_request,
                                'activity_location': activity_location,
                                'activity_location_photo': activity_location_photo,
                                'activity_unjoinable': activity_unjoinable,
                                'is_user_activity_join': is_user_activity_join,
                                'friends': friends,
                                'friends_join': friends_join,
                                'member_login': member_login,
                                'new_buzzes': new_buzzes,
                                'new_mail': new_mail,
                                'new_notify': new_notify
                            },
                            context_instance = RequestContext(request))
コード例 #17
0
def member_main_page(request, username):
    autocomplete_data = get_autocomplete_data(request)

    request.session['current_user'] = username

    member_login = get_member_login_object(request)
    if request.method == 'POST':
        # Handle multiple POST request. The one below is for create activity
        if 'activity_name' in request.POST:
            new_activity = Activity()
            try:
                new_activity.name = request.POST['activity_name']
                new_activity.description = request.POST['activity_description']
                starttime_tmp = request.POST['activity_starttime'].split()
                new_activity.start_time = convert_time(starttime_tmp[0],
                                                       starttime_tmp[1],
                                                       starttime_tmp[2])
                endtime_tmp = request.POST['activity_endtime'].split()
                new_activity.end_time = convert_time(endtime_tmp[0],
                                                     endtime_tmp[1],
                                                     endtime_tmp[2])
                new_activity.member_create = member_login
                new_activity.location = Location.objects.get(
                    pk=int(request.POST['location']))
                new_activity.activity_type = request.POST['activity_type']

                if new_activity.activity_type == 'blind_date':
                    new_activity.limit = 1
                    new_activity.age_range_start = int(
                        request.POST['activity_age_range_from'])
                    new_activity.age_range_end = int(
                        request.POST['activity_age_range_to'])
                else:
                    if 'activity_unlimited' not in request.POST:
                        new_activity.limit = request.POST['activity_limit']
                new_activity.save()
            except:
                return render_to_response(
                    "activity_template/admin_page/create_error.html", {
                        "member_login": member_login,
                        "autocomplete_data": autocomplete_data,
                        'location_id': int(request.POST['location'])
                    },
                    context_instance=RequestContext(request))
            return HttpResponseRedirect("/activity/" + str(new_activity.pk) +
                                        "/manage/")

        if 'location_name' in request.POST:
            new_location = Location()
            try:
                new_location.name = request.POST['location_name']
                new_location.description = request.POST['location_description']
                new_location.category = request.POST['location_category']
                new_location.address1 = request.POST['location_address1']
                new_location.address2 = request.POST['location_address2']
                new_location.city = request.POST['location_city']
                new_location.state = request.POST['location_state']
                new_location.zip_code = int(request.POST['location_zipcode'])
                new_location.preference = request.POST['location_preference']
                new_location.create_by = member_login
                if "location_avatar" in request.FILES:
                    new_location.avatar = request.FILES['location_avatar']
                new_location.save()
            except:
                return render_to_response(
                    "location_template/page/create_error.html", {
                        "member_login": member_login,
                        "autocomplete_data": autocomplete_data,
                    },
                    context_instance=RequestContext(request))
            return HttpResponseRedirect("/location/" + str(new_location.pk))

    if member_login != None:
        if check_confirm_email(request) == False:
            notice = "resend_email"

    member_view = get_object_or_404(Member,
                                    user=get_object_or_404(User,
                                                           username=username))
    template = ""
    section = None
    notice = None
    if 'section' in request.GET:
        section = request.GET['section']
    else:
        section = 'activity'

    # Define whether this is user login page or not. If yes, return
    # his/her admin page. If not return the view page of this user
    if check_user_login_page(request, username):
        if "act" in request.GET:
            notice = request.GET['act']
        template = "member_template/admin_page/main_page.html"
        is_friend = None
    else:
        if member_login != None:
            if check_user_block(member_login.user, member_view.user):
                raise Http404
        template = "member_template/normal_page/main_page.html"
        is_friend = check_friendship(request, username)

    # Necessary data here
    new_buzzes = get_new_buzzes(request)
    new_mail = get_new_mail(request)
    new_notify = len(new_buzzes) + len(new_mail)
    location_create = Location.objects.filter(create_by=member_view)
    location_follow = Location.objects.filter(follow_by=member_view)
    location_categories = LocationCategory.objects.all()
    activity_create = Activity.objects.filter(member_create=member_view)
    activity_join = Activity.objects.filter(member_join=member_view)
    friends = member_view.get_friends()
    recent_activity_stream = user_streams.get_stream_items(
        User.objects.get(username=username))[:NORMAL_STREAM_LIMIT]
    friends_activity_stream = get_friend_activity_stream(
        request, 'friend_content')[:NORMAL_STREAM_LIMIT]

    # Return the response and render the template view
    return render_to_response(
        template, {
            'autocomplete_data': autocomplete_data,
            'is_friend': is_friend,
            "notice": notice,
            'section': section,
            "new_buzzes": new_buzzes,
            'new_mail': new_mail,
            'new_notify': new_notify,
            "member_login": member_login,
            'member_view': member_view,
            'location_create': location_create,
            'location_follow': location_follow,
            'location_categories': location_categories,
            'activity_create': activity_create,
            'activity_join': activity_join,
            'friends': friends,
            'recent_activity_stream': recent_activity_stream,
            'friends_activity_stream': friends_activity_stream,
        },
        context_instance=RequestContext(request))
コード例 #18
0
ファイル: views.py プロジェクト: itamsvtd/FrittieHome
def show_location(request,location_id): 
    # Autocomplete Data
    autocomplete_data = get_autocomplete_data(request)

    member_login = get_member_login_object(request)
    if request.method == 'POST':
        # Handle multiple POST request. The one below is for create activity
        if 'activity_name' in request.POST:
            new_activity = Activity()
            try:
                new_activity.name = request.POST['activity_name']
                new_activity.description = request.POST['activity_description']
                starttime_tmp = request.POST['activity_starttime'].split()
                new_activity.start_time = convert_time(starttime_tmp[0],starttime_tmp[1],starttime_tmp[2])
                endtime_tmp = request.POST['activity_endtime'].split()
                new_activity.end_time = convert_time(endtime_tmp[0],endtime_tmp[1],endtime_tmp[2])
                new_activity.member_create = member_login
                new_activity.location = Location.objects.get(pk=int(request.POST['location']))
                new_activity.activity_type = request.POST['activity_type']

                if new_activity.activity_type == 'blind_date':
                    new_activity.limit = 1
                    new_activity.age_range_start = int(request.POST['activity_age_range_from'])
                    new_activity.age_range_end = int(request.POST['activity_age_range_to'])
                else:
                    if 'activity_unlimited' not in request.POST:
                        new_activity.limit = request.POST['activity_limit']
                new_activity.save()
            except:
                return render_to_response("activity_template/admin_page/create_error.html",
                                            {
                                                "member_login": member_login,
                                                "autocomplete_data": autocomplete_data,
                                                'location_id':location_id
                                            },
                                            context_instance = RequestContext(request))
            return HttpResponseRedirect("/activity/" + str(new_activity.pk) + "/manage/")

    # User login and his/her friends
    new_buzzes = get_new_buzzes(request)
    new_mail = get_new_mail(request)
    new_notify = len(new_buzzes) + len(new_mail)
    friends = None
    if member_login != None:
        friends = member_login.get_friends()

    # Location Data
    location = get_object_or_404(Location, pk=location_id)
    is_user_location = check_user_location(request,location_id)
    is_user_follow = check_user_follow(request,location_id)
    location_photo = Photo.objects.filter(photo_type='location',object_id=location.pk)
    location_comment = Comment.objects.filter(comment_type='location',object_id=location.pk)
    for comment in location_comment:
        comment.save()
        
    # Activity for this location
    upcoming_activities = get_upcoming_activity(location_id)
    past_activities = get_past_activity(location_id)
    happening_activities = get_happening_activity(location_id)

    template = 'location_template/normal_page/main_page.html'
    if is_user_location:
        template = 'location_template/admin_page/main_page.html'

    return render_to_response(
            template,
            {
                "location": location,
                "member_login": member_login,
                'new_buzzes': new_buzzes,
                'new_mail': new_mail,
                'new_buzzes': new_buzzes,
                "friends": friends,
                #"is_user_location": is_user_location,
                "is_user_follow": is_user_follow,
                "location_photo": location_photo,
                "location_comment": location_comment,
                "autocomplete_data": autocomplete_data,
                'upcoming_activities': upcoming_activities,
                'past_activities': past_activities,
                'happening_activities': happening_activities,
            },
            context_instance = RequestContext(request)
        )
コード例 #19
0
ファイル: views.py プロジェクト: itamsvtd/FrittieHome
def member_main_page(request, username):
    autocomplete_data = get_autocomplete_data(request)

    request.session["current_user"] = username

    member_login = get_member_login_object(request)
    if request.method == "POST":
        # Handle multiple POST request. The one below is for create activity
        if "activity_name" in request.POST:
            new_activity = Activity()
            try:
                new_activity.name = request.POST["activity_name"]
                new_activity.description = request.POST["activity_description"]
                starttime_tmp = request.POST["activity_starttime"].split()
                new_activity.start_time = convert_time(starttime_tmp[0], starttime_tmp[1], starttime_tmp[2])
                endtime_tmp = request.POST["activity_endtime"].split()
                new_activity.end_time = convert_time(endtime_tmp[0], endtime_tmp[1], endtime_tmp[2])
                new_activity.member_create = member_login
                new_activity.location = Location.objects.get(pk=int(request.POST["location"]))
                new_activity.activity_type = request.POST["activity_type"]

                if new_activity.activity_type == "blind_date":
                    new_activity.limit = 1
                    new_activity.age_range_start = int(request.POST["activity_age_range_from"])
                    new_activity.age_range_end = int(request.POST["activity_age_range_to"])
                else:
                    if "activity_unlimited" not in request.POST:
                        new_activity.limit = request.POST["activity_limit"]
                new_activity.save()
            except:
                return render_to_response(
                    "activity_template/admin_page/create_error.html",
                    {
                        "member_login": member_login,
                        "autocomplete_data": autocomplete_data,
                        "location_id": int(request.POST["location"]),
                    },
                    context_instance=RequestContext(request),
                )
            return HttpResponseRedirect("/activity/" + str(new_activity.pk) + "/manage/")

        if "location_name" in request.POST:
            new_location = Location()
            try:
                new_location.name = request.POST["location_name"]
                new_location.description = request.POST["location_description"]
                new_location.category = request.POST["location_category"]
                new_location.address1 = request.POST["location_address1"]
                new_location.address2 = request.POST["location_address2"]
                new_location.city = request.POST["location_city"]
                new_location.state = request.POST["location_state"]
                new_location.zip_code = int(request.POST["location_zipcode"])
                new_location.preference = request.POST["location_preference"]
                new_location.create_by = member_login
                if "location_avatar" in request.FILES:
                    new_location.avatar = request.FILES["location_avatar"]
                new_location.save()
            except:
                return render_to_response(
                    "location_template/page/create_error.html",
                    {"member_login": member_login, "autocomplete_data": autocomplete_data},
                    context_instance=RequestContext(request),
                )
            return HttpResponseRedirect("/location/" + str(new_location.pk))

    if member_login != None:
        if check_confirm_email(request) == False:
            notice = "resend_email"

    member_view = get_object_or_404(Member, user=get_object_or_404(User, username=username))
    template = ""
    section = None
    notice = None
    if "section" in request.GET:
        section = request.GET["section"]
    else:
        section = "activity"

        # Define whether this is user login page or not. If yes, return
        # his/her admin page. If not return the view page of this user
    if check_user_login_page(request, username):
        if "act" in request.GET:
            notice = request.GET["act"]
        template = "member_template/admin_page/main_page.html"
        is_friend = None
    else:
        if member_login != None:
            if check_user_block(member_login.user, member_view.user):
                raise Http404
        template = "member_template/normal_page/main_page.html"
        is_friend = check_friendship(request, username)

        # Necessary data here
    new_buzzes = get_new_buzzes(request)
    new_mail = get_new_mail(request)
    new_notify = len(new_buzzes) + len(new_mail)
    location_create = Location.objects.filter(create_by=member_view)
    location_follow = Location.objects.filter(follow_by=member_view)
    location_categories = LocationCategory.objects.all()
    activity_create = Activity.objects.filter(member_create=member_view)
    activity_join = Activity.objects.filter(member_join=member_view)
    friends = member_view.get_friends()
    recent_activity_stream = user_streams.get_stream_items(User.objects.get(username=username))[:NORMAL_STREAM_LIMIT]
    friends_activity_stream = get_friend_activity_stream(request, "friend_content")[:NORMAL_STREAM_LIMIT]

    # Return the response and render the template view
    return render_to_response(
        template,
        {
            "autocomplete_data": autocomplete_data,
            "is_friend": is_friend,
            "notice": notice,
            "section": section,
            "new_buzzes": new_buzzes,
            "new_mail": new_mail,
            "new_notify": new_notify,
            "member_login": member_login,
            "member_view": member_view,
            "location_create": location_create,
            "location_follow": location_follow,
            "location_categories": location_categories,
            "activity_create": activity_create,
            "activity_join": activity_join,
            "friends": friends,
            "recent_activity_stream": recent_activity_stream,
            "friends_activity_stream": friends_activity_stream,
        },
        context_instance=RequestContext(request),
    )