1st commit

This commit is contained in:
2026-05-25 19:45:43 -03:00
commit 55087c8278
44 changed files with 1522 additions and 0 deletions

View File

@@ -0,0 +1,38 @@
{% extends 'base.html' %}
{% block content %}
<div class="container">
<div class="row center">
<div class="col-md-6 offset-md-3">
{% if edit_choice %}
<h2>Update choice</h2>
{% else %}
<h2>Add new choice</h2>
{% endif %}
{% if messages %}
<ul class="messages">
{% for message in messages %}
<li {% if message.tags %} class="{{ message.tags }}" {% endif %}>{{ message }}</li>
{% endfor %}
</ul>
{% endif %}
<form action="" method="POST">
{% csrf_token %}
{% for field in form %}
<div class="form-group">
{{ field.errors }}
{{ field.label_tag }}
{{ field }}
</div>
{% endfor %}
{% if edit_choice %}
<button type="submit" class="btn btn-primary">Update</button>
<a class="btn btn-danger" href="{% url 'polls:choice_delete' choice.id %}" role="button" onclick="return confirm('Are you sure you want to delete this?')">Delete</a>
{% else %}
<button type="submit" class="btn btn-primary">Add</button>
{% endif %}
</form>
</div>
</div>
</div>
{% endblock %}

View File

@@ -0,0 +1,30 @@
{% extends 'base.html' %}
{% block content %}
<div class="container">
<div class="row center">
<div class="col-md-6 offset-md-3">
<h2>Create new poll</h2>
{% if messages %}
<ul class="messages">
{% for message in messages %}
<li {% if message.tags %} class="{{ message.tags }}" {% endif %}>{{ message }}</li>
{% endfor %}
</ul>
{% endif %}
<form action="" method="POST">
{% csrf_token %}
{% for field in form %}
<div class="form-group">
{{ field.errors }}
{{ field.label_tag }}
{{ field }}
</div>
{% endfor %}
<button type="submit" class="btn btn-primary">Add Poll</button>
<a class="btn btn-warning" href="{% url 'polls:list' %}" role="button">Back</a>
</form>
</div>
</div>
</div>
{% endblock %}

View File

@@ -0,0 +1,43 @@
{% extends 'base.html' %}
{% block content %}
<div class="container">
{% if messages %}
<div class="messages">
{% for message in messages %}
<div {% if message.tags %} class="{{ message.tags }}" {% endif %}>{{ message }}
<button type="button" class="close" data-dismiss="alert" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
</div>
{% endfor %}
</div>
{% else %}
<div class="row">
<div class="col-md-8 offset-sm-2">
<h3 class="mt-3 mb-3 text-center">Result for: {{ poll.text }}</h3>
<!-- progress bar -->
<div class="progress mt-3">
{% for choice in poll.get_result_dict %}
<div class="progress-bar bg-{{ choice.alert_class }}" role="progressbar" style="width: {{ choice.percentage }}%;" aria-valuenow="30" aria-valuemin="0"
aria-valuemax="100"><b>{{ choice.text }}-{{ choice.percentage|floatformat }}%</b></div>
{% endfor %}
</div>
<ul class="list-group">
{% for choice in poll.choice_set.all %}
<li class="list-group-item d-flex justify-content-between align-items-center">
{{ choice.choice_text }}
<span class="badge badge-primary badge-pill">{{ choice.get_vote_count }}</span>
</li>
{% endfor %}
</ul>
{% endif %}
<a class="btn btn-primary mt-3" href="{% url 'polls:list' %}" role="button">Back To Polls</a>
</div>
</div>
</div>
{% endblock content %}

View File

@@ -0,0 +1,33 @@
{% extends 'base.html' %}
{% block content %}
<div class="container">
<h1>Polls details page</h1>
{% if messages %}
<div class="messages">
{% for message in messages %}
<div {% if message.tags %} class="{{ message.tags }}" {% endif %}>{{ message }}
<button type="button" class="close" data-dismiss="alert" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
</div>
{% endfor %}
</div>
{% endif %}
<hr>
<h2 class="mt-3 mb-3">{{ poll }}</h2>
<form action="{% url 'polls:vote' poll.id %}" method="POST">
{% csrf_token %}
{% for choice in poll.choice_set.all %}
<input type="radio" name="choice" id="choice{{ forloop.counter }}" value="{{ choice.id }}">
<label for="choice{{ forloop.counter }}">{{ choice.choice_text }}</label>
<br>
{% endfor %}
<input type="submit" value="Vote" class="btn btn-primary mt-3">
<a class="btn btn-warning mt-3" href="{% url 'polls:list' %}" role="button">Cancel</a>
</form>
</div>
{% endblock content %}

View File

@@ -0,0 +1,49 @@
{% extends 'base.html' %}
{% block content %}
<div class="container">
<div class="row center">
<div class="col-md-6 offset-md-3">
<h2>Edit poll</h2>
{% if messages %}
{% if messages %}
<div class="messages">
{% for message in messages %}
<div {% if message.tags %} class="{{ message.tags }}" {% endif %}>{{ message }}
<button type="button" class="close" data-dismiss="alert" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
</div>
{% endfor %}
</div>
{% endif %}
{% endif %}
<form action="" method="POST">
{% csrf_token %}
{% for field in form %}
<div class="form-group">
{{ field.errors }}
{{ field.label_tag }}
{{ field }}
</div>
{% endfor %}
<button type="submit" class="btn btn-primary">Update</button>
<a class="btn btn-danger" href="{% url 'polls:delete_poll' poll.id %}" role="button" onclick="return confirm('Are you sure?')">Delete</a>
<a class="btn btn-warning" href="{% url 'polls:add_choice' poll.id %}" role="button">Add Choice</a>
</form>
<div class="choices">
<h2 class="text-center mt-3">Choices</h2>
<hr>
<ul class="list-group">
{% for choice in poll.choice_set.all %}
<li class="list-group-item"><a href="{% url 'polls:choice_edit' choice.id %}"><i class="fas fa-pencil-alt"></i></a>&nbsp
{{ choice.choice_text }}</li>
{% endfor %}
</ul>
</div>
</div>
</div>
</div>
{% endblock %}

