コード例 #1
0
ファイル: settings.py プロジェクト: LeskoIam/homeNET
def view_settings():
    form = SettingsForm()
    if form.validate_on_submit():
        print form.node_details_plot_back_period.data
        update_setting("NODE_DETAILS_PLOT_BACK_PERIOD",
                       form.node_details_plot_back_period.data,
                       int)
        update_setting("SERVER_TEMP_PLOT_BACK_PERIOD",
                       form.server_temp_plot_back_period.data,
                       int)
        update_setting("PROC_MAX_TEMP_LIMIT",
                       form.server_temp_proc_max_temp_limit.data,
                       float)
        update_setting("ENVIRONMENT_BACK_PLOT_PERIOD",
                       form.temperature_back_plot_period.data,
                       int)
        update_setting("ENVIRONMENT_SCAN_PERIOD",
                       form.temperature_scan_period.data,
                       float)
        flash("Settings successfully changed!")
    details_plot_back_period = get_setting("NODE_DETAILS_PLOT_BACK_PERIOD", int)
    server_temp_plot_back_period = get_setting("SERVER_TEMP_PLOT_BACK_PERIOD", int)
    server_temp_proc_max_temp_limit = get_setting("PROC_MAX_TEMP_LIMIT", float)
    temperature_plot_back_period = get_setting("ENVIRONMENT_BACK_PLOT_PERIOD", int)
    temperature_scan_period = get_setting("ENVIRONMENT_SCAN_PERIOD", float)

    form.node_details_plot_back_period.data = details_plot_back_period.value
    form.server_temp_plot_back_period.data = server_temp_plot_back_period.value
    form.server_temp_proc_max_temp_limit.data = server_temp_proc_max_temp_limit.value
    form.temperature_back_plot_period.data = temperature_plot_back_period.value
    form.temperature_scan_period.data = temperature_scan_period.value
    return render_template("settings.html",
                           form=form,
                           page_loc="settings")
コード例 #2
0
ファイル: routes.py プロジェクト: jubuc/jubuc
def admin_settings():
    form = SettingsForm()
    admin = db.session.query(Administrator).get(1)
    if request.method == "GET":
        form.username.data = admin.username
        form.first_name.data = admin.first_name
        form.last_name.data = admin.last_name
        form.email.data = admin.email

        form.jumbotron_header.data = admin.jumbotron_header
        form.jumbotron_subheader.data = admin.jumbotron_subheader

        form.desc_details.data = admin.desc_details
        form.desc_header.data = admin.desc_header

        form.about_details.data = admin.about_detail
        form.about_heading.data = admin.about_heading

        form.site_dominant_color.data = admin.site_dominant_color
        form.site_accent_color.data = admin.site_accent_color

        form.facebook.data = admin.facebook
        form.twitter.data = admin.twitter
        form.instagram.data = admin.instagram
        form.soundcloud.data = admin.soundcloud
        form.spotify.data = admin.spotify
        form.youtube.data = admin.youtube

    if form.validate_on_submit():
        admin = db.session.query(Administrator).get(1)
        admin.first_name = form.first_name.data
        admin.last_name = form.last_name.data
        admin.email = form.email.data

        admin.jumbotron_header = form.jumbotron_header.data
        admin.jumbotron_subheader = form.jumbotron_subheader.data
        admin.desc_header = form.desc_header.data
        admin.desc_details = form.desc_details.data

        admin.about_detail = form.about_details.data
        admin.about_heading = form.about_heading.data

        admin.site_dominant_color = form.site_dominant_color.data
        admin.site_accent_color = form.site_accent_color.data
        admin.facebook = form.facebook.data
        admin.twitter = form.twitter.data
        admin.soundcloud = form.soundcloud.data
        admin.spotify = form.spotify.data
        admin.youtube = form.youtube.data
        admin.instagram = form.instagram.data

        db.session.add(admin)
        db.session.commit()

        message = Markup(
            '<div class="alert alert-success alert-dismissible"><button type="button" class="close" data-dismiss="alert">&times;</button>Settings saved</div>'
        )
        flash(message)
        return redirect(url_for('admin_settings'))
    return render_template('admin/settings.html', form=form)
