Skip to content

Commit

Permalink
Merge pull request #1102 from 18F/junefix
Browse files Browse the repository at this point in the history
1024 make organization required
  • Loading branch information
Jkrzy authored Jun 15, 2020
2 parents ffa7c9e + 46c93cd commit 43a4ba7
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 3 deletions.
3 changes: 2 additions & 1 deletion tock/employees/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ class UserDataAdmin(admin.ModelAdmin):
list_filter = (
'current_employee',
'is_aws_eligible',
'organization__name',
'organization',
'unit',
)
search_fields = ('user__username',)
Expand All @@ -78,6 +78,7 @@ def get_organization_name(self, obj):

return '-'
get_organization_name.short_description = 'Organization Name'
get_organization_name.admin_order_field = 'organization'


class EmployeeGradeAdmin(admin.ModelAdmin):
Expand Down
19 changes: 19 additions & 0 deletions tock/employees/migrations/0034_auto_20200604_1756.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Generated by Django 2.2.12 on 2020-06-04 21:56

from django.db import migrations, models
import django.db.models.deletion


class Migration(migrations.Migration):

dependencies = [
('employees', '0033_auto_20200515_1103'),
]

operations = [
migrations.AlterField(
model_name='userdata',
name='organization',
field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.CASCADE, to='organizations.Organization'),
),
]
2 changes: 1 addition & 1 deletion tock/employees/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ class UserData(models.Model):
default=False,
verbose_name='Is alternative work schedule eligible'
)
organization = models.ForeignKey(Organization, blank=True, null=True, on_delete=models.CASCADE)
organization = models.ForeignKey(Organization, blank=False, null=True, on_delete=models.CASCADE)
unit = models.ForeignKey(Unit, blank=True, null=True, on_delete=models.CASCADE,
verbose_name="Business Unit",
help_text="The business unit within the organization in which this person sits."
Expand Down
5 changes: 4 additions & 1 deletion tock/employees/tests/test_admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,15 @@
from django.contrib.auth.models import User
from django.test import TestCase
from employees.admin import UserDataForm
from organizations.models import Organization
from projects.models import ProfitLossAccount


class TestUserDataForm(TestCase):
fixtures = [
'employees/fixtures/user_data.json',
'tock/fixtures/prod_user.json'
'tock/fixtures/prod_user.json',
'organizations/fixtures/organizations.json'
]

def setUp(self):
Expand All @@ -28,6 +30,7 @@ def setUp(self):
'start_date': datetime.date.today(),
'end_date': '',
'current_employee': '',
'organization': Organization.objects.first().id,
'unit': '',
'profit_loss_account': ProfitLossAccount.objects.first().id,
'expected_billable_hours': settings.DEFAULT_EXPECTED_BILLABLE_HOURS
Expand Down

0 comments on commit 43a4ba7

Please sign in to comment.