mirror of https://github.com/snachodog/mybuddy.git
Add tags to most things except: Timers and Children
This commit is contained in:
parent
33005b930e
commit
ce21f39ec7
|
@ -6,7 +6,6 @@ from django.utils import timezone
|
|||
from django.utils.translation import gettext as _
|
||||
|
||||
from core import models
|
||||
from core.widgets import TagsEditor
|
||||
|
||||
|
||||
def set_initial_values(kwargs, form_type):
|
||||
|
@ -128,7 +127,7 @@ class ChildDeleteForm(forms.ModelForm):
|
|||
class DiaperChangeForm(CoreModelForm):
|
||||
class Meta:
|
||||
model = models.DiaperChange
|
||||
fields = ["child", "time", "wet", "solid", "color", "amount", "notes"]
|
||||
fields = ["child", "time", "wet", "solid", "color", "amount", "notes", "tags"]
|
||||
widgets = {
|
||||
"time": forms.DateTimeInput(
|
||||
attrs={
|
||||
|
@ -143,7 +142,7 @@ class DiaperChangeForm(CoreModelForm):
|
|||
class FeedingForm(CoreModelForm):
|
||||
class Meta:
|
||||
model = models.Feeding
|
||||
fields = ["child", "start", "end", "type", "method", "amount", "notes"]
|
||||
fields = ["child", "start", "end", "type", "method", "amount", "notes", "tags"]
|
||||
widgets = {
|
||||
"start": forms.DateTimeInput(
|
||||
attrs={
|
||||
|
@ -172,14 +171,13 @@ class NoteForm(CoreModelForm):
|
|||
"data-target": "#datetimepicker_time",
|
||||
}
|
||||
),
|
||||
"tags": TagsEditor(),
|
||||
}
|
||||
|
||||
|
||||
class SleepForm(CoreModelForm):
|
||||
class Meta:
|
||||
model = models.Sleep
|
||||
fields = ["child", "start", "end", "notes"]
|
||||
fields = ["child", "start", "end", "notes", "tags"]
|
||||
widgets = {
|
||||
"start": forms.DateTimeInput(
|
||||
attrs={
|
||||
|
@ -200,7 +198,7 @@ class SleepForm(CoreModelForm):
|
|||
class TemperatureForm(CoreModelForm):
|
||||
class Meta:
|
||||
model = models.Temperature
|
||||
fields = ["child", "temperature", "time", "notes"]
|
||||
fields = ["child", "temperature", "time", "notes", "tags"]
|
||||
widgets = {
|
||||
"time": forms.DateTimeInput(
|
||||
attrs={
|
||||
|
@ -239,7 +237,7 @@ class TimerForm(CoreModelForm):
|
|||
class TummyTimeForm(CoreModelForm):
|
||||
class Meta:
|
||||
model = models.TummyTime
|
||||
fields = ["child", "start", "end", "milestone"]
|
||||
fields = ["child", "start", "end", "milestone", "tags"]
|
||||
widgets = {
|
||||
"start": forms.DateTimeInput(
|
||||
attrs={
|
||||
|
@ -259,7 +257,7 @@ class TummyTimeForm(CoreModelForm):
|
|||
class WeightForm(CoreModelForm):
|
||||
class Meta:
|
||||
model = models.Weight
|
||||
fields = ["child", "weight", "date", "notes"]
|
||||
fields = ["child", "weight", "date", "notes", "tags"]
|
||||
widgets = {
|
||||
"date": forms.DateInput(
|
||||
attrs={
|
||||
|
@ -274,7 +272,7 @@ class WeightForm(CoreModelForm):
|
|||
class HeightForm(CoreModelForm):
|
||||
class Meta:
|
||||
model = models.Height
|
||||
fields = ["child", "height", "date", "notes"]
|
||||
fields = ["child", "height", "date", "notes", "tags"]
|
||||
widgets = {
|
||||
"date": forms.DateInput(
|
||||
attrs={
|
||||
|
@ -289,7 +287,7 @@ class HeightForm(CoreModelForm):
|
|||
class HeadCircumferenceForm(CoreModelForm):
|
||||
class Meta:
|
||||
model = models.HeadCircumference
|
||||
fields = ["child", "head_circumference", "date", "notes"]
|
||||
fields = ["child", "head_circumference", "date", "notes", "tags"]
|
||||
widgets = {
|
||||
"date": forms.DateInput(
|
||||
attrs={
|
||||
|
@ -304,7 +302,7 @@ class HeadCircumferenceForm(CoreModelForm):
|
|||
class BMIForm(CoreModelForm):
|
||||
class Meta:
|
||||
model = models.BMI
|
||||
fields = ["child", "bmi", "date", "notes"]
|
||||
fields = ["child", "bmi", "date", "notes", "tags"]
|
||||
widgets = {
|
||||
"date": forms.DateInput(
|
||||
attrs={
|
||||
|
|
|
@ -0,0 +1,113 @@
|
|||
# Generated by Django 4.0.3 on 2022-03-08 12:42
|
||||
|
||||
import core.models
|
||||
from django.db import migrations
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
("core", "0019_tag_tagged_note_tags"),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name="bmi",
|
||||
name="tags",
|
||||
field=core.models.TaggableManager(
|
||||
blank=True,
|
||||
help_text="Click on the tags to add (+) or remove (-) tags or use the text editor to create new tags.",
|
||||
through="core.Tagged",
|
||||
to="core.Tag",
|
||||
verbose_name="Tags",
|
||||
),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name="diaperchange",
|
||||
name="tags",
|
||||
field=core.models.TaggableManager(
|
||||
blank=True,
|
||||
help_text="Click on the tags to add (+) or remove (-) tags or use the text editor to create new tags.",
|
||||
through="core.Tagged",
|
||||
to="core.Tag",
|
||||
verbose_name="Tags",
|
||||
),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name="feeding",
|
||||
name="tags",
|
||||
field=core.models.TaggableManager(
|
||||
blank=True,
|
||||
help_text="Click on the tags to add (+) or remove (-) tags or use the text editor to create new tags.",
|
||||
through="core.Tagged",
|
||||
to="core.Tag",
|
||||
verbose_name="Tags",
|
||||
),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name="headcircumference",
|
||||
name="tags",
|
||||
field=core.models.TaggableManager(
|
||||
blank=True,
|
||||
help_text="Click on the tags to add (+) or remove (-) tags or use the text editor to create new tags.",
|
||||
through="core.Tagged",
|
||||
to="core.Tag",
|
||||
verbose_name="Tags",
|
||||
),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name="height",
|
||||
name="tags",
|
||||
field=core.models.TaggableManager(
|
||||
blank=True,
|
||||
help_text="Click on the tags to add (+) or remove (-) tags or use the text editor to create new tags.",
|
||||
through="core.Tagged",
|
||||
to="core.Tag",
|
||||
verbose_name="Tags",
|
||||
),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name="sleep",
|
||||
name="tags",
|
||||
field=core.models.TaggableManager(
|
||||
blank=True,
|
||||
help_text="Click on the tags to add (+) or remove (-) tags or use the text editor to create new tags.",
|
||||
through="core.Tagged",
|
||||
to="core.Tag",
|
||||
verbose_name="Tags",
|
||||
),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name="temperature",
|
||||
name="tags",
|
||||
field=core.models.TaggableManager(
|
||||
blank=True,
|
||||
help_text="Click on the tags to add (+) or remove (-) tags or use the text editor to create new tags.",
|
||||
through="core.Tagged",
|
||||
to="core.Tag",
|
||||
verbose_name="Tags",
|
||||
),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name="tummytime",
|
||||
name="tags",
|
||||
field=core.models.TaggableManager(
|
||||
blank=True,
|
||||
help_text="Click on the tags to add (+) or remove (-) tags or use the text editor to create new tags.",
|
||||
through="core.Tagged",
|
||||
to="core.Tag",
|
||||
verbose_name="Tags",
|
||||
),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name="weight",
|
||||
name="tags",
|
||||
field=core.models.TaggableManager(
|
||||
blank=True,
|
||||
help_text="Click on the tags to add (+) or remove (-) tags or use the text editor to create new tags.",
|
||||
through="core.Tagged",
|
||||
to="core.Tag",
|
||||
verbose_name="Tags",
|
||||
),
|
||||
),
|
||||
]
|
|
@ -1,4 +1,5 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
import random
|
||||
from datetime import timedelta
|
||||
from typing import Iterable, Optional
|
||||
|
||||
|
@ -12,8 +13,6 @@ from django.utils.text import format_lazy
|
|||
from django.utils.translation import gettext_lazy as _
|
||||
from django.core.validators import RegexValidator
|
||||
|
||||
import random
|
||||
|
||||
from taggit.managers import TaggableManager as TaggitTaggableManager
|
||||
from taggit.models import TagBase, GenericTaggedItemBase
|
||||
|
||||
|
@ -151,6 +150,13 @@ class TaggableManager(TaggitTaggableManager):
|
|||
)
|
||||
super().__init__(*args, **kwargs)
|
||||
|
||||
def formfield(self, *args, **kwargs):
|
||||
# Local import required because .widgets imports .models
|
||||
from core.widgets import TagsEditor
|
||||
|
||||
kwargs["widget"] = TagsEditor
|
||||
return super().formfield(*args, **kwargs)
|
||||
|
||||
|
||||
class Child(models.Model):
|
||||
model_name = "child"
|
||||
|
@ -230,6 +236,7 @@ class DiaperChange(models.Model):
|
|||
)
|
||||
amount = models.FloatField(blank=True, null=True, verbose_name=_("Amount"))
|
||||
notes = models.TextField(blank=True, null=True, verbose_name=_("Notes"))
|
||||
tags = TaggableManager(blank=True, through=Tagged)
|
||||
|
||||
objects = models.Manager()
|
||||
|
||||
|
@ -299,6 +306,7 @@ class Feeding(models.Model):
|
|||
)
|
||||
amount = models.FloatField(blank=True, null=True, verbose_name=_("Amount"))
|
||||
notes = models.TextField(blank=True, null=True, verbose_name=_("Notes"))
|
||||
tags = TaggableManager(blank=True, through=Tagged)
|
||||
|
||||
objects = models.Manager()
|
||||
|
||||
|
@ -364,6 +372,7 @@ class Sleep(models.Model):
|
|||
editable=False, null=True, verbose_name=_("Duration")
|
||||
)
|
||||
notes = models.TextField(blank=True, null=True, verbose_name=_("Notes"))
|
||||
tags = TaggableManager(blank=True, through=Tagged)
|
||||
|
||||
objects = models.Manager()
|
||||
naps = NapsManager()
|
||||
|
@ -414,6 +423,7 @@ class Temperature(models.Model):
|
|||
)
|
||||
time = models.DateTimeField(blank=False, null=False, verbose_name=_("Time"))
|
||||
notes = models.TextField(blank=True, null=True, verbose_name=_("Notes"))
|
||||
tags = TaggableManager(blank=True, through=Tagged)
|
||||
|
||||
objects = models.Manager()
|
||||
|
||||
|
@ -541,6 +551,7 @@ class TummyTime(models.Model):
|
|||
milestone = models.CharField(
|
||||
blank=True, max_length=255, verbose_name=_("Milestone")
|
||||
)
|
||||
tags = TaggableManager(blank=True, through=Tagged)
|
||||
|
||||
objects = models.Manager()
|
||||
|
||||
|
@ -576,6 +587,7 @@ class Weight(models.Model):
|
|||
weight = models.FloatField(blank=False, null=False, verbose_name=_("Weight"))
|
||||
date = models.DateField(blank=False, null=False, verbose_name=_("Date"))
|
||||
notes = models.TextField(blank=True, null=True, verbose_name=_("Notes"))
|
||||
tags = TaggableManager(blank=True, through=Tagged)
|
||||
|
||||
objects = models.Manager()
|
||||
|
||||
|
@ -603,6 +615,7 @@ class Height(models.Model):
|
|||
height = models.FloatField(blank=False, null=False, verbose_name=_("Height"))
|
||||
date = models.DateField(blank=False, null=False, verbose_name=_("Date"))
|
||||
notes = models.TextField(blank=True, null=True, verbose_name=_("Notes"))
|
||||
tags = TaggableManager(blank=True, through=Tagged)
|
||||
|
||||
objects = models.Manager()
|
||||
|
||||
|
@ -632,6 +645,7 @@ class HeadCircumference(models.Model):
|
|||
)
|
||||
date = models.DateField(blank=False, null=False, verbose_name=_("Date"))
|
||||
notes = models.TextField(blank=True, null=True, verbose_name=_("Notes"))
|
||||
tags = TaggableManager(blank=True, through=Tagged)
|
||||
|
||||
objects = models.Manager()
|
||||
|
||||
|
@ -656,6 +670,7 @@ class BMI(models.Model):
|
|||
bmi = models.FloatField(blank=False, null=False, verbose_name=_("BMI"))
|
||||
date = models.DateField(blank=False, null=False, verbose_name=_("Date"))
|
||||
notes = models.TextField(blank=True, null=True, verbose_name=_("Notes"))
|
||||
tags = TaggableManager(blank=True, through=Tagged)
|
||||
|
||||
objects = models.Manager()
|
||||
|
||||
|
|
Loading…
Reference in New Issue