Ejemplo n.º 1
0
def edit_admin(admin_id):
    admin = Admin(admin_id)
    admin_is_current_user = (admin._id == session['admin_username'])
    current_studies = sorted(Studies(admins=admin._id),
                             key=lambda x: x.name.lower())
    return render_template('edit_admin.html',
                           admin=admin,
                           current_studies=current_studies,
                           all_studies=Studies.get_all_studies(),
                           allowed_studies=get_admins_allowed_studies(),
                           admin_is_current_user=admin_is_current_user,
                           system_admin=admin_is_system_admin())
Ejemplo n.º 2
0
def create_study():
    if request.method == 'GET':
        return render_template('create_study.html',
                               studies=Studies.get_all_studies(),
                               allowed_studies=get_admins_allowed_studies(),
                               system_admin=admin_is_system_admin())
    name = request.form.get('name')
    encryption_key = request.form.get('encryption_key')
    try:
        study = Study.create_default_study(name, encryption_key)
        flash("Successfully created a new study.", 'success')
        copy_existing_study_if_asked_to(study)
        return redirect('/device_settings/' + str(study._id))
    except (InvalidEncryptionKeyError, StudyAlreadyExistsError) as e:
        flash(e.message, 'danger')
        return redirect('/create_study')
Ejemplo n.º 3
0
def manage_studies():
    return render_template('manage_studies.html',
                           studies=Studies.get_all_studies(),
                           allowed_studies=get_admins_allowed_studies(),
                           system_admin=admin_is_system_admin())