Added inventory view and challenge blurb + recurring field

This commit is contained in:
teras
2017-12-02 22:26:04 +02:00
committed by Lauri Võsandi
parent fc79e01494
commit 3322c4e6c9
5 changed files with 51 additions and 6 deletions

View File

@@ -36,9 +36,11 @@ class ChallengeTag(models.Model):
class Challenge(models.Model):
id = models.AutoField(primary_key=True)
creator = models.ForeignKey(User, blank=True, null=True, editable=False, on_delete=models.SET_NULL)
name = models.CharField(max_length=256)
name = models.CharField(max_length=64)
blurb = models.CharField(max_length=140, blank=True, null=True )
description = models.TextField(blank=True, null=True)
tags = models.ManyToManyField(ChallengeTag, blank=True)
recurring = models.BooleanField(default=False)
def __str__(self):
return self.name

View File

@@ -27,6 +27,7 @@ urlpatterns = [
url(r'^challenge/(?P<id>[0-9]+)', views.challenge),
url(r'^challenges/', views.challenges),
url(r'^halloffame/', views.hall_of_fame),
url(r'^inventory/', views.inventory),
url(r'^profile/(?P<username>[\w.-]+)', views.profile),
url(r'^favicon.ico$', RedirectView.as_view(url=staticfiles_storage.url('favicon.ico'), permanent=False), name='favicon')
] + static(settings.STATIC_URL, document_root=settings.STATICFILES_DIRS) + \

View File

@@ -1,8 +1,5 @@
from django.http import HttpResponse
from django.shortcuts import render
from django.views.decorators.csrf import csrf_protect
from django.contrib.auth.models import User
from django.contrib.auth import authenticate, login, logout
from kspace.models import *
@@ -38,6 +35,14 @@ def challenges(request):
return render(request, 'challenges.html', data)
def inventory(request):
if request.method == 'GET':
data = {
'inventory': InventoryItem.objects.all()
}
return render(request, 'inventory.html', data)
def hall_of_fame(request):
if request.method == 'GET':
data = {