Commit e66964a4 authored by Alessandro Olivar's avatar Alessandro Olivar

Questboard page layout updated to show quests of a corresponding questboard.

parent f84862df
No preview for this file type
# Generated by Django 3.1.7 on 2021-12-16 07:46
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
('qBoard', '0004_auto_20211215_1702'),
]
operations = [
migrations.RenameField(
model_name='quest',
old_name='QBoard',
new_name='qboard',
),
]
......@@ -11,7 +11,7 @@ class QBoard(models.Model):
return self.name
class Quest(models.Model):
QBoard = models.ForeignKey(QBoard, null = True, on_delete = models.SET_NULL)
qboard = models.ForeignKey(QBoard, null = True, on_delete = models.SET_NULL)
name = models.CharField(max_length = 200, null = True)
desc = models.CharField(max_length = 200, null = True, blank = True)
stars = models.CharField(max_length = 200, null = True)
......
......@@ -8,12 +8,6 @@
<li class="nav-item active">
<a class="nav-link" href="#">Homepage</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Create Quest Board</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Quest Board 1</a>
</li>
</ul>
</div>
</nav>
\ No newline at end of file
{% extends 'qBoard/main.html' %}
{% block content %}
<h1>Homepage</h1>
<div class="row">
<div class="col-md-5">
<h5>QUESTBOARDS</h5>
<h1>{{qboard.name}}</h1>
<hr>
<a class="btn btn-primary btn-sm btn-block" href="">New Questboard</a>
<a class="btn btn-primary btn-sm btn-block" href="">New Quest</a>
<hr>
{% for i in quests %}
{% for quest in quests %}
<div class="card card-body">
<a class="btn btn-primary btn-sm btn-block" href="">Edit Questboard</a>
<table>
<tr>
<td><a class="btn btn-primary btn-sm btn-block" href="">Edit Quest</a></td>
<td><a class="btn btn-primary btn-sm btn-block" href="">Delete Quest</a></td>
</tr>
</table>
<table class="table table-sm">
<tr>
<th colspan = 3 class="text-center">{{i.name}}</th>
<th colspan = 3 class="text-center">{{quest.name}}</th>
</tr>
<tr>
<td colspan = 3 class="text-center"><p>{{i.desc}}</p></td>
<td colspan = 3 class="text-center"><p>{{quest.desc}}</p></td>
</tr>
<tr>
<td rowspan = 3>Dibs:</td>
<td colspan = 2 class="text-left">{{i.student1}}</td>
<td colspan = 2 class="text-left">{{quest.student1}}</td>
</tr>
<tr>
<td colspan = 2 class="text-left">{{i.student2}}</td>
<td colspan = 2 class="text-left">{{quest.student2}}</td>
</tr>
<tr>
<td colspan = 2 class="text-left">{{i.student3}}</td>
<td colspan = 2 class="text-left">{{quest.student3}}</td>
</tr>
<tr>
<td colspan = 3 class="text-center">{{i.stars}}</td>
<td colspan = 3 class="text-center">{{quest.stars}}</td>
</tr>
</table>
</div>
......
......@@ -3,5 +3,5 @@ from . import views
urlpatterns = [
path('', views.home),
path('questBoard/', views.quests),
path('questboard/<str:pk_test>/', views.quests),
]
\ No newline at end of file
......@@ -4,8 +4,13 @@ from django.http import HttpResponse
from .models import *
def home(request):
qboards = QBoard.objects.all
return render(request,'qBoard/homepage.html', {'qboards' : qboards})
def quests(request):
quests = Quest.objects.all()
return render(request, 'qBoard/quests.html', {'quests' : quests})
\ No newline at end of file
qboards = QBoard.objects.all()
context = {'qboards' : qboards}
return render(request,'qBoard/homepage.html', context)
def quests(request, pk_test):
qboard = QBoard.objects.get(id = pk_test)
quests = qboard.quest_set.all()
context = {'qboard' : qboard, 'quests' : quests}
return render(request, 'qBoard/quests.html', context)
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment