예제 #1
0
def add_note():
    user_id = get_jwt_identity()

    body = request.get_json()

    user = User.objects.get(id=user_id)
    note = Note(**body, added_by=user)
    note.save()

    response = make_response({"status": "success", "note": note})

    return response
예제 #2
0
파일: note.py 프로젝트: zenolab/Web-Notes
 def post(self):
     try:
         user_id = get_jwt_identity()
         body = request.get_json()
         user = User.objects.get(id=user_id)
         note = Note(**body, added_by=user)
         note.save()
         user.update(push__notes=note)
         user.save()
         id = note.id
         return {'id': str(id)}, 200
     except (FieldDoesNotExist, ValidationError):
         raise SchemaValidationError
     except NotUniqueError:
         raise NoteAlreadyExistsError
     except Exception as e:
         raise InternalServerError
예제 #3
0
def add_note():
    description = request.json['description']
    title = request.json['title']
    rentalID = request.json['rentalID']
    rental = dq.getRentalByRentalID(rentalID)
    board = rental.board
    category = request.json['category']
    note = Note(description=description, title=title, board=board,
                category=category)
    dq.add(note)
    return jsonify({}), 201
예제 #4
0
def add_note(note, meeting_id, student_id, time, status=None):
    '''
    '''
    new_note = Note(details=note,
                    status=status,
                    meeting_id=meeting_id,
                    student_id=student_id,
                    time=time)
    db.session.add(new_note)
    db.session.commit()
    print('Note added')
예제 #5
0
 def get(self):
     nott = Note.objects().to_json()
     return Response(nott, mimetype="application/json", status=200)
예제 #6
0
 def post(self):
     body = request.get_json()
     print("bbbb", body)
     nott = Note(**body).save()
     id = nott.id
     return {'id': str(id)}, 200
예제 #7
0
def get_notes():
    user_id = get_jwt_identity()
    notes = Note.objects(added_by=user_id)
    response = make_response({"status": "success", "notes": notes})
    return response, 200