Skip to content

Commit

Permalink
Merge pull request #91 from GeriLife/remove-work-duration-hours-field
Browse files Browse the repository at this point in the history
Remove Work.duration_hours
  • Loading branch information
brylie authored Jan 9, 2024
2 parents e5bf148 + e798bab commit 4a0ca84
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 13 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Generated by Django 5.0 on 2024-01-09 17:28

from django.db import migrations


class Migration(migrations.Migration):

dependencies = [
('work', '0007_alter_work_caregiver_role_alter_work_date_and_more'),
]

operations = [
migrations.RemoveConstraint(
model_name='work',
name='work_duration_hours_gte_zero',
),
migrations.RemoveField(
model_name='work',
name='duration_hours',
),
]
13 changes: 0 additions & 13 deletions work/models.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
from django.core.validators import MinValueValidator
from django.db.models import CheckConstraint, Q
from django.db import models
from django.utils.translation import gettext_lazy as _

Expand Down Expand Up @@ -43,22 +41,11 @@ class Work(models.Model):
duration_minutes = models.PositiveIntegerField(
help_text=_("The number of minutes used performing this work"),
)
duration_hours = models.FloatField(
validators=[
MinValueValidator(0.0),
],
)

class Meta:
db_table = "work"
verbose_name = _("work")
verbose_name_plural = _("work")
constraints = (
CheckConstraint(
check=Q(duration_hours__gte=0.0),
name="work_duration_hours_gte_zero",
),
)

def get_duration_hours(self):
return self.duration_minutes / HOUR_MINUTES
Expand Down

0 comments on commit 4a0ca84

Please sign in to comment.