api/participant_administration.py
def reset_participant_password():
    """ Takes a patient ID and resets its password. Returns the new random password."""
    patient_id = request.values['patient_id']
    study_id = request.values['study_id']

    try:
        participant = Participant.objects.get(patient_id=patient_id)
    except Participant.DoesNotExist:
        flash(f'The participant {patient_id} does not exist', 'danger')
        return redirect(f'/view_study/{study_id}/')

    if participant.study.id != int(study_id):
        flash(f'Participant {patient_id} is not in study {Study.objects.get(id=study_id).name}', 'danger')
        return redirect(request.referrer)

    new_password = participant.reset_password()
    flash(f'Patient {patient_id}\'s password has been reset to {new_password}.', 'success')
    return redirect(request.referrer)
 Takes a patient ID and resets its password. Returns the new random password.
Takes a patient ID and resets its password. Returns the new random password.
Takes a patient ID and resets its password . Returns the new random password .
def reset_participant_password():
    patient_id = request.values['patient_id']
    study_id = request.values['study_id']
    try:
        participant = Participant.objects.get(patient_id=patient_id)
    except Participant.DoesNotExist:
        flash(f'The participant {patient_id} does not exist', 'danger')
        return redirect(f'/view_study/{study_id}/')
    if participant.study.id != int(study_id):
        flash(f'Participant {patient_id} is not in study {Study.objects.get(id=study_id).name}', 'danger')
        return redirect(request.referrer)
    new_password = participant.reset_password()
    flash(f'Patient {patient_id}\'s password has been reset to {new_password}.', 'success')
    return redirect(request.referrer)
def reset_participant_password ( ) : patient_id = request . values [ 'patient_id' ] study_id = request . values [ 'study_id' ] try : participant = Participant . objects . get ( patient_id = patient_id ) except Participant . DoesNotExist : flash ( f'The participant {patient_id} does not exist' , 'danger' ) return redirect ( f'/view_study/{study_id}/' ) if participant . study . id != int ( study_id ) : flash ( f'Participant {patient_id} is not in study {Study.objects.get(id=study_id).name}' , 'danger' ) return redirect ( request . referrer ) new_password = participant . reset_password ( ) flash ( f'Patient {patient_id}\'s password has been reset to {new_password}.' , 'success' ) return redirect ( request . referrer )
Takes a patient ID and resets its password.
Takes a patient ID and resets its password .
""" Takes a patient ID and resets its password. Returns the new random password."""