Ejemplo n.º 1
0
    def test_board_post_connections(self):
        """Make sure that posts to a board are properly associated and posts can be found."""
        i1 = Image(name="1", photo=bytearray("1", "utf-8"))
        i2 = Image(name="2", photo=bytearray("2", "utf-8"))
        i3 = Image(name="3", photo=bytearray("3", "utf-8"))
        i1.save()
        i2.save()
        i3.save()

        b1 = Board(title="foo", description="bar", bg=i1)
        b2 = Board(title="foo2", description="bar", bg=i2)
        b1.save()
        b2.save()

        p1 = Post(associated_board=b1, name="a", message="b")
        p2 = Post(associated_board=b1, name="a", photo=i3)
        p3 = Post(associated_board=b2, name="a", message="b")
        p4 = Post(associated_board=b1, name="a", message="b")
        p1.save()
        p2.save()
        p3.save()
        p4.save()

        self.assertQuerysetEqual(b1.post_set.all(), [p1, p2, p4],
                                 ordered=False)
        self.assertQuerysetEqual(b2.post_set.all(), [p3], ordered=False)
Ejemplo n.º 2
0
    def test_post_creation_combinations(self):
        """Make sure that creating posts in different combinations doesn't break anything."""
        i1 = Image(name="1", photo=bytearray("1", "utf-8"), uuid=uuid.uuid4())
        i2 = Image(name="2", photo=bytearray("2", "utf-8"))
        i3 = Image(name="3", photo=bytearray("3", "utf-8"))
        i4 = Image(name="2", photo=bytearray("2", "utf-8"))
        i5 = Image(name="3", photo=bytearray("3", "utf-8"))
        i1.save()
        i2.save()
        i3.save()
        i4.save()
        i5.save()

        b1 = Board(title="foo", description="bar", bg=i1)
        b2 = Board(title="green eggs", description="and ham")
        b1.save()
        b2.save()

        # just make sure that none of these throw an exception when creating
        p1 = Post(associated_board=b1, message="post1")
        p2 = Post(associated_board=b1, name="author2", photo=i2)
        p3 = Post(associated_board=b1, photo=i3)
        p4 = Post(associated_board=b1,
                  name="author4",
                  message="post4",
                  photo=i4)
        p5 = Post(associated_board=b1, message="post5", photo=i5)

        p1.save()
        p2.save()
        p3.save()
        p4.save()
        p5.save()
Ejemplo n.º 3
0
def board_edit(request, board_id=None):

    user = request.user.pk
    user_type = request.user.profile.type

    if board_id:
        board = get_object_or_404(Board, pk=board_id)
    else:
        board = Board()

    if request.method == "POST":
        # POST 된 request 데이터를 가지고 Form 생성
        form = BoardForm(request.POST, instance=board)
        if form.is_valid():
            board = form.save(commit=False)
            board.board_id = Board(board_id)
            board.writer = User(user)
            if not board_id:
                board.category = user_type
            board.save()
            # request 없이 페이지 이동만 한다.
        return redirect('board:list')
    else:
        # book instance에서 Form 생성
        form = BoardForm(instance=board)
        # 사용자의 request를 가지고 이동한다.
        return render(request, 'board/board_edit.html',
                      dict(form=form, board=board))
Ejemplo n.º 4
0
    def test_board_post_image_connections(self):
        """Make sure that boards and posts and their connections to an image does not throw errors."""
        b1 = Board(title="board1", description="bar")
        b1.save()

        i2 = Image(name="foo", photo=bytearray("bar", "utf-8"))
        i3 = Image(name="ham", photo=bytearray("sam", "utf-8"))
        i2.save()
        i3.save()

        b2 = Board(title="board2", description="foo", bg=i2)
        b2.save()

        self.assertIs(b2.bg, i2)
        self.assertIs(i2.board, b2)

        p1 = Post(associated_board=b2, name="p1", message="m1")
        p2 = Post(associated_board=b2,
                  name="p1",
                  message="m1",
                  photo=Image(name="spam", photo=bytearray("eggs",
                                                           "utf-8")).save())
        p3 = Post(associated_board=b2, name="p1", message="m1", photo=i3)
        p1.save()
        p2.save()
        p3.save()

        self.assertIs(p3.photo, i3)
        self.assertIs(i3.post, p3)
        self.assertIs(p2.photo.name, "spam")
