示例#1
0
	def handle(self, *args, **options):
		print("Board title?")
		title = input()

		print("Board letter?")
		letter = input()

		board = Boards(board_title=title, board_letter=letter)
		board.save()
示例#2
0
def view(request,board_id):
	boards = Boards.objects.get(board_id=board_id)
	if request.method == 'POST':
		content = request.POST.get('comment_contents',None)
		email = request.session['email']
		info = Info.objects.get(email=email)
		comment = Boards()
		comment.board_pid = board_id
		comment.user_id = email
		comment.user_name = info.last_name
		comment.subject = ""
		comment.contents = content
		comment.hits = 0
		comment.save()
		lists = Boards.objects.all().filter(board_pid=board_id)
		return render(request,'board/view.html',{"lists":lists,"bd":boards})
	else:
		boards.hits += 1
		boards.save()
		comment = Boards.objects.all().filter(board_pid=board_id)
		return render(request,'board/view.html',{"lists":comment,"bd":boards})
示例#3
0
def post_write(request, store_id):
    authId = request.session.get('_auth_user_id')
    userinfo = Userinfo.objects.get(id=authId)
    store = Stores.objects.get(id=int(store_id))

    if request.method == "POST":
        form = BoardsForm(request.POST, request.FILES)
        if form.is_valid():
            # 게시글 먼저 등록
            post = Boards()
            post.store = store
            post.writer = userinfo
            post.writer_name = userinfo.name
            post.title = request.POST.get('title')
            post.content = request.POST.get('content')
            post.thumbnail = request.POST.get('thumbnail')
            post.views = 0
            post.date_posted = timezone.now()

            post.save()

            # 등록된 게시글 통해 item 등록
            uploadedPost = Boards.objects.get(writer=post.writer,
                                              date_posted=post.date_posted)

            itemname = request.POST.getlist('itemname[]')
            itemprice = request.POST.getlist('itemprice[]')
            # itemcount = request.POST.getlist('itemcount[]')

            for name, price in zip(itemname, itemprice):
                item = Items()
                item.name = name
                item.price = price
                item.board_id = uploadedPost
                item.store_id = store
                item.save()

            # 등록된 게시글에 item항목 추가
            itemList = Items.objects.filter(board_id=uploadedPost)

            itemId = ''
            for idx in itemList:  # item 번호 이어 붙이기
                itemId += str(idx.id) + ','

            uploadedPost.item = itemId
            uploadedPost.save()

            return redirect(
                reverse('mainpage:detailStore', kwargs={'store_id': store_id}))

    else:
        form = BoardsForm()

    context = {'store': store, 'form': form}
    return render(request, 'mainpage/post_write.html', context)