예제 #1
0
def listSpecificPageWork(request):
    current_page = request.GET["current_page"]
    totalCnt = DjangoBoard.objects.all().count()

    print "current_page=", current_page

    # 페이지를 가지고 범위 데이터를 조회한다 => raw SQL 사용함
    boardList = DjangoBoard.objects.raw(
        "SELECT Z.* FROM(SELECT X.*, ceil( rownum / %s ) as page FROM ( SELECT ID,SUBJECT,NAME, CREATED_DATE, MAIL,MEMO,HITS \
                                        FROM SAMPLE_BOARD_DJANGOBOARD  ORDER BY ID DESC ) X ) Z WHERE page = %s",
        [rowsPerPage, current_page],
    )

    print "boardList=", boardList, "count()=", totalCnt

    # 전체 페이지를 구해서 전달...
    pagingHelperIns = pagingHelper()

    totalPageList = pagingHelperIns.getTotalPageList(totalCnt, rowsPerPage)

    print "totalPageList", totalPageList

    return render_to_response(
        "listSpecificPage.html",
        {
            "boardList": boardList,
            "totalCnt": totalCnt,
            "current_page": int(current_page),
            "totalPageList": totalPageList,
        },
    )
예제 #2
0
def listSearchedSpecificPageWork(request):
    searchStr = request.GET["searchStr"]
    pageForView = request.GET["pageForView"]
    print "listSearchedSpecificPageWork:searchStr", searchStr, "pageForView=", pageForView

    # boardList = DjangoBoard.objects.filter(subject__contains=searchStr)
    # print  'boardList=',boardList

    totalCnt = DjangoBoard.objects.filter(subject__contains=searchStr).count()
    print "totalCnt=", totalCnt

    pagingHelperIns = pagingHelper()
    totalPageList = pagingHelperIns.getTotalPageList(totalCnt, rowsPerPage)

    # like 구문 적용방법
    boardList = DjangoBoard.objects.raw(
        """SELECT Z.* FROM ( SELECT X.*, ceil(rownum / %s) as page \
        FROM ( SELECT ID,SUBJECT,NAME, CREATED_DATE, MAIL,MEMO,HITS FROM SAMPLE_BOARD_DJANGOBOARD \
        WHERE SUBJECT LIKE '%%'||%s||'%%' ORDER BY ID DESC) X ) Z WHERE page = %s""",
        [rowsPerPage, searchStr, pageForView],
    )

    print "boardList=", boardList

    return render_to_response(
        "listSearchedSpecificPage.html",
        {
            "boardList": boardList,
            "totalCnt": totalCnt,
            "pageForView": int(pageForView),
            "searchStr": searchStr,
            "totalPageList": totalPageList,
        },
    )
예제 #3
0
def listSearchedSpecificPageWork(request):
    searchStr = request.GET['searchStr']
    pageForView = request.GET['pageForView']
    print 'listSearchedSpecificPageWork:searchStr', searchStr, 'pageForView=', pageForView
        
    #boardList = DjangoBoard.objects.filter(subject__contains=searchStr)
    #print  'boardList=',boardList
    
    totalCnt = DjangoBoard.objects.filter(subject__contains=searchStr).count()
    print  'totalCnt=',totalCnt
    
    pagingHelperIns = pagingHelper();
    totalPageList = pagingHelperIns.getTotalPageList( totalCnt, rowsPerPage)
    
    # like 구문 적용방법 
#    boardList = DjangoBoard.objects.raw("""SELECT Z.* FROM ( SELECT X.*, ceil(rownum / %s) as page \
#        FROM ( SELECT ID,SUBJECT,NAME, CREATED_DATE, MAIL,MEMO,HITS FROM SAMPLE_BOARD_DJANGOBOARD \
#        WHERE SUBJECT LIKE '%%'||%s||'%%' ORDER BY ID DESC) X ) Z WHERE page = %s""", [rowsPerPage, searchStr, pageForView])
        
    boardList = DjangoBoard.objects.raw("""SELECT Z.* FROM(SELECT X.*, ceil( rnum+1 / %s ) as page FROM ( SELECT (SELECT @rownum:=0) rnum, id,subject,name, created_date, mail,memo,hits \
                                        FROM SAMPLE_BOARD_DJANGOBOARD WHERE SUBJECT LIKE concat('%%', %s) ORDER BY ID DESC ) X ) Z 
                                        WHERE page = %s""", [rowsPerPage, searchStr, pageForView])
        
    print'boardList=',boardList
    
    return render_to_response('listSearchedSpecificPage.html', {'boardList': boardList, 'totalCnt': totalCnt, 
                                                        'pageForView':int(pageForView) ,'searchStr':searchStr, 'totalPageList':totalPageList} )            