Ejemplo n.º 5
0
def insert(request):
    fname = ""
    fsize = 0
    if "file" in request.FILES:
        file = request.FILES["file"]
        fname = file.name
        fsize = file.size
        fp = open("%s%s" % (UPLOAD_DIR, fname), "wb")
        for chunk in file.chunks():
            fp.write(chunk)
            fp.close()

    dto = Board(writer=request.POST["writer"], title=request.POST["title"],
                content=request.POST["content"], filename=fname, filesize=fsize,
                video_url=request.POST["video_url"],
                section_school=request.POST["section_school"],
                section_subject=request.POST["section_subject"],
                section_semester=request.POST["section_semester"],
                grade=request.POST["grade"],
                th_high=request.POST["th_high"],
                th_medium=request.POST["th_medium"],
                th_default=request.POST["th_default"]
                )
    dto.save()

    return redirect("/")
Ejemplo n.º 6
0
def insert(request):
    # 파일 업로드 작업
    fname = ""
    fsize = 0
    # 업로드된 파일이 있으면
    if "file" in request.FILES:
        # <input type="file">태그의 name
        file = request.FILES["file"]
        # 첨부파일의 이름
        fname = file._name

        # wb : 이진파일 쓰기 모드
        fp = open("%s%s" % (UPLOAD_DIR, fname), "wb")
        # 파일을 몇개의 뭉치로 나눠서 저장
        for chunk in file.chunks():
            fp.write(chunk)
        fp.close()

        # 첨부파일의 크기(업로드 완료 후 계산)
        fsize = os.path.getsize(UPLOAD_DIR + fname)

    vo = Board(writer=request.POST["writer"],
               title=request.POST["title"],
               content=request.POST["content"],
               filename=fname,
               filesize=fsize)

    # insert query가 실행됨
    vo.save()
    # django의 콘솔에 출력됨
    print(vo)
    # 목록으로 이동
    return redirect("/")
Ejemplo n.º 7
0
def reply(request):
    boardid = request.GET['id']
    parent_board = Board.objects.get(id=boardid)
    newreply = Board()
    newreply.group_no = parent_board.group_no

    #group = Board.objects.all().filter(group_no=parent_board.group_no)

    if parent_board.order_no == 1:
        # 제일 윗 글에 답글 달 때
        max_order_no = Board.objects.filter(
            group_no=parent_board.group_no).aggregate(Max('order_no'))
        newreply.order_no = max_order_no['order_no__max'] + 1
        newreply.depth = 1
    else:
        # 답글이 여러개 일 때
        if parent_board.depth >= 1:
            # 답글에 답글이 없을 때
            oth_reply = Board.objects.all().filter(
                order_no__gt=parent_board.order_no)
            oth_reply.update(order_no=F('order_no') + 1)
            newreply.order_no = parent_board.order_no + 1
            newreply.depth = parent_board.depth + 1

    newreply.userid_id = request.GET['userid']
    newreply.title = request.POST['title']
    newreply.content = request.POST['content']
    newreply.save()

    pagenum = request.session['pagenum']

    return HttpResponseRedirect("/board/list?page={}".format(pagenum))
Ejemplo n.º 8
0
def write(request):
    # user = models.ForeignKey(User, to_field='id', on_delete=models.CASCADE)
    board = Board()
    board.title = request.POST['title']
    board.content = request.POST['content']
    userid = request.session['authUser']['id']
    user = User.objects.get(id=userid)
    board.user = user

    if request.POST['groupno'] != '':
        print('request.POST[groupno] !=')
        board.groupno = request.POST['groupno']
        board.depth = int(request.POST['depth']) + 1
        board.orderno = int(request.POST['orderno']) + 1
    else:
        max_board = Board.objects.aggregate(max_groupno=Max('groupno'))
        if max_board is not None:
            max_groupno = 0 if max_board['max_groupno'] is None else max_board[
                "max_groupno"]
            board.groupno = max_groupno + 1
        else:
            board.groupno = 1

    board.save()

    return HttpResponseRedirect('/board')
Ejemplo n.º 9
0
def insert(request):
    if 'authuser' not in request.session:
        return HttpResponseRedirect('/board')

    board = Board()

    board.title = request.POST['title']
    board.content = request.POST['content']
    board.user = User(**request.session['authuser'])

    # 그룹번호 1부터 시작
    groupno = int(request.POST['groupno'])
    if groupno == 0:
        value = Board.objects.aggregate(max_groupno=Max('groupno'))
        groupno = 1 if value[
            'max_groupno'] is None else value['max_groupno'] + 1
    board.groupno = groupno

    orderno = 0 if request.POST['groupno'] == '0' else int(
        request.POST['orderno'])
    Board.objects.filter(groupno=groupno).filter(
        orderno__gte=orderno + 1).update(orderno=F('orderno') + 1)
    board.orderno = orderno + 1

    board.depth = 0 if request.POST['groupno'] == '0' else int(
        request.POST['depth']) + 1

    board.save()

    page = request.POST['page']
    kwd = request.POST['kwd']

    return HttpResponseRedirect(f'/board/list?page={page}&kwd={kwd}')
