Skip to content

Commit

Permalink
Commit before delete the last commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Heibert committed Aug 2, 2024
1 parent dd44804 commit 203cb4d
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 2 deletions.
2 changes: 1 addition & 1 deletion INSIGHTSAPI/INSIGHTSAPI/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ def str_to_bool(value: str) -> bool:

USE_I18N = True

# USE_L10N = True
USE_L10N = True

USE_THOUSAND_SEPARATOR = True

Expand Down
23 changes: 23 additions & 0 deletions INSIGHTSAPI/hierarchy/models.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,39 @@
"""This file contains the models for the hierarchy app. """

from django.db import models
from users.models import User
from django.db.models import Q
from django.core.mail import mail_admins


class Area(models.Model):
"""Model for the area"""

name = models.CharField(max_length=100)
# manager = models.ForeignKey(
# "User", on_delete=models.SET_NULL, null=True, related_name="managed_areas"
# )

def __str__(self):
"""String representation of the model."""
return self.name

# def save(self, *args, **kwargs):
# """Save method for the model."""
# if not self.manager:
# self.manager = (
# User.objects.filter(area__name=self.name, job_position__rank__gte=5)
# .order_by("job_position__rank")
# .first()
# )
# if not self.manager:
# mail_admins(
# "Warning",
# f"No manager found for area {self.name}. Please assign a manager.",
# )
# super(Area, self).save(*args, **kwargs)


class JobPosition(models.Model):
name = models.CharField(max_length=100, unique=True)
rank = models.PositiveIntegerField()
Expand Down
12 changes: 11 additions & 1 deletion INSIGHTSAPI/hierarchy/tests.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
from django.test import TestCase
from services.tests import BaseTestCase
from hierarchy.models import Area

# Create your tests here.
# class AreaTest(BaseTestCase):
# def test_manager_assignment(self):
# """Test the manager assignment for the area model."""
# self.area = Area.objects.create(name="Test Area")
# area = Area.objects.create(name="Test Area")
# self.assertEqual(area.manager, None)
# area.save()
# self.assertEqual(area.manager, None)

0 comments on commit 203cb4d

Please sign in to comment.