예제 #4
0
def DeleteSpecificRow(request):
    memo_id = request.GET['memo_id']
    current_page = request.GET['current_page']
    print '#### DeleteSpecificRow ######'
    print 'memo_id', memo_id
    print 'current_page', current_page
    
    p = DjangoBoard.objects.get(id=memo_id)
    p.delete()
    
    # Display Page    
    # 마지막 메모를 삭제하는 경우, 페이지를 하나 줄임.
    totalCnt = DjangoBoard.objects.all().count()  
    pagingHelperIns = pagingHelper();
    
    totalPageList = pagingHelperIns.getTotalPageList( totalCnt, rowsPerPage)
    print 'totalPages', totalPageList
    
    if( int(current_page) in totalPageList):
        print 'current_page No Change'
        current_page=current_page
    else:
        current_page= int(current_page)-1
        print 'current_page--'            
            
    url = '/listSpecificPageWork?current_page=' + str(current_page)
    return HttpResponseRedirect(url)    
예제 #5
0
def DeleteSpecificRow(request):
    memo_id = request.GET["memo_id"]
    current_page = request.GET["current_page"]
    print "#### DeleteSpecificRow ######"
    print "memo_id", memo_id
    print "current_page", current_page

    p = DjangoBoard.objects.get(id=memo_id)
    p.delete()

    # Display Page
    # 마지막 메모를 삭제하는 경우, 페이지를 하나 줄임.
    totalCnt = DjangoBoard.objects.all().count()
    pagingHelperIns = pagingHelper()

    totalPageList = pagingHelperIns.getTotalPageList(totalCnt, rowsPerPage)
    print "totalPages", totalPageList

    if int(current_page) in totalPageList:
        print "current_page No Change"
        current_page = current_page
    else:
        current_page = int(current_page) - 1
        print "current_page--"

    url = "/listSpecificPageWork?current_page=" + str(current_page)
    return HttpResponseRedirect(url)
예제 #6
0
def listSpecificPageWork(request):
    current_page = request.GET['current_page']
    totalCnt = DjangoBoard.objects.all().count()

    print 'current_page=', current_page

    # 페이지를 가지고 범위 데이터를 조사한다 -> raw SQL 사용함
    PageIndex = int(current_page) - 1
    start = int(rowsPerPage * PageIndex)
    boardList = DjangoBoard.objects.raw(
        'SELECT * FROM SAMPLE_BOARD_DJANGOBOARD ORDER BY ID DESC LIMIT %s, %s',
        [start, rowsPerPage])

    print 'boardList=', boardList, 'count()=', totalCnt

    # 전체 페이지를 구해서 전달
    pagingHelperIns = pagingHelper()
    totalPageList = pagingHelperIns.getTotalPageList(totalCnt, rowsPerPage)

    print 'totalPageList', totalPageList

    return render_to_response(
        'listSpecificPage.html', {
            'boardList': boardList,
            'totalCnt': totalCnt,
            'current_page': int(current_page),
            'totalPageList': totalPageList
        })
예제 #7
0
def home(request):
	boardList = DjangoBoard.objects.order_by('-id')[0:2]
	current_page = 1
	
	totalCnt = DjangoBoard.objects.all().count()

	pagingHelperIns = pagingHelper();
        totalPageList = pagingHelperIns.getTotalPageList( totalCnt, rowsPerPage)
        print 'totalPageList', totalPageList
        return render_to_response('listSpecificPage.html', {'boardList': boardList, 'totalCnt': totalCnt, 'current_page':current_page, 'totalPageList':totalPageList} )