View File

@@ -0,0 +1,48 @@
{% extends 'base.html' %}
{% block content %}
<div class="container">
{% if messages %}
<div class="messages">
{% for message in messages %}
<div {% if message.tags %} class="{{ message.tags }}" {% endif %}>{{ message }}
<button type="button" class="close" data-dismiss="alert" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
</div>
{% endfor %}
</div>
{% else %}
<div class="row">
<div class="col-md-8 offset-sm-2">
{% if poll.active %}
<h3 class="mt-3 mb-3 text-center">Result for: {{ poll.text }}</h3>
{% else %}
<h3 class="mt-3 mb-3 text-center">"{{ poll.text }}" Has Ended Polling!</h3>
{% endif %}
<h3 class="mb-2 text-center">Total: {{ poll.get_vote_count }} votes</h3>
<!-- progress bar -->
<div class="progress mt-3 mb-2">
{% for choice in poll.get_result_dict %}
<div class="progress-bar bg-{{ choice.alert_class }}" role="progressbar" style="width: {{ choice.percentage }}%;"
aria-valuenow="30" aria-valuemin="0" aria-valuemax="100"><b>
{{choice.text|truncatewords:2}}-{{choice.percentage|floatformat}}%</b>
</div>
{% endfor %}
</div>
<ul class="list-group">
{% for choice in poll.choice_set.all %}
<li class="list-group-item d-flex justify-content-between align-items-center">
{{ choice.choice_text }}
<span class="badge badge-primary badge-pill">{{ choice.get_vote_count }}</span>
</li>
{% endfor %}
</ul>
{% endif %}
<a class="btn btn-primary mt-3" href="{% url 'polls:list' %}" role="button">Back To Polls</a>
</div>
</div>
</div>
{% endblock content %}

View File

@@ -0,0 +1,78 @@
{% extends 'base.html' %}
{% block content %}
<div class="container">
<div class="row">
<div class="col-md-8 offset-sm-2">
<h1 class="text-center mb-5">Welcome to polls List!</h1>
{% if messages %}
<div class="messages">
{% for message in messages %}
<div {% if message.tags %} class="{{ message.tags }}" {% endif %}>{{ message }}
<button type="button" class="close" data-dismiss="alert" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
</div>
{% endfor %}
</div>
{% endif %}
<a class="btn btn-{% if 'name' in request.GET %}warning{% else %}primary{% endif %} mb-3" href="?name=True"
role="button"><i class="fas fa-sort-alpha-down"></i>
Name</a>
<a class="btn btn-{% if 'date' in request.GET %}warning{% else %}primary{% endif %} mb-3" href="?date=True"
role="button"><i class="far fa-clock"></i> Date</a>
<a class="btn btn-{% if 'vote' in request.GET %}warning{% else %}primary{% endif %} mb-3" href="?vote=True"
role="button"><i class="fas fa-poll"></i> Vote</a>
<a class="btn btn-primary mb-3 float-right" href="{% url 'polls:add' %}" role="button">Add <i class="fas fa-plus"></i></a>
<form class="form-inline">
<div class="form-group mr-sm-2 mb-2">
<input type="search" class="form-control" name="search" placeholder="Search" value={{ search_term }}>
</div>
<button type="submit" class="btn btn-primary mb-2"><i class="fas fa-search"></i></button>
</form>
<ul class="list-group">
{% for poll in polls %}
<li class="list-group-item"><a href="{% url 'polls:detail' poll.id %}">{{ poll.text|truncatewords:5 }}
{% if not poll.active%}
<i class="fas fa-check-circle ml-2"></i>
{% endif %}
</a>
{% if request.user == poll.owner %}
{% if poll.active %}
<a href="{% url 'polls:end_poll' poll.id %}" data-toggle="tooltip" data-placement="top" title="End Poll"
onclick="return confirm('Are you sure ?')"><i class="fas fa-step-forward float-right btn btn-danger btn-sm"></i></a>
{% endif %}
<a href="{% url 'polls:edit' poll.id %}" class="mr-3" data-toggle="tooltip" data-placement="top"
title="Edit Poll"><i class="fas fa-pencil-alt float-right btn btn-primary btn-sm mr-1"></i></a>
{% endif %}
</li>
{% endfor %}
</ul>
{% if polls.paginator.num_pages > 1 %}
<nav class="mt-3">
<ul class="pagination">
{% if polls.has_previous %}
<li class="page-item"><a class="page-link" href="?page=1&{{ params }}">First</a></li>
<li class="page-item"><a class="page-link" href="?page={{ polls.previous_page_number }}&{{ params }}">Previous</a></li>
{% endif %}
<li class="page-item active"><a class="page-link" href="">{{ polls.number }}</a></li>
{% if polls.has_next %}
<li class="page-item"><a class="page-link" href="?page={{ polls.next_page_number }}&{{ params }}">Next</a></li>
<li class="page-item"><a class="page-link" href="?page={{ polls.paginator.num_pages }}&{{ params }}">Last</a></li>
{% endif %}
</ul>
</nav>
{% endif %}
</div>
</div>
</div>
{% endblock content %}