Created
March 21, 2012 20:15
-
-
Save h4/2152399 to your computer and use it in GitHub Desktop.
Построение персонала
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def contacts(request): | |
persons = PersonToPosition.objects.all() | |
departments = {} | |
for person in persons: | |
department_id = person.position.department.id | |
if (department_id not in departments): | |
departments[department_id] = { | |
'title': person.position.department.title, | |
'id': department_id, | |
'persons': [], | |
'subdepartments': {} | |
} | |
if (person.education_department): | |
education_department_id = person.education_department.id | |
if(education_department_id not in departments[department_id]['subdepartments']): | |
departments[department_id]['subdepartments'][education_department_id] = { | |
'title': person.education_department.title, | |
'id': education_department_id, | |
'persons': [] | |
} | |
departments[department_id]['subdepartments'][education_department_id]['persons'].append(person) | |
else: | |
departments[department_id]['persons'].append(person) | |
return render_to_response('contacts.html', { | |
'departments': departments | |
}, | |
RequestContext(request)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment