Add a base template for polls app
This commit is contained in:
parent
a24bfa4806
commit
6f64fbb092
96
polls/templates/base.html
Normal file
96
polls/templates/base.html
Normal file
@ -0,0 +1,96 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en" data-bs-theme="dark">
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
|
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-QWTKZyjpPEjISv5WaRU9OFeRpok6YctnYmDr5pNlyT2bRjXh0JMhjY6hW+ALEwIH" crossorigin="anonymous">
|
||||||
|
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js" integrity="sha384-YvpcrYf0tY3lHB60NNkmXc5s9fDVZLESaAA55NDzOxhy9GkcIdslK1eN7N6jIeHz" crossorigin="anonymous"></script>
|
||||||
|
<title>{% block title %}Test site{% endblock %}</title>
|
||||||
|
<style>
|
||||||
|
.darker-bg {
|
||||||
|
background-color: #171a1e;
|
||||||
|
}
|
||||||
|
body {
|
||||||
|
min-height: 75rem;
|
||||||
|
padding-top: 3rem;
|
||||||
|
}
|
||||||
|
.list-group {
|
||||||
|
width: 100%;
|
||||||
|
max-width: 460px;
|
||||||
|
margin-inline: 1.5rem;
|
||||||
|
}
|
||||||
|
.list-group-checkable .list-group-item {
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
.list-group-item-check {
|
||||||
|
position: absolute;
|
||||||
|
clip: rect(0, 0, 0, 0);
|
||||||
|
}
|
||||||
|
.list-group-item-check:hover + .list-group-item {
|
||||||
|
background-color: var(--bs-secondary-bg);
|
||||||
|
}
|
||||||
|
.list-group-item-check:checked + .list-group-item {
|
||||||
|
color: #fff;
|
||||||
|
background-color: var(--bs-primary);
|
||||||
|
border-color: var(--bs-primary);
|
||||||
|
}
|
||||||
|
.list-group-item-check[disabled] + .list-group-item,
|
||||||
|
.list-group-item-check:disabled + .list-group-item {
|
||||||
|
pointer-events: none;
|
||||||
|
filter: none;
|
||||||
|
opacity: .5;
|
||||||
|
}
|
||||||
|
.list-group-radio .list-group-item {
|
||||||
|
cursor: pointer;
|
||||||
|
border-radius: .5rem;
|
||||||
|
}
|
||||||
|
.list-group-radio .form-check-input {
|
||||||
|
z-index: 2;
|
||||||
|
margin-top: -.5em;
|
||||||
|
}
|
||||||
|
.list-group-radio .list-group-item:hover,
|
||||||
|
.list-group-radio .list-group-item:focus {
|
||||||
|
background-color: var(--bs-secondary-bg);
|
||||||
|
}
|
||||||
|
|
||||||
|
.list-group-radio .form-check-input:checked + .list-group-item {
|
||||||
|
background-color: var(--bs-body);
|
||||||
|
border-color: var(--bs-primary);
|
||||||
|
box-shadow: 0 0 0 2px var(--bs-primary);
|
||||||
|
}
|
||||||
|
.list-group-radio .form-check-input[disabled] + .list-group-item,
|
||||||
|
.list-group-radio .form-check-input:disabled + .list-group-item {
|
||||||
|
pointer-events: none;
|
||||||
|
filter: none;
|
||||||
|
opacity: .5;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<nav class="navbar navbar-expand-md navbar-dark fixed-top bg-dark">
|
||||||
|
<div class="container-fluid">
|
||||||
|
<a class="navbar-brand" href="/polls">Test App</a>
|
||||||
|
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarCollapse" aria-controls="navbarCollapse" aria-expanded="false" aria-label="Toggle navigation">
|
||||||
|
<span class="navbar-toggler-icon"></span>
|
||||||
|
</button>
|
||||||
|
<div class="collapse navbar-collapse" id="navbarCollapse">
|
||||||
|
<ul class="navbar-nav me-auto mb-2 mb-md-0">
|
||||||
|
<li class="nav-item">
|
||||||
|
<a class="nav-link active" aria-current="page" href="/polls">Polls</a>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
<div class="d-flex">
|
||||||
|
{% if user.is_authenticated %}
|
||||||
|
<a href="/logout"><button class="btn btn-outline-success">Log out</button></a>
|
||||||
|
{% else %}
|
||||||
|
<button class="btn btn-primary">Log In</button>
|
||||||
|
{% endif %}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</nav>
|
||||||
|
<main class="px-4 py-5 shadow darker-bg">
|
||||||
|
{% block content %}{% endblock %}
|
||||||
|
</main>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
@ -1,86 +1,25 @@
|
|||||||
<!DOCTYPE html>
|
{% extends "base.html" %}
|
||||||
<html lang="en" data-bs-theme="dark">
|
|
||||||
<head>
|
|
||||||
<meta charset="utf-8">
|
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
||||||
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-QWTKZyjpPEjISv5WaRU9OFeRpok6YctnYmDr5pNlyT2bRjXh0JMhjY6hW+ALEwIH" crossorigin="anonymous">
|
|
||||||
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js" integrity="sha384-YvpcrYf0tY3lHB60NNkmXc5s9fDVZLESaAA55NDzOxhy9GkcIdslK1eN7N6jIeHz" crossorigin="anonymous"></script>
|
|
||||||
<title>Testapp</title>
|
|
||||||
<style>
|
|
||||||
.darker-bg {
|
|
||||||
background-color: #171a1e;
|
|
||||||
}
|
|
||||||
.list-group {
|
|
||||||
width: 100%;
|
|
||||||
max-width: 460px;
|
|
||||||
margin-inline: 1.5rem;
|
|
||||||
}
|
|
||||||
.list-group-checkable .list-group-item {
|
|
||||||
cursor: pointer;
|
|
||||||
}
|
|
||||||
.list-group-item-check {
|
|
||||||
position: absolute;
|
|
||||||
clip: rect(0, 0, 0, 0);
|
|
||||||
}
|
|
||||||
.list-group-item-check:hover + .list-group-item {
|
|
||||||
background-color: var(--bs-secondary-bg);
|
|
||||||
}
|
|
||||||
.list-group-item-check:checked + .list-group-item {
|
|
||||||
color: #fff;
|
|
||||||
background-color: var(--bs-primary);
|
|
||||||
border-color: var(--bs-primary);
|
|
||||||
}
|
|
||||||
.list-group-item-check[disabled] + .list-group-item,
|
|
||||||
.list-group-item-check:disabled + .list-group-item {
|
|
||||||
pointer-events: none;
|
|
||||||
filter: none;
|
|
||||||
opacity: .5;
|
|
||||||
}
|
|
||||||
.list-group-radio .list-group-item {
|
|
||||||
cursor: pointer;
|
|
||||||
border-radius: .5rem;
|
|
||||||
}
|
|
||||||
.list-group-radio .form-check-input {
|
|
||||||
z-index: 2;
|
|
||||||
margin-top: -.5em;
|
|
||||||
}
|
|
||||||
.list-group-radio .list-group-item:hover,
|
|
||||||
.list-group-radio .list-group-item:focus {
|
|
||||||
background-color: var(--bs-secondary-bg);
|
|
||||||
}
|
|
||||||
|
|
||||||
.list-group-radio .form-check-input:checked + .list-group-item {
|
{% block title %}{{ question.question_text }}{% endblock %}
|
||||||
background-color: var(--bs-body);
|
|
||||||
border-color: var(--bs-primary);
|
{% block content %}
|
||||||
box-shadow: 0 0 0 2px var(--bs-primary);
|
<div class="text-center">
|
||||||
}
|
<h1 class="display-5 fw-bold text-body-emphasis">{{ question.question_text }}</h1>
|
||||||
.list-group-radio .form-check-input[disabled] + .list-group-item,
|
<br/>
|
||||||
.list-group-radio .form-check-input:disabled + .list-group-item {
|
|
||||||
pointer-events: none;
|
<form action="{% url 'polls:vote' question.id %}" method="post">
|
||||||
filter: none;
|
{% csrf_token %}
|
||||||
opacity: .5;
|
<fieldset class="d-flex flex-column flex-md-row col-lg-6 mx-auto align-items-center justify-content-center">
|
||||||
}
|
{% if error_message %}<p><strong>{{ error_message }}</strong></p>{% endif %}
|
||||||
</style>
|
<div class="list-group list-group-checkable d-grid gap-2 border-0">
|
||||||
</head>
|
{% for choice in question.choice_set.all %}
|
||||||
<body>
|
<input class="list-group-item-check pe-none" type="radio" name="choice" id="choice{{ forloop.counter }}" value="{{ choice.id }}">
|
||||||
<div class="px-4 py-5 my-5 text-center shadow darker-bg">
|
<label class="list-group-item rounded-3 py-3" for="choice{{ forloop.counter }}">{{ choice.choice_text }}</label><br>
|
||||||
<h1 class="display-5 fw-bold text-body-emphasis">{{ question.question_text }}</h1>
|
{% endfor %}
|
||||||
|
</div>
|
||||||
|
</fieldset>
|
||||||
<br/>
|
<br/>
|
||||||
|
<input class="btn btn-success rounded-3 px-3" type="submit" value="Vote">
|
||||||
<form action="{% url 'polls:vote' question.id %}" method="post">
|
</form>
|
||||||
{% csrf_token %}
|
</div>
|
||||||
<fieldset class="d-flex flex-column flex-md-row col-lg-6 mx-auto align-items-center justify-content-center">
|
{% endblock %}
|
||||||
{% if error_message %}<p><strong>{{ error_message }}</strong></p>{% endif %}
|
|
||||||
<div class="list-group list-group-checkable d-grid gap-2 border-0">
|
|
||||||
{% for choice in question.choice_set.all %}
|
|
||||||
<input class="list-group-item-check pe-none" type="radio" name="choice" id="choice{{ forloop.counter }}" value="{{ choice.id }}">
|
|
||||||
<label class="list-group-item rounded-3 py-3" for="choice{{ forloop.counter }}">{{ choice.choice_text }}</label><br>
|
|
||||||
{% endfor %}
|
|
||||||
</div>
|
|
||||||
</fieldset>
|
|
||||||
<br/>
|
|
||||||
<input class="btn btn-success rounded-3 px-3" type="submit" value="Vote">
|
|
||||||
</form>
|
|
||||||
</div>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
|
|||||||
@ -1,45 +1,31 @@
|
|||||||
|
{% extends "base.html" %}
|
||||||
|
|
||||||
<!DOCTYPE html>
|
{% block title %}Polls{% endblock %}
|
||||||
<html lang="en" data-bs-theme="dark">
|
|
||||||
<head>
|
{% block content %}
|
||||||
<meta charset="utf-8">
|
<h1 class="display-5 fw-bold text-body-emphasis text-center">Polls</h1>
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
<br/>
|
||||||
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-QWTKZyjpPEjISv5WaRU9OFeRpok6YctnYmDr5pNlyT2bRjXh0JMhjY6hW+ALEwIH" crossorigin="anonymous">
|
<div class="d-flex flex-column flex-md-row col-lg-6 mx-auto align-items-center justify-content-center">
|
||||||
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js" integrity="sha384-YvpcrYf0tY3lHB60NNkmXc5s9fDVZLESaAA55NDzOxhy9GkcIdslK1eN7N6jIeHz" crossorigin="anonymous"></script>
|
{% if latest_question_list %}
|
||||||
<title>Testapp</title>
|
<div class="list-group">
|
||||||
<style>
|
{% for question in latest_question_list %}
|
||||||
.darker-bg {
|
<a href="{% url 'polls:detail' question.id %}" class="list-group-item list-group-item-action d-flex gap-3 py-3" aria-current="true">
|
||||||
background-color: #171a1e;
|
<!--<img src="https://github.com/twbs.png" alt="twbs" width="32" height="32" class="rounded-circle flex-shrink-0"> -->
|
||||||
}
|
<div class="d-flex gap-2 w-100 justify-content-between">
|
||||||
</style>
|
<div>
|
||||||
</head>
|
<h6 class="mb-0">{{ question.question_text }}</h6>
|
||||||
<body>
|
<!-- <p class="mb-0 opacity-75">Some placeholder content in a paragraph.</p> -->
|
||||||
<div class="px-4 py-5 my-5 shadow darker-bg">
|
</div>
|
||||||
<h1 class="display-5 fw-bold text-body-emphasis text-center">Polls</h1>
|
<small class="opacity-50 text-nowrap">{{ question.pub_date }}</small>
|
||||||
<br/>
|
|
||||||
<div class="d-flex flex-column flex-md-row col-lg-6 mx-auto align-items-center justify-content-center">
|
|
||||||
{% if latest_question_list %}
|
|
||||||
<div class="list-group">
|
|
||||||
{% for question in latest_question_list %}
|
|
||||||
<a href="{% url 'polls:detail' question.id %}" class="list-group-item list-group-item-action d-flex gap-3 py-3" aria-current="true">
|
|
||||||
<!--<img src="https://github.com/twbs.png" alt="twbs" width="32" height="32" class="rounded-circle flex-shrink-0"> -->
|
|
||||||
<div class="d-flex gap-2 w-100 justify-content-between">
|
|
||||||
<div>
|
|
||||||
<h6 class="mb-0">{{ question.question_text }}</h6>
|
|
||||||
<!-- <p class="mb-0 opacity-75">Some placeholder content in a paragraph.</p> -->
|
|
||||||
</div>
|
|
||||||
<small class="opacity-50 text-nowrap">{{ question.pub_date }}</small>
|
|
||||||
</div>
|
|
||||||
</a>
|
|
||||||
{% endfor %}
|
|
||||||
</div>
|
</div>
|
||||||
{% else %}
|
</a>
|
||||||
<p class="text-center text-muted">
|
{% endfor %}
|
||||||
No polls are available.<br />
|
</div>
|
||||||
You can create polls in the <a href="/admin/polls/question/">admin panel</a>
|
{% else %}
|
||||||
</p>
|
<p class="text-center text-muted">
|
||||||
{% endif %}
|
No polls are available.<br />
|
||||||
</div>
|
You can create polls in the <a href="/admin/polls/question/">admin panel</a>
|
||||||
</div>
|
</p>
|
||||||
</body>
|
{% endif %}
|
||||||
</html>
|
</div>
|
||||||
|
{% endblock %}
|
||||||
|
|||||||
@ -1,92 +1,28 @@
|
|||||||
<!DOCTYPE html>
|
{% extends "base.html" %}
|
||||||
<html lang="en" data-bs-theme="dark">
|
|
||||||
<head>
|
|
||||||
<meta charset="utf-8">
|
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
||||||
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-QWTKZyjpPEjISv5WaRU9OFeRpok6YctnYmDr5pNlyT2bRjXh0JMhjY6hW+ALEwIH" crossorigin="anonymous">
|
|
||||||
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js" integrity="sha384-YvpcrYf0tY3lHB60NNkmXc5s9fDVZLESaAA55NDzOxhy9GkcIdslK1eN7N6jIeHz" crossorigin="anonymous"></script>
|
|
||||||
<title>Testapp</title>
|
|
||||||
<style>
|
|
||||||
.darker-bg {
|
|
||||||
background-color: #171a1e;
|
|
||||||
}
|
|
||||||
.list-group {
|
|
||||||
width: 100%;
|
|
||||||
max-width: 460px;
|
|
||||||
margin-inline: 1.5rem;
|
|
||||||
}
|
|
||||||
.list-group-checkable .list-group-item {
|
|
||||||
cursor: pointer;
|
|
||||||
}
|
|
||||||
.list-group-item-check {
|
|
||||||
position: absolute;
|
|
||||||
clip: rect(0, 0, 0, 0);
|
|
||||||
}
|
|
||||||
.list-group-item-check:hover + .list-group-item {
|
|
||||||
background-color: var(--bs-secondary-bg);
|
|
||||||
}
|
|
||||||
.list-group-item-check:checked + .list-group-item {
|
|
||||||
color: #fff;
|
|
||||||
background-color: var(--bs-primary);
|
|
||||||
border-color: var(--bs-primary);
|
|
||||||
}
|
|
||||||
.list-group-item-check[disabled] + .list-group-item,
|
|
||||||
.list-group-item-check:disabled + .list-group-item {
|
|
||||||
pointer-events: none;
|
|
||||||
filter: none;
|
|
||||||
opacity: .5;
|
|
||||||
}
|
|
||||||
.list-group-radio .list-group-item {
|
|
||||||
cursor: pointer;
|
|
||||||
border-radius: .5rem;
|
|
||||||
}
|
|
||||||
.list-group-radio .form-check-input {
|
|
||||||
z-index: 2;
|
|
||||||
margin-top: -.5em;
|
|
||||||
}
|
|
||||||
.list-group-radio .list-group-item:hover,
|
|
||||||
.list-group-radio .list-group-item:focus {
|
|
||||||
background-color: var(--bs-secondary-bg);
|
|
||||||
}
|
|
||||||
|
|
||||||
.list-group-radio .form-check-input:checked + .list-group-item {
|
{% block title %}{{ question.question_text }} Results{% endblock %}
|
||||||
background-color: var(--bs-body);
|
|
||||||
border-color: var(--bs-primary);
|
{% block content %}
|
||||||
box-shadow: 0 0 0 2px var(--bs-primary);
|
<h1 class="display-5 fw-bold text-body-emphasis text-center">{{ question.question_text }}</h1>
|
||||||
}
|
<br/>
|
||||||
.list-group-radio .form-check-input[disabled] + .list-group-item,
|
<h1 class="text-center">Results</h1>
|
||||||
.list-group-radio .form-check-input:disabled + .list-group-item {
|
<div class="d-flex flex-column flex-md-row col-lg-6 mx-auto align-items-center justify-content-center">
|
||||||
pointer-events: none;
|
<div class="list-group">
|
||||||
filter: none;
|
{% for choice_text, choice_votes, choice_percent in choices %}
|
||||||
opacity: .5;
|
<div class="list-group-item list-group-item-action d-flex gap-3 py-3">
|
||||||
}
|
<div class="d-flex gap-2 w-100 justify-content-between">
|
||||||
</style>
|
<div>
|
||||||
</head>
|
<h6 class="mb-0">{{ choice_text }}</h6>
|
||||||
<body>
|
<!--
|
||||||
<div class="px-4 py-5 my-5 shadow darker-bg">
|
<div role="progressbar" aria-label="{{ choice_text }}" aria-valuenow="{{ choice_percent }}" aria-valuemin="0" aria-valuemax="100" class="progress">
|
||||||
<h1 class="display-5 fw-bold text-body-emphasis text-center">{{ question.question_text }}</h1>
|
<div class="progress-bar" style="width: {{ choice_percent }}%"></div>
|
||||||
<br/>
|
|
||||||
<h1 class="text-center">Results</h1>
|
|
||||||
<div class="d-flex flex-column flex-md-row col-lg-6 mx-auto align-items-center justify-content-center">
|
|
||||||
<div class="list-group">
|
|
||||||
{% for choice_text, choice_votes, choice_percent in choices %}
|
|
||||||
<div class="list-group-item list-group-item-action d-flex gap-3 py-3">
|
|
||||||
<div class="d-flex gap-2 w-100 justify-content-between">
|
|
||||||
<div>
|
|
||||||
<h6 class="mb-0">{{ choice_text }}</h6>
|
|
||||||
<!--
|
|
||||||
<div role="progressbar" aria-label="{{ choice_text }}" aria-valuenow="{{ choice_percent }}" aria-valuemin="0" aria-valuemax="100" class="progress">
|
|
||||||
<div class="progress-bar" style="width: {{ choice_percent }}%"></div>
|
|
||||||
</div>
|
|
||||||
-->
|
|
||||||
</div>
|
</div>
|
||||||
|
-->
|
||||||
<small class="text-nowrap">{{ choice_votes }} vote{{ choice_votes|pluralize }}</small>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
{% endfor %}
|
<small class="text-nowrap">{{ choice_votes }} vote{{ choice_votes|pluralize }}</small>
|
||||||
</div{{ question.question_text }}>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</body>
|
{% endfor %}
|
||||||
</html>
|
</div{{ question.question_text }}>
|
||||||
|
</div>
|
||||||
|
{% endblock %}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user