コード例 #3
0
def settings():
    sfo = SettingsForm()

    class Einstellungen:
        pass

    if conf.IPC_FLAG:
        msg = '{"cmd": "get-settings" }'
        queue_c_to_s.put(msg)
        result = queue_s_to_c.get()  # list of dict
        logger.info("/settings: {}".format(msg))

    einstellungen = Einstellungen()
    einstellungen.dauer_manuell = result[1]['val']  # int!

    if sfo.validate_on_submit():
        if isNotBlank(sfo.dauer_manuell.data):
            einstellungen.dauer_manuell = int(sfo.dauer_manuell.data)

        if conf.IPC_FLAG:
            D = {'type': 'manual_delay', 'val': int(sfo.dauer_manuell.data)}
            msg = json.dumps({"cmd": "set-settings", "manual_delay": D})
            logger.info("{}".format(msg))
            queue_c_to_s.put(msg)
            result = queue_s_to_c.get()

        return redirect(url_for('settings'))

    return render_template('settings.html',
                           title='Einstellungen',
                           sfo=sfo,
                           einstellungen=einstellungen)
コード例 #4
0
ファイル: routes.py プロジェクト: rajivghanta/atlas
def settings():
	form = SettingsForm()
	if form.validate_on_submit():
		current_user.secret = form.secret.data
		db.session.commit()
		flash('Secret successfully stored.')
		return redirect(url_for('index'))
	return render_template('settings.html', title='Settings', form=form)
コード例 #5
0
ファイル: routes.py プロジェクト: z0glen/cloud-tracker
def settings():
    form = SettingsForm(obj=current_user)
    if form.validate_on_submit():
        current_user.daily_email = form.daily_email.data
        db.session.commit()
        flash('Your preferences have been updated')
        return redirect(url_for('index'))
    return render_template('settings.html', title='Settings', form=form)
コード例 #6
0
ファイル: views.py プロジェクト: asivokon/hacktus
def settings():
    form = SettingsForm()
    if form.validate_on_submit():
        flash('Settings saved!')
        session['cf_login'] = form.cf_login.data
    else:
        if 'cf_login' in session:
            form.cf_login.data = session['cf_login']
    return render_template('settings.html', form=form, title='Settings')
コード例 #7
0
ファイル: main.py プロジェクト: damienSeffray/LostInNetwork
def settings():
    form = SettingsForm(request.form)
    if form.validate_on_submit():
        if form.newpassword.data and form.oldpassword.data and form.repeat.data:
            current_user.set_password(form.newpassword.data)
            current_user.save()
            flash("Successfully set new password")
        return redirect(url_for('settings'))
    else:
        return render_template("settings.html", form=form)
コード例 #8
0
def settings():
    form = SettingsForm(current_user.username)
    if form.validate_on_submit():
        current_user.username = form.username.data
        db.session.commit()
        flash('Your changes have been saved.')
        return redirect(url_for('settings'))
    elif request.method == 'GET':
        form.username.data = current_user.username
    return render_template('settings.html', title='Edit Profile', form=form)
コード例 #9
0
ファイル: routes.py プロジェクト: Xerronn/CHAI
def setSettings():
    form = SettingsForm()
    if form.validate_on_submit():
        if form.token.data != "":
            current_user.token = form.token.data
            db.session.commit()
            flash(f'New token has been successfully set {current_user.token}')
        if form.passphrase.data != "":
            current_user.grades_password = form.passphrase.data
            db.session.commit()
        return redirect(url_for('index'))
    return render_template('settings.html', title='Settings', form=form)
コード例 #10
0
ファイル: auth.py プロジェクト: deker104/hleber
def settings():
    """Изменение настроек пользователя"""
    form = SettingsForm(obj=current_user)
    next = request.args.get('next')
    if next is None or not is_safe_url(next):
        next = url_for('.settings')
    if form.validate_on_submit():
        current_user.phone = form.phone.data
        current_user.address = form.address.data
        db.session.add(current_user)
        db.session.commit()
        flash('Настройки успешно изменены.')
        return redirect(next)
    return render_template('auth_settings.html', form=form)
コード例 #11
0
def settings():
    user_record = db_base.get_user_record()
    mp.track(f"user_{current_user.id}", "settings visit")

    form = SettingsForm()

    if form.validate_on_submit():
        user_record.name = form.name.data
        user_record.time_zone = form.time_zone.data
        db.session.commit()
        flash("settings updated")
        return redirect(url_for("auth.settings"))

    return render_template("auth/settings.html",
                           form=form,
                           user_record=user_record)