예제 #8
0
def listSearchedSpecificPageWork(request):
	searchStr = request.GET['searchStr']
	pageForView = int(request.GET['pageForView'])
	
	totalCnt = DjangoBoard.objects.filter(subject__contains=searchStr).count()

	pagingHelperlns = pagingHelper();
	totalPageList = pagingHelperlns.getTotalPageList(totalCnt, rowsPerPage)
	sumString = '%' + searchStr + '%'
	boardList = DjangoBoard.objects.raw("SELECT id, subject,name, created_date, mail, memo, hits FROM sample_board_djangoboard WHERE subject LIKE %s ORDER BY id DESC LIMIT %s,%s", [sumString, rowsPerPage*(pageForView-1), rowsPerPage])

	return render_to_response('listSearchedSpecificPage.html', {'boardList': boardList, 'totalCnt': totalCnt, 'pageForView':pageForView ,'searchStr':searchStr, 'totalPageList':totalPageList} )
예제 #9
0
def listSpecificPageWork(request):
	current_page = int(request.GET['current_page'])
	totalCnt = DjangoBoard.objects.all().count()
	print 'current_page=', current_page

	boardList = DjangoBoard.objects.raw('SELECT id, subject, name, created_date, mail, memo, hits FROM sample_board_djangoboard ORDER BY id DESC LIMIT %s, %s', [rowsPerPage*(current_page - 1), rowsPerPage])
    	print 'boardList=',boardList, 'count()=', totalCnt

	pagingHelperIns = pagingHelper();
    	totalPageList = pagingHelperIns.getTotalPageList( totalCnt, rowsPerPage)

	print 'totalPageList', totalPageList

    	return render_to_response('listSpecificPage.html', {'boardList': boardList, 'totalCnt': totalCnt, 'current_page':current_page ,'totalPageList':totalPageList} )
예제 #10
0
파일: views.py 프로젝트: ShinJJang/dj_board
def home(request):
	boardList = DjangoBoard.objects.order_by('-id')[0:rowsPerPage]
	current_page = 1

	# model을 사용해서 전체 데이터 갯수를 구한다.
	totalCnt = DjangoBoard.objects.all().count()

	# 이것은 페이징 처리를 위해 생성한 간단한 헬퍼 클래스이다. 
	pagingHelperIns = pagingHelper();
	totalPageList = pagingHelperIns.getTotalPageList(totalCnt, rowsPerPage)
	print 'totalPageList', totalPageList

	return render_to_response('listSpecificPage.html', {'boardList':boardList, 'totalCnt':totalCnt,
								'current_page':current_page, 'totalPageList':totalPageList})
예제 #11
0
def home(request):   
    #OK
    #url = '/listSpecificPageWork?current_page=1' 
    #return HttpResponseRedirect(url)  

    boardList = DjangoBoard.objects.order_by('-id')[0:2]        
    current_page =1
    totalCnt = DjangoBoard.objects.all().count() 
    
    pagingHelperIns = pagingHelper();
    totalPageList = pagingHelperIns.getTotalPageList( totalCnt, rowsPerPage)
    print 'totalPageList', totalPageList
    
    return render_to_response('listSpecificPage.html', {'boardList': boardList, 'totalCnt': totalCnt, 
                                                        'current_page':current_page ,'totalPageList':totalPageList} ) 
예제 #12
0
파일: views.py 프로젝트: ShinJJang/dj_board
def listSearchedSpecificPageWork(request):
	searchStr = request.GET['searchStr']
	pageForView = request.GET['pageForView']

	totalCnt = DjangoBoard.objects.filter(subject__contains=searchStr).count()

	pagingHelperIns = pagingHelper();
	totalPageList = pagingHelperIns.getTotalPageList(totalCnt, rowsPerPage)

	PageIndex = int(pageForView)-1
	start = int(rowsPerPage*PageIndex)

	boardList = DjangoBoard.objects.raw('SELECT X.* FROM ( SELECT * FROM SAMPLE_BOARD_DJANGOBOARD WHERE SUBJECT LIKE %s) X ORDER BY ID DESC LIMIT %s, %s', [searchStr, start, rowsPerPage])

	return render_to_response('listSearchedSpecificPage.html', {'boardList': boardList, 'totalCnt': totalCnt,
								'pageForView': int(pageForView), 'searchStr': searchStr, 'totalPageList': totalPageList})
예제 #13
0
def home(request):
    # OK
    # url = '/listSpecificPageWork?current_page=1'
    # return HttpResponseRedirect(url)

    boardList = DjangoBoard.objects.order_by("-id")[0:2]
    current_page = 1
    totalCnt = DjangoBoard.objects.all().count()

    pagingHelperIns = pagingHelper()
    totalPageList = pagingHelperIns.getTotalPageList(totalCnt, rowsPerPage)
    print "totalPageList", totalPageList

    return render_to_response(
        "listSpecificPage.html",
        {"boardList": boardList, "totalCnt": totalCnt, "current_page": current_page, "totalPageList": totalPageList},
    )
