#4: add base template; extend base template in views

This commit is contained in:
Lexi / Zoe 2019-11-10 23:37:31 +01:00
parent fe7fce76c0
commit b7311f2308
Signed by: binaryDiv
GPG Key ID: F8D4956E224DA232
7 changed files with 110 additions and 62 deletions

View File

@ -1,6 +1,12 @@
<h2>#{{ issue.id }}: {{ issue.title }}</h2>
<p>
<b>Project:</b> {{ issue.project }}<br/>
<b>Created:</b> {{ issue.create_date }}
</p>
<p>{{ issue.text }}</p>
{% extends "base.html" %}
{% block title %}Issue: {{ issue.title }}{% endblock %}
{% block content %}
<h2>#{{ issue.id }}: {{ issue.title }}</h2>
<p>
<b>Project:</b> {{ issue.project }}<br/>
<b>Created:</b> {{ issue.create_date }}
</p>
<p>{{ issue.text }}</p>
{% endblock %}

View File

@ -1,13 +1,19 @@
{% if issue_list %}
<ul>
{% for issue in issue_list %}
<li>
<a href="{% url 'issues:detail' issue.id %}">{{ issue.title }}</a>
</li>
{% endfor %}
</ul>
{% else %}
<p>No issues.</p>
{% endif %}
{% extends "base.html" %}
<p><a href="{% url 'issues:new' %}">Create new issue</a></p>
{% block title %}Issues{% endblock %}
{% block content %}
{% if issue_list %}
<ul>
{% for issue in issue_list %}
<li>
<a href="{% url 'issues:detail' issue.id %}">{{ issue.title }}</a>
</li>
{% endfor %}
</ul>
{% else %}
<p>No issues.</p>
{% endif %}
<p><a href="{% url 'issues:new' %}">Create new issue</a></p>
{% endblock %}

View File

@ -1,15 +1,21 @@
<h2>Create new issue</h2>
{% extends "base.html" %}
{% if error_message %}<p><strong>{{ error_message }}</strong></p>{% endif %}
{% block title %}Create issue{% endblock %}
<form action="{% url 'issues:new' %}" method="post">
{% csrf_token %}
<table>
{{ form.as_table }}
<tr>
<td colspan="2">
<input type="submit" value="Create issue" />
</td>
</tr>
</table>
</form>
{% block content %}
<h2>Create new issue</h2>
{% if error_message %}<p><strong>{{ error_message }}</strong></p>{% endif %}
<form action="{% url 'issues:new' %}" method="post">
{% csrf_token %}
<table>
{{ form.as_table }}
<tr>
<td colspan="2">
<input type="submit" value="Create issue" />
</td>
</tr>
</table>
</form>
{% endblock %}

View File

@ -1,11 +1,17 @@
{% if project_list %}
<ul>
{% for project in project_list %}
<li>
<a href="{% url 'projects:view' project.project_key %}">{{ project.project_key }}: {{ project.name }}</a>
</li>
{% endfor %}
</ul>
{% else %}
<p>No projects.</p>
{% endif %}
{% extends "base.html" %}
{% block title %}Projects{% endblock %}
{% block content %}
{% if project_list %}
<ul>
{% for project in project_list %}
<li>
<a href="{% url 'projects:view' project.project_key %}">{{ project.project_key }}: {{ project.name }}</a>
</li>
{% endfor %}
</ul>
{% else %}
<p>No projects.</p>
{% endif %}
{% endblock %}

View File

@ -1,15 +1,21 @@
<h2>{{ project.project_key }} - {{ project.name }}</h2>
<p>{{ project.description }}</p>
{% extends "base.html" %}
<h3>Issues</h3>
{% if issue_list %}
<ul>
{% for issue in issue_list %}
<li>
<a href="{% url 'issues:detail' issue.id %}">{{ issue.title }}</a>
</li>
{% endfor %}
</ul>
{% else %}
<p>This project has no issues yet.</p>
{% endif %}
{% block title %}Project: {{ project.name }}{% endblock %}
{% block content %}
<h2>{{ project.project_key }} - {{ project.name }}</h2>
<p>{{ project.description }}</p>
<h3>Issues</h3>
{% if issue_list %}
<ul>
{% for issue in issue_list %}
<li>
<a href="{% url 'issues:detail' issue.id %}">{{ issue.title }}</a>
</li>
{% endfor %}
</ul>
{% else %}
<p>This project has no issues yet.</p>
{% endif %}
{% endblock %}

12
templates/base.html Normal file
View File

@ -0,0 +1,12 @@
<!DOCTYPE html>
<html lang="en">
<head>
<title>{% block title %}Tofu{% endblock %} - Tofu</title>
</head>
<body>
<h1>Tofu</h1>
{% block content %}No content.{% endblock %}
</body>
</html>

View File

@ -1,7 +1,13 @@
<h2>Login</h2>
{% extends "base.html" %}
<form method="POST">
{% csrf_token %}
{{ form.as_p }}
<button type="submit">Login</button>
</form>
{% block title %}Login{% endblock %}
{% block content %}
<h2>Login</h2>
<form method="POST">
{% csrf_token %}
{{ form.as_p }}
<button type="submit">Login</button>
</form>
{% endblock %}