Ejemplo n.º 1
0
def chart_edit():
    id = flask.request.args.get('id', default=None, type=int)

    if flask.request.method == "GET":

        session = db_session.create_session()
        try:
            chart_types = get_objects(ChartType, session)
            data_obj = search_object(id, Chart, session)
        except Exception as error:
            print(str(error))
        finally:
            session.close()

        return flask.render_template('chart_edit.html',
                                     item_type='chart',
                                     data_obj=data_obj,
                                     back_link=flask.request.referrer,
                                     chart_types=chart_types)

    if flask.request.method == "POST":
        data = flask.request.form
        session = db_session.create_session()
        try:
            save_object('chart', id, data, session)
            session.commit()
        except Exception as error:
            print(str(error))
        finally:
            session.close()
        return flask.redirect('/chart')
Ejemplo n.º 2
0
def user_group_edit():
    id = flask.request.args.get('id', default=None, type=int)
    user_id = flask.request.args.get('user_id', default=None, type=int)

    if flask.request.method == "GET":

        session = db_session.create_session()
        try:
            user = search_object(user_id, User, session)
            groups = get_objects(Group, session)
        except Exception as error:
            print(str(error))
        finally:
            session.close()

        return flask.render_template('user_group_edit.html',
                                     item_type='user_group',
                                     user=user,
                                     back_link=flask.request.referrer,
                                     groups=groups)

    if flask.request.method == "POST":
        data = flask.request.form
        session = db_session.create_session()
        try:
            save_object('user_group', id, data, session)
            session.commit()
        except Exception as error:
            print(str(error))
        finally:
            session.close()
        return flask.redirect('/user/user_group/edit?user_id=' + str(user_id))
Ejemplo n.º 3
0
def group_edit():
    id = flask.request.args.get('id', default=None, type=int)
    if flask.request.method == "GET":

        session = db_session.create_session()
        try:
            group_categories = get_objects(GroupCategory, session)
            data_obj = search_object(id, Group, session)
        except Exception as error:
            print(str(error))
        finally:
            session.close()

        return flask.render_template('edit_group.html',
                                     item_type='group',
                                     data_obj=data_obj,
                                     back_link=flask.request.referrer,
                                     group_categories=group_categories)

    if flask.request.method == "POST":
        data = flask.request.form
        session = db_session.create_session()
        try:
            save_object('group', id, data, session)
            session.commit()
        except Exception as error:
            print(str(error))
        finally:
            session.close()
        return flask.redirect('/group/group?category_id=' +
                              str(data["group_category_id"]))
Ejemplo n.º 4
0
def reset():
    id = flask.request.args.get('id', default=None, type=int)

    if flask.request.method == "GET":

        session = db_session.create_session()
        try:
            data_obj = search_object(id, User, session)
        except Exception as error:
            print(str(error))
        finally:
            session.close()

        return flask.render_template('user/edit_user.html',
                                     item_type='user',
                                     data_obj=data_obj,
                                     back_link=flask.request.referrer)

    if flask.request.method == "POST":
        data = flask.request.form
        session = db_session.create_session()
        try:
            save_object('user', id, data, session)
            session.commit()
        except Exception as error:
            print(str(error))
        finally:
            session.close()

        return flask.redirect('/user')
Ejemplo n.º 5
0
def schedule_edit():
    id = flask.request.args.get('id', default=None, type=int)
    schedule_id = flask.request.args.get('schedule_id', default=None, type=int)

    if flask.request.method == "GET":

        session = db_session.create_session()
        try:
            schedule = search_object(schedule_id, Schedule, session)
            queries = get_objects(Query, session)
        except Exception as error:
            print(str(error))
        finally:
            session.close()

        return flask.render_template('schedule_step_edit.html',
                                     item_type='schedule_step',
                                     schedule=schedule,
                                     back_link=flask.request.referrer,
                                     queries=queries)

    if flask.request.method == "POST":
        data = flask.request.form
        session = db_session.create_session()
        try:
            save_object('schedule_step', id, data, session)
            session.commit()
        except Exception as error:
            print(str(error))
        finally:
            session.close()
        return flask.redirect('/schedule/schedule_step/edit?schedule_id=' +
                              str(schedule_id))
Ejemplo n.º 6
0
def dashboard_chart_edit():
	id = flask.request.args.get('id', default = None, type = int)
	dashboard_id = flask.request.args.get('dashboard_id', default = None, type = int)

	if flask.request.method == "GET":

		session = db_session.create_session()
		try:
			charts = get_objects(Chart, session)
			dashboard = search_object(dashboard_id, Dashboard, session)
		except Exception as error:
			print(str(error))
		finally:
			session.close()

		return flask.render_template(
			'dashboard_chart_edit.html'
			, item_type = 'dashboard_chart'
			, dashboard = dashboard
			, back_link = flask.request.referrer
			, charts = charts

			)

	if flask.request.method == "POST":
		data = flask.request.form		
		session = db_session.create_session()
		try:
			save_object('dashboard_chart', id, data, session)
			session.commit()
		except Exception as error:
			print(str(error))
		finally:
			session.close()
		return flask.redirect('/dashboard/dashboard_chart/edit?dashboard_id=' + str(dashboard_id))
Ejemplo n.º 7
0
def edit():
	id = flask.request.args.get('id', default = None, type = int)
	
	if flask.request.method == "GET":
	
		session = db_session.create_session()
		try:
			request_methods = get_objects(RequestMethod, session)
			data_obj = search_object(id, Endpoint, session)
		except Exception as error:
			print(str(error))
		finally:
			session.close()

	
		return flask.render_template(
			'edit.html'
			, item_type = 'endpoint'
			, data_obj = data_obj
			, back_link = flask.request.referrer
			, request_methods = request_methods
			)

	if flask.request.method == "POST":
		data = flask.request.form
		session = db_session.create_session()
		try:
			save_object('endpoint', id, data, session)
			session.commit()
		except Exception as error:
			print(str(error))
		finally:
			session.close()
		return flask.redirect('/api')
Ejemplo n.º 8
0
def edit(item_type: str):
    id = flask.request.args.get('id', default=None, type=int)
    if flask.request.method == "GET":

        session = db_session.create_session()
        try:
            locations = get_objects(Location, session)
            subtypes = get_objects(Subtype, session)
            request_methods = get_objects(RequestMethod, session)
            location_types = get_objects(LocationType, session)
            data_obj = search_object(id, type_variables[item_type + "_class"],
                                     session)
        except Exception as error:
            print(str(error))
        finally:
            session.close()

        return flask.render_template(type_variables[item_type + "_template"],
                                     item_type=item_type,
                                     back_link=flask.request.referrer,
                                     locations=locations,
                                     subtypes=subtypes,
                                     request_methods=request_methods,
                                     location_types=location_types,
                                     data_obj=data_obj)

    if flask.request.method == "POST":
        data = flask.request.form
        session = db_session.create_session()
        try:
            save_object(item_type, id, data, session)
            session.commit()
        except Exception as error:
            print(str(error))
        finally:
            session.close()
        return flask.redirect('/process')