30 lines
666 B
Python
30 lines
666 B
Python
#!/usr/bin/env python3
|
|
"""
|
|
/user app views.
|
|
"""
|
|
from django.http import HttpResponse
|
|
from django.shortcuts import redirect, render
|
|
from django.core.exceptions import ObjectDoesNotExist
|
|
|
|
from .models import User
|
|
from quest.models import Quest
|
|
|
|
def index(request):
|
|
"""
|
|
The user index page.
|
|
"""
|
|
return HttpResponse("Hello, world. You're at the user index.")
|
|
|
|
|
|
def profile(request, user_id):
|
|
"""
|
|
User profile.
|
|
"""
|
|
try:
|
|
user = User.objects.get(id=user_id)
|
|
except ObjectDoesNotExist:
|
|
return HttpResponse(f"User_id {user_id} does not exist.")
|
|
quests = Quest.objects.filter(owner=user)
|
|
context = locals()
|
|
return render(request, 'user/profile.html', context)
|