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): ...@@ -11,7 +11,7 @@ class QBoard(models.Model):
return self.name return self.name
class Quest(models.Model): 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) name = models.CharField(max_length = 200, null = True)
desc = models.CharField(max_length = 200, null = True, blank = True) desc = models.CharField(max_length = 200, null = True, blank = True)
stars = models.CharField(max_length = 200, null = True) stars = models.CharField(max_length = 200, null = True)
......
...@@ -8,12 +8,6 @@ ...@@ -8,12 +8,6 @@
<li class="nav-item active"> <li class="nav-item active">
<a class="nav-link" href="#">Homepage</a> <a class="nav-link" href="#">Homepage</a>
</li> </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> </ul>
</div> </div>
</nav> </nav>
\ No newline at end of file
{% extends 'qBoard/main.html' %} {% extends 'qBoard/main.html' %}
{% block content %} {% block content %}
<h1>Homepage</h1>
<div class="row"> <div class="row">
<div class="col-md-5"> <div class="col-md-5">
<h5>QUESTBOARDS</h5> <h1>{{qboard.name}}</h1>
<hr> <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> <hr>
{% for i in quests %} {% for quest in quests %}
<div class="card card-body"> <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"> <table class="table table-sm">
<tr> <tr>
<th colspan = 3 class="text-center">{{i.name}}</th> <th colspan = 3 class="text-center">{{quest.name}}</th>
</tr> </tr>
<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>
<tr> <tr>
<td rowspan = 3>Dibs:</td> <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>
<tr> <tr>
<td colspan = 2 class="text-left">{{i.student2}}</td> <td colspan = 2 class="text-left">{{quest.student2}}</td>
</tr> </tr>
<tr> <tr>
<td colspan = 2 class="text-left">{{i.student3}}</td> <td colspan = 2 class="text-left">{{quest.student3}}</td>
</tr> </tr>
<tr> <tr>
<td colspan = 3 class="text-center">{{i.stars}}</td> <td colspan = 3 class="text-center">{{quest.stars}}</td>
</tr> </tr>
</table> </table>
</div> </div>
......
...@@ -3,5 +3,5 @@ from . import views ...@@ -3,5 +3,5 @@ from . import views
urlpatterns = [ urlpatterns = [
path('', views.home), 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 ...@@ -4,8 +4,13 @@ from django.http import HttpResponse
from .models import * from .models import *
def home(request): def home(request):
qboards = QBoard.objects.all qboards = QBoard.objects.all()
return render(request,'qBoard/homepage.html', {'qboards' : qboards})
def quests(request): context = {'qboards' : qboards}
quests = Quest.objects.all() return render(request,'qBoard/homepage.html', context)
return render(request, 'qBoard/quests.html', {'quests' : quests}) def quests(request, pk_test):
\ No newline at end of file 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