def get_departments(library = None):
    if library == get_page_loc_name(CRERAR_HOMEPAGE):
        departments = [
            'Science Libraries - Administration',
            'Science Libraries - Crerar Library Access Services',
            'Science Libraries - Science Technical Services'
        ]
    elif library == get_page_loc_name(DANGELO_HOMEPAGE):
        departments = [
            'D\'Angelo Law Library',
            'D\'Angelo Law Library - Administration',
            'D\'Angelo Law Library - Law Collection Services',
            'D\'Angelo Law Library - Law User Services',
            'D\'Angelo Law Library - Law User Services - Access Services',
            'D\'Angelo Law Library - Law User Services - Reference'
        ]
    elif library == get_page_loc_name(ECKHART_HOMEPAGE):
        departments = []
    elif library == get_page_loc_name(MANSUETO_HOMEPAGE):
        departments = []
    elif library == LocationPage.objects.live().get(id=REGENSTEIN_HOMEPAGE).title:
        departments = [
            'Administration - Communications',
            'Administration - Development',
            'Administration - Director\'s Office',
            'Adminstrative Services - Budget',
            'Adminstrative Services - Building Services',
            'Adminstrative Services - Human Resources',
            'Adminstrative Services - Shipping and Receiving',
            'Collection Services',
            'Collection Services - Preservation',
            'Collection Services - Technical Services',
            'Digital Services',
            'User Services - Access Services - ID & Privileges Office & Entry Control',
            'User Services - Access Services - Regenstein Circulation',
            'User Services - Collection Management and Special Projects - Regenstein Search Services',
            'User Services - Dissertation Office',
            'User Services - Reference, Instruction, and Outreach'
        ]
    elif library == get_page_loc_name(SCRC_HOMEPAGE):
        departments = [
            'Special Collections Research Center - SCRC Administration',
            'Special Collections Research Center - SCRC Archives and Manuscripts',
            'Special Collections Research Center - SCRC Collection Management',
            'Special Collections Research Center - SCRC Exhibits',
            'Special Collections Research Center - SCRC Rare Books',
            'Special Collections Research Center - SCRC Reader Services'
        ]
    elif library == get_page_loc_name(SSA_HOMEPAGE):
        departments = []
    else:
        departments = []

    output = []
    for d in departments:
        output.append({
            'directory_unit': DirectoryUnit.objects.get(fullName=d),
            'label': d.split(' - ').pop()
        })
    return sorted(output, key=lambda d: d['label'])
Example #2
0
def get_departments(library = None):
    if library == get_page_loc_name(CRERAR_HOMEPAGE):
        departments = [
            'Science Libraries - Administration',
            'Science Libraries - Crerar Library Access Services',
            'Science Libraries - Science Technical Services'
        ]
    elif library == get_page_loc_name(DANGELO_HOMEPAGE):
        departments = [
            'D\'Angelo Law Library',
            'D\'Angelo Law Library - Administration',
            'D\'Angelo Law Library - Law Collection Services',
            'D\'Angelo Law Library - Law User Services',
            'D\'Angelo Law Library - Law User Services - Access Services',
            'D\'Angelo Law Library - Law User Services - Reference'
        ]
    elif library == get_page_loc_name(ECKHART_HOMEPAGE):
        departments = []
    elif library == get_page_loc_name(MANSUETO_HOMEPAGE):
        departments = []
    elif library == LocationPage.objects.live().get(id=REGENSTEIN_HOMEPAGE).title:
        departments = [
            'Administration - Communications',
            'Administration - Development',
            'Administration - Director\'s Office',
            'Adminstrative Services - Budget',
            'Adminstrative Services - Building Services',
            'Adminstrative Services - Human Resources',
            'Adminstrative Services - Shipping and Receiving',
            'Collection Services',
            'Collection Services - Preservation',
            'Collection Services - Technical Services',
            'Digital Services',
            'User Services - Access Services - ID & Privileges Office & Entry Control',
            'User Services - Access Services - Regenstein Circulation',
            'User Services - Collection Management and Special Projects - Regenstein Search Services',
            'User Services - Dissertation Office',
            'User Services - Reference, Instruction, and Outreach'
        ]
    elif library == get_page_loc_name(SCRC_HOMEPAGE):
        departments = [
            'Special Collections Research Center - SCRC Administration',
            'Special Collections Research Center - SCRC Archives and Manuscripts',
            'Special Collections Research Center - SCRC Collection Management',
            'Special Collections Research Center - SCRC Exhibits',
            'Special Collections Research Center - SCRC Rare Books',
            'Special Collections Research Center - SCRC Reader Services'
        ]
    elif library == get_page_loc_name(SSA_HOMEPAGE):
        departments = []
    else:
        departments = []

    output = []
    for d in departments:
        output.append({
            'directory_unit': DirectoryUnit.objects.get(fullName=d),
            'label': d.split(' - ').pop()
        })
    return sorted(output, key=lambda d: d['label'])
