Add feature to view other user profiles

This commit is contained in:
Trever Fischer
2012-04-21 10:33:25 -04:00
parent 5a64db3b29
commit ebbd7df499
4 changed files with 20 additions and 10 deletions

View File

@@ -4,6 +4,8 @@ from django.views.generic.simple import direct_to_template
urlpatterns = patterns('local',
url(r'^me$', 'views.profile', name='user_profile'),
url(r'^user/(?P<username>.+)$', 'views.profile'),
url(r'^player/(?P<mc_username>.+)$', 'views.profile'),
url(r'^list$', 'views.list'),
url(r'^welcome', direct_to_template, {'template': 'local/welcome.html'}, name='welcome'),
url(r'^register', 'views.register'),

View File

@@ -14,11 +14,18 @@ import forms
import models
from forums.models import Forum
from minecraft.forms import ProfileForm
from minecraft.models import MinecraftProfile
from django.conf import settings
@login_required
def profile(request):
return render_to_response('local/profile.html', context_instance = RequestContext(request))
def profile(request, username=None, mc_username=None):
if username is None and mc_username is None:
user = request.user
elif mc_username is None:
user = User.objects.get(username=username)
else:
user = MinecraftProfile.objects.get(mc_username=mc_username).user
return render_to_response('local/profile.html', {'profile': user}, context_instance = RequestContext(request))
@login_required
def edit(request):