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): class Challenge(models.Model):
id = models.AutoField(primary_key=True) id = models.AutoField(primary_key=True)
creator = models.ForeignKey(User, blank=True, null=True, editable=False, on_delete=models.SET_NULL) 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) description = models.TextField(blank=True, null=True)
tags = models.ManyToManyField(ChallengeTag, blank=True) tags = models.ManyToManyField(ChallengeTag, blank=True)
recurring = models.BooleanField(default=False)
def __str__(self): def __str__(self):
return self.name return self.name

View File

@ -27,6 +27,7 @@ urlpatterns = [
url(r'^challenge/(?P<id>[0-9]+)', views.challenge), url(r'^challenge/(?P<id>[0-9]+)', views.challenge),
url(r'^challenges/', views.challenges), url(r'^challenges/', views.challenges),
url(r'^halloffame/', views.hall_of_fame), url(r'^halloffame/', views.hall_of_fame),
url(r'^inventory/', views.inventory),
url(r'^profile/(?P<username>[\w.-]+)', views.profile), 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') 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) + \ ] + static(settings.STATIC_URL, document_root=settings.STATICFILES_DIRS) + \

View File

@ -1,8 +1,5 @@
from django.http import HttpResponse from django.http import HttpResponse
from django.shortcuts import render 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 * from kspace.models import *
@ -38,6 +35,14 @@ def challenges(request):
return render(request, 'challenges.html', data) 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): def hall_of_fame(request):
if request.method == 'GET': if request.method == 'GET':
data = { data = {

View File

@ -66,7 +66,7 @@
</div> </div>
</div> </div>
<a href="#" class="btn-large amber hide-on-med-and-up">to equipment</a> <a href="/inventory" class="btn-large amber hide-on-med-and-up">to equipment</a>
</div> </div>
</div> </div>
@ -94,7 +94,7 @@
<a class="btn-large blue" href="/challenges">to ideas</a> <a class="btn-large blue" href="/challenges">to ideas</a>
</div> </div>
<div class="col s12 m4"> <div class="col s12 m4">
<a href="#" class="btn-large amber ">to equipment</a> <a href="/inventory" class="btn-large amber ">to equipment</a>
</div> </div>
<div class="col s12 m4"> <div class="col s12 m4">
<a href="/halloffame" class="btn-large green ">to success</a> <a href="/halloffame" class="btn-large green ">to success</a>

37
templates/inventory.html Normal file
View File

@ -0,0 +1,37 @@
{% extends 'base.html' %}
{% block content %}
<div class="row container">
<div class="section slogan">
<h2 class="center-align" style="font-weight:bold">Inventory<br></h2>
</div>
</div>
<div class="row container challenges">
<div class="row">
{% for item in inventory %}
<div class="col s12 m3">
<div class="card" style="height:350px;">
<div class="card-content">
<div class="row" style="height:210px;">
<div class="col s12 m12">
<div class="card-title"><b>{{ item.item_name }}</b></div>
<p>Serial: {{ item.serial_nr }}</p>
<p style="text-align: justify; max-height: 120px; overflow: auto;">{{ item.description }}</p>
<div class="card-image">
{% if item.photo %}
<img src='/media/{{ item.photo }}'>
{% else %}
<img src='/media/missing_photo.png'>
{% endif %}
</div>
</div>
</div>
</br>
</div>
</div>
</div>
{% endfor %}
</div>
</div>
{% endblock %}