예제 #1
0
def workspace_test():
	print_data('workspaces objects', br=False)

	for index in range(3):
		w = Workspace()
		w.name = 'New workspace name'
		w.description = 'Some new description'
		w.save()

	workspaces = Workspace.all()
	print_data('new objects -> model.all()', workspaces)

	w.name = 'Updated name'
	w.save()

	workspaces = Workspace.all()
	print_data('UPDATED -> model.all()', workspaces)

	workspaces = Workspace.get(id=w.id, name=w.name)
	print_data('GET -> model.get()', [workspaces])

	workspaces = Workspace.filter(name='New workspace name')
	print_data('FILTER -> model.filter()', workspaces)

	for index in range(2):
		o = Application()
		o.workspace_id = w.guid
		o.save()

	a = View()
	a.application_id = o.guid
	a.save()

	a = Resource()
	a.application_id = o.guid
	a.save()

	for index in range(3):
		o = Widget()
		o.workspace_id = w.guid
		o.save()

	for index in range(3):
		o = DataSource()
		o.workspace_id = w.guid
		o.save()

	objects = Workspace.all() + Resource.all() + Application.all() + Widget.all() + DataSource.all() + View.all()
	print_data('All objects in db', objects)

#	[w.delete() for w in Workspace.all()]
	workspaces = Workspace.all()
	print_data('cleaned', workspaces)

	workspaces = Workspace.filter(include_deleted=True)
	print_data('cleaned with deleted if exists', workspaces)

	objects = Workspace.all() + Resource.all() + Application.all() + Widget.all() + DataSource.all() + View.all()
	print_data('no objects left', objects)
예제 #2
0
from models import Application, Workspace
from forms import ApplicationCreate

args = request.arguments

if 'workspace_id' not in args:
    raise Exception('Workspace ID is not provided')

workspace_id = args.get('workspace_id')
command = args.get('command', u'')

workspace = Workspace.get(guid=workspace_id)

if not workspace:
    self.action('goTo', ['/main'])

elif command in ['delete', 'update']:

    if 'application_id' not in args:
        raise Exception(u'Application ID is not provided')
    application_id = args['application_id']
    app = Application.get(guid=application_id, workspace_id=workspace.guid)

    if app:
        if command == 'delete':
            app.delete()
        else:
            title = args['title']
            if title:
                app.name = title
                app.save()
예제 #3
0
from models import Application, Workspace, Resource, AppScript
from templates import (ViewTemplateCollection, RoleTemplateCollection,
                       RightTemplateCollection, ResourceListTemplate,
                       ScriptTemplateCollection)
from urls import reverse

application_id = request.arguments.get('application_id')
app = Application.get(guid=application_id) if application_id else None
if app:
    self.tab_app.tab_view.hpt_views.htmlcode = ViewTemplateCollection(
        app.views, many=True, add_new=True).html
    self.tab_app.tab_resources.hpt_resources.htmlcode = ResourceListTemplate(
        app.resources, add_new=True).html
    self.tab_app.tab_script.hpt_scripts.htmlcode = ScriptTemplateCollection(
        app.scripts, add_new=True).html

workspace_id = request.arguments.get('workspace_id')
workspace = Workspace.get(guid=workspace_id) if workspace_id else None
if workspace:
    self.tab_app.tab_roles.hpt_roles.htmlcode = RoleTemplateCollection(
        workspace.roles, many=True, add_new=True).html
    self.tab_app.tab_roles.hpt_roles.htmlcode += RightTemplateCollection(
        workspace.rights, many=True, add_new=True).html