Exemplo n.º 1
0
from django.http import HttpResponseBadRequest
from ninja import Router
import records.models
import cal.schemas

from typing import List

from security.api import AuthBearer

router = Router()

@router.post('/post_record', auth=AuthBearer())
def post_cal_record(request, r: cal.schemas.CalendarRecordIn):
    try:
        if r.note.__len__() < 4:
            raise ValueError('Note must contain at least 4 chars')
        record = r.get_object()
        record.owner_token = request.auth.owner_token
        record.save()
    except ValueError as e:
        return {'result': 'error', 'code': 1, 'info': f'{e}'}
    except Exception as e:
        print(f'Failed to post record: {e}')
        return {'result': 'error', 'code': 2}
    else:
        return {'result': 'success', 'code': 0}


@router.get('/get_record', response=cal.schemas.CalendarRecordOut, auth=AuthBearer())
def get_cal_record(request, id: int):
    try:
Exemplo n.º 2
0
from django.http import HttpResponseBadRequest
from ninja import Router
import records.models
import archive.schemas

from typing import List

from security.api import AuthBearer

router = Router()


@router.post('/post_record', auth=AuthBearer())
def post_archive_record(request, r: archive.schemas.ArchiveRecordIn):
    try:
        if r.note.__len__() < 4:
            raise ValueError('Note must contain at least 4 chars')
        record = r.get_object()
        record.owner_token = request.auth.owner_token
        record.save()
    except ValueError as e:
        return {'result': 'error', 'code': 1, 'info': f'{e}'}
    except Exception as e:
        print(f'Failed to post record: {e}')
        return {'result': 'error', 'code': 2}
    else:
        return {'result': 'success', 'code': 0}


@router.get('/get_record',
            response=archive.schemas.ArchiveRecordOut,
Exemplo n.º 3
0
from django.http import HttpResponseBadRequest
from ninja import Router
import records.models
import wait.schemas

from typing import List

from security.api import AuthBearer

router = Router()


@router.post('/post_record', auth=AuthBearer())
def post_wait_record(request, r: wait.schemas.AwaitRecordIn):
    try:
        if r.note.__len__() < 4:
            raise ValueError('Note must contain at least 4 chars')
        record = r.get_object()
        record.owner_token = request.auth.owner_token
        record.save()
    except ValueError as e:
        return {'result': 'error', 'code': 1, 'info': f'{e}'}
    except Exception as e:
        print(f'Failed to post record: {e}')
        return {'result': 'error', 'code': 2}
    else:
        return {'result': 'success', 'code': 0}


@router.get('/get_record',
            response=wait.schemas.AwaitRecordOut,
Exemplo n.º 4
0
from django.http import HttpResponseBadRequest
from ninja import Router
import records.models
import crate.schemas
import wait.schemas
import wait.api

from typing import List
from datetime import datetime, timedelta, date

from security.api import AuthBearer

router = Router()


@router.post('/post_record', auth=AuthBearer())
def post_crate_record(request, r: crate.schemas.CrateRecordIn):
    try:
        if r.note.__len__() < 4:
            raise ValueError('Note must contain at least 4 chars')
        record = r.get_object()
        record.owner_token = request.auth.owner_token
        record.save()
    except ValueError as e:
        return {'result': 'error', 'code': 1, 'info': f'{e}'}
    except Exception as e:
        print(f'Failed to post record: {e}')
        return {'result': 'error', 'code': 2}
    else:
        return {'result': 'success', 'code': 0}
Exemplo n.º 5
0
from django.http import HttpResponseBadRequest
from ninja import Router
import records.models
import projects.schemas

from typing import List

from security.api import AuthBearer

from crate.api import post_crate_record
import records.models

router = Router()


@router.post('/post_record', auth=AuthBearer())
def post_projects_record(request, r: projects.schemas.ProjectRecordIn):
    try:
        if r.note.__len__() < 4:
            raise ValueError('Note must contain at least 4 chars')
        record = r.get_object()
        record.owner_token = request.auth.owner_token
        record.save()
    except ValueError as e:
        return {'result': 'error', 'code': 1, 'info': f'{e}'}
    except Exception as e:
        print(f'Failed to post record: {e}')
        return {'result': 'error', 'code': 2}
    else:
        return {'result': 'success', 'code': 0}
Exemplo n.º 6
0
from django.http import HttpResponseBadRequest
from ninja import Router
import records.models
import notes.schemas

from typing import List

from security.api import AuthBearer

router = Router()


@router.post('/post_record', auth=AuthBearer())
def post_notes_record(request, r: notes.schemas.NotesRecordIn):
    try:
        if r.note.__len__() < 4:
            raise ValueError('Note must contain at least 4 chars')
        record = r.get_object()
        record.owner_token = request.auth.owner_token
        record.save()
    except ValueError as e:
        return {'result': 'error', 'code': 1, 'info': f'{e}'}
    except Exception as e:
        print(f'Failed to post record: {e}')
        return {'result': 'error', 'code': 2}
    else:
        return {'result': 'success', 'code': 0}


@router.get('/get_record', response=notes.schemas.NotesRecordOut, auth=AuthBearer())
def get_notes_record(request, id: int):