-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
solution #1
base: main
Are you sure you want to change the base?
solution #1
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
#!/usr/bin/env python | ||
"""Django's command-line utility for administrative tasks.""" | ||
import os | ||
import sys | ||
|
||
|
||
def main(): | ||
"""Run administrative tasks.""" | ||
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "todo_list.settings") | ||
try: | ||
from django.core.management import execute_from_command_line | ||
except ImportError as exc: | ||
raise ImportError( | ||
"Couldn't import Django. Are you sure it's installed and " | ||
"available on your PYTHONPATH environment variable? Did you " | ||
"forget to activate a virtual environment?" | ||
) from exc | ||
execute_from_command_line(sys.argv) | ||
|
||
|
||
if __name__ == "__main__": | ||
main() |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
django==4.0.2 | ||
django-debug-toolbar==3.2.4 | ||
django-crispy-forms==1.14.0 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
body { | ||
margin-top: 20px; | ||
} | ||
|
||
.btn-blurred { | ||
background-color: grey; | ||
color: white; | ||
} | ||
|
||
.done { | ||
color: green; | ||
} | ||
|
||
.not-done { | ||
color: red; | ||
} | ||
|
||
.text-tag { | ||
color: grey; | ||
} | ||
|
||
.text-deadline { | ||
color: #de5416; | ||
} | ||
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
|
||
<head> | ||
{% block title %}<title>Todo list</title>{% endblock %} | ||
<meta charset="utf-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1"> | ||
<link rel="stylesheet" | ||
href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" | ||
integrity="sha384-TX8t27EcRE3e/ihU7zmQxVncDAy5uIKz4rEkgIXeMed4M0jlfIDPvg6uqKI2xXr2" | ||
crossorigin="anonymous"> | ||
<!-- Add additional CSS in static file --> | ||
{% load static %} | ||
<link rel="stylesheet" href="{% static 'css/styles.css' %}"> | ||
</head> | ||
|
||
<body> | ||
|
||
<div class="container-fluid"> | ||
<div class="row"> | ||
<div class="col-sm-2"> | ||
|
||
{% block sidebar %} | ||
{% include "includes/sidebar.html" %} | ||
{% endblock %} | ||
|
||
</div> | ||
<div class="col-sm-10 "> | ||
|
||
{% block content %}{% endblock %} | ||
|
||
{% block pagination %} | ||
{% include "includes/pagination.html" %} | ||
{% endblock %} | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please be consistent with identation |
||
</div> | ||
</div> | ||
</div> | ||
</body> | ||
|
||
</html> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
{% if is_paginated %} | ||
<ul class="pagination"> | ||
{% if page_obj.has_previous %} | ||
<li class="page-item"> | ||
<a href="?page= {{ page_obj.previous_page_number }}" class="page-link">prev</a> | ||
</li> | ||
{% endif %} | ||
<li class="page-item active"> | ||
<span class="page-link">{{ page_obj.number }} of {{ paginator.num_pages }}</span> | ||
</li> | ||
{% if page_obj.has_next %} | ||
<li class="page-item"> | ||
<a href="?page= {{ page_obj.next_page_number }}" class="page-link">next</a> | ||
</li> | ||
{% endif %} | ||
</ul> | ||
{% endif %} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
<ul class="sidebar-nav list-group"> | ||
<li class="list-group-item"><a href="{% url 'todo:task-list' %}">Home</a></li> | ||
<li class="list-group-item"><a href="{% url 'todo:tag-list' %}">Tags</a></li> | ||
</ul> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
{% extends "base.html" %} | ||
|
||
{% block content %} | ||
|
||
<h1>Delete tag</h1> | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. To many blank lines |
||
|
||
<p>Are you sure you want to delete the tag {{ tag }}</p> | ||
|
||
<form action="" method="post"> | ||
{% csrf_token %} | ||
<input type="submit" value="Yes, delete" class="btn btn-danger"> | ||
</form> | ||
{% endblock %} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{% extends "base.html" %} | ||
{% load crispy_forms_filters %} | ||
|
||
{% block content %} | ||
<h1>{{ object|yesno:"Update,Create" }} Tag</h1> | ||
|
||
<form action="" method="post"> | ||
{% csrf_token %} | ||
{{ form|crispy }} | ||
<input class="btn btn-primary" type="submit" value="submit"> | ||
</form> | ||
{% endblock %} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
{% extends "base.html" %} | ||
|
||
{% block content %} | ||
<h1>Tags</h1> | ||
<button style="float: right; margin-right: 25px; bottom: 50px; position:relative;" class="btn btn-primary"> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's recommended to have styles in a css file |
||
<a role="button" style="color: white" | ||
href="{% url 'todo:tag-create'%}">Add</a> | ||
</button> | ||
|
||
{% if tag_list %} | ||
<table class="table"> | ||
<tr> | ||
<th>Name</th> | ||
<th>Update</th> | ||
<th>Delete</th> | ||
</tr> | ||
{% for tag in tag_list %} | ||
<tr> | ||
<td>{{ tag.name }}</td> | ||
<td> | ||
<button style="background: gray" class="btn"><a role="button" style="color: white" | ||
href="{% url 'todo:task_change_status' pk=tag.id %}">Update</a> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Incorrect url. Must be 'todo:tag-update' |
||
</button> | ||
</td> | ||
<td> | ||
<button style="background: gray" class="btn"><a role="button" style="color: white" | ||
href="{% url 'todo:task_change_status' pk=tag.id %}">Delete</a> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Incorrect url. Must be 'todo:tag-delete' |
||
</button> | ||
</td> | ||
|
||
</tr> | ||
{% endfor %} | ||
|
||
</table> | ||
|
||
{% else %} | ||
<p>There are no todos</p> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please change to 'tags' |
||
{% endif %} | ||
|
||
{% endblock %} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
{% extends "base.html" %} | ||
|
||
{% block content %} | ||
|
||
<h1>Delete task</h1> | ||
|
||
<p>Are you sure you want to delete the task {{ task }}</p> | ||
|
||
<form action="" method="post"> | ||
{% csrf_token %} | ||
<input type="submit" value="Yes, delete" class="btn btn-danger"> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's recommended to add a cancel button. |
||
</form> | ||
{% endblock %} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{% extends "base.html" %} | ||
{% load crispy_forms_filters %} | ||
|
||
{% block content %} | ||
<h1>{{ object|yesno:"Update,Create" }} Task</h1> | ||
|
||
<form action="" method="post"> | ||
{% csrf_token %} | ||
{{ form|crispy }} | ||
<input class="btn btn-primary" type="submit" value="submit"> | ||
</form> | ||
{% endblock %} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
{% extends "base.html" %} | ||
|
||
{% block content %} | ||
<h1>TODO list</h1> | ||
<button style="float: right; bottom: 50px; position: relative" class="btn btn-primary" | ||
type="submit" | ||
value="submit"> | ||
<a role="button" style="color: white" | ||
href="{% url 'todo:task-create' %}">Add task</a> | ||
</button> | ||
<br> | ||
|
||
{% if task_list %} | ||
{% for task in task_list %} | ||
<br> | ||
<div class="form-group"> | ||
<b>{{ task.content }}</b> | ||
|
||
|
||
{% if task.is_done %} | ||
<b><span class="done">Done</span></b> | ||
<form method="post" action="{% url 'todo:task_change_status' pk=task.id %}"> | ||
{% csrf_token %} | ||
|
||
<button style="float: right" type="submit" class="btn btn-blurred"> | ||
Undo | ||
</button> | ||
|
||
</form> | ||
|
||
{% else %} | ||
<b><span class="not-done">Not done</span></b> | ||
|
||
<form method="post" action="{% url 'todo:task_change_status' pk=task.id %}"> | ||
{% csrf_token %} | ||
<button style="float: right" type="submit" class="btn btn-success"> | ||
Complete | ||
</button> | ||
</form> | ||
|
||
{% endif %} | ||
|
||
</div> | ||
<div class="form-group"> | ||
Created: {{ task.created_at }} {% if task.deadline %} | ||
<span class="text-deadline">Deadline: {{ task.deadline }}</span> | ||
{% endif %} | ||
</div> | ||
<div class="form-group"> | ||
<b><span class="text-tag"> Tags: | ||
{% for tag in task.tags.all %} | ||
{{ tag.name }} | ||
{% endfor %} | ||
</span></b> | ||
|
||
|
||
<a href="{% url 'todo:task-update' pk=task.id %}">Update</a> | ||
<a href="{% url 'todo:task-delete' pk=task.id %}">Delete</a> | ||
</div> | ||
{% endfor %} | ||
|
||
{% else %} | ||
<p>There are no todos</p> | ||
{% endif %} | ||
|
||
|
||
|
||
{% endblock %} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
from django.contrib import admin | ||
|
||
from todo.models import Tag, Task | ||
|
||
|
||
@admin.register(Task) | ||
class TaskAdmin(admin.ModelAdmin): | ||
pass | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If there are no special modifications to the logic, this can be simplified to regular model registration. |
||
|
||
|
||
@admin.register(Tag) | ||
class AdminTag(admin.ModelAdmin): | ||
pass |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
from django.apps import AppConfig | ||
|
||
|
||
class TodoConfig(AppConfig): | ||
default_auto_field = "django.db.models.BigAutoField" | ||
name = "todo" |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
from django import forms | ||
from django.core.exceptions import ValidationError | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Unused import |
||
|
||
from todo.models import Tag, Task | ||
|
||
|
||
class TagForm(forms.ModelForm): | ||
class Meta: | ||
model = Tag | ||
fields = "__all__" | ||
|
||
|
||
class TaskForm(forms.ModelForm): | ||
tags = forms.ModelMultipleChoiceField( | ||
queryset=Tag.objects.all(), | ||
widget=forms.CheckboxSelectMultiple, | ||
required=False | ||
) | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Also would be great to define 'SelectDateWidget' for deadline field |
||
class Meta: | ||
model = Task | ||
fields = "__all__" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add blank line to all files where is missing