Skip to content
This repository has been archived by the owner on Dec 7, 2022. It is now read-only.

Commit

Permalink
once more update to-do app
Browse files Browse the repository at this point in the history
  • Loading branch information
jackshendrikov committed Feb 6, 2021
1 parent 5076402 commit 68e34ec
Show file tree
Hide file tree
Showing 12 changed files with 121 additions and 82 deletions.
2 changes: 1 addition & 1 deletion staticfiles/staticfiles.json

Large diffs are not rendered by default.

44 changes: 28 additions & 16 deletions staticfiles/todo/css/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -671,14 +671,24 @@ body.light-mode:before {
margin-right: 8px;
}

.apps-card {
.items {
display: flex;
align-items: center;
flex-wrap: wrap;
width: calc(100% + 20px);
}

.app-card {
.card {
display: flex;
font-size: 16px;
background-color: var(--content-bg);
border-radius: 14px;
border: 1px solid var(--theme-bg-color);
padding: 20px;
transition: 0.3s ease;
margin: 0 20px 0 20px;
}
.item {
display: flex;
flex-direction: column;
width: calc(30.3% - 20px);
Expand All @@ -691,55 +701,57 @@ body.light-mode:before {
transition: 0.3s ease;
margin: 0 14px 0 38px;
}
.app-card:hover {
.item:hover {
transform: scale(1.02);
background-color: var(--theme-bg-color);
}
.app-card svg {
.item svg {
width: 28px;
border-radius: 6px;
margin-right: 12px;
flex-shrink: 0;
}
.app-card + .app-card {
.item + .item {
margin-left: 20px;
}
.app-card span {
.item span {
display: flex;
align-items: center;
}
.app-card__subtext {
font-size: 14px;
font-weight: 400;
.item-text {
font-size: 20px;
line-height: 1.6em;
margin-top: 20px;
text-align: center;
border-bottom: 1px solid var(--border-color);
padding-bottom: 20px;
padding-bottom: 15px;
}
.app-card-buttons {
.item-button {
display: flex;
align-items: center;
margin-left: auto;
margin-top: 16px;
}
@media screen and (max-width: 1110px) {
.app-card {
.item {
width: calc(50% - 20px);
margin: 14px 0 14px 0;
}
.app-card:last-child {
.item:last-child {
margin-top: 20px;
margin-left: 0;
}
}
@media screen and (max-width: 565px) {
.app-card {
.item {
width: calc(100% - 20px);
margin-top: 20px;
}
.app-card + .app-card {
.item + .item {
margin-left: 0;
}
.card {
margin: 0;
}
}

::-webkit-scrollbar {
Expand Down
Binary file modified staticfiles/todo/css/style.css.gz
Binary file not shown.
2 changes: 2 additions & 0 deletions staticfiles/todo/csv/csv_example.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Title,Group,Task List,Created By,Created Date,Due Date,Completed,Assigned To,Note,Priority
Write some AI,Whispering Vision,Entertainment,guest,,2020-08-27,No,,Maybe text to image?,1
Binary file added staticfiles/todo/csv/csv_example.csv.gz
Binary file not shown.
14 changes: 7 additions & 7 deletions todo/operations/csv_importer.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ def validate_row(self, row):

creator = get_user_model().objects.filter(username=row.get("Created By")).first()
if not creator:
msg = f"Invalid task creator {row.get('Created By')}"
msg = f"Invalid task creator \"{row.get('Created By')}\""
row_errors.append(msg)

# #######################
Expand All @@ -124,28 +124,28 @@ def validate_row(self, row):
if assigned.exists():
assignee = assigned.first()
else:
msg = f"Missing or invalid task assignee {row.get('Assigned To')}"
msg = f"Missing or invalid task assignee \"{row.get('Assigned To')}\""
row_errors.append(msg)

# #######################
# Group must exist
try:
target_group = Group.objects.get(name=row.get("Group"))
except Group.DoesNotExist:
msg = f"Could not find group {row.get('Group')}."
msg = f"Could not find group \"{row.get('Group')}\""
row_errors.append(msg)
target_group = None

# #######################
# Task creator must be in the target group
if creator and target_group not in creator.groups.all():
msg = f"{creator} is not in group {target_group}"
msg = f"{creator} is not in group \"{target_group}\""
row_errors.append(msg)

# #######################
# Assignee must be in the target group
if assignee and target_group not in assignee.groups.all():
msg = f"{assignee} is not in group {target_group}"
msg = f"{assignee} is not in group \"{target_group}\""
row_errors.append(msg)

# #######################
Expand All @@ -154,7 +154,7 @@ def validate_row(self, row):
tasklist = TaskList.objects.get(name=row.get("Task List"), group=target_group)
row["Task List"] = tasklist
except TaskList.DoesNotExist:
msg = f"Task list {row.get('Task List')} in group {target_group} does not exist"
msg = f"Task list \"{row.get('Task List')}\" in group \"{target_group}\" does not exist"
row_errors.append(msg)

# #######################
Expand All @@ -167,7 +167,7 @@ def validate_row(self, row):
if valid_date:
row[datefield] = valid_date
else:
msg = f"Could not convert {datefield} {datestring} to valid date instance"
msg = f"Could not convert \"{datefield} {datestring}\" to valid date instance"
row_errors.append(msg)

# #######################
Expand Down
44 changes: 28 additions & 16 deletions todo/static/todo/css/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -671,14 +671,24 @@ body.light-mode:before {
margin-right: 8px;
}

.apps-card {
.items {
display: flex;
align-items: center;
flex-wrap: wrap;
width: calc(100% + 20px);
}

.app-card {
.card {
display: flex;
font-size: 16px;
background-color: var(--content-bg);
border-radius: 14px;
border: 1px solid var(--theme-bg-color);
padding: 20px;
transition: 0.3s ease;
margin: 0 20px 0 20px;
}
.item {
display: flex;
flex-direction: column;
width: calc(30.3% - 20px);
Expand All @@ -691,55 +701,57 @@ body.light-mode:before {
transition: 0.3s ease;
margin: 0 14px 0 38px;
}
.app-card:hover {
.item:hover {
transform: scale(1.02);
background-color: var(--theme-bg-color);
}
.app-card svg {
.item svg {
width: 28px;
border-radius: 6px;
margin-right: 12px;
flex-shrink: 0;
}
.app-card + .app-card {
.item + .item {
margin-left: 20px;
}
.app-card span {
.item span {
display: flex;
align-items: center;
}
.app-card__subtext {
font-size: 14px;
font-weight: 400;
.item-text {
font-size: 20px;
line-height: 1.6em;
margin-top: 20px;
text-align: center;
border-bottom: 1px solid var(--border-color);
padding-bottom: 20px;
padding-bottom: 15px;
}
.app-card-buttons {
.item-button {
display: flex;
align-items: center;
margin-left: auto;
margin-top: 16px;
}
@media screen and (max-width: 1110px) {
.app-card {
.item {
width: calc(50% - 20px);
margin: 14px 0 14px 0;
}
.app-card:last-child {
.item:last-child {
margin-top: 20px;
margin-left: 0;
}
}
@media screen and (max-width: 565px) {
.app-card {
.item {
width: calc(100% - 20px);
margin-top: 20px;
}
.app-card + .app-card {
.item + .item {
margin-left: 0;
}
.card {
margin: 0;
}
}

::-webkit-scrollbar {
Expand Down
2 changes: 2 additions & 0 deletions todo/static/todo/csv/csv_example.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Title,Group,Task List,Created By,Created Date,Due Date,Completed,Assigned To,Note,Priority
Write some AI,Whispering Vision,Entertainment,guest,,2020-08-27,No,,Maybe text to image?,1
1 change: 1 addition & 0 deletions todo/templates/todo/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
<link rel="icon" href="{% static 'home/ico/logo.ico' %}" type="image/x-icon">

<!-- Bootstrap core CSS -->
<link rel='stylesheet' href='https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css'>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" integrity="sha384-B0vP5xmATw1+K9KRQjQERJvTumQW0nPEzvF6L/Z6nronJ3oUOFUFpCjEUQouq2+l" crossorigin="anonymous">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/normalize/5.0.0/normalize.min.css">

Expand Down
48 changes: 25 additions & 23 deletions todo/templates/todo/import_csv.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,66 +5,68 @@
{% block content %}
<div class="content-section-main-title" style="margin-bottom: 14px; font-size: 24px;">Import CSV</div>

<p style="text-align: center">Here you can upload a specifically-formatted CSV. All problems will be reported here.
<p style="text-align: center; color: var(--content-title-color);">Here you can upload a specifically-formatted CSV. All problems will be reported here.
</p>

{% if results %}
<div class="card mb-4">
<div class="card-header">
<div class="item-text" style="color: var(--theme-color);">
Results of CSV upload
</div>

<div class="card-body">

{% if results.summaries %}
<p><b>Summary:</b></p>
<p style="margin: 15px 0 15px 30px; font-size: 16px;"><b>Summary:</b></p>
<ul>
{% for line in results.summaries %}
<li>{{ line }}</li>
<li style="font-size: 14px; color: var(--content-title-color); cursor: default;">{{ line }}</li>
{% endfor %}
</ul>
{% endif %}

{% if results.upserts %}
<p><b>Upserts (tasks created or updated):</b></p>
<p style="margin: 25px 0 15px 30px; font-size: 16px;"><b>Upserts (tasks created or updated):</b></p>
<ul>
{% for line in results.upserts %}
<li>{{ line }}</li>
<li style="font-size: 14px; color: var(--content-title-color); cursor: default;">{{ line }}</li>
{% endfor %}
</ul>
{% endif %}

{% if results.errors %}
<p><b>Errors (tasks NOT created or updated):</b></p>
<ul>
{% for error_row in results.errors %}
{% for k, error_list in error_row.items %}
<li>CSV row {{ k }}</li>
<ul>
{% for err in error_list %}
<li>{{ err }}</li>
{% endfor %}
</ul>
{% endfor %}
<p style="margin: 25px 0 15px 30px; font-size: 16px;"><b>Errors (tasks NOT created or updated):</b></p>
{% for error_row in results.errors %}
{% for k, error_list in error_row.items %}
<p style="font-size: 14px; text-align: center;">Errors at CSV row {{ k }}:</p>
<ul>
{% for err in error_list %}
<li style="font-size: 14px; color: var(--content-title-color); cursor: default;">{{ err }}</li>
{% endfor %}
</ul>
{% endfor %}
</ul>
{% endfor %}
{% endif %}
</div>

</div>
{% endif %}

<div class="card">
<div class="card-header" style="color: #2C2C2C;">
<div class="item-text" style="color: var(--theme-color); font-size: 20px;">
Upload Tasks
</div>

<div class="card-body">
<form method="post" enctype="multipart/form-data">
{% csrf_token %}
<div style="color: #2C2C2C;">
<input type="file" name="csvfile" accept="text/csv">
<div style="color: var(--content-title-color);">
<input type="file" class="form-control" name="csvfile" accept="text/csv" style="height: 100%;">
</div>
<button type="submit" class="btn btn-primary mt-4" style="width: 150px;">Upload</button>
</form>
</div>
</div>

<form method="get" style="text-align: center;" action="{% static 'todo/csv/csv_example.csv' %}">
<button type="submit" class="btn btn-success mt-4" style="width: 250px;">Download Example &nbsp;<i class="fa fa-download"></i></button>
</form>
{% endblock %}
12 changes: 10 additions & 2 deletions todo/templates/todo/list_detail.html
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
<th>Owner</th>
<th>Assigned</th>
<th>Mark</th>
<th>Delete</th>
</tr>

{% for task in tasks %}
Expand All @@ -38,11 +39,11 @@
<a href="{% url 'todo:task_detail' task.id %}">{{ task.title|truncatewords:10 }}</a>
</td>

<td>{{ task.created_date|date:"m/d/Y" }}</td>
<td>{{ task.created_date|date:"d/m/Y" }}</td>

<td>
<span {% if task.overdue_status %}class="overdue"{% endif %}>
{{ task.due_date|date:"m/d/Y" }}
{{ task.due_date|date:"d/m/Y" }}
</span>
</td>

Expand All @@ -62,6 +63,13 @@
</button>
</form>
</td>

<td>
<form method="post" action="{% url "todo:delete_task" task.id %}" role="form">
{% csrf_token %}
<input type="submit" value="X" class="btn btn-danger btn-sm" name="submit_delete" style="width: 40px; font-size: 14px;">
</form>
</td>
</tr>
{% endfor %}
</table>
Expand Down
Loading

0 comments on commit 68e34ec

Please sign in to comment.