コード例 #12
0
def settings_profile():
    form = SettingsForm(obj=current_user)
    if form.validate_on_submit():
        user = User.query.filter_by(id=int(current_user.id)).first()
        if user is None:
            flash('Error! We could not update your settings.', 'error')
            return redirect(url_for('settings_profile'))

        user.firstname = form.firstname.data
        user.lastname = form.lastname.data
        user.email = form.email.data
        db.session.commit()
        return redirect(url_for('settings_profile'))

    return render_template('settings_profile.html',
                           title='Settings',
                           form=form)
コード例 #13
0
def settings():
    form = SettingsForm(request.form)
    if form.validate_on_submit():
        if form.newpassword.data and form.oldpassword.data and form.repeat.data:
            # Handling the decryption and re-encryption of the passwords in case of a password change
            new_pwdh = PasswordManager.generate_pwdh_from_password(form.newpassword.data)
            for device in Device.query.all():
                # Decrypts the password using the session pwdh and encrypts it with the new pwdh (not in session)
                device.password = PasswordManager.encrypt_string(device.decrypt_password(), new_pwdh)
                device.save(encrypt=False)  # The password is already encrypted
            PasswordManager.set_session_pwdh(form.newpassword.data)
            current_user.set_password(form.newpassword.data)
            current_user.save()
            flash("Successfully set new password", "info")
        return redirect(url_for('settings'))
    else:
        return render_template("settings.html", form=form, active_page="settings")
コード例 #14
0
ファイル: routes.py プロジェクト: ant443/Facebook-clone
def settings():
    del_account_form = DeleteAccountForm()
    settings_form = SettingsForm()
    saved = ""
    if del_account_form.form_identifier.data and del_account_form.validate_on_submit(
    ):
        try:
            user_folder = app.config["UPLOAD_FOLDER"].joinpath(
                str(current_user.id))
            if user_folder.is_dir():
                target_path = app.config["UPLOAD_FOLDER"].joinpath(
                    "scheduled_delete",
                    f"{current_user.id} {int(time.time())}")
                user_folder.rename(target_path)
            db.session.delete(current_user)
            db.session.commit()
            try:
                delete_id_folder_else_log_path(str(current_user.id))
            except Exception as e:
                delete_account_logger.exception(
                    f"Delete folder error for user: {current_user.id} {e}")
            return redirect(url_for("logout"))
        except Exception as e:
            delete_account_logger.exception(f"Delete account error for user: "******"{current_user.id} {e}")
            flash(
                "An unexpected error occured. Please try again, or contact support."
            )
    if settings_form.settings_submit.data and settings_form.validate_on_submit(
    ):
        current_user.settings.preserve_photo_data = settings_form.photo_metadata.data
        try:
            db.session.commit()
            saved = "1"
        except Exception as e:
            flash(
                "An unexpected error occured. Please try again, or contact support."
            )
            general_logger.error(
                f"Problem changing settings for {current_user.id} {e}")
    return render_template('settings.html',
                           delete_account_form=del_account_form,
                           settings_form=settings_form,
                           title="Alienbook",
                           saved=saved)
コード例 #15
0
ファイル: routes.py プロジェクト: TarEnethil/trivia
def settings():
    redirect_non_admins()

    form = SettingsForm()
    settings = GeneralSetting.query.get(1)

    if form.validate_on_submit():
        settings.title = form.title.data

        flash("Settings changed.")

        db.session.commit()
    else:
        form.title.data = settings.title

    categories = Category.query.all()

    return render_template("trivia/settings.html",
                           form=form,
                           categories=categories,
                           title=page_title("Categories"))
コード例 #16
0
ファイル: routes.py プロジェクト: kartoffelus/archivar
def settings():
    form = SettingsForm()
    settings = GeneralSetting.query.get(1)

    if form.validate_on_submit():
        settings.title = form.title.data
        settings.world_name = form.world_name.data
        settings.welcome_page = form.welcome_page.data
        settings.quicklinks = form.quicklinks.data

        flash("Settings changed.", "success")

        db.session.commit()
    else:
        form.title.data = settings.title
        form.world_name.data = settings.world_name
        form.welcome_page.data = settings.welcome_page
        form.quicklinks.data = settings.quicklinks

    return render_template("settings.html",
                           settings=settings,
                           form=form,
                           title=page_title("General Settings"))
