Esempio n. 1
0
    def update_faculty_table(dept):

        # Do not display table for aggregate views
        if dept in ['AS', 'HUM', 'NS', 'SS']:
            return [], {'display': 'none'}

        # Do not display table without chair-level access
        # to the selected department
        current_user = User()
        if dept not in current_user.deptprofile_access('dept_chair'):
            return [], {'display': 'none'}
        else:
            resp = table.query(KeyConditionExpression=
                               'PK = :pk AND SK BETWEEN :lower AND :upper',
                               ExpressionAttributeValues={
                                   ':pk':
                                   f'DEPT#{dept}',
                                   ':lower':
                                   f'DATA#FACULTY_LIST#{MAX_FISCAL_YEAR}',
                                   ':upper':
                                   f'DATA#FACULTY_LIST#{MAX_FISCAL_YEAR}$',
                               },
                               ScanIndexForward=True)

            return resp['Items'], {'display': 'inline'}
Esempio n. 2
0
def serve_deptprofile_layout():

    current_user = User()

    depts = current_user.deptprofile_access('dept')

    if depts:

        logger.log_access(has_access=True)

        # Create a list of dropdown options based on user permissions
        # Do this here to call deptprofile_access only once
        dropdown_options = []
        for option in ALL_DROPDOWN_OPTIONS:
            if option['value'].strip('_') in depts:
                dropdown_options.append(option)

        layout = html.Div([
            serve_navbar(),
            html.Div(
                [
                    header,
                    serve_dept_dropdown(dropdown_options=dropdown_options),
                    tabs
                ],
                className='container pb-5',
            ),
        ])

    else:

        # Log that a user accesssed this view and was NOT authorized
        logger.log_access(has_access=False)

        no_access_alert = dbc.Alert([
            html.H5('You don\'t have access to this page.',
                    className='alert-heading'),
            html.P(
                'Please reach out to Timur Gulyamov (tg2648) to get access.',
                className='mb-0',
            ),
        ],
                                    color='warning',
                                    className='mt-3')

        layout = html.Div([
            serve_navbar(),
            html.Div([no_access_alert], className='container'),
        ])

    return layout