def board_write(request): if request.method == "POST": if not request.body is None: if User.objects.filter(user = request.POST['user']).exists() : d = timezone.localtime(timezone.now()) board = Board(user = User.objects.get(user = request.POST['user']), title = request.POST['title'], content = request.POST['content'], cost = request.POST['cost'], item = request.POST['item'], date = d.strftime('%Y-%m-%d') ) board.save() if not request.FILES.getlist('image') is None: for f in request.FILES.getlist('image'): boardImage = BoardImage(board = board, image = f ) boardImage.save() return JSONResponse('') else : return HttpResponse(status=400) else : return HttpResponse(status=400) else : return HttpResponse(status=400)
def post(data): board = Board() board.title = data.get('title') board.description = data.get('description') board.save() access = BoardAccessMatrix() access.board = board access.user = User.objects.get(email=data.get('email')) access.level = 'admin' access.save() return board
def add_board(request): print('add_board_test1') #게시물 작성 후 리다이렉트 print(request.POST.get("board_title")) print(request.POST.get("board_content")) board = Board( board_title=request.POST.get("board_title"), board_content=request.POST.get("board_content"), ) # db에 반영 board.save() # 게시물 목록으로 리다이렉트 return redirect("/get_board_list")
def post(self): data = parser.parse_args() name = data['name'] owner_id = data['owner_id'] try: new_board = BoardModel( name=name, owner_id=uuid.UUID(owner_id) ) new_board.save() return { 'board': marshal(new_board, permitted) }, HTTPStatus.CREATED except Exception as error: return { 'message': str(error) }, HTTPStatus.INTERNAL_SERVER_ERROR
def board_write(request): if request.method == "POST": if not request.body is None: if User.objects.filter(user=request.POST['user']).exists(): d = timezone.localtime(timezone.now()) board = Board(user=User.objects.get(user=request.POST['user']), title=request.POST['title'], content=request.POST['content'], cost=request.POST['cost'], item=request.POST['item'], date=d.strftime('%Y-%m-%d')) board.save() if not request.FILES.getlist('image') is None: for f in request.FILES.getlist('image'): boardImage = BoardImage(board=board, image=f) boardImage.save() return JSONResponse('') else: return HttpResponse(status=400) else: return HttpResponse(status=400) else: return HttpResponse(status=400)