Ejemplo n.º 10
0
def write(request, page=1):
    # 인증
    authuser = request.session.get('authUser')
    if authuser is None:
        return HttpResponseRedirect('/board/list')
    board = Board()
    board.title = request.POST['title']
    board.content = request.POST['content']
    board.user = User.objects.get(id=request.session['authUser']['id'])

    # 새글 작성
    if request.POST['no'] == '-1':
        value = Board.objects.aggregate(max_groupno=Max('groupno'))
        board.groupno = value["max_groupno"] + 1
        board.save()
    # 답글 작성
    else:
        board2 = Board.objects.get(id=request.POST['no'])
        Board.objects.filter(orderno__gte=board2.orderno +
                             1).update(orderno=F('orderno') + 1)
        board.groupno = board2.groupno
        board.orderno = board2.orderno + 1
        board.depth = board2.depth + 1
        board.save()
    data = {'page': 1}
    # 검색어
    kwd = request.GET.get('kwd')
    print(kwd, "@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@")
    if kwd is None:
        data['kwd'] = json.dumps(kwd)
    else:
        data['kwd'] = kwd
    return HttpResponseRedirect(f'/board/list/{page}?kwd={kwd}')
Ejemplo n.º 11
0
    def test_get_posts_optional_fields(self):
        """Get posts that does have every field"""
        b = Board(title='hi', description='hello')
        b.save()

        posts = [
            Post(associated_board=b, message='hi', created_at=timezone.now()),
            Post(associated_board=b,
                 name='shari',
                 message='cool',
                 created_at=timezone.now() - timezone.timedelta(1)),
            Post(
                associated_board=b,
                name='joseph',
                photo=Image(name='i', photo=bytearray('b', 'utf-8')).save(),
                created_at=timezone.now() - timezone.timedelta(2),
            ),
        ]
        exp = []
        for p in posts:
            exp.append(get_post_dict(p))
            p.save()

        res = self.client.get(
            reverse('board:posts-get'),
            {
                'board': str(b.uuid),
                'index': '0',
                'amount': '10',
            },
            HTTP_ACCEPT='application/json',
        )
        self.assertEqual(res.json(), exp)
Ejemplo n.º 12
0
def write_reply(request, parent_id):
    authuser = check_login_auth(request)
    if authuser is None:
        return HttpResponseRedirect('/user/loginform')

    board = Board()

    parent = Board.objects.get(id=parent_id)

    groupno = parent.groupno
    orderno = parent.orderno + 1
    depth = parent.depth + 1

    results = Board.objects.filter(groupno=groupno).filter(
        orderno__gte=orderno).update(orderno=F('orderno') + 1)

    title = request.POST['title']
    content = request.POST['content']
    userid = request.session['authuser']['id']

    board.title = title
    board.content = content
    board.user_id = userid
    board.groupno = groupno
    board.orderno = orderno
    board.depth = depth

    board.save()

    return HttpResponseRedirect('/board')
Ejemplo n.º 13
0
def write(request):
    board = Board()

    try:
        groupno = int(request.POST['groupno'])
        orderno = int(request.POST['orderno'])
        depth = int(request.POST['depth'])
        Board.objects.filter(groupno=groupno). \
            filter(orderno__gte=orderno + 1). \
            update(orderno=F('orderno') + 1)

        board.title = request.POST['title']
        board.content = request.POST['content']
        board.user_id = request.POST['user_id']
        board.groupno = groupno
        board.orderno = orderno + 1
        board.depth = depth + 1

    except Exception as e:
        board.title = request.POST['title']
        board.content = request.POST['content']
        board.user_id = request.POST['user_id']
        board.groupno = groupno_max() + 1

    board.save()
    return HttpResponseRedirect('/board')
