Skip to content
This repository has been archived by the owner on May 13, 2024. It is now read-only.

Commit

Permalink
docs(models): add __str__
Browse files Browse the repository at this point in the history
  • Loading branch information
c0rydoras committed Apr 17, 2024
1 parent 2dbcee4 commit 3a87248
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 0 deletions.
6 changes: 6 additions & 0 deletions timed/employment/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,9 @@ class AbsenceCredit(models.Model):
Mark whether this absence credit is a transfer from last year.
"""

def __str__(self) -> str:
return f"{self.user.username} ({self.duration})"


class OvertimeCredit(models.Model):
"""Overtime credit model.
Expand All @@ -159,6 +162,9 @@ class OvertimeCredit(models.Model):
Mark whether this absence credit is a transfer from last year.
"""

def __str__(self) -> str:
return f"{self.user.username} ({self.duration})"


class EmploymentManager(models.Manager):
"""Custom manager for employments."""
Expand Down
9 changes: 9 additions & 0 deletions timed/projects/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,9 @@ class CustomerAssignee(models.Model):
is_manager = models.BooleanField(default=False)
is_customer = models.BooleanField(default=False)

def __str__(self) -> str:
return f"{self.user.username} {self.customer}"


class ProjectAssignee(models.Model):
"""Project assignee model.
Expand All @@ -236,6 +239,9 @@ class ProjectAssignee(models.Model):
is_manager = models.BooleanField(default=False)
is_customer = models.BooleanField(default=False)

def __str__(self) -> str:
return f"{self.user.username} {self.project}"


class TaskAssignee(models.Model):
"""Task assignee model.
Expand All @@ -256,6 +262,9 @@ class TaskAssignee(models.Model):
is_manager = models.BooleanField(default=False)
is_customer = models.BooleanField(default=False)

def __str__(self) -> str:
return f"{self.user.username} {self.task}"


@receiver(pre_save, sender=Project)
def update_billed_flag_on_reports(sender, instance, **kwargs): # noqa: ARG001
Expand Down
3 changes: 3 additions & 0 deletions timed/redmine/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,6 @@ class RedmineProject(models.Model):
Project, on_delete=models.CASCADE, related_name="redmine_project"
)
issue_id = models.PositiveIntegerField()

def __str__(self) -> str:
return f"{self.issue_id} {self.project}"
9 changes: 9 additions & 0 deletions timed/subscription/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ class Package(models.Model):
duration = models.DurationField()
price = MoneyField(max_digits=7, decimal_places=2, default_currency="CHF")

def __str__(self) -> str:
return f"{self.billing_type} {self.duration} {self.price}"


class Order(models.Model):
"""Order of customer for specific amount of hours."""
Expand All @@ -41,6 +44,9 @@ class Order(models.Model):
related_name="orders_confirmed",
)

def __str__(self) -> str:
return f"{self.project} {self.duration}"


class CustomerPassword(models.Model):
"""Password per customer used for login into SySupport portal.
Expand All @@ -51,3 +57,6 @@ class CustomerPassword(models.Model):

customer = models.OneToOneField("projects.Customer", on_delete=models.CASCADE)
password = models.CharField(_("password"), max_length=128, null=True, blank=True)

def __str__(self) -> str:
return f"{self.customer}"
12 changes: 12 additions & 0 deletions timed/tracking/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,18 @@ class Meta:

unique_together = ("date", "user")

def __str__(self):
"""Represent the model as a string.
:return: The string representation
:rtype: str
"""
return "{}: {} {}".format(
self.user,
self.date.strftime("%Y-%m-%d"),
self.comment,
)

def calculate_duration(self, employment):
"""Calculate duration of absence with given employment.
Expand Down

0 comments on commit 3a87248

Please sign in to comment.