コード例 #17
0
ファイル: routes.py プロジェクト: angelinahli/meet-me-2
def settings():
    dct = {"title": "Settings", "current_user": current_user}
    form = SettingsForm()
    dct["form"] = form
    if form.validate_on_submit():
        if form.delete.data:
            username = current_user.username
            logout_user()
            u = User.query.filter_by(username=username).first()
            db.session.delete(u)
            db.session.commit()
            flash("Successfully deleted account!", "info")
            return redirect(url_for("index"))
        elif form.submit.data:
            current_user.username = form.username.data
            current_user.email = form.email.data
            current_user.first_name = form.name.data.split()[0]
            current_user.full_name = form.name.data
            if form.new_password.data:
                current_user.set_password(form.new_password.data)
            db.session.commit()
            flash("Updated settings!", "info")
    return render_template("settings.html", **dct)
コード例 #18
0
def settings():
    form = SettingsForm()
    if form.validate_on_submit():
        flash('Settings Saved')
        return redirect(url_for('index'))
    return render_template('settings.html', title='Settings', form=form)
コード例 #19
0
ファイル: routes.py プロジェクト: jxshi/speciesprimer
def settings():
    target_choice_list, tmp_db = check_targets()
    if len(target_choice_list) == 0:
        flash("Press Start Primerdesign to start primer design")
        return redirect(url_for('controlrun'))

    if tmp_db['new_run']['same_settings']:
        def_path = tmp_db['new_run']['path']
        form = SettingsForm(change_wd=def_path)
        form.targets.choices = [("All targets", "All targets")]
    elif tmp_db['new_run']['change_settings']:
        try:
            form = SettingsForm(data=load_settings(tmp_db))
            form.targets.choices = target_choice_list
        except KeyError as exc:
            flash(" ".join([
                'Setting not found:',
                str(exc), 'maybe you are using an outdated config file'
            ]))
            def_path = tmp_db['new_run']['path']
            form = SettingsForm(change_wd=def_path)
            form.targets.choices = target_choice_list
    else:
        def_path = tmp_db['new_run']['path']
        form = SettingsForm(change_wd=def_path)
        form.targets.choices = target_choice_list

    if form.validate_on_submit():
        if form.reset.data is True:
            reset_form = reset_settings(form)
            return render_template('settings.html',
                                   title='Settings for primerdesign',
                                   form=reset_form)

        settings_data = get_settings(form)
        if tmp_db['new_run']['same_settings']:
            for target in tmp_db['new_run']['targets']:  # for same settings
                config = tmp_db['new_run']['targets'][target]
                new_config = update_db(config, target, settings_data)
                tmp_db['new_run']['targets'][target].update(new_config)
                with open(tmp_db_path, 'w') as f:
                    f.write(json.dumps(tmp_db))
        else:
            for target in [form.targets.data]:
                config = tmp_db['new_run']['targets'][target]
                new_config = update_db(config, target, settings_data)
                tmp_db['new_run']['targets'][target].update(new_config)
                with open(tmp_db_path, 'w') as f:
                    f.write(json.dumps(tmp_db))

        if tmp_db['new_run']['same_settings']:
            flash('Saved settings for {}'.format(
                " & ".join(target_choice_list)))
            flash("Press Start Primerdesign to start primer design for " +
                  " & ".join(target_choice_list))
            return redirect(url_for('controlrun'))
        if tmp_db['new_run']['change_settings']:
            conf_path = tmp_db['new_run']['targets'][target]['path']
            save_to = os.path.join(conf_path, target, "config", "config.json")
            try:
                with open(save_to, 'w') as f:
                    f.write(json.dumps(new_config))
                flash('Changed settings for {}'.format(' '.join(
                    target.split('_'))))
                flash(json.dumps(new_config))
                flash("Press Start Primerdesign to start primer design for " +
                      ' '.join(target.split('_')))
                return redirect(url_for('controlrun'))
            except FileNotFoundError:
                flash("The selected directory does not exist")
                return redirect(url_for('settings'))

        else:
            flash('Saved settings for {}'.format(' '.join(target.split('_'))))
        flash(json.dumps(new_config, sort_keys=True))
        return redirect(url_for('settings'))

    return render_template('settings.html',
                           title='Settings for primerdesign',
                           form=form)