Ejemplo n.º 14
0
def write(request):
    user_id = get_session_user_id(request)
    if not user_id:
        return HttpResponseRedirect('/board/1')

    article = Board()
    article.user = User.objects.get(id=user_id)
    article.title = request.POST['title']
    article.content = request.POST['content']

    if request.POST["write_type"] == "new":
        value = Board.objects.aggregate(max_groupno=Max('groupno'))
        if value["max_groupno"] is not None:
            article.groupno = value["max_groupno"] + 1
            print("new")
    else:
        obj = Board.objects.get(id=request.POST["write_type"])
        article.groupno = obj.groupno
        article.orderno = obj.orderno + 1
        article.depth = obj.depth + 1
        Board.objects.filter(groupno=obj.groupno). \
            filter(orderno__gt=obj.orderno). \
            update(orderno=F('orderno') + 1)

    article.save()
    obj = Board.objects.latest('id')

    return HttpResponseRedirect('/board/view/' + str(obj.id))
Ejemplo n.º 15
0
def list(request):
    board = Board()
    board.user.id = request.POST.get('user.id')
    board.tilte = request.POST['title']
    board.content = request.POST['content']

    return render(request, 'board/list.html')
Ejemplo n.º 16
0
def write(request):
    user = User.objects.get(id=request.session['authuser']['id'])
    board = Board()
    board.user = user
    board.title = request.POST['title']
    board.content = request.POST['content']

    print('-------------',request.POST['replyno'])
    if int(request.POST['replyno']) != 0:
        # 답글인 경우
        originboard = Board.objects.get(id=request.POST['replyno'])
        Board.objects\
            .filter(groupno=originboard.groupno)\
            .filter(orderno__gte=originboard.orderno)\
            .update(orderno=F('orderno')+1)
        board.groupno = originboard.groupno
        board.orderno = originboard.orderno
        board.depth = originboard.depth + 1

    else:
        insert_groupno = Board.objects.aggregate(groupno=Max('groupno'))['groupno'] + 1
        print(insert_groupno,type(insert_groupno))
        board.groupno = insert_groupno

    board.save()

    return HttpResponseRedirect('/board/list')
Ejemplo n.º 17
0
def write(request):
    authuser = request.session.get('authuser')
    if authuser is None:
        # 유저가 아닌 접근이므로. 비정상 접근이거나 세션 해제된 상태.
        return HttpResponseRedirect('/')

    title = request.POST.get('title', '')
    contents = request.POST.get('contents', '')

    user = User.objects.get(id=authuser['id'])

    max_gno = Board.objects.aggregate(g_no=Max('g_no'))['g_no']
    if max_gno is None or max_gno == '':
        max_gno = 0

    # 저장 처리
    board = Board()
    board.title = title
    board.contents = contents
    board.user = user
    board.g_no = int(max_gno) + 1
    board.save()

    # board = Board(title=title, contents=contents, user=user)
    # board.save()

    # ret = Board.insert(data)
    # if ret != 1:
    #     return HttpResponse('오류 발생')

    return HttpResponseRedirect('/board/')
Ejemplo n.º 18
0
def reply(request):
    authuser = request.session.get('authuser')
    if authuser is None:
        # 유저가 아닌 접근이므로. 비정상 접근이거나 세션 해제된 상태.
        return HttpResponseRedirect('/')

    title = request.POST.get('title', '')
    contents = request.POST.get('contents', '')

    g_no = request.POST.get('g_no', 0)
    o_no = request.POST.get('o_no', 0)
    depth = request.POST.get('depth', 0)

    user = User.objects.get(id=authuser['id'])

    # 저장 처리
    board = Board()
    board.title = title
    board.contents = contents
    board.user = user
    board.g_no = int(g_no)
    board.o_no = int(o_no) + 1
    board.depth = int(depth) + 1
    board.save()

    # ret = Board.reply(data)
    # if ret != 1:
    #    return HttpResponse('오류 발생')

    return HttpResponseRedirect('/board/')
Ejemplo n.º 19
0
def replyadd(request):
    authuser = request.session["authuser"]
    user_id = authuser["id"]

    board = Board()

    board.group_no = request.GET['gno']
    board.title = request.POST['title']
    board.message = request.POST['message']
    board.user_id_id = user_id

    numbers = Board.objects.get(id=request.GET['id'])

    if numbers.order_no == 0:
        board.order_no = numbers.order_no + 1
        board.depth = numbers.depth + 1
    elif numbers.order_no >= 1:
        last_ono = Board.objects.filter(group_no=numbers.group_no).aggregate(
            Max('order_no'))
        board.order_no = last_ono['order_no__max'] + 1

        if board.order_no > numbers.order_no:
            board.order_no = numbers.order_no + 1
            board.depth = numbers.depth + 1
        else:
            last_depth = Board.objects.aggregate(Max('depth'))
            numbers.depth = last_depth['depth__max'] + 1

    board.save()

    return HttpResponseRedirect("/board")
