Use markdown for task notes, also add markdown task description

This commit is contained in:
Adam Goldsmith 2020-12-22 15:15:43 -05:00
parent 06e493ea19
commit 86fe80b375
9 changed files with 145 additions and 6 deletions

View File

@ -8,6 +8,8 @@ python-dateutil = "*"
django = "*"
django-widget-tweaks = "*"
django-auth-ldap = "*"
django-markdownx = "*"
django-markdownify = "*"
[dev-packages]

91
Pipfile.lock generated
View File

@ -1,7 +1,7 @@
{
"_meta": {
"hash": {
"sha256": "1e48e365c2c728401d312d756e9d5075ca07a78c9264d08155ea6589edfef0e4"
"sha256": "cfcee52e11d5622d49f83f1195e0de50ee5c8508cd57d328d315f2a29142957d"
},
"pipfile-spec": 6,
"requires": {
@ -24,6 +24,14 @@
"markers": "python_version >= '3.5'",
"version": "==3.3.1"
},
"bleach": {
"hashes": [
"sha256:52b5919b81842b1854196eaae5ca29679a2f2e378905c346d3ca8227c2c66080",
"sha256:9f8ccbeb6183c6e6cddea37592dfb0167485c1e3b13b3363bc325aa8bda3adbd"
],
"markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3, 3.4'",
"version": "==3.2.1"
},
"django": {
"hashes": [
"sha256:5c866205f15e7a7123f1eec6ab939d22d5bde1416635cab259684af66d8e48a2",
@ -40,6 +48,22 @@
"index": "pypi",
"version": "==2.2.0"
},
"django-markdownify": {
"hashes": [
"sha256:5460fc41db2da02c57e2f49f55258aa71a74af48c21b7989985b0a860069a954",
"sha256:c9406e1187c68f2ad9e251bf7b586dd4c9309021fafce2c83be99584cb130173"
],
"index": "pypi",
"version": "==0.8.1"
},
"django-markdownx": {
"hashes": [
"sha256:e18e395cad0ade96afbb250a81cad15618e417ac3c0d9c37d964be3d8fd57bcf",
"sha256:f4d8998618c0548bf5349713d805e7440684d70116de0f10413932286c4e375f"
],
"index": "pypi",
"version": "==3.0.1"
},
"django-widget-tweaks": {
"hashes": [
"sha256:9f91ca4217199b7671971d3c1f323a2bec71a0c27dec6260b3c006fa541bc489",
@ -48,6 +72,56 @@
"index": "pypi",
"version": "==1.4.8"
},
"markdown": {
"hashes": [
"sha256:5d9f2b5ca24bc4c7a390d22323ca4bad200368612b5aaa7796babf971d2b2f18",
"sha256:c109c15b7dc20a9ac454c9e6025927d44460b85bd039da028d85e2b6d0bcc328"
],
"markers": "python_version >= '3.6'",
"version": "==3.3.3"
},
"packaging": {
"hashes": [
"sha256:24e0da08660a87484d1602c30bb4902d74816b6985b93de36926f5bc95741858",
"sha256:78598185a7008a470d64526a8059de9aaa449238f280fc9eb6b13ba6c4109093"
],
"markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3'",
"version": "==20.8"
},
"pillow": {
"hashes": [
"sha256:006de60d7580d81f4a1a7e9f0173dc90a932e3905cc4d47ea909bc946302311a",
"sha256:0a2e8d03787ec7ad71dc18aec9367c946ef8ef50e1e78c71f743bc3a770f9fae",
"sha256:0eeeae397e5a79dc088d8297a4c2c6f901f8fb30db47795113a4a605d0f1e5ce",
"sha256:11c5c6e9b02c9dac08af04f093eb5a2f84857df70a7d4a6a6ad461aca803fb9e",
"sha256:2fb113757a369a6cdb189f8df3226e995acfed0a8919a72416626af1a0a71140",
"sha256:4b0ef2470c4979e345e4e0cc1bbac65fda11d0d7b789dbac035e4c6ce3f98adb",
"sha256:59e903ca800c8cfd1ebe482349ec7c35687b95e98cefae213e271c8c7fffa021",
"sha256:5abd653a23c35d980b332bc0431d39663b1709d64142e3652890df4c9b6970f6",
"sha256:5f9403af9c790cc18411ea398a6950ee2def2a830ad0cfe6dc9122e6d528b302",
"sha256:6b4a8fd632b4ebee28282a9fef4c341835a1aa8671e2770b6f89adc8e8c2703c",
"sha256:6c1aca8231625115104a06e4389fcd9ec88f0c9befbabd80dc206c35561be271",
"sha256:795e91a60f291e75de2e20e6bdd67770f793c8605b553cb6e4387ce0cb302e09",
"sha256:7ba0ba61252ab23052e642abdb17fd08fdcfdbbf3b74c969a30c58ac1ade7cd3",
"sha256:7c9401e68730d6c4245b8e361d3d13e1035cbc94db86b49dc7da8bec235d0015",
"sha256:81f812d8f5e8a09b246515fac141e9d10113229bc33ea073fec11403b016bcf3",
"sha256:895d54c0ddc78a478c80f9c438579ac15f3e27bf442c2a9aa74d41d0e4d12544",
"sha256:8de332053707c80963b589b22f8e0229f1be1f3ca862a932c1bcd48dafb18dd8",
"sha256:92c882b70a40c79de9f5294dc99390671e07fc0b0113d472cbea3fde15db1792",
"sha256:95edb1ed513e68bddc2aee3de66ceaf743590bf16c023fb9977adc4be15bd3f0",
"sha256:b63d4ff734263ae4ce6593798bcfee6dbfb00523c82753a3a03cbc05555a9cc3",
"sha256:bd7bf289e05470b1bc74889d1466d9ad4a56d201f24397557b6f65c24a6844b8",
"sha256:cc3ea6b23954da84dbee8025c616040d9aa5eaf34ea6895a0a762ee9d3e12e11",
"sha256:cc9ec588c6ef3a1325fa032ec14d97b7309db493782ea8c304666fb10c3bd9a7",
"sha256:d3d07c86d4efa1facdf32aa878bd508c0dc4f87c48125cc16b937baa4e5b5e11",
"sha256:d8a96747df78cda35980905bf26e72960cba6d355ace4780d4bdde3b217cdf1e",
"sha256:e38d58d9138ef972fceb7aeec4be02e3f01d383723965bfcef14d174c8ccd039",
"sha256:eb472586374dc66b31e36e14720747595c2b265ae962987261f044e5cce644b5",
"sha256:fbd922f702582cb0d71ef94442bfca57624352622d75e3be7a1e7e9360b07e72"
],
"markers": "python_version >= '3.6'",
"version": "==8.0.1"
},
"pyasn1": {
"hashes": [
"sha256:014c0e9976956a08139dc0712ae195324a75e142284d5f87f1a87ee1b068a359",
@ -84,6 +158,14 @@
],
"version": "==0.2.8"
},
"pyparsing": {
"hashes": [
"sha256:c203ec8783bf771a155b207279b9bccb8dea02d8f0c9e5f8ead507bc3246ecc1",
"sha256:ef9d7589ef3c200abe66653d3f1ab1033c3c419ae9b9bdb1240a85b024efc88b"
],
"markers": "python_version >= '2.6' and python_version not in '3.0, 3.1, 3.2, 3.3'",
"version": "==2.4.7"
},
"python-dateutil": {
"hashes": [
"sha256:73ebfe9dbf22e832286dafa60473e4cd239f8592f699aa5adaf10050e6e1823c",
@ -121,6 +203,13 @@
],
"markers": "python_version >= '3.5'",
"version": "==0.4.1"
},
"webencodings": {
"hashes": [
"sha256:a0af1213f3c2226497a97e2b3aa01a7e4bee4f403f95be16fc9acd2947514a78",
"sha256:b36a1c245f2d304965eb4e0a82848379241dc04b865afcc4aab16748587e1923"
],
"version": "==0.5.1"
}
},
"develop": {}

View File

@ -24,6 +24,8 @@ ALLOWED_HOSTS = []
INSTALLED_APPS = [
'tasks.apps.TasksConfig',
'widget_tweaks',
'markdownx',
'markdownify',
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',

View File

@ -29,5 +29,6 @@ urlpatterns = [
template_name="auth/login.djhtml",
redirect_authenticated_user=True), name='login'),
path('logout/', LogoutView.as_view(template_name="auth/logout.djhtml"), name='logout'),
]))
])),
path('markdownx/', include('markdownx.urls')),
]

