Skip to content

Commit

Permalink
Add periods display property and rename PositionView
Browse files Browse the repository at this point in the history
  • Loading branch information
CaitBarnard committed Dec 17, 2024
1 parent 13e5f9c commit 4f59556
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
4 changes: 4 additions & 0 deletions core/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,10 @@ class Meta:
def periods(self) -> list[float]:
return [getattr(self, month) for month in MONTHS]

@property
def periods_as_percentage(self) -> list[float]:
return [month * 100 for month in self.periods]

financial_year = models.ForeignKey(FinancialYear, on_delete=models.PROTECT)
apr = models.FloatField(default=1.0)
may = models.FloatField(default=1.0)
Expand Down
8 changes: 4 additions & 4 deletions payroll/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
from .services import payroll as payroll_service


class PositionView(UserPassesTestMixin, View):
class EditPayrollView(UserPassesTestMixin, View):
def test_func(self) -> bool | None:
return self.request.user.is_superuser

Expand Down Expand Up @@ -49,7 +49,7 @@ def post(self, request, *args, **kwargs):


# TODO: check user has access to cost centre
class PayrollView(PositionView):
class PayrollView(EditPayrollView):
def get_data(self):
return payroll_service.get_payroll_data(
self.cost_centre,
Expand All @@ -64,7 +64,7 @@ def post_data(self, data):
)


class VacancyView(PositionView):
class VacancyView(EditPayrollView):
def get_data(self):
return payroll_service.get_vacancies_data(
self.cost_centre,
Expand All @@ -79,7 +79,7 @@ def post_data(self, data):
)


class PayModifierView(PositionView):
class PayModifierView(EditPayrollView):
def get_data(self):
return payroll_service.get_pay_modifiers_data(
self.cost_centre,
Expand Down

0 comments on commit 4f59556

Please sign in to comment.