# Path: src/user/models.py
# class UserProfile(models.Model):
# 
#     user = models.OneToOneField(User, on_delete=models.CASCADE)
# 
# class QuestEntry(models.Model):
# 
#     user = models.ForeignKey(UserProfile, on_delete=models.CASCADE)
#     quest = models.ForeignKey(Quest, on_delete=models.CASCADE)
#     discovery_date = models.DateTimeField(auto_now_add=True)
#     completion_date = models.DateTimeField(null=True)
# 
#     def completed(self):
#         return self.completion_date != None


from django.contrib.auth.mixins import LoginRequiredMixin
from django.contrib.auth.models import User
from django.core.exceptions import SuspiciousOperation
from django.shortcuts import render
from django.urls import reverse_lazy
from django.utils import timezone
from django.views.generic.base import RedirectView
from django.views.generic.detail import DetailView
from .models import UserProfile, QuestEntry
from quests.models import Quest
"""botw-tracker user app views

Copyright (c) 2017, Evan Moritz.

botw-tracker is an open source software project released under the MIT License.
See the accompanying LICENSE file for terms.

"""

def index(request):

# Path: src/user/models.py
# class UserProfile(models.Model):
# 
#     user = models.OneToOneField(User, on_delete=models.CASCADE)
# 
# class QuestEntry(models.Model):
# 
#     user = models.ForeignKey(UserProfile, on_delete=models.CASCADE)
#     quest = models.ForeignKey(Quest, on_delete=models.CASCADE)
#     discovery_date = models.DateTimeField(auto_now_add=True)
#     completion_date = models.DateTimeField(null=True)
# 
#     def completed(self):
#         return self.completion_date != None


# Path: src/user/views.py
from django.contrib.auth.mixins import LoginRequiredMixin
from django.contrib.auth.models import User
from django.core.exceptions import SuspiciousOperation
from django.shortcuts import render
from django.urls import reverse_lazy
from django.utils import timezone
from django.views.generic.base import RedirectView
from django.views.generic.detail import DetailView
from .models import UserProfile, QuestEntry
from quests.models import Quest

"""botw-tracker user app views

Copyright (c) 2017, Evan Moritz.

botw-tracker is an open source software project released under the MIT License.
See the accompanying LICENSE file for terms.

"""

def index(request):

    user_list = UserProfile.objects.order_by('user__username')