View File

@ -1,4 +1,5 @@
from django.contrib import admin
from markdownx.admin import MarkdownxModelAdmin
from .models import Tool, Task, Event, GroupTaskSubscription, GroupToolSubscription
@ -6,7 +7,7 @@ admin.site.register(Tool)
@admin.register(Task)
class TaskAdmin(admin.ModelAdmin):
class TaskAdmin(MarkdownxModelAdmin):
prepopulated_fields = {"slug": ("name",)}

View File

@ -0,0 +1,19 @@
# Generated by Django 3.1.4 on 2020-12-22 19:17
from django.db import migrations
import markdownx.models
class Migration(migrations.Migration):
dependencies = [
('tasks', '0002_grouptasksubscription_grouptoolsubscription'),
]
operations = [
migrations.AlterField(
model_name='event',
name='notes',
field=markdownx.models.MarkdownxField(blank=True),
),
]

View File

@ -0,0 +1,19 @@
# Generated by Django 3.1.4 on 2020-12-22 19:37
from django.db import migrations
import markdownx.models
class Migration(migrations.Migration):
dependencies = [
('tasks', '0003_auto_20201222_1417'),
]
operations = [
migrations.AddField(
model_name='task',
name='description',
field=markdownx.models.MarkdownxField(blank=True),
),
]