예제 #14
0
def home(request):
    boardList = DjangoBoard.objects.order_by('-id')[0:rowsPerPage]
    current_page = 1

    # model을 사용해서 전체 데이터 갯수를 구한다.
    totalCnt = DjangoBoard.objects.all().count()

    # 이것은 페이징 처리를 위해 생성한 간단한 헬퍼 클래스이다.
    pagingHelperIns = pagingHelper()
    totalPageList = pagingHelperIns.getTotalPageList(totalCnt, rowsPerPage)
    print 'totalPageList', totalPageList

    return render_to_response(
        'listSpecificPage.html', {
            'boardList': boardList,
            'totalCnt': totalCnt,
            'current_page': current_page,
            'totalPageList': totalPageList
        })
예제 #15
0
def listSpecificPageWork(request):    
    current_page = request.GET['current_page']
    totalCnt = DjangoBoard.objects.all().count()                  
    
    print 'current_page=', current_page
        
    # 페이지를 가지고 범위 데이터를 조회한다 => raw SQL 사용함
    boardList = DjangoBoard.objects.raw('SELECT Z.* FROM(SELECT X.*, ceil( rnum+1 / %s ) as page FROM ( SELECT (SELECT @rownum:=0) rnum, id,subject,name, created_date, mail,memo,hits \
                                        FROM SAMPLE_BOARD_DJANGOBOARD  ORDER BY ID DESC ) X ) Z WHERE page = %s', [rowsPerPage, current_page])
        
    print  'boardList=',boardList, 'count()=', totalCnt
    
    # 전체 페이지를 구해서 전달...
    pagingHelperIns = pagingHelper();
    
    totalPageList = pagingHelperIns.getTotalPageList( totalCnt, rowsPerPage)
        
    print 'totalPageList', totalPageList
    
    return render_to_response('listSpecificPage.html', {'boardList': boardList, 'totalCnt': totalCnt, 
                                                        'current_page':int(current_page) ,'totalPageList':totalPageList} )
예제 #16
0
파일: views.py 프로젝트: ShinJJang/dj_board
def listSpecificPageWork(request):
	current_page = request.GET['current_page']
	totalCnt = DjangoBoard.objects.all().count()

	print 'current_page=', current_page

	# 페이지를 가지고 범위 데이터를 조사한다 -> raw SQL 사용함
	PageIndex = int(current_page)-1
	start = int(rowsPerPage*PageIndex)
	boardList = DjangoBoard.objects.raw('SELECT * FROM SAMPLE_BOARD_DJANGOBOARD ORDER BY ID DESC LIMIT %s, %s', [start, rowsPerPage])
        
	 
	print 'boardList=', boardList, 'count()=', totalCnt

	# 전체 페이지를 구해서 전달
	pagingHelperIns = pagingHelper();
	totalPageList = pagingHelperIns.getTotalPageList(totalCnt, rowsPerPage)

	print 'totalPageList', totalPageList

	return render_to_response('listSpecificPage.html', {'boardList':boardList, 'totalCnt':totalCnt,
								'current_page':int(current_page), 'totalPageList':totalPageList})
예제 #17
0
def listSearchedSpecificPageWork(request):
    searchStr = request.GET['searchStr']
    pageForView = request.GET['pageForView']

    totalCnt = DjangoBoard.objects.filter(subject__contains=searchStr).count()

    pagingHelperIns = pagingHelper()
    totalPageList = pagingHelperIns.getTotalPageList(totalCnt, rowsPerPage)

    PageIndex = int(pageForView) - 1
    start = int(rowsPerPage * PageIndex)

    boardList = DjangoBoard.objects.raw(
        'SELECT X.* FROM ( SELECT * FROM SAMPLE_BOARD_DJANGOBOARD WHERE SUBJECT LIKE %s) X ORDER BY ID DESC LIMIT %s, %s',
        [searchStr, start, rowsPerPage])

    return render_to_response(
        'listSearchedSpecificPage.html', {
            'boardList': boardList,
            'totalCnt': totalCnt,
            'pageForView': int(pageForView),
            'searchStr': searchStr,
            'totalPageList': totalPageList
        })