mirror of
https://github.com/TrentSPalmer/todo_app_flask.git
synced 2025-08-23 05:43:58 -07:00
initial commit
This commit is contained in:
72
app/tasks/delete_move_toggle_task.py
Normal file
72
app/tasks/delete_move_toggle_task.py
Normal file
@@ -0,0 +1,72 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
from flask import Blueprint, redirect, url_for, flash
|
||||
from flask_login import current_user
|
||||
from flask import current_app
|
||||
from app.models import Task, Category
|
||||
from .. import db
|
||||
from .reorder_priorities import reorder_priorities
|
||||
|
||||
movecat = Blueprint(
|
||||
"movecat", __name__, template_folder="templates"
|
||||
)
|
||||
|
||||
toggletaskdone = Blueprint(
|
||||
"toggletaskdone", __name__, template_folder="templates"
|
||||
)
|
||||
|
||||
deletetask = Blueprint(
|
||||
"deletetask", __name__, template_folder="templates"
|
||||
)
|
||||
|
||||
|
||||
@movecat.route("/move-cat/<int:taskid>/<int:catid>")
|
||||
def move_cat(taskid, catid):
|
||||
task = Task.query.get(taskid)
|
||||
if current_user.is_anonymous or current_user.id != task.contributor_id:
|
||||
return(redirect(url_for('cats.index')))
|
||||
if bool(Category.query.get(catid)):
|
||||
category = Category.query.get(catid)
|
||||
if category.contributor_id == task.contributor_id:
|
||||
previous_catid = task.catid
|
||||
task.catid = catid
|
||||
db.session.commit()
|
||||
flash("Task {} moved!".format(taskid))
|
||||
reorder_priorities(catid, task.contributor_id, task.done, current_app.config)
|
||||
reorder_priorities(previous_catid, task.contributor_id, task.done, current_app.config)
|
||||
if task.done:
|
||||
return(redirect(url_for('tsks.hidden_tasks', category_id=task.catid)))
|
||||
else:
|
||||
return(redirect(url_for('tsks.tasks', category_id=task.catid)))
|
||||
|
||||
|
||||
@deletetask.route("/delete-task/<int:taskid>")
|
||||
def delete_task(taskid):
|
||||
task = Task.query.get(taskid)
|
||||
if current_user.is_anonymous or current_user.id != task.contributor_id:
|
||||
return(redirect(url_for('cats.index')))
|
||||
db.session.delete(task)
|
||||
db.session.commit()
|
||||
flash("Task {} deleted!".format(taskid))
|
||||
reorder_priorities(task.catid, task.contributor_id, task.done, current_app.config)
|
||||
if task.done:
|
||||
return(redirect(url_for('tsks.hidden_tasks', category_id=task.catid)))
|
||||
else:
|
||||
return(redirect(url_for('tsks.tasks', category_id=task.catid)))
|
||||
|
||||
|
||||
@toggletaskdone.route("/toggle-task-done/<int:taskid>")
|
||||
def toggle_task_done(taskid):
|
||||
task = Task.query.get(taskid)
|
||||
if current_user.is_anonymous or current_user.id != task.contributor_id:
|
||||
return(redirect(url_for('cats.index')))
|
||||
task.done = not task.done
|
||||
db.session.commit()
|
||||
reorder_priorities(task.catid, task.contributor_id, True, current_app.config)
|
||||
reorder_priorities(task.catid, task.contributor_id, False, current_app.config)
|
||||
if task.done:
|
||||
flash("Task {} unmarked done!".format(taskid))
|
||||
return(redirect(url_for('tsks.tasks', category_id=task.catid)))
|
||||
else:
|
||||
flash("Task {} marked done!".format(taskid))
|
||||
return(redirect(url_for('tsks.hidden_tasks', category_id=task.catid)))
|
46
app/tasks/edit_task.py
Normal file
46
app/tasks/edit_task.py
Normal file
@@ -0,0 +1,46 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
from flask import Blueprint, redirect, url_for, flash, render_template, request
|
||||
from flask_login import current_user
|
||||
from app.models import Task
|
||||
from flask_wtf import FlaskForm
|
||||
from wtforms import SubmitField, TextAreaField
|
||||
from wtforms.validators import DataRequired
|
||||
from .. import db
|
||||
|
||||
edittask = Blueprint(
|
||||
"edittask", __name__, template_folder="templates"
|
||||
)
|
||||
|
||||
|
||||
@edittask.route("/edit-task/<int:taskid>", methods=["GET", "POST"])
|
||||
def edit_task(taskid):
|
||||
if current_user.is_anonymous:
|
||||
return(redirect(url_for('cats.index')))
|
||||
task = Task.query.get(taskid)
|
||||
form = EditTask()
|
||||
if task.done:
|
||||
cancel_nav_link = ('cancel', url_for('tsks.hidden_tasks', category_id=task.catid))
|
||||
else:
|
||||
cancel_nav_link = ('cancel', url_for('tsks.tasks', category_id=task.catid))
|
||||
nl = (cancel_nav_link, )
|
||||
if request.method == 'GET':
|
||||
form.content.data = task.content
|
||||
if form.validate_on_submit():
|
||||
task.content = form.content.data
|
||||
db.session.commit()
|
||||
flash("Thanks for the task edit!")
|
||||
if task.done:
|
||||
return(redirect(url_for('tsks.hidden_tasks', category_id=task.catid)))
|
||||
else:
|
||||
return(redirect(url_for('tsks.tasks', category_id=task.catid)))
|
||||
return render_template('edit_task.html', title='Edit Task', form=form, navbar_links=nl, task=task)
|
||||
|
||||
|
||||
class EditTask(FlaskForm):
|
||||
content = TextAreaField(
|
||||
'Edit Task - Markdown Supported',
|
||||
validators=[DataRequired(), ],
|
||||
render_kw={'autofocus': True}
|
||||
)
|
||||
submit = SubmitField('Save')
|
73
app/tasks/new_task.py
Normal file
73
app/tasks/new_task.py
Normal file
@@ -0,0 +1,73 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
import psycopg2
|
||||
from datetime import datetime
|
||||
from flask import Blueprint, redirect, url_for, flash, render_template
|
||||
from flask import current_app as app
|
||||
from flask_login import current_user
|
||||
from flask_wtf import FlaskForm
|
||||
from wtforms import SubmitField, TextAreaField
|
||||
from wtforms.validators import DataRequired
|
||||
from app.models import Task, Category
|
||||
|
||||
newtask = Blueprint(
|
||||
"newtask", __name__, template_folder="templates"
|
||||
)
|
||||
|
||||
|
||||
def insert_task(task):
|
||||
conn = psycopg2.connect(
|
||||
dbname=app.config['DATABASE_NAME'],
|
||||
user=app.config['DATABASE_USER'],
|
||||
host=app.config['DATABASE_HOST'],
|
||||
password=app.config['DATABASE_PASSWORD']
|
||||
)
|
||||
cur = conn.cursor()
|
||||
cur.execute("SELECT setval('task_id_seq', (SELECT MAX(id) FROM task))")
|
||||
conn.commit()
|
||||
cur.execute(
|
||||
"SELECT MAX(priority) FROM task WHERE catid=%s AND contributor_id=%s AND done=%s",
|
||||
(task.catid, task.contributor_id, False)
|
||||
)
|
||||
max_priority = cur.fetchone()[0]
|
||||
task.priority = 1 if max_priority is None else max_priority + 1
|
||||
cur.execute(
|
||||
"SELECT count(id) FROM task WHERE content=%s AND contributor_id=%s",
|
||||
(task.content, task.contributor_id)
|
||||
)
|
||||
if cur.fetchone()[0] == 0:
|
||||
cur.execute(
|
||||
"INSERT INTO task(content, contributor_id, catid, priority, timestamp) VALUES(%s,%s,%s,%s,%s)",
|
||||
(task.content, task.contributor_id, task.catid, task.priority, task.timestamp)
|
||||
)
|
||||
conn.commit()
|
||||
conn.close
|
||||
|
||||
|
||||
@newtask.route("/new-task/<int:category_id>", methods=["GET", "POST"])
|
||||
def new_task(category_id):
|
||||
if current_user.is_anonymous:
|
||||
return(redirect(url_for('cats.index')))
|
||||
form = NewTask()
|
||||
category = Category.query.get(category_id)
|
||||
nl = (('cancel', url_for('tsks.tasks', category_id=category_id)), )
|
||||
if form.validate_on_submit():
|
||||
task = Task(
|
||||
content=form.content.data,
|
||||
contributor_id=current_user.id,
|
||||
catid=category_id,
|
||||
timestamp=str(datetime.utcnow()),
|
||||
)
|
||||
insert_task(task)
|
||||
flash("Thanks for the new task!")
|
||||
return(redirect(url_for('tsks.tasks', category_id=category_id)))
|
||||
return render_template('new_task.html', title='New Task', form=form, navbar_links=nl, category=category)
|
||||
|
||||
|
||||
class NewTask(FlaskForm):
|
||||
content = TextAreaField(
|
||||
'New Task - Markdown Supported',
|
||||
validators=[DataRequired(), ],
|
||||
render_kw={'autofocus': True}
|
||||
)
|
||||
submit = SubmitField('Save')
|
74
app/tasks/reorder_priorities.py
Normal file
74
app/tasks/reorder_priorities.py
Normal file
@@ -0,0 +1,74 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
import psycopg2
|
||||
from flask import Blueprint, redirect, url_for, request, flash
|
||||
from flask import current_app
|
||||
from app.models import Task
|
||||
from flask_login import current_user
|
||||
from .task_action import make_move_up_down_bools
|
||||
from .. import db
|
||||
|
||||
reorderp = Blueprint(
|
||||
"reorderp", __name__, template_folder="templates"
|
||||
)
|
||||
|
||||
|
||||
@reorderp.route('/move-task/<int:taskid>')
|
||||
def move_task(taskid):
|
||||
task = Task.query.get(taskid)
|
||||
if task is None or current_user.is_anonymous or task.contributor_id != current_user.id:
|
||||
return(redirect(url_for('cats.index')))
|
||||
make_move_up_down_bools(task)
|
||||
priority = task.priority
|
||||
if request.args['move'] == 'up' and task.can_move_up:
|
||||
other_task = Task.query.filter(
|
||||
Task.catid == task.catid,
|
||||
Task.contributor_id == task.contributor_id,
|
||||
Task.done == task.done, Task.priority > task.priority).order_by(Task.priority).first()
|
||||
other_priority = other_task.priority
|
||||
other_task.priority = task.priority
|
||||
task.priority = other_priority
|
||||
if request.args['move'] == 'down' and task.can_move_down:
|
||||
other_task = Task.query.filter(
|
||||
Task.catid == task.catid,
|
||||
Task.contributor_id == task.contributor_id,
|
||||
Task.done == task.done, Task.priority < task.priority).order_by(Task.priority.desc()).first()
|
||||
other_priority = other_task.priority
|
||||
other_task.priority = task.priority
|
||||
task.priority = other_priority
|
||||
if request.args['move'] == 'top' and task.can_move_top:
|
||||
other_task = Task.query.filter(
|
||||
Task.catid == task.catid,
|
||||
Task.contributor_id == task.contributor_id,
|
||||
Task.done == task.done).order_by(Task.priority.desc()).first()
|
||||
task.priority = other_task.priority + 1
|
||||
if request.args['move'] == 'end' and task.can_move_end:
|
||||
task.priority = 0
|
||||
db.session.commit()
|
||||
if request.args['move'] == 'end' or request.args['move'] == 'top':
|
||||
reorder_priorities(task.catid, task.contributor_id, task.done, current_app.config)
|
||||
flash("task {} is moved {}".format(priority, request.args['move']))
|
||||
ru = 'tsks.{}tasks'.format('hidden_' if task.done else '')
|
||||
return(redirect(url_for(ru, category_id=task.catid)))
|
||||
|
||||
|
||||
def reorder_priorities(catid, conid, done, app_config):
|
||||
conn = psycopg2.connect(
|
||||
dbname=app_config['DATABASE_NAME'],
|
||||
user=app_config['DATABASE_USER'],
|
||||
host=app_config['DATABASE_HOST'],
|
||||
password=app_config['DATABASE_PASSWORD']
|
||||
)
|
||||
cur = conn.cursor()
|
||||
cur.execute(
|
||||
"SELECT COUNT(id) FROM task WHERE catid=%s AND contributor_id=%s AND done=%s",
|
||||
(catid, conid, done))
|
||||
if cur.fetchone()[0] > 1:
|
||||
cur.execute(
|
||||
"SELECT id FROM task WHERE catid=%s AND contributor_id=%s AND done=%s ORDER BY priority",
|
||||
(catid, conid, done))
|
||||
ids = [x[0] for x in cur.fetchall()]
|
||||
for i, task in enumerate(ids, 1):
|
||||
cur.execute("UPDATE task SET priority=%s WHERE id=%s", (i, task))
|
||||
conn.commit()
|
||||
conn.close()
|
64
app/tasks/task_action.py
Normal file
64
app/tasks/task_action.py
Normal file
@@ -0,0 +1,64 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
from flask import Blueprint, redirect, url_for, render_template
|
||||
from flask_login import current_user
|
||||
from app.models import Task
|
||||
|
||||
taskaction = Blueprint(
|
||||
"taskaction", __name__, template_folder="templates"
|
||||
)
|
||||
|
||||
|
||||
@taskaction.route('/task-action/<int:taskid>')
|
||||
def task_action(taskid):
|
||||
if current_user.is_anonymous:
|
||||
return(redirect(url_for('cats.index')))
|
||||
task = Task.query.get(taskid)
|
||||
if task.done:
|
||||
cancel_nav_link = ('cancel', url_for('tsks.hidden_tasks', category_id=task.catid))
|
||||
else:
|
||||
cancel_nav_link = ('cancel', url_for('tsks.tasks', category_id=task.catid))
|
||||
nl = (
|
||||
cancel_nav_link,
|
||||
('categories', url_for('cats.index')),
|
||||
('logout', url_for('auths.logout'))
|
||||
)
|
||||
make_move_up_down_bools(task)
|
||||
return(render_template(
|
||||
'task_action.html',
|
||||
title="Task Actions",
|
||||
navbar_links=nl,
|
||||
task=task
|
||||
))
|
||||
|
||||
|
||||
def make_move_up_down_bools(task):
|
||||
num_higher = Task.query.filter(
|
||||
Task.catid == task.catid,
|
||||
Task.contributor_id == task.contributor_id,
|
||||
Task.done == task.done,
|
||||
Task.priority > task.priority).count()
|
||||
num_lower = Task.query.filter(
|
||||
Task.catid == task.catid,
|
||||
Task.contributor_id == task.contributor_id,
|
||||
Task.done == task.done,
|
||||
Task.priority < task.priority).count()
|
||||
print(num_higher, num_lower)
|
||||
if num_higher > 1:
|
||||
task.can_move_top = True
|
||||
task.can_move_up = True
|
||||
elif num_higher == 1:
|
||||
task.can_move_top = False
|
||||
task.can_move_up = True
|
||||
else:
|
||||
task.can_move_top = False
|
||||
task.can_move_up = False
|
||||
if num_lower > 1:
|
||||
task.can_move_end = True
|
||||
task.can_move_down = True
|
||||
elif num_lower == 1:
|
||||
task.can_move_end = False
|
||||
task.can_move_down = True
|
||||
else:
|
||||
task.can_move_end = False
|
||||
task.can_move_down = False
|
72
app/tasks/tasks.py
Normal file
72
app/tasks/tasks.py
Normal file
@@ -0,0 +1,72 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
from flask import Blueprint, redirect, url_for, render_template
|
||||
from flask_login import current_user
|
||||
from app.models import Category, Task
|
||||
from markdown import markdown
|
||||
|
||||
tsks = Blueprint(
|
||||
"tsks", __name__, template_folder="templates"
|
||||
)
|
||||
|
||||
|
||||
@tsks.route("/hidden-tasks/<int:category_id>")
|
||||
def hidden_tasks(category_id):
|
||||
category = Category.query.get(category_id)
|
||||
if current_user.is_anonymous or current_user.id != category.contributor_id:
|
||||
return(redirect(url_for('cats.index')))
|
||||
|
||||
tasks = Task.query.filter_by(
|
||||
catid=category_id,
|
||||
contributor_id=current_user.id,
|
||||
done=True
|
||||
).order_by(Task.priority.desc()).all()
|
||||
|
||||
for task in tasks:
|
||||
task.markup = markdown(task.content)
|
||||
task.href = url_for('taskaction.task_action', taskid=task.id)
|
||||
task.time = task.timestamp.strftime("%Y-%m-%d %H:%M")
|
||||
|
||||
nl = (
|
||||
('new', url_for('newtask.new_task', category_id=category_id)),
|
||||
('categories', url_for('cats.index')),
|
||||
('open', url_for('tsks.tasks', category_id=category_id))
|
||||
)
|
||||
return render_template(
|
||||
'tasks.html',
|
||||
title="Completed Tasks",
|
||||
navbar_links=nl,
|
||||
tasks=tasks,
|
||||
heading="{}:completed tasks".format(category.name)
|
||||
)
|
||||
|
||||
|
||||
@tsks.route("/tasks/<int:category_id>")
|
||||
def tasks(category_id):
|
||||
category = Category.query.get(category_id)
|
||||
if current_user.is_anonymous or current_user.id != category.contributor_id:
|
||||
return(redirect(url_for('cats.index')))
|
||||
|
||||
tasks = Task.query.filter_by(
|
||||
catid=category_id,
|
||||
contributor_id=current_user.id,
|
||||
done=False
|
||||
).order_by(Task.priority.desc()).all()
|
||||
|
||||
for task in tasks:
|
||||
task.markup = markdown(task.content)
|
||||
task.href = url_for('taskaction.task_action', taskid=task.id)
|
||||
task.time = task.timestamp.strftime("%Y-%m-%d %H:%M")
|
||||
|
||||
nl = (
|
||||
('new', url_for('newtask.new_task', category_id=category_id)),
|
||||
('categories', url_for('cats.index')),
|
||||
('done', url_for('tsks.hidden_tasks', category_id=category_id))
|
||||
)
|
||||
return render_template(
|
||||
'tasks.html',
|
||||
title="Tasks",
|
||||
navbar_links=nl,
|
||||
tasks=tasks,
|
||||
heading="{}:tasks".format(category.name)
|
||||
)
|
37
app/tasks/templates/edit_task.html
Normal file
37
app/tasks/templates/edit_task.html
Normal file
@@ -0,0 +1,37 @@
|
||||
<style>
|
||||
#content {
|
||||
font-size: 1.2rem;
|
||||
width: 100%;
|
||||
}
|
||||
form {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
width: 100%;
|
||||
}
|
||||
form p {
|
||||
width: 100%;
|
||||
}
|
||||
h1 {
|
||||
align-self: center;
|
||||
margin-top: 50px;
|
||||
}
|
||||
</style>
|
||||
{% extends "base.html" %}
|
||||
|
||||
{% block content %}
|
||||
<div class="formContainer">
|
||||
<h1>Edit {{ task.content[0:10] }}</h1>
|
||||
<form action="" method="post">
|
||||
{{ form.hidden_tag() }}
|
||||
<p>
|
||||
{{ form.content.label }}<br>
|
||||
{{ form.content(rows=20) }}<br>
|
||||
{% for error in form.content.errors %}
|
||||
<span class="formWarning">[{{ error }}]</span>
|
||||
{% endfor %}
|
||||
</p>
|
||||
<p>{{ form.submit() }}</p>
|
||||
</form>
|
||||
</div>
|
||||
{% endblock %}
|
37
app/tasks/templates/new_task.html
Normal file
37
app/tasks/templates/new_task.html
Normal file
@@ -0,0 +1,37 @@
|
||||
<style>
|
||||
#content {
|
||||
font-size: 1.2rem;
|
||||
width: 100%;
|
||||
}
|
||||
form {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
width: 100%;
|
||||
}
|
||||
form p {
|
||||
width: 100%;
|
||||
}
|
||||
h1 {
|
||||
align-self: center;
|
||||
margin-top: 50px;
|
||||
}
|
||||
</style>
|
||||
{% extends "base.html" %}
|
||||
|
||||
{% block content %}
|
||||
<div class="formContainer">
|
||||
<h1>New Task For {{ category.name }}</h1>
|
||||
<form action="" method="post">
|
||||
{{ form.hidden_tag() }}
|
||||
<p>
|
||||
{{ form.content.label }}<br>
|
||||
{{ form.content(rows=20) }}<br>
|
||||
{% for error in form.content.errors %}
|
||||
<span class="formWarning">[{{ error }}]</span>
|
||||
{% endfor %}
|
||||
</p>
|
||||
<p>{{ form.submit() }}</p>
|
||||
</form>
|
||||
</div>
|
||||
{% endblock %}
|
70
app/tasks/templates/task_action.html
Normal file
70
app/tasks/templates/task_action.html
Normal file
@@ -0,0 +1,70 @@
|
||||
<style>
|
||||
#main {
|
||||
align-items: center;
|
||||
}
|
||||
.heading {
|
||||
margin-top: 40px;
|
||||
}
|
||||
.buttonLink {
|
||||
width: 95%;
|
||||
max-width: 700px;
|
||||
text-decoration: none;
|
||||
}
|
||||
.buttonLink button {
|
||||
width: 100%;
|
||||
background-color: black;
|
||||
padding-top: 10px;
|
||||
padding-bottom: 10px;
|
||||
padding-left: 20px;
|
||||
margin-bottom: 10px;
|
||||
border-radius: 9px;
|
||||
font-size: 1.3rem;
|
||||
display: flex;
|
||||
font-weight: bold;
|
||||
}
|
||||
</style>
|
||||
{% extends "base.html" %}
|
||||
|
||||
{% if task.done == True %}
|
||||
{% set textColor = "color: grey;" %}
|
||||
{% else %}
|
||||
{% set textColor = "color: white;" %}
|
||||
{% endif %}
|
||||
|
||||
{% block content %}
|
||||
<h1 class="heading">Actions For {{ task.content[0:10] }}...</h1>
|
||||
<a href="{{ url_for('toggletaskdone.toggle_task_done', taskid=task.id) }}" class="buttonLink">
|
||||
<button style="{{ textColor }}">
|
||||
{% if task.done == True %} UnMark Done {% else %} Mark Done {% endif %}
|
||||
</button>
|
||||
</a>
|
||||
<a href="{{ url_for('edittask.edit_task', taskid=task.id) }}" class="buttonLink">
|
||||
<button style="{{ textColor }}">Edit</button>
|
||||
</a>
|
||||
<a href="{{ url_for('deletetask.delete_task', taskid=task.id) }}" class="buttonLink">
|
||||
<button style="{{ textColor }}">Delete</button>
|
||||
</a>
|
||||
<a href="{{ url_for('cats.move_categories', taskid=task.id) }}" class="buttonLink">
|
||||
<button style="{{ textColor }}">Move-Category</button>
|
||||
</a>
|
||||
{% if task.can_move_top == True %}
|
||||
<a href="{{ url_for('reorderp.move_task', taskid=task.id, move='top') }}" class="buttonLink">
|
||||
<button style="{{ textColor }}">Move-Top</button>
|
||||
</a>
|
||||
{% endif %}
|
||||
{% if task.can_move_up == True %}
|
||||
<a href="{{ url_for('reorderp.move_task', taskid=task.id, move='up') }}" class="buttonLink">
|
||||
<button style="{{ textColor }}">Move-Up</button>
|
||||
</a>
|
||||
{% endif %}
|
||||
{% if task.can_move_down == True %}
|
||||
<a href="{{ url_for('reorderp.move_task', taskid=task.id, move='down') }}" class="buttonLink">
|
||||
<button style="{{ textColor }}">Move-Down</button>
|
||||
</a>
|
||||
{% endif %}
|
||||
{% if task.can_move_end == True %}
|
||||
<a href="{{ url_for('reorderp.move_task', taskid=task.id, move='end') }}" class="buttonLink">
|
||||
<button style="{{ textColor }}">Move-End</button>
|
||||
</a>
|
||||
{% endif %}
|
||||
{% endblock %}
|
58
app/tasks/templates/tasks.html
Normal file
58
app/tasks/templates/tasks.html
Normal file
@@ -0,0 +1,58 @@
|
||||
<style>
|
||||
#main {
|
||||
align-items: center;
|
||||
}
|
||||
.heading {
|
||||
margin-top: 40px;
|
||||
font-size: 2.3rem;
|
||||
}
|
||||
.taskContainer {
|
||||
width: 99%;
|
||||
max-width: 600px;
|
||||
margin-bottom: 10px;
|
||||
border-radius: 9px;
|
||||
font-size: 1.3rem;
|
||||
font-weight: bold;
|
||||
border: 1px solid;
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
}
|
||||
.task {
|
||||
padding-left: 20px;
|
||||
padding-right: 20px;
|
||||
max-width: calc(100% - 70px);
|
||||
word-wrap: break-word;
|
||||
}
|
||||
.taskAction {
|
||||
background-color: black;
|
||||
height: 100%;
|
||||
border-top-right-radius: 9px;
|
||||
border-bottom-right-radius: 9px;
|
||||
width: 30px;
|
||||
}
|
||||
.taskActionLink {
|
||||
text-decoration: none;
|
||||
}
|
||||
</style>
|
||||
{% extends "base.html" %}
|
||||
|
||||
{% block content %}
|
||||
<h1 class="heading">{{ heading }}</h1>
|
||||
{% for task in tasks %}
|
||||
{% if task.done == True %}
|
||||
{% set textColor = "color: grey;" %}
|
||||
{% else %}
|
||||
{% set textColor = "color: black;" %}
|
||||
{% endif %}
|
||||
<div class="taskContainer">
|
||||
|
||||
<div class="task" style="{{ textColor }}">
|
||||
<p>{{ task.time }}</p> {{ task.markup|safe }}
|
||||
</div>
|
||||
|
||||
<a href="{{ task.href }}" class="taskActionLink">
|
||||
<button class="taskAction" style="color: white;">{{ task.priority }}</button>
|
||||
</a>
|
||||
</div>
|
||||
{% endfor %}
|
||||
{% endblock %}
|
Reference in New Issue
Block a user