<s> from django . conf import settings <EOL> from django . contrib import messages <EOL> from django . contrib . auth . models import User <EOL> from django . contrib . auth . decorators import login_required <EOL> from django . core . urlresolvers import reverse <EOL> from django . http import HttpResponseRedirect , HttpResponse <EOL> from django . shortcuts import render_to_response , get_object_or_404 <EOL> from django . template import RequestContext <EOL> from django . template . loader import render_to_string <EOL> from django . views . generic import list_detail <EOL> from easy_profiles . forms import ProfileForm <EOL> from easy_profiles . models import Profile <EOL> @ login_required <EOL> def profile_detail ( request , username , template_name = "<STR_LIT>" ) : <EOL> user = get_object_or_404 ( User , username = username ) <EOL> profile = get_object_or_404 ( Profile , user = user ) <EOL> return render_to_response ( template_name , <EOL> { <EOL> "<STR_LIT>" : profile , <EOL> "<STR_LIT>" : Activity . objects . filter ( author = user ) <EOL> } , <EOL> context_instance = RequestContext ( request ) <EOL> ) <EOL> @ login_required <EOL> def profile_edit ( request , template_name = "<STR_LIT>" ) : <EOL> profile = get_object_or_404 ( Profile , user = request . user ) <EOL> form = ProfileForm ( request . POST or None , request . FILES or None , instance = profile ) <EOL> if form . is_valid ( ) : <EOL> form . save ( ) <EOL> msg = '<STR_LIT>' <EOL> messages . add_message ( request , messages . INFO , msg ) <EOL> return HttpResponseRedirect ( reverse ( "<STR_LIT>" , kwargs = { "<STR_LIT:username>" : profile . user . username } ) ) <EOL> return render_to_response ( template_name , <EOL> { <EOL> "<STR_LIT>" : profile , <EOL> "<STR_LIT>" : form , <EOL> } , <EOL> context_instance = RequestContext ( request ) <EOL> ) <EOL> @ login_required <EOL> def profile_list ( request , page = None , template_name = "<STR_LIT>" ) : <EOL> """<STR_LIT>""" <EOL> qs = Profile . objects . filter ( is_active = True ) . order_by ( "<STR_LIT>" , "<STR_LIT>" ) <EOL> return list_detail . object_list ( <EOL> request , <EOL> qs , <EOL> allow_empty = True , <EOL> template_name = template_name , <EOL> template_object_name = '<STR_LIT>' , <EOL> paginate_by = <NUM_LIT> , <EOL> page = page , <EOL> ) </s>