Ejemplo n.º 20
0
def add(request):
    board = Board()
    user = User.objects.get(id=request.session['authuser']['id'])

    board.title = request.POST['title']
    board.content = request.POST['content']
    board.user_id = user

    #  만약 추가하는것이 첫 글쓰기일때
    if request.POST['add'] == 'write':
        g_no = Board.objects.aggregate(g_no=Max('g_no'))
        if g_no['g_no'] is None:
            g_no['g_no'] = 0
        board.g_no = g_no['g_no'] + 1
        board.o_no = 0
        board.depth = 0
    else:
        id = request.POST['id']
        p_board = Board.objects.get(id=id)
        board.g_no = p_board.g_no

        results = Board.objects.filter(o_no__gt=p_board.o_no,
                                       g_no=p_board.g_no)
        results.update(o_no=F('o_no') + 1)
        board.o_no = p_board.o_no + 1
        board.depth = p_board.depth + 1

    board.save()

    return HttpResponseRedirect('/board' + "?page=" +
                                str(request.session['session_page']))
Ejemplo n.º 21
0
def write_comment(request):
    board_id = request.GET.get('board_id', )
    input_comment = request.GET.get('comment', )
    user = request.user.pk

    comment = Comment()

    comment.board_id = Board(board_id)
    comment.writer = User(user)
    comment.content = input_comment
    comment.status = 'y'

    try:
        comment.save()

        result = json.dumps([
            {'result': 'seccess'}
        ])

    except Exception as e:
        print(e)
        result = json.dumps([
            {'result':'fail'}
        ])

    return HttpResponse(result, content_type="application/json:charset=UTF-8")
Ejemplo n.º 22
0
def board_write(request):
    if not request.session.get('user'):
        return redirect('/scum/login/')

    if request.method == 'POST':
        form = BoardForm(request.POST)
        if form.is_valid():
            user_id = request.session.get('user')
            scumuser = scumUser.objects.get(pk=user_id)

            tags = form.cleaned_data['tags'].split(',')

            board = Board()
            board.title = form.cleaned_data['title']
            board.contents = form.cleaned_data['contents']
            board.writer = scumuser
            board.save()

            for tag in tags:
                if not tag:
                    continue
                _tag, _= Tag.objects.get_or_create(name=tag)
                board.tags.add(_tag)



            return redirect('/board/list/')

    else:
        form = BoardForm
    return render(request, 'board_write.html', {'form': form})
Ejemplo n.º 23
0
def board_write(request):
    parents_id = request.POST['parentsNo']
    board = Board()
    if parents_id == "":
        value = Board.objects.aggregate(max_groupno=Max('groupno'))
        max_groupno = 0 if value["max_groupno"] is None else value["max_groupno"]
        board.groupno = max_groupno + 1
        board.orderno = 1
        board.depth = 0
    else:
        value = Board.objects.filter(id=parents_id)

        # orderno를 하나씩 밀어주기
        Board.objects.filter(orderno__gte=value[0].orderno + 1).update(orderno=F('orderno') + 1)

        board.groupno = value[0].groupno
        board.orderno = value[0].orderno + 1
        board.depth = value[0].depth + 1

    board.user_id = int(request.session['authuser']['id'])
    board.title = request.POST['title']
    board.content = request.POST['content']

    board.save()

    return HttpResponseRedirect('/board')
Ejemplo n.º 24
0
def write(request):
    user = User.objects.get(id=request.session['authuser']['id'])
    board = Board()
    board.user = user
    board.title = request.POST['title']
    board.content = request.POST['content']

    if int(request.POST['replyno']) != 0:
        # 답글인 경우
        originboard = Board.objects.get(id=request.POST['replyno'])
        Board.objects \
            .filter(groupno=originboard.groupno) \
            .filter(orderno__gte=originboard.orderno) \
            .update(orderno=F('orderno') + 1)
        board.groupno = originboard.groupno
        board.orderno = originboard.orderno
        board.depth = originboard.depth + 1

    else:
        insert_groupno = 1 if Board.objects.aggregate(groupno=Max(
            'groupno'))['groupno'] is None else Board.objects.aggregate(
                groupno=Max('groupno'))['groupno'] + 1
        board.groupno = insert_groupno

    board.save()
    response = HttpResponseRedirect('/board/list')
    cookie_name = f'view_user_{board.id}'
    set_cookie(response, cookie_name, '',
               1)  # 유효기간이 1일인 쿠키를 만든다. (게시물 카운트를 위해)
    return response
