示例#1
0
    def patch(self, student_id, application_id):
        parser = reqparse.RequestParser()
        parser.add_argument('state')
        application_args = parser.parse_args()
        state = application_args.get('state')

        if state is None:
            error_dict = {
                'error_message': f'Empty payload',
            }
            LOGGER.error(error_dict)
            return error_dict, 400

        if state not in APPLICATION_STATES:
            error_dict = {
                'error_message': f'Invalid state {state}',
            }
            LOGGER.error(error_dict)
            return error_dict, 400
        try:
            application = Application.get(id=application_id,
                                          student=student_id)
            application.state = state
            application.save()
            return application
        except DoesNotExist:
            error_dict = {
                'error_message':
                f'Application with id `{application_id}` does not exist'
                f' for student with id {student_id}',
            }
            LOGGER.error(error_dict)
            return error_dict, 400
示例#2
0
    def get(self, student_id, application_id):
        # check student exists
        try:
            Student.get(id=student_id)
        except DoesNotExist:
            error_dict = {
                'error_message':
                f'Student with id {student_id} does not exist',
            }
            LOGGER.error(error_dict)
            return error_dict, 400

        try:
            return Application.get(id=application_id, student=student_id)
        except DoesNotExist:
            error_dict = {
                'error_message':
                f'Application with id `{application_id}` does not exist'
                f' for student with id {student_id}',
            }
            LOGGER.error(error_dict)
            return error_dict, 400
    def get(self, company_id, job_id, application_id):
        # check job exists
        try:
            Job.get(id=job_id, company=company_id)
        except DoesNotExist:
            error_dict = {
                'error_message':
                f'Job with id {job_id} does not exist for company {company_id}',
            }
            LOGGER.error(error_dict)
            return error_dict, 400

        try:
            return Application.get(id=application_id, job=job_id)
        except DoesNotExist:
            error_dict = {
                'error_message':
                f'Application with id `{application_id}` does not exist'
                f' for job with id {job_id}',
            }
            LOGGER.error(error_dict)
            return error_dict, 400
示例#4
0
    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()

    self.dialog_update.action('hide', ['0'])

elif command == 'create':
    form = ApplicationCreate(name=args.get('title', ''),
                             workspace_id=workspace.guid)
示例#5
0
from models import Application, View
from forms import ViewCreateForm, ViewUpdateForm

args = request.arguments

error_objects = dict(
    name=self.dialog_update.form_update.tab_view_detail.tab_params.error_name,
)

if 'application_id' not in args:
    raise Exception('Application ID is not provided')

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

app = Application.get(guid=application_id)

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

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

    if 'view_id' not in args:
        raise Exception(u'View ID is not provided')

    for error_key, error_object in error_objects.items():
        error_object.action('setText', [''])

    view_id = args['view_id']
    app_view = View.get(guid=view_id, application_id=app.guid)
示例#6
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
 def v_getnamebyguid(self, app_guid=None):
     app = Application.get(guid=app_guid)
     return "<not_found>" if not app else app.name