Skip to content

Commit

Permalink
move expectation default to settings
Browse files Browse the repository at this point in the history
  • Loading branch information
Jkrzy committed Apr 24, 2020
1 parent 31273a0 commit 2f9119b
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 20 deletions.
9 changes: 5 additions & 4 deletions tock/employees/admin.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
from django.contrib import admin
from django import forms

from .models import UserData, EmployeeGrade
from django.conf import settings
from django.contrib import admin
from hours.admin import TimecardPrefillDataInline

from .models import EmployeeGrade, UserData


class UserDataForm(forms.ModelForm):
billable_expectation = forms.DecimalField(initial=0.80)
billable_expectation = forms.DecimalField(initial=settings.DEFAULT_BILLABLE_EXPECTATION)

class Meta:
model = UserData
Expand Down
3 changes: 2 additions & 1 deletion tock/employees/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from decimal import Decimal

from django.apps import apps
from django.conf import settings
from django.contrib.auth import get_user_model
from django.core.validators import MaxValueValidator
from django.db import IntegrityError, models
Expand Down Expand Up @@ -82,7 +83,7 @@ class UserData(models.Model):
current_employee = models.BooleanField(default=True, verbose_name='Is Current Employee')
is_18f_employee = models.BooleanField(default=True, verbose_name='Is 18F Employee')
billable_expectation = models.DecimalField(validators=[MaxValueValidator(limit_value=1)],
default=Decimal(0.80), decimal_places=2, max_digits=3,
default=Decimal(settings.DEFAULT_BILLABLE_EXPECTATION), decimal_places=2, max_digits=3,
verbose_name="Percentage of hours (expressed as a decimal) expected to be billable each week")
profit_loss_account = models.ForeignKey(
ProfitLossAccount,
Expand Down
7 changes: 4 additions & 3 deletions tock/employees/tests/test_admin.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import datetime

from django.test import TestCase
from django.conf import settings
from django.contrib.auth.models import User

from django.test import TestCase
from employees.admin import UserDataForm
from projects.models import ProfitLossAccount


class TestUserDataForm(TestCase):
fixtures = [
'employees/fixtures/user_data.json',
Expand Down Expand Up @@ -34,7 +35,7 @@ def test_user_data_form(self):
'is_18f_employee': '',
'unit': '',
'profit_loss_account': ProfitLossAccount.objects.first().id,
'billable_expectation': 0.80
'billable_expectation': settings.DEFAULT_BILLABLE_EXPECTATION
}
form = UserDataForm(data=form_data)
self.assertTrue(form.is_valid())
Expand Down
18 changes: 7 additions & 11 deletions tock/hours/admin.py
Original file line number Diff line number Diff line change
@@ -1,20 +1,16 @@
from decimal import Decimal

from django.conf import settings
from django.contrib import admin
from django.core.exceptions import ValidationError
from django.forms.models import BaseInlineFormSet
from django.forms import DecimalField, ModelForm

from .models import (
HolidayPrefills,
ReportingPeriod,
Timecard,
TimecardNote,
TimecardObject,
TimecardPrefillData
)
from django.forms.models import BaseInlineFormSet
from employees.models import UserData

from .models import (HolidayPrefills, ReportingPeriod, Timecard, TimecardNote,
TimecardObject, TimecardPrefillData)


class ReportingPeriodListFilter(admin.SimpleListFilter):
parameter_name = 'reporting_period'
title = 'Reporting Period'
Expand Down Expand Up @@ -79,7 +75,7 @@ class TimecardObjectInline(admin.TabularInline):


class TimecardAdminForm(ModelForm):
billable_expectation = DecimalField(initial=0.80)
billable_expectation = DecimalField(initial=settings.DEFAULT_BILLABLE_EXPECTATION)

class Meta:
model = Timecard
Expand Down
2 changes: 1 addition & 1 deletion tock/hours/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ class Timecard(models.Model):
created = models.DateTimeField(auto_now_add=True)
modified = models.DateTimeField(auto_now=True)
billable_expectation = models.DecimalField(validators=[MaxValueValidator(limit_value=1)],
default=Decimal(0.80), decimal_places=2, max_digits=3,
default=Decimal(settings.DEFAULT_BILLABLE_EXPECTATION), decimal_places=2, max_digits=3,
verbose_name="Percentage of hours which are expected to be billable this week")

# Utilization reporting
Expand Down
1 change: 1 addition & 0 deletions tock/tock/settings/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,3 +139,4 @@
STARTING_FY_FOR_REPORTS_PAGE = 2019
RECENT_TIMECARDS_FOR_BILLABILITY = 4
HOURS_IN_A_REGULAR_WORK_WEEK = 40
DEFAULT_BILLABLE_EXPECTATION = 0.80

0 comments on commit 2f9119b

Please sign in to comment.