Ejemplo n.º 25
0
def add(request):
    if request.session.get('authuser') == None:
        return HttpResponseRedirect('/user/loginform')

    authuser = request.session['authuser']
    paraentno = request.POST.get('parentno')

    if authuser is None:
        return HttpResponseRedirect('/board')

    board = Board()
    board.user_id = authuser['id']
    board.title = request.POST.get('title')
    board.content = request.POST.get('contents')

    if paraentno != '':
        parent = Board.objects.get(id=paraentno)
        board.groupno = parent.groupno
        board.orderno = parent.orderno + 1
        Board.objects.filter(groupno=board.groupno).filter(orderno__gte=board.orderno).update(orderno=F('orderno') + 1)
        board.depth = parent.depth + 1
    else:
        lastboard = Board.objects.order_by('id').last()
        if lastboard == None:
            board.groupno = 1
        else:
            board.groupno = lastboard.id +1


    board.save()

    return HttpResponseRedirect('/board')
Ejemplo n.º 26
0
def reply(request, id=0):
    # 로그인 체크
    if check_authuser(request) is None:
        return HttpResponseRedirect('/user/loginform')
    else:
        if request.method == 'GET':
            return render(request, 'board/write.html')
        elif request.method == 'POST':
            board = Board.objects.get(id=id)
            # query set 예제
            # groupno = 1이고 orderno >=1 의
            # 게시물의 order_no를 1씩 증가
            # __gt, __lt, __gte, __lte
            reply_board = Board()
            reply_board.title = request.POST['title']
            reply_board.content = request.POST['content']
            reply_board.user = User.objects.get(id=request.session['authuser']['id'])
            reply_board.groupno = board.groupno
            # value = Board.objects.filter(groupno=board.groupno).filter(depth=board.depth+1).aggregate(max_orderno=Max('orderno'))
            # max_orderno = 0 if value["max_orderno"] is None else value["max_orderno"]
            reply_board.orderno = board.orderno + 1
            reply_board.depth = board.depth + 1
            reply_board.save()
            # Board.objects.filter(groupno=board.groupno).filter(orderno=board.orderno).update(depth=F('depth') + 1)
            return HttpResponseRedirect('/board/1')
Ejemplo n.º 27
0
def write(request):
    board = Board()
    board.name = request.session['authuser']['name']
    board.title = request.POST['title']
    board.content = request.POST['content']

    board.save()
    return HttpResponseRedirect("/board")
Ejemplo n.º 28
0
def write(request):
    board = Board()
    board.title = request.POST['title']
    board.content = request.POST['content']
    board.user = User.objects.get(id=request.session['authuser']['id'])
    board.groupno = counter_max()
    board.save()
    return HttpResponseRedirect('/board')
Ejemplo n.º 29
0
def add(request):
    add_up = Board(pwd=request.POST['pwd'],
                   writer=request.POST['writer'],
                   subject=request.POST['subject'],
                   content=request.POST['content'])

    add_up.save()
    return redirect('/board')
Ejemplo n.º 30
0
    def test_get_posts_fully_loaded(self):
        """ Test for when the client requests more posts than what the database have available. 
        
        Ex. If the database only have 10 more posts but the client is requesting 20 posts.
        
        It should return back whatever is available.
        """

        b1 = Board(title='hi',
                   description='hello',
                   bg=Image(name='i', photo=bytearray('hi', 'utf-8')).save())
        b2 = Board(title='hi2',
                   description='hello2',
                   bg=Image(name='i2', photo=bytearray('hi', 'utf-8')).save())

        b1.save()
        b2.save()
        posts1 = self.add_posts(b1, 5)

        # board 1 has only 5 posts but the client requested 10
        res1 = self.client.get(
            reverse('board:posts-get'),
            {
                'board': str(b1.uuid),
                'index': '0',
                'amount': '10',
            },
            HTTP_ACCEPT='application/json',
        )
        exp1 = []
        for i in range(5):
            exp1.append(get_post_dict(posts1[-i - 1]))
        self.assertEqual(res1.json(), exp1)

        # board 2 has no posts but the client requested 10
        res2 = self.client.get(
            reverse('board:posts-get'),
            {
                'board': str(b2.uuid),
                'index': '5',
                'amount': '10',
            },
            HTTP_ACCEPT='application/json',
        )
        exp2 = []
        self.assertEqual(res2.json(), exp2)