from django.contrib.auth.decorators import login_required
from django.shortcuts import render_to_response, redirect
from django.core.exceptions import ObjectDoesNotExist 
from models import UserTag
from forms import ProfileEditForm, Profile
from django.template import RequestContext
from django.http import HttpResponseRedirect, HttpResponse

@login_required
def edit(request):
    try:
        profile = request.user.get_profile()
    except ObjectDoesNotExist:
        profile = Profile.objects.create(user=request.user)
    if request.method == 'POST':
        form = ProfileEditForm(request.POST, request.FILES, instance=profile)
        if form.is_valid():
            try:          
                form.save()
            except:
                return HttpResponse('save failed!')
            return HttpResponseRedirect('/home/')
    else:
        form = ProfileEditForm(instance=profile)
    return render_to_response('profile/edit.html', {'form': form, },
                              context_instance=RequestContext(request))

@login_required
def edit_tags(request):
    hot_tags = UserTag.objects.all()
    return render_to_response('profile/edit_tags.html', {'hot_tags': hot_tags,},
                              context_instance=RequestContext(request))

@login_required
def add_tag(request, tag_id=None):
    tag_name = request.POST.get('tag_name', default=None)
    request.user.profile.add_tag(tag_name=tag_name, tag_id=tag_id)
    return redirect('/person/settings/?content=tag')
    
@login_required
def remove_tag(request, tag_id):
    request.user.profile.remove_tag(tag_id=tag_id)
    return redirect('/person/settings/?content=tag')
ff6dc6735bcddd5e7f9a5e03413bdc1cce91088c
<mask token>


@login_required
def add_tag(request, tag_id=None):
    tag_name = request.POST.get('tag_name', default=None)
    request.user.profile.add_tag(tag_name=tag_name, tag_id=tag_id)
    return redirect('/person/settings/?content=tag')


<mask token>

<mask token>


@login_required
def edit(request):
    try:
        profile = request.user.get_profile()
    except ObjectDoesNotExist:
        profile = Profile.objects.create(user=request.user)
    if request.method == 'POST':
        form = ProfileEditForm(request.POST, request.FILES, instance=profile)
        if form.is_valid():
            try:
                form.save()
            except:
                return HttpResponse('save failed!')
            return HttpResponseRedirect('/home/')
    else:
        form = ProfileEditForm(instance=profile)
    return render_to_response('profile/edit.html', {'form': form},
        context_instance=RequestContext(request))


<mask token>


@login_required
def add_tag(request, tag_id=None):
    tag_name = request.POST.get('tag_name', default=None)
    request.user.profile.add_tag(tag_name=tag_name, tag_id=tag_id)
    return redirect('/person/settings/?content=tag')


@login_required
def remove_tag(request, tag_id):
    request.user.profile.remove_tag(tag_id=tag_id)
    return redirect('/person/settings/?content=tag')

<mask token>


@login_required
def edit(request):
    try:
        profile = request.user.get_profile()
    except ObjectDoesNotExist:
        profile = Profile.objects.create(user=request.user)
    if request.method == 'POST':
        form = ProfileEditForm(request.POST, request.FILES, instance=profile)
        if form.is_valid():
            try:
                form.save()
            except:
                return HttpResponse('save failed!')
            return HttpResponseRedirect('/home/')
    else:
        form = ProfileEditForm(instance=profile)
    return render_to_response('profile/edit.html', {'form': form},
        context_instance=RequestContext(request))


@login_required
def edit_tags(request):
    hot_tags = UserTag.objects.all()
    return render_to_response('profile/edit_tags.html', {'hot_tags':
        hot_tags}, context_instance=RequestContext(request))


@login_required
def add_tag(request, tag_id=None):
    tag_name = request.POST.get('tag_name', default=None)
    request.user.profile.add_tag(tag_name=tag_name, tag_id=tag_id)
    return redirect('/person/settings/?content=tag')


@login_required
def remove_tag(request, tag_id):
    request.user.profile.remove_tag(tag_id=tag_id)
    return redirect('/person/settings/?content=tag')

from django.contrib.auth.decorators import login_required
from django.shortcuts import render_to_response, redirect
from django.core.exceptions import ObjectDoesNotExist
from models import UserTag
from forms import ProfileEditForm, Profile
from django.template import RequestContext
from django.http import HttpResponseRedirect, HttpResponse


@login_required
def edit(request):
    try:
        profile = request.user.get_profile()
    except ObjectDoesNotExist:
        profile = Profile.objects.create(user=request.user)
    if request.method == 'POST':
        form = ProfileEditForm(request.POST, request.FILES, instance=profile)
        if form.is_valid():
            try:
                form.save()
            except:
                return HttpResponse('save failed!')
            return HttpResponseRedirect('/home/')
    else:
        form = ProfileEditForm(instance=profile)
    return render_to_response('profile/edit.html', {'form': form},
        context_instance=RequestContext(request))


@login_required
def edit_tags(request):
    hot_tags = UserTag.objects.all()
    return render_to_response('profile/edit_tags.html', {'hot_tags':
        hot_tags}, context_instance=RequestContext(request))


@login_required
def add_tag(request, tag_id=None):
    tag_name = request.POST.get('tag_name', default=None)
    request.user.profile.add_tag(tag_name=tag_name, tag_id=tag_id)
    return redirect('/person/settings/?content=tag')


@login_required
def remove_tag(request, tag_id):
    request.user.profile.remove_tag(tag_id=tag_id)
    return redirect('/person/settings/?content=tag')

from django.contrib.auth.decorators import login_required
from django.shortcuts import render_to_response, redirect
from django.core.exceptions import ObjectDoesNotExist 
from models import UserTag
from forms import ProfileEditForm, Profile
from django.template import RequestContext
from django.http import HttpResponseRedirect, HttpResponse

@login_required
def edit(request):
    try:
        profile = request.user.get_profile()
    except ObjectDoesNotExist:
        profile = Profile.objects.create(user=request.user)
    if request.method == 'POST':
        form = ProfileEditForm(request.POST, request.FILES, instance=profile)
        if form.is_valid():
            try:          
                form.save()
            except:
                return HttpResponse('save failed!')
            return HttpResponseRedirect('/home/')
    else:
        form = ProfileEditForm(instance=profile)
    return render_to_response('profile/edit.html', {'form': form, },
                              context_instance=RequestContext(request))

@login_required
def edit_tags(request):
    hot_tags = UserTag.objects.all()
    return render_to_response('profile/edit_tags.html', {'hot_tags': hot_tags,},
                              context_instance=RequestContext(request))

@login_required
def add_tag(request, tag_id=None):
    tag_name = request.POST.get('tag_name', default=None)
    request.user.profile.add_tag(tag_name=tag_name, tag_id=tag_id)
    return redirect('/person/settings/?content=tag')
    
@login_required
def remove_tag(request, tag_id):
    request.user.profile.remove_tag(tag_id=tag_id)
    return redirect('/person/settings/?content=tag')