Skip to content
This repository has been archived by the owner on Dec 9, 2022. It is now read-only.

Commit

Permalink
Merge pull request #294 from ropable/prod-oldui
Browse files Browse the repository at this point in the history
Increment wagtail to v1.11.1. 	Added chart_acct_name to CostCentreAdmin list_filter. Registered DepartmentUser with with reversion app.
  • Loading branch information
ropable committed Jul 10, 2017
2 parents 533cba9 + 1148113 commit 4eba58c
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 13 deletions.
13 changes: 10 additions & 3 deletions oim_cms/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,13 @@ def setUp(self):
self.loc2 = mixer.blend(Location, manager=None)
# Generate a basic org structure.
# NOTE: don't use mixer to create OrgUnit objects (it breaks MPTT).
self.dept = OrgUnit.objects.create(name='Department 1', unit_type=0)
self.dept = OrgUnit.objects.create(name='Department 1', unit_type=0, acronym='DEPT')
self.div1 = OrgUnit.objects.create(
name='Divison 1', unit_type=1, parent=self.dept, location=self.loc1)
name='Divison 1', unit_type=1, parent=self.dept, location=self.loc1, acronym='D1')
self.cc1 = CostCentre.objects.create(
name='Cost centre 1', code='001', division=self.div1, org_position=self.div1)
self.div2 = OrgUnit.objects.create(
name='Divison 2', unit_type=1, parent=self.dept, location=self.loc2)
name='Divison 2', unit_type=1, parent=self.dept, location=self.loc2, acronym='D2')
self.cc2 = CostCentre.objects.create(
name='Cost centre 2', code='002', division=self.div2, org_position=self.div2)
# Give each of the divisions some members.
Expand Down Expand Up @@ -274,9 +274,16 @@ def test_list_filtering(self):
self.assertNotContains(response, self.user2.email)

def test_detail(self):
"""Test the DepartmentUserResource detail response
"""
# Test detail URL using ad_guid.
url = '/api/users/{}/'.format(self.user1.ad_guid)
response = self.client.get(url)
self.assertEqual(response.status_code, 200)
# Test URL using email also.
url = '/api/users/{}/'.format(self.user1.email.lower())
response = self.client.get(url)
self.assertEqual(response.status_code, 200)

def test_org_structure(self):
"""Test the DepartmentUserResource org_structure response
Expand Down
7 changes: 5 additions & 2 deletions organisation/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
from django.utils.html import format_html
from django_mptt_admin.admin import DjangoMpttAdmin
from leaflet.admin import LeafletGeoAdmin
from reversion.admin import VersionAdmin
from threading import Thread
import time

Expand Down Expand Up @@ -41,7 +42,9 @@ def clean_employee_id(self):


@register(DepartmentUser)
class DepartmentUserAdmin(ModelAdmin):
class DepartmentUserAdmin(VersionAdmin):
# Override the default reversion/change_list.html template:
change_list_template = 'admin/organisation/departmentuser/change_list.html'
form = DepartmentUserForm
list_display = [
'email', 'title', 'employee_id', 'username', 'active', 'vip', 'executive',
Expand Down Expand Up @@ -243,7 +246,7 @@ class CostCentreAdmin(ModelAdmin):
search_fields = (
'name', 'code', 'chart_acct_name', 'org_position__name', 'division__name',
'org_position__acronym', 'division__acronym')
list_filter = ('active',)
list_filter = ('active', 'chart_acct_name')
raw_id_fields = (
'org_position', 'manager', 'business_manager', 'admin', 'tech_contact')

Expand Down
4 changes: 2 additions & 2 deletions organisation/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ def list(self):
# No other filtering:
# Return 'active' DU objects, excluding predefined account types and contractors.
FILTERS = DepartmentUser.ACTIVE_FILTER.copy()
users = DepartmentUser.objects.filter(**FILTERS).exclude(account_type__in=[4, 5, 9, 10, 11, 12, 14, 15, 16])
users = DepartmentUser.objects.filter(**FILTERS).exclude(account_type__in=[4, 5, 9, 10, 11, 12, 14, 16])
users = users.exclude(expiry_date__lte=timezone.now())
# Non-mutually-exclusive filters:
if 'o365_licence' in self.request.GET:
Expand Down Expand Up @@ -292,7 +292,7 @@ def org_structure(self, sync_o365=False, exclude_populate_groups=False):
"""
qs = DepartmentUser.objects.filter(**DepartmentUser.ACTIVE_FILTER)
# Exclude predefined account types:
qs = qs.exclude(account_type__in=[4, 5, 9, 10, 11, 12, 14, 15, 16])
qs = qs.exclude(account_type__in=[4, 5, 9, 10, 11, 12, 14, 16])
if exclude_populate_groups: # Exclude objects where populate_primary_group == False
qs = qs.exclude(populate_primary_group=False)
structure = []
Expand Down
2 changes: 1 addition & 1 deletion organisation/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -479,7 +479,7 @@ def __str__(self):
if self.acronym:
name = '{} - {}'.format(self.acronym, name)
if self.cc():
return '{} - CC{}'.format(name, self.cc())
return '{} - CC {}'.format(name, self.cc())
return name

def members(self):
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{% extends "admin/change_list.html" %}
{% extends "reversion/change_list.html" %}

{% block object-tools-items %}
<li>
Expand Down
8 changes: 4 additions & 4 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
Django==1.10.7
django-extensions==1.7.9
django-extensions==1.8.1
django-uwsgi==0.1.6
git+https://github.com/parksandwildlife/dpaw-utils.git@0.3a16#egg=dpaw-utils
wagtail==1.10.1
wagtail==1.11.1
wagtailtinymce==4.2.1.5
django-queryset-csv==1.0.0
django-mptt==0.8.7
django-mptt-admin==0.4.4
django-mptt-admin==0.4.6
django-leaflet==0.21.0
django-reversion==2.0.8
django-reversion==2.0.9
python-dateutil==2.4.2
django-model-utils==2.5
django-debug-toolbar==1.7
Expand Down

0 comments on commit 4eba58c

Please sign in to comment.