mirror of
https://github.com/peter-tanner/money-manager.git
synced 2024-11-30 14:20:17 +08:00
add log categories and fix notifications
This commit is contained in:
parent
a6e7d0a970
commit
c076e1b963
|
@ -9,6 +9,7 @@ from .models import (
|
||||||
Log,
|
Log,
|
||||||
Expense,
|
Expense,
|
||||||
ExpenseCategory,
|
ExpenseCategory,
|
||||||
|
LogCategory,
|
||||||
Timesheet,
|
Timesheet,
|
||||||
TimesheetRate,
|
TimesheetRate,
|
||||||
Todo,
|
Todo,
|
||||||
|
@ -91,6 +92,7 @@ class LogsAdmin(AdminBase):
|
||||||
"truncated_title",
|
"truncated_title",
|
||||||
"date",
|
"date",
|
||||||
"goodness_value",
|
"goodness_value",
|
||||||
|
"category",
|
||||||
)
|
)
|
||||||
list_display_links = (
|
list_display_links = (
|
||||||
"title",
|
"title",
|
||||||
|
@ -99,6 +101,11 @@ class LogsAdmin(AdminBase):
|
||||||
search_fields = (
|
search_fields = (
|
||||||
"title",
|
"title",
|
||||||
"date",
|
"date",
|
||||||
|
"category",
|
||||||
|
)
|
||||||
|
list_filter = (
|
||||||
|
"date",
|
||||||
|
# "category",
|
||||||
)
|
)
|
||||||
form = LogsAdminForm
|
form = LogsAdminForm
|
||||||
|
|
||||||
|
@ -352,4 +359,20 @@ class ExpenseAdmin(AdminBase, AdminChartMixin, ImportExportModelAdmin):
|
||||||
|
|
||||||
@admin.register(ExpenseCategory)
|
@admin.register(ExpenseCategory)
|
||||||
class ExpenseCategoryAdmin(AdminBase):
|
class ExpenseCategoryAdmin(AdminBase):
|
||||||
search_fields = ("name",)
|
list_display = (
|
||||||
|
"name",
|
||||||
|
"description",
|
||||||
|
)
|
||||||
|
search_fields = list_display
|
||||||
|
|
||||||
|
|
||||||
|
@admin.register(LogCategory)
|
||||||
|
class LogCategoryAdmin(AdminBase):
|
||||||
|
list_display = (
|
||||||
|
"name",
|
||||||
|
"description",
|
||||||
|
)
|
||||||
|
search_fields = list_display
|
||||||
|
|
||||||
|
class Media:
|
||||||
|
css = {"all": ("/static/logs.css",)}
|
||||||
|
|
|
@ -0,0 +1,60 @@
|
||||||
|
# Generated by Django 4.2.5 on 2023-10-08 14:39
|
||||||
|
|
||||||
|
from django.conf import settings
|
||||||
|
from django.db import migrations, models
|
||||||
|
import django.db.models.deletion
|
||||||
|
import simple_history.models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
|
||||||
|
('expenses', '0010_todo_historicaltodo'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.CreateModel(
|
||||||
|
name='LogCategory',
|
||||||
|
fields=[
|
||||||
|
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||||
|
('deleted', models.BooleanField(default=False)),
|
||||||
|
('name', models.CharField(blank=True, max_length=256)),
|
||||||
|
('description', models.TextField(blank=True)),
|
||||||
|
],
|
||||||
|
options={
|
||||||
|
'abstract': False,
|
||||||
|
},
|
||||||
|
),
|
||||||
|
migrations.CreateModel(
|
||||||
|
name='HistoricalLogCategory',
|
||||||
|
fields=[
|
||||||
|
('id', models.BigIntegerField(auto_created=True, blank=True, db_index=True, verbose_name='ID')),
|
||||||
|
('deleted', models.BooleanField(default=False)),
|
||||||
|
('name', models.CharField(blank=True, max_length=256)),
|
||||||
|
('description', models.TextField(blank=True)),
|
||||||
|
('history_id', models.AutoField(primary_key=True, serialize=False)),
|
||||||
|
('history_date', models.DateTimeField(db_index=True)),
|
||||||
|
('history_change_reason', models.CharField(max_length=100, null=True)),
|
||||||
|
('history_type', models.CharField(choices=[('+', 'Created'), ('~', 'Changed'), ('-', 'Deleted')], max_length=1)),
|
||||||
|
('history_user', models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='+', to=settings.AUTH_USER_MODEL)),
|
||||||
|
],
|
||||||
|
options={
|
||||||
|
'verbose_name': 'historical log category',
|
||||||
|
'verbose_name_plural': 'historical log categorys',
|
||||||
|
'ordering': ('-history_date', '-history_id'),
|
||||||
|
'get_latest_by': ('history_date', 'history_id'),
|
||||||
|
},
|
||||||
|
bases=(simple_history.models.HistoricalChanges, models.Model),
|
||||||
|
),
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='historicallog',
|
||||||
|
name='category',
|
||||||
|
field=models.ForeignKey(blank=True, db_constraint=False, null=True, on_delete=django.db.models.deletion.DO_NOTHING, related_name='+', to='expenses.logcategory'),
|
||||||
|
),
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='log',
|
||||||
|
name='category',
|
||||||
|
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='logs', to='expenses.logcategory'),
|
||||||
|
),
|
||||||
|
]
|
|
@ -41,6 +41,14 @@ class Todo(DeletableModel):
|
||||||
return f"{self.title} [{self.due_date}]"
|
return f"{self.title} [{self.due_date}]"
|
||||||
|
|
||||||
|
|
||||||
|
class LogCategory(DeletableModel):
|
||||||
|
name = models.CharField(max_length=256, blank=True)
|
||||||
|
description = models.TextField(blank=True)
|
||||||
|
|
||||||
|
def __str__(self):
|
||||||
|
return truncate_string(self.name, 48)
|
||||||
|
|
||||||
|
|
||||||
class Log(DeletableModel):
|
class Log(DeletableModel):
|
||||||
# TODO: Use Markdown formatting!
|
# TODO: Use Markdown formatting!
|
||||||
title = models.CharField(max_length=256, blank=True)
|
title = models.CharField(max_length=256, blank=True)
|
||||||
|
@ -53,6 +61,13 @@ class Log(DeletableModel):
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
information = models.TextField(blank=True)
|
information = models.TextField(blank=True)
|
||||||
|
category = models.ForeignKey(
|
||||||
|
LogCategory,
|
||||||
|
on_delete=models.SET_NULL,
|
||||||
|
null=True,
|
||||||
|
blank=True,
|
||||||
|
related_name="logs",
|
||||||
|
)
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return f"{self.date}: {self.title}"
|
return f"{self.date}: {self.title}"
|
||||||
|
|
|
@ -63,7 +63,9 @@ function parseDateString(dateString) {
|
||||||
}
|
}
|
||||||
|
|
||||||
const alerted = new Set();
|
const alerted = new Set();
|
||||||
const deletedParam = urlParams.get("deleted__exact");
|
const url = new URL(window.location.href);
|
||||||
|
const urlParams = new URLSearchParams(url.search);
|
||||||
|
const deletedParam = urlParams.get("deleted__exact") || false;
|
||||||
|
|
||||||
// DO NOT NOTIFY FOR DELETED ITEMS
|
// DO NOT NOTIFY FOR DELETED ITEMS
|
||||||
if (deletedParam !== "1") {
|
if (deletedParam !== "1") {
|
||||||
|
|
|
@ -1,11 +1,10 @@
|
||||||
/* Hide title of log when mouse is not hovering over it for privacy */
|
/* Hide title of log when mouse is not hovering over it for privacy */
|
||||||
.field-title:not(:hover) > a {
|
.field-title:not(:hover) > a,
|
||||||
color: transparent;
|
.field-goodness_value:not(:hover),
|
||||||
text-decoration: none;
|
.field-name:not(:hover) > a,
|
||||||
cursor: pointer;
|
.field-category:not(:hover),
|
||||||
}
|
.field-description:not(:hover) {
|
||||||
|
transition: none;
|
||||||
.field-goodness_value:not(:hover) {
|
|
||||||
color: transparent;
|
color: transparent;
|
||||||
text-decoration: none;
|
text-decoration: none;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user