def get_staff_pages_for_library(library = None):
    staff_pks = []
    if library:
        # get a queryset of units from each library building, then get a list of distinct StaffPage pks for each queryset. 
        if library == get_page_loc_name(ECKHART_HOMEPAGE):
            eckhart_units = DirectoryUnit.objects.get(name='Eckhart Library').get_descendants(True)
            staff_pks = StaffPagePageVCards.objects.filter(unit__in=eckhart_units).values_list('page', flat=True).distinct()
        elif library == get_page_loc_name(CRERAR_HOMEPAGE):
            crerar_units = DirectoryUnit.objects.get(name='Science Libraries').get_descendants(True)
            eckhart_units = DirectoryUnit.objects.get(name='Eckhart Library').get_descendants(True)
            staff_pks = StaffPagePageVCards.objects.filter(unit__in=crerar_units).exclude(unit__in=eckhart_units).values_list('page', flat=True).distinct()
        elif library == get_page_loc_name(DANGELO_HOMEPAGE):
            dangelo_units = DirectoryUnit.objects.get(name='D\'Angelo Law Library').get_descendants(True)
            staff_pks = StaffPagePageVCards.objects.filter(unit__in=dangelo_units).values_list('page', flat=True).distinct()
        elif library == get_page_loc_name(SSA_HOMEPAGE):
            ssa = DirectoryUnit.objects.get(name='Social Service Administration Library (SSA)').get_descendants(True)
            staff_pks = StaffPagePageVCards.objects.filter(unit__in=ssa).values_list('page', flat=True).distinct()
        elif library == LocationPage.objects.live().get(id=REGENSTEIN_HOMEPAGE).title:
            crerar = DirectoryUnit.objects.get(name='Science Libraries').get_descendants(True)
            dangelo = DirectoryUnit.objects.get(name='D\'Angelo Law Library').get_descendants(True)
            ssa = DirectoryUnit.objects.get(name='Social Service Administration Library (SSA)').get_descendants(True)
            staff_pks = StaffPagePageVCards.objects.all().exclude(unit__in=crerar).exclude(unit__in=dangelo).exclude(unit__in=ssa).values_list('page', flat=True).distinct()
        elif library == get_page_loc_name(SCRC_HOMEPAGE):
            scrc = DirectoryUnit.objects.get(name='Special Collections Research Center').get_descendants(True)
            staff_pks = StaffPagePageVCards.objects.all().filter(unit__in=scrc).values_list('page', flat=True).distinct()
        elif library == get_page_loc_name(MANSUETO_HOMEPAGE):
            mansueto = DirectoryUnit.objects.filter(Q(name='Mansueto') | Q(name='Mansueto Library'))
            staff_pks = StaffPagePageVCards.objects.all().filter(unit__in=mansueto).values_list('page', flat=True).distinct()

    # get StaffPages themselves from the pk list. 
    if staff_pks:
        staff_pages_all = StaffPage.objects.filter(pk__in=staff_pks).order_by('last_name', 'first_name')
    else:
        staff_pages_all = StaffPage.objects.live().order_by('last_name', 'first_name')
    return staff_pages_all
Example #4
0
def get_staff_pages_for_library(library = None):
    staff_pks = []
    if library:
        # get a queryset of units from each library building, then get a list of distinct StaffPage pks for each queryset. 
        if library == get_page_loc_name(ECKHART_HOMEPAGE):
            eckhart_units = DirectoryUnit.objects.get(name='Eckhart Library').get_descendants(True)
            staff_pks = StaffPagePageVCards.objects.filter(unit__in=eckhart_units).values_list('page', flat=True).distinct()
        elif library == get_page_loc_name(CRERAR_HOMEPAGE):
            crerar_units = DirectoryUnit.objects.get(name='Science Libraries').get_descendants(True)
            eckhart_units = DirectoryUnit.objects.get(name='Eckhart Library').get_descendants(True)
            staff_pks = StaffPagePageVCards.objects.filter(unit__in=crerar_units).exclude(unit__in=eckhart_units).values_list('page', flat=True).distinct()
        elif library == get_page_loc_name(DANGELO_HOMEPAGE):
            dangelo_units = DirectoryUnit.objects.get(name='D\'Angelo Law Library').get_descendants(True)
            staff_pks = StaffPagePageVCards.objects.filter(unit__in=dangelo_units).values_list('page', flat=True).distinct()
        elif library == get_page_loc_name(SSA_HOMEPAGE):
            ssa = DirectoryUnit.objects.get(name='Social Service Administration Library (SSA)').get_descendants(True)
            staff_pks = StaffPagePageVCards.objects.filter(unit__in=ssa).values_list('page', flat=True).distinct()
        elif library == LocationPage.objects.live().get(id=REGENSTEIN_HOMEPAGE).title:
            crerar = DirectoryUnit.objects.get(name='Science Libraries').get_descendants(True)
            dangelo = DirectoryUnit.objects.get(name='D\'Angelo Law Library').get_descendants(True)
            ssa = DirectoryUnit.objects.get(name='Social Service Administration Library (SSA)').get_descendants(True)
            staff_pks = StaffPagePageVCards.objects.all().exclude(unit__in=crerar).exclude(unit__in=dangelo).exclude(unit__in=ssa).values_list('page', flat=True).distinct()
        elif library == get_page_loc_name(SCRC_HOMEPAGE):
            scrc = DirectoryUnit.objects.get(name='Special Collections Research Center').get_descendants(True)
            staff_pks = StaffPagePageVCards.objects.all().filter(unit__in=scrc).values_list('page', flat=True).distinct()
        elif library == get_page_loc_name(MANSUETO_HOMEPAGE):
            mansueto = DirectoryUnit.objects.filter(Q(name='Mansueto') | Q(name='Mansueto Library'))
            staff_pks = StaffPagePageVCards.objects.all().filter(unit__in=mansueto).values_list('page', flat=True).distinct()

    # get StaffPages themselves from the pk list. 
    if staff_pks:
        staff_pages_all = StaffPage.objects.live().filter(pk__in=staff_pks).order_by('last_name', 'first_name')
    else:
        staff_pages_all = StaffPage.objects.live().order_by('last_name', 'first_name')
    return staff_pages_all