View File

@ -5,7 +5,7 @@ from django.contrib.auth import get_user_model
from django.contrib.auth.models import Group
from django.db import models
from django.urls import reverse
from markdownx.models import MarkdownxField
class Tool(models.Model):
name = models.CharField(max_length=200)
@ -22,6 +22,7 @@ class Task(models.Model):
name = models.CharField(max_length=200)
slug = models.SlugField(primary_key=True)
tool = models.ForeignKey(Tool, on_delete=models.CASCADE)
description = MarkdownxField(blank=True)
recurrence_interval = models.CharField(max_length=200)
recurrence_base = models.DateField(null=True, blank=True)
@ -112,7 +113,7 @@ class Event(models.Model):
task = models.ForeignKey(Task, on_delete=models.CASCADE)
user = models.ForeignKey(get_user_model(), on_delete=models.CASCADE)
date = models.DateField()
notes = models.TextField(blank=True)
notes = MarkdownxField(blank=True)
def __str__(self):
return f"{self.task}: {self.user} {self.date}"

View File

@ -1,5 +1,6 @@
{% extends "base.djhtml" %}
{% load markdownify %}
{% load widget_tweaks %}
{% block title %} {{ tool.name }} - {{ task.name }} | RecMaint {% endblock %}
@ -20,6 +21,8 @@
</div>
{% endif %}
{{ task.description|markdownify }}
{% if form.errors %}
<div class="alert alert-warning">
<h3> Error: </h3>
@ -45,6 +48,8 @@
</fieldset>
<input type="submit" class="btn btn-primary" value="Submit">
</form>
{{ form.media }}
</div>
<h2> Event Log </h2>
@ -70,7 +75,7 @@
<tr>
<td class="text-nowrap"> {{ event.date }} </td>
<td> {{ event.user }} </td>
<td> {{ event.notes }} </td>
<td> {{ event.notes|markdownify }} </td>
</tr>
{% endfor %}
</tbody>