Skip to content

Remove Worker.get_details and rewrite extend_context

method extend_context calls to static method Worker.get_details but we already have get_by_user static method which returns either None or a Worker. Then, if this method returns None we proceed with return the_user.get_full_name(), '<No worker information>' and in other case we return unicode(person), person.role.

def extend_context(params, request):
    person, role = Worker.get_details(request.user)
    notifications = get_notifications(request.user)
    final_params = params.copy()
    final_params.update({
        'person': person,
        'role': role,
        'notifications': notifications,
        'study_id': GLOBAL_STUDY_ID
    })
    return final_params