def submission_record(memberIdIndex, sortCondition, pageNum):
    
    # Not Accept URL Check
    if sortCondition not in (LanguageResources().const.SubmissionDate[1],
                             LanguageResources().const.Memory[1],
                             LanguageResources().const.FileSize[1],
                             LanguageResources().const.Runtime[1]):
        return page_not_found()
    try:       
        # Get MemberId
        try:
            member = select_member(memberIdIndex).first()
        except Exception:
            member = []
            
                # 모든 제출 정보
        submissions = select_all_submissions(memberIdIndex).subquery()
         
        try:
                        # 차트 정보
            chartSubmissionRecords = select_member_chart_submissions(submissions).first()
        except Exception:
            #None Type Exception
            chartSubmissionRecords = []

        # Viiew Value Text
        chartSubmissionDescriptions = [LanguageResources().const.SolvedProblems,
                                       LanguageResources().const.Count,
                                       LanguageResources().const.Solved,
                                       LanguageResources().const.WrongAnswer,
                                       LanguageResources().const.TimeOver,
                                       LanguageResources().const.MemoryOverflow,
                                       LanguageResources().const.CompileError,
                                       LanguageResources().const.RuntimeError]
        
        try:                           
                        # 모든 제출 정보
            count = select_count(submissions.c.memberId).first().\
                                                         count  
            # Sorted
            submissionRecords = get_page_record(submissions_sorted(submissions,
                                                                   sortCondition = sortCondition,
                                                                   DESC = True),
                                                pageNum = pageNum).all()
        except Exception:
            count = 0
            submissionRecords = []

        return render_template(HTMLResources().const.SUBMISSION_RECORD_HTML,
                               memberIdIndex = memberIdIndex,
                               sortCondition = sortCondition,
                               member = member,
                               submissionRecords = submissionRecords,
                               chartSubmissionDescriptions = chartSubmissionDescriptions,
                               chartSubmissionRecords = chartSubmissionRecords,
                               pages = get_page_pointed(pageNum = pageNum,
                                                        count = count))
    except Exception as e:
        # Unknow Error
        return unknown_error(e)
Ejemplo n.º 2
0
def article_notice(filterCondition, keyWord, pageNum):
    try:
        # get Notice Articles
        articlesOnBoard = select_articles().subquery()

        # Get MemberId
        articlesOnBoard = join_member_id(articlesOnBoard,
                                         subMemberIdIndex = articlesOnBoard.c.\
                                                                            writerIdIndex).subquery()

        # Get Problem Name
        articlesOnBoard = join_problems_name(
            subquery=articlesOnBoard,
            subProblemIndex=articlesOnBoard.c.problemIndex).subquery()
        # 과목 공지글
        try:
            if request.method == 'POST':
                for form in request.form:
                    # FilterCondition
                    if 'keyWord' != form:
                        filterCondition = form
                        keyWord = get_request_value(form=request.form,
                                                    name='keyWord')
                        pageNum = 1

                if not keyWord:
                    keyWord = ' '
            # Notices Sorted
            articleNoticeRecords = select_sorted_articles(
                articlesOnBoard,
                FilterFindParameter(filterCondition,
                                    (keyWord if keyWord != ' ' else '')),
                isAll=True)
            # Get Notices count
            count = select_count(articleNoticeRecords.subquery().\
                                                      c.\
                                                      articleIndex).first().\
                                                                    count
            # Get Notices in Page
            articleNoticeRecords = get_page_record(articleNoticeRecords,
                                                   pageNum=pageNum).all()
        except Exception:
            count = 0
            articleNoticeRecords = []

        return render_template(
            HTMLResources().const.ARTICLE_NOTICE_HTML,
            articleNoticeRecords=articleNoticeRecords,
            pages=get_page_pointed(pageNum, count),
            # 검색시 FilterCondition List
            Filters=[
                LanguageResources().const.All,
                LanguageResources().const.Writer,
                LanguageResources().const.Title
            ],
            filterCondition=filterCondition,
            keyWord=keyWord)
    except Exception as e:
        return unknown_error(e)
def article_notice(filterCondition, keyWord, pageNum): 
    try:
        # get Notice Articles
        articlesOnBoard = select_articles().subquery()

        # Get MemberId
        articlesOnBoard = join_member_id(articlesOnBoard,
                                         subMemberIdIndex = articlesOnBoard.c.\
                                                                            writerIdIndex).subquery()
                                                            
        # Get Problem Name
        articlesOnBoard = join_problems_name(subquery = articlesOnBoard,
                                             subProblemIndex = articlesOnBoard.c.problemIndex).subquery()
                # 과목 공지글 
        try:
            if request.method == 'POST':
                for form in request.form:
                    # FilterCondition
                    if 'keyWord' != form:
                        filterCondition = form
                        keyWord = get_request_value(form = request.form,
                                                    name = 'keyWord')
                        pageNum = 1

                if not keyWord:
                    keyWord = ' '                
            # Notices Sorted
            articleNoticeRecords = select_sorted_articles(articlesOnBoard,
                                                          FilterFindParameter(filterCondition,
                                                                              (keyWord if keyWord != ' '
                                                                               else '')),
                                                          isAll = True)        
            # Get Notices count
            count = select_count(articleNoticeRecords.subquery().\
                                                      c.\
                                                      articleIndex).first().\
                                                                    count
            # Get Notices in Page                                                                           
            articleNoticeRecords = get_page_record(articleNoticeRecords,
                                                   pageNum = pageNum).all()
        except Exception:
            count = 0
            articleNoticeRecords = []
        
        return render_template(HTMLResources().const.ARTICLE_NOTICE_HTML,
                               articleNoticeRecords = articleNoticeRecords,
                               pages = get_page_pointed(pageNum,
                                                        count),
                                                              # 검색시 FilterCondition List
                               Filters = [LanguageResources().const.All,
                                          LanguageResources().const.Writer,
                                          LanguageResources().const.Title],
                               filterCondition = filterCondition,
                               keyWord = keyWord)
    except Exception as e:
        return unknown_error(e)
Ejemplo n.º 4
0
def submission_record(memberId, sortCondition, pageNum):
    try:       
        # 모든 제출 정보
        submissions = select_all_submissions(lastSubmission = None,
                                             memberCourseProblemParameter = MemberCourseProblemParameter(memberId = memberId)).subquery()
        # List Count
        try:
            count = select_count(submissions.c.memberId).first().\
                                                         count  
        except Exception:
            count = 0
         
        try:
                        # 차트 정보
            chartSubmissionRecords = select_member_chart_submissions(submissions).first()
        except Exception:
            #None Type Exception
            chartSubmissionRecords = []
        # Viiew Value Text
        chartSubmissionDescriptions = ['Solved Problems',
                                       'Total Submissions',
                                       'Solved',
                                       'Wrong answer',
                                       'Timeover',
                                       'Compile error',
                                       'Runtime error',
                                       'Server error']
        
        try:                           
                        # 모든 제출 정보
            # Sorted
            submissionRecords = get_page_record(submissions_sorted(submissions,
                                                                   sortCondition = sortCondition),
                                                pageNum = pageNum).all()
        except Exception:
            #None Type Exception
            submissionRecords = []
            
        return render_template(HTMLResources().const.SUBMISSION_RECORD_HTML,
                               memberId = memberId,
                               sortCondition = sortCondition,
                               submissionRecords = submissionRecords,
                               chartSubmissionDescriptions = chartSubmissionDescriptions,
                               chartSubmissionRecords = chartSubmissionRecords,
                               pages = get_page_pointed(pageNum = pageNum,
                                                        count = count))
    except Exception:
        # Unknow Error
        return unknown_error()
Ejemplo n.º 5
0
def problem_list(courseId, pageNum):
    """ problem submitting page """
    try:
        # Get Last Submitted History
        lastSubmission = select_last_submissions(memberCourseProblemParameter = MemberCourseProblemParameter(memberId = session[SessionResources().const.MEMBER_ID],
                                                                                                             courseId = courseId)).subquery()
        # Current Submission                                      
        submissions = select_current_submissions(lastSubmission).subquery()
        
        # Get Problem Informations
        problems = join_problems_names(select_problems_of_course(memberCourseProblemParameter = MemberCourseProblemParameter(memberId = None,
                                                                                                                             courseId = courseId)).subquery()).subquery()
        # Get ProblemList Count
        try:
            count = select_count(problems.c.problemId).first().\
                                                       count
        except Exception:
            count = 0
        # Get ProblemListRecords OuterJoin
        try:
            problemListRecords = get_page_record(join_problem_lists_submissions(problems,
                                                                                submissions),
                                                 pageNum = pageNum).all()
        except Exception:
            problemListRecords = []
            
        # Get Course Information
        try:
            courseRecords = dao.query(RegisteredCourses.courseId,
                                      RegisteredCourses.courseName).\
                                filter(RegisteredCourses.courseId == courseId).\
                                first()
        except:
            courseRecords = []
        
        return render_template(HTMLResources().const.PROBLEM_LIST_HTML,
                               SETResources = SETResources,
                               SessionResources = SessionResources,
                               LanguageResources = LanguageResources,
                               courseRecords = courseRecords,
                               problemListRecords = problemListRecords,
                               pages = get_page_pointed(pageNum = pageNum,
                                                        count = count))
    except Exception:
        return unknown_error()
Ejemplo n.º 6
0
def manage_problem(problemLevel, pageNum, error=None):
    try:
        # Upload Problems Files
        if request.method == 'POST':
            if is_authority(session[SessionResources().const.AUTHORITY])[0]:
                error = post_problem(request)
            else:
                error = LanguageResources().const.GetOutHere

        # GET, POST 공통 사항
        problems = select_problems(None if problemLevel == LanguageResources().
                                   const.All[1] else problemLevel)

        try:
            count = select_count(problems.subquery().c.problemIndex).first().\
                                                          count

            problemRecords = get_page_record(problems, pageNum=pageNum).all()

        except Exception:
            count = 0
            problemRecords = []

        return render_template('/manage_problem.html',
                               types=[
                                   ENUMResources().const.SOLUTION,
                                   ENUMResources().const.CHECKER
                               ],
                               levels=[
                                   LanguageResources().const.GoldLevel,
                                   LanguageResources().const.SilverLevel,
                                   LanguageResources().const.BronzeLevel
                               ],
                               problemLevel=problemLevel,
                               problemRecords=problemRecords,
                               pages=get_page_pointed(pageNum, count),
                               error=error)
    except Exception as e:
        return unknown_error(e)
def rank(sortCondition, pageNum, error =None):
    
    # Not Accept URL Check
    if sortCondition not in (LanguageResources().const.Rate[1],
                             LanguageResources().const.SolvedProblems[1]):
        return page_not_found()
    
    try:
        #Searched MemberId
        memberId = None
        try:
            # Auto Complete MemberIds
            memberRecords = select_members().all()
        except Exception:
            memberRecords = []
            
        # Last Submission Max Count
        submissions = select_ranks(select_last_submissions().subquery()).subquery()
        submissions = join_member_id(submissions,
                                     subMemberIdIndex = submissions.c.memberIdIndex).subquery() 
        # records count
        try:
            count = select_count(submissions.c.memberIdIndex).first().\
                                                              count
        except Exception:
            count = 0

        # Paging Pointed
        pages = get_page_pointed(pageNum = pageNum,
                                 count = count)
        submissions = ranks_sorted(submissions,
                                   sortCondition = sortCondition)
        # Find MemberId 뷰 호출
        if request.method == 'POST':
            # Finding MemberId
            memberId = get_request_value(form = request.form,
                                             name = 'memberId')
            try:
                memberIdIndex = select_match_member_id(memberId).first().memberIdIndex
                            # 순차 탐색으로 찾아야 함
                for i in range(1, pages['allPage'] + 1):
                    # memberId in Pages 
                    ranks = get_page_record(submissions,
                                            pageNum = i).subquery()
                    # finding MemberId in Pages
                    if select_match_member_sub(ranks,
                                               memberIdIndex = memberIdIndex).first() != None:
                        # Finding move to page
                        pageNum = i
                        # searchLine Check
                        # RePaging Pointed
                        pages = get_page_pointed(pageNum = pageNum,
                                                 count = count)
                    
                        break
            except Exception:
                error = LanguageResources().const.NotExist
                # 랭크 정보
        try:
            rankMemberRecords = get_page_record(submissions,
                                                pageNum = pageNum).all()
        except Exception:
            rankMemberRecords = []
        
        return render_template(HTMLResources().const.RANK_HTML,
                               sortCondition =  sortCondition,
                               memberRecords = memberRecords,
                               rankMemberRecords = rankMemberRecords,
                               pages = pages,
                               memberId = memberId,
                               error = error) # 페이지 정보
    except Exception as e:
        return unknown_error(e)     
Ejemplo n.º 8
0
def team(pageNum = 1, error = None):
    """ team main page """
    try:
        try:
            # 초대 목록
            teamInvitationRecords = dao.query(TeamInvitations.teamName).\
                                        filter(TeamInvitations.inviteeId == session[SessionResources().const.MEMBER_ID],
                                                  TeamInvitations.isDeleted == ENUMResources().const.FALSE).\
                                        all()
        except Exception:
            # None Type Exception
            teamInvitationRecords = []
           
        # 내가 속한 팀 정보
        teamNames = dao.query(RegisteredTeamMembers.teamName).\
                        filter(RegisteredTeamMembers.teamMemberId == session[SessionResources().const.MEMBER_ID],
                               RegisteredTeamMembers.isDeleted == ENUMResources().const.FALSE).\
                        subquery()
        try:
            count = dao.query(func.count(teamNames.c.teamName).label("count")).\
                        first().\
                        count
        except Exception:
            count = 0
            
        # 내가 속한 팀 인원 수
        teamMemberCounts = dao.query(RegisteredTeamMembers.teamName,
                                     func.count(RegisteredTeamMembers.teamMemberId).label("teamMemberCount")).\
                               join(teamNames,
                                    RegisteredTeamMembers.teamName == teamNames.c.teamName).\
                               filter(RegisteredTeamMembers.isDeleted == ENUMResources().const.FALSE).\
                               group_by(RegisteredTeamMembers.teamName).\
                               subquery()
                            
        # 내가 속한 팀장
        teamMasters = dao.query(RegisteredTeamMembers.teamName,
                                RegisteredTeamMembers.teamMemberId.label("teamMasterId")).\
                          join(teamNames,
                               RegisteredTeamMembers.teamName == teamNames.c.teamName).\
                          filter(RegisteredTeamMembers.isTeamMaster == ENUMResources().const.TRUE,
                                 RegisteredTeamMembers.isDeleted == ENUMResources().const.FALSE).\
                          group_by(RegisteredTeamMembers.teamName).\
                          subquery()
    
        # NonType Exception
        try:
            # order and get record
            teamRecords = get_page_record(dao.query(teamMasters.c.teamName,
                                                    teamMasters.c.teamMasterId,
                                                    teamMemberCounts.c.teamMemberCount).\
                                              join(teamMemberCounts,
                                                   teamMasters.c.teamName == teamMemberCounts.c.teamName).\
                                              order_by(teamMasters.c.teamName.asc()),
                                          pageNum = int(pageNum)).\
                          all()
        except Exception:
            # None Type Error
            teamRecords =[]
        
        return render_template(HTMLResources().const.TEAM_HTML,
                               SETResources = SETResources,
                               SessionResources = SessionResources,
                               LanguageResources = LanguageResources,
                               teamInvitationRecords = teamInvitationRecords,
                               teamRecords = teamRecords,
                               pages = get_page_pointed(pageNum = int(pageNum),
                                                        count = count),
                               error = error)
    except Exception:
        # Unknown Error
        return unknown_error()
Ejemplo n.º 9
0
def problem_list(pageNum):
    """ problem submitting page """
    try:
        # Get Last Submitted History
        lastSubmission = select_last_submissions(memberIdIndex=session[
            SessionResources().const.MEMBER_ID_INDEX]).subquery()

        # Current Submission
        submissions = select_submissions_result(lastSubmission).subquery()

        # Get Problem Informations
        problems = select_all_problems().subquery()

        # Get ProblemList Count
        # Get ProblemListRecords OuterJoin
        try:
            count = select_count(problems.c.problemIndex).first().\
                                                          count

            problemListRecords = get_page_record(
                join_problem_lists_submissions(problems, submissions),
                pageNum=pageNum).all()

        except Exception:
            count = 0
            problemListRecords = []

        # Get Course Information

        browserInformations = request.user_agent.string
        if browserInformations.find('Trident') == -1:
            if browserInformations.find('MSIE') == -1:
                browserVersion = ENUMResources().const.TRUE
            else:
                browserVersion = ENUMResources().const.FALSE
        elif int(browserInformations[browserInformations.find('Trident') +
                                     8]) < 6:
            browserVersion = ENUMResources().const.FALSE
        else:
            browserVersion = ENUMResources().const.TRUE
        wrongTestCaseText = {}
        for problemListRecord in problemListRecords:
            if problemListRecord.wrongTestCaseNumber != 0:
                try:
                    f = open(
                        make_wrong_test_case_path(
                            str(problemListRecord.problemPath),
                            str(problemListRecord.problemName),
                            str(problemListRecord.solutionCheckType),
                            str(problemListRecord.wrongTestCaseNumber)), "r")
                    temp = {problemListRecord.problemName: f.read()}
                    wrongTestCaseText.update(temp)
                    f.close()
                except:
                    pass

        return render_template(HTMLResources().const.PROBLEM_LIST_HTML,
                               problemListRecords=problemListRecords,
                               wrongTestCaseText=wrongTestCaseText,
                               browserVersion=browserVersion,
                               datetime=datetime.now(),
                               pages=get_page_pointed(pageNum=pageNum,
                                                      count=count))
    except Exception as e:
        return unknown_error(e)
Ejemplo n.º 10
0
def article_board(filterCondition, keyWord, pageNum):
    try:
        # get Articles
        articlesOnBoard = select_articles().subquery()
        # Get MemberId
        articlesOnBoard = join_member_id(articlesOnBoard,
                                         subMemberIdIndex = articlesOnBoard.c.\
                                                                            writerIdIndex).subquery()

        # Get Problem Name
        articlesOnBoard = join_problems_name(
            articlesOnBoard,
            subProblemIndex=articlesOnBoard.c.problemIndex).subquery()
        # 과목 공지글
        try:
            articleNoticeRecords = select_sorted_articles(
                articlesOnBoard).all()
        except Exception:
            articleNoticeRecords = []

            # 과목 게시글
        try:
            # Search Event
            if request.method == 'POST':
                for form in request.form:
                    # FilterCondition
                    if 'keyWord' != form:
                        filterCondition = form
                        keyWord = get_request_value(form=request.form,
                                                    name='keyWord')
                        pageNum = 1

                if not keyWord:
                    keyWord = ' '
            articlesOnBoardSub = select_sorted_articles(
                articlesOnBoard,
                FilterFindParameter(filterCondition,
                                    (keyWord if keyWord != ' ' else '')),
                articleType=ENUMResources().const.QUESTION)
            count = select_count(articlesOnBoardSub.subquery().\
                                                    c.articleIndex).first().\
                                                                    count
            articleRecords = get_page_record(articlesOnBoardSub,
                                             pageNum=pageNum,
                                             LIST=int(20)).all()
        except Exception:
            count = 0
            articleRecords = []

        return render_template(
            HTMLResources().const.BOARD_HTML,
            articleRecords=articleRecords,
            articleNoticeRecords=articleNoticeRecords,
            pages=get_page_pointed(pageNum, count, int(20)),
            # 검색시 FilterCondition List
            Filters=[
                LanguageResources().const.All,
                LanguageResources().const.Writer,
                LanguageResources().const.Title
            ],
            filterCondition=filterCondition,
            keyWord=keyWord)
    except Exception as e:
        return unknown_error(e)
def article_board(filterCondition, keyWord, pageNum):    
    try:
        # get Articles
        articlesOnBoard = select_articles().subquery()
        # Get MemberId
        articlesOnBoard = join_member_id(articlesOnBoard,
                                         subMemberIdIndex = articlesOnBoard.c.\
                                                                            writerIdIndex).subquery()
                                                                    
        # Get Problem Name
        articlesOnBoard = join_problems_name(articlesOnBoard,
                                             subProblemIndex = articlesOnBoard.c.problemIndex).subquery()
                # 과목 공지글
        try:  
            articleNoticeRecords = select_sorted_articles(articlesOnBoard).all()
        except Exception:
            articleNoticeRecords = []
            
                # 과목 게시글
        try:
            # Search Event
            if request.method == 'POST':
                for form in request.form:
                    # FilterCondition
                    if 'keyWord' != form:
                        filterCondition = form
                        keyWord = get_request_value(form = request.form,
                                                    name = 'keyWord')
                        pageNum = 1
                    
                if not keyWord:
                    keyWord = ' '
            articlesOnBoardSub = select_sorted_articles(articlesOnBoard,
                                                        FilterFindParameter(filterCondition,
                                                                            (keyWord if keyWord != ' '
                                                                             else '')),
                                                        articleType = ENUMResources().const.QUESTION)
            count = select_count(articlesOnBoardSub.subquery().\
                                                    c.articleIndex).first().\
                                                                    count
            articleRecords = get_page_record(articlesOnBoardSub,
                                             pageNum = pageNum,
                                             LIST = int(20)).all()
        except Exception:
            count = 0
            articleRecords = []
            
        return render_template(HTMLResources().const.BOARD_HTML,
                               articleRecords = articleRecords,
                               articleNoticeRecords = articleNoticeRecords,
                               pages = get_page_pointed(pageNum,
                                                        count,
                                                        int(20)),
                                                              # 검색시 FilterCondition List
                               Filters = [LanguageResources().const.All,
                                          LanguageResources().const.Writer,
                                          LanguageResources().const.Title],
                               filterCondition = filterCondition,
                               keyWord = keyWord)  
    except Exception as e:
        return unknown_error(e)
Ejemplo n.º 12
0
def submission_record(memberIdIndex, sortCondition, pageNum):

    # Not Accept URL Check
    if sortCondition not in (LanguageResources().const.SubmissionDate[1],
                             LanguageResources().const.Memory[1],
                             LanguageResources().const.FileSize[1],
                             LanguageResources().const.Runtime[1]):
        return page_not_found()
    try:
        # Get MemberId
        try:
            member = select_member(memberIdIndex).first()
        except Exception:
            member = []

            # 모든 제출 정보
        submissions = select_all_submissions(memberIdIndex).subquery()

        try:
            # 차트 정보
            chartSubmissionRecords = select_member_chart_submissions(
                submissions).first()
        except Exception:
            #None Type Exception
            chartSubmissionRecords = []

        # Viiew Value Text
        chartSubmissionDescriptions = [
            LanguageResources().const.SolvedProblems,
            LanguageResources().const.Count,
            LanguageResources().const.Solved,
            LanguageResources().const.WrongAnswer,
            LanguageResources().const.TimeOver,
            LanguageResources().const.MemoryOverflow,
            LanguageResources().const.CompileError,
            LanguageResources().const.RuntimeError
        ]

        try:
            # 모든 제출 정보
            count = select_count(submissions.c.memberId).first().\
                                                         count
            # Sorted
            submissionRecords = get_page_record(submissions_sorted(
                submissions, sortCondition=sortCondition, DESC=True),
                                                pageNum=pageNum).all()
        except Exception:
            count = 0
            submissionRecords = []

        return render_template(
            HTMLResources().const.SUBMISSION_RECORD_HTML,
            memberIdIndex=memberIdIndex,
            sortCondition=sortCondition,
            member=member,
            submissionRecords=submissionRecords,
            chartSubmissionDescriptions=chartSubmissionDescriptions,
            chartSubmissionRecords=chartSubmissionRecords,
            pages=get_page_pointed(pageNum=pageNum, count=count))
    except Exception as e:
        # Unknow Error
        return unknown_error(e)
Ejemplo n.º 13
0
def rank(sortCondition, pageNum, error=None):

    # Not Accept URL Check
    if sortCondition not in (LanguageResources().const.Rate[1],
                             LanguageResources().const.SolvedProblems[1]):
        return page_not_found()

    try:
        #Searched MemberId
        memberId = None
        try:
            # Auto Complete MemberIds
            memberRecords = select_members().all()
        except Exception:
            memberRecords = []

        # Last Submission Max Count
        submissions = select_ranks(
            select_last_submissions().subquery()).subquery()
        submissions = join_member_id(
            submissions,
            subMemberIdIndex=submissions.c.memberIdIndex).subquery()
        # records count
        try:
            count = select_count(submissions.c.memberIdIndex).first().\
                                                              count
        except Exception:
            count = 0

        # Paging Pointed
        pages = get_page_pointed(pageNum=pageNum, count=count)
        submissions = ranks_sorted(submissions, sortCondition=sortCondition)
        # Find MemberId 뷰 호출
        if request.method == 'POST':
            # Finding MemberId
            memberId = get_request_value(form=request.form, name='memberId')
            try:
                memberIdIndex = select_match_member_id(
                    memberId).first().memberIdIndex
                # 순차 탐색으로 찾아야 함
                for i in range(1, pages['allPage'] + 1):
                    # memberId in Pages
                    ranks = get_page_record(submissions, pageNum=i).subquery()
                    # finding MemberId in Pages
                    if select_match_member_sub(
                            ranks,
                            memberIdIndex=memberIdIndex).first() != None:
                        # Finding move to page
                        pageNum = i
                        # searchLine Check
                        # RePaging Pointed
                        pages = get_page_pointed(pageNum=pageNum, count=count)

                        break
            except Exception:
                error = LanguageResources().const.NotExist
                # 랭크 정보
        try:
            rankMemberRecords = get_page_record(submissions,
                                                pageNum=pageNum).all()
        except Exception:
            rankMemberRecords = []

        return render_template(HTMLResources().const.RANK_HTML,
                               sortCondition=sortCondition,
                               memberRecords=memberRecords,
                               rankMemberRecords=rankMemberRecords,
                               pages=pages,
                               memberId=memberId,
                               error=error)  # 페이지 정보
    except Exception as e:
        return unknown_error(e)
Ejemplo n.º 14
0
def article_notice(activeTabCourseId, pageNum):    
    try:
        # 검색시 FilterCondition List
        Filters = ['모두', '작성자', '제목 및 내용']
        
                # 허용 과목 리스트
        myCourses = select_current_courses(select_accept_courses().subquery()).subquery()
        # TabActive Course or All Articles
        # get course or All Articles 
        articlesOnBoard = join_courses_names(# get TabActive Articles
                                             select_articles(activeTabCourseId = activeTabCourseId,
                                                             isDeleted = ENUMResources().const.FALSE).subquery(),
                                             myCourses).subquery()
                # 과목 공지글 
        try:
            if request.method == 'POST':
                try:
                    for form in request.form:
                        # FilterCondition
                        if 'keyWord' != form:
                            filterCondition = form
                            keyWord = request.form['keyWord']
                except Exception:
                    filterCondition = None
                    keyWord = None
            else:
                filterCondition = None
                keyWord = None
                
            # Notices Sorted
            articleNoticeRecords = select_sorted_articles(articlesOnBoard,
                                                          isNotice = ENUMResources().const.TRUE,
                                                          filterFindParameter = FilterFindParameter(filterCondition,
                                                                                                    keyWord))
            # Get Notices count
            count = select_count(articleNoticeRecords.subquery().\
                                                      c.articleIndex).\
                                                      first().\
                                                      count
            # Get Notices in Page                                                                           
            articleNoticeRecords = get_page_record(articleNoticeRecords,
                                                   pageNum = pageNum).all()
        except Exception:
            count = 0
            articleNoticeRecords = []
            
        try:
            myCourses = dao.query(myCourses).all()
        except Exception:
            myCourses = []
        # myCourses Default Add ALL
        myCourses.insert(0, OtherResources().const.ALL)
        
        return render_template(HTMLResources().const.ARTICLE_NOTICE_HTML,
                               articleNoticeRecords =  articleNoticeRecords,
                               myCourses = myCourses,
                               pages = get_page_pointed(pageNum,
                                                        count),
                               Filters = Filters,
                               activeTabCourseId = activeTabCourseId) # classType, condition은 검색 할 때 필요한 변수    
        
    except Exception:
        return 
def problem_list(pageNum):
    """ problem submitting page """
    try:
        # Get Last Submitted History
        lastSubmission = select_last_submissions(memberIdIndex = session[SessionResources().const.MEMBER_ID_INDEX]).subquery()
        
        # Current Submission                                      
        submissions = select_submissions_result(lastSubmission).subquery()

        # Get Problem Informations
        problems = select_all_problems().subquery()
        
        # Get ProblemList Count
        # Get ProblemListRecords OuterJoin
        try:
            count = select_count(problems.c.problemIndex).first().\
                                                          count
                                                      
            problemListRecords = get_page_record(join_problem_lists_submissions(problems,
                                                                                submissions),
                                                 pageNum = pageNum).all()
        
        except Exception:
            count = 0
            problemListRecords = []

        # Get Course Information
        
        browserInformations = request.user_agent.string
        if browserInformations.find('Trident') == -1:
            if browserInformations.find('MSIE') == -1:
                browserVersion = ENUMResources().const.TRUE
            else:
                browserVersion = ENUMResources().const.FALSE        
        elif int(browserInformations[browserInformations.find('Trident') + 8]) < 6:
            browserVersion = ENUMResources().const.FALSE
        else:
            browserVersion = ENUMResources().const.TRUE
        wrongTestCaseText = {}
        for problemListRecord in problemListRecords:
            if problemListRecord.wrongTestCaseNumber != 0:
                try:
                    f = open(make_wrong_test_case_path(str(problemListRecord.problemPath),
                                                   str(problemListRecord.problemName),
                                                   str(problemListRecord.solutionCheckType),
                                                   str(problemListRecord.wrongTestCaseNumber)), "r")
                    temp = {problemListRecord.problemName : f.read()}
                    wrongTestCaseText.update(temp)
                    f.close()
                except:
                    pass

        return render_template(HTMLResources().const.PROBLEM_LIST_HTML,
                               problemListRecords = problemListRecords,
                               wrongTestCaseText = wrongTestCaseText,
                               browserVersion = browserVersion,
                               datetime = datetime.now(),
                               pages = get_page_pointed(pageNum = pageNum,
                                                        count = count))
    except Exception as e:
        return unknown_error(e)
Ejemplo n.º 16
0
def board(activeTabCourseId, pageNum):    
    try:
        # 검색시 FilterCondition List
        Filters = ['모두', '작성자', '제목 및 내용']
        
                # 허용 과목 리스트
        myCourses = select_current_courses(select_accept_courses().subquery()).subquery()
        # TabActive Course or All Articles
        # get course or All Articles 
        articlesOnBoard = join_courses_names(# get TabActive Articles
                                             select_articles(activeTabCourseId = activeTabCourseId,
                                                             isDeleted = ENUMResources().const.FALSE).subquery(),
                                             myCourses).subquery()
                # 과목 공지글    
        try:  
            articleNoticeRecords = get_page_record((select_sorted_articles(articlesOnBoard,
                                                                           isNotice = ENUMResources().const.TRUE)),
                                                   pageNum = int(1),
                                                   LIST = OtherResources().const.NOTICE_LIST).all()
        except Exception:
            articleNoticeRecords = []
                # 과목 게시글
        try:
            if request.method == 'POST':
                try:
                    for form in request.form:
                        # FilterCondition
                        if 'keyWord' != form:
                            filterCondition = form
                            keyWord = request.form['keyWord']
                except Exception:
                    filterCondition = None
                    keyWord = None
            else:
                filterCondition = None
                keyWord = None
                
            articlesOnBoardSub = select_sorted_articles(articlesOnBoard,
                                                        isNotice = ENUMResources().const.FALSE,
                                                        filterFindParameter = FilterFindParameter(filterCondition,
                                                                                                  keyWord))
            count = select_count(articlesOnBoardSub.subquery().\
                                                    c.articleIndex).first().\
                                                                    count
            articleRecords = get_page_record(articlesOnBoardSub,
                                             pageNum = pageNum).all()
        except Exception:
            count = 0
            articleRecords = []
            
        try:
            myCourses = dao.query(myCourses).all()
        except Exception:
            myCourses = []
        # myCourses Default Add ALL
        myCourses.insert(0, OtherResources().const.ALL)
        
        return render_template(HTMLResources().const.BOARD_HTML,
                               SETResources = SETResources,
                               SessionResources = SessionResources,
                               LanguageResources = LanguageResources,
                               articleRecords = articleRecords,
                               articleNoticeRecords =  articleNoticeRecords,
                               myCourses = myCourses,
                               pages = get_page_pointed(pageNum,
                                                        count),
                               Filters = Filters,
                               activeTabCourseId = activeTabCourseId) # classType, condition은 검색 할 때 필요한 변수    
        
    except Exception:
        return unknown_error()
Ejemplo n.º 17
0
def rank(activeTabCourseId, sortCondition, pageNum, error =None):
    
    try:
        findMemberId = None
        try:
            # Auto Complete MemberIds
            memberRecords = select_all_users().all()
        except Exception:
            memberRecords = []
            
        # Last Submission Max Count
        submissions = select_ranks(select_last_submissions(memberCourseProblemParameter = MemberCourseProblemParameter(memberId = None,
                                                                                                                       courseId = activeTabCourseId)).subquery()).subquery()
        
        # records count
        try:
            count = select_count(submissions.c.memberId).first().\
                                                         count
        except Exception:
            count = 0
            
        # Paging Pointed
        pages = get_page_pointed(pageNum = pageNum,
                                 count = count)
        submissions = ranks_sorted(submissions,
                                   sortCondition = sortCondition)
        # Find MemberId 뷰 호출
        if request.method == 'POST':
            # Finding MemberId
            findMemberId = request.form['memberId']
                        # 순차 탐색으로 찾아야 함
            for i in range(1, pages['allPage'] + 1):
                # memberId in Pages 
                ranks = get_page_record(submissions,
                                        pageNum = i).subquery()
                # finding MemberId in Pages
                try:
                    if select_match_member_sub(ranks,
                                               memberCourseProblemParameter = MemberCourseProblemParameter(memberId = findMemberId)).first().\
                                                                                                                                     memberId:
                        # Finding move to page
                        pageNum = i
                        # searchLine Check
                    
                        break
                except Exception:
                    pass
            else:
                                # 같은 아이디가 없을 때 메세지
                error = get_message('notExists')
       
                # 랭크 정보
        try:
            rankMemberRecords = get_page_record(submissions,
                                                pageNum = pageNum).all()
        except Exception:
            rankMemberRecords = []
        
        try:
            myCourses = select_accept_courses().all()
        except Exception:
            myCourses = []
        # myCourses Default Add ALL
        myCourses.insert(0, OtherResources().const.ALL)
       
        return render_template(HTMLResources().const.RANK_HTML,
                               activeTabCourseId = activeTabCourseId,
                               sortCondition =  sortCondition,
                               memberRecords = memberRecords,
                               rankMemberRecords = rankMemberRecords,
                               myCourses = myCourses,
                               pages = pages,
                               findMemberId = findMemberId,
                               error = error) # 페이지 정보
    except Exception:
        return unknown_error()     
Ejemplo n.º 18
0
def manage_user(filterCondition, keyWord, sortCondition, pageNum, error=None):
    # Not Accept URL Check

    if sortCondition not in (LanguageResources().const.ID[1],
                             LanguageResources().const.Name[1]):
        return page_not_found()

    try:
        # Request Post
        if request.method == 'POST':
            # Search Event
            # FilterCondition
            if len(request.form) <= 2 and 'keyWord' in request.form:
                for form in request.form:
                    if 'keyWord' != form:
                        filterCondition = form
                        keyWord = get_request_value(form=request.form,
                                                    name='keyWord')
                        pageNum = 1

                        break
            elif is_authority(session[SessionResources().const.AUTHORITY])[0]:
                if 'memberDeleted' in request.form:
                    for form in request.form:
                        if 'member' not in form and 'keyWord' not in form:
                            memberIdIndex = form
                            # Get Folder Path
                            member = select_member(
                                memberIdIndex=memberIdIndex).first()

                            try:
                                update_member_deleted(memberIdIndex)
                                dao.commit()

                                userPath = '{0}/Current/{1}_{2}'.format(
                                    projectPath, member.memberId,
                                    member.memberName)
                                # Delete Folder
                                if os.path.exists(userPath):
                                    shutil.rmtree(userPath)
                            except Exception:
                                dao.rollback()
                                error = LanguageResources().const.DBFailed
                else:
                    for form in request.form:
                        # Insert Indivisual
                        if 'memberInsert' in form:
                            insertCount = int(form[len('memberInsert'):]) + 1

                            for i in range(1, insertCount):
                                # Get Input Data
                                detailInformation = get_request_value(
                                    form=request.form,
                                    name='detailInformation{0}'.format(i))
                                memberId = get_request_value(
                                    form=request.form,
                                    name='memberId{0}'.format(i))
                                memberName = get_request_value(
                                    form=request.form,
                                    name='memberName{0}'.format(i))

                                if memberId\
                                   and memberName:
                                    try:
                                        memberIdIndex = select_match_member_id(memberId).first().\
                                                                                         memberIdIndex
                                    except Exception:
                                        memberIdIndex = None
                                    try:
                                        error = insert_member_registration(
                                            memberIdIndex=memberIdIndex,
                                            memberId=memberId,
                                            memberName=memberName,
                                            password=generate_password_hash(
                                                TripleDES.encrypt(
                                                    str(memberId))),
                                            detailInformation=detailInformation
                                        )
                                        dao.commit()

                                        # Get Folder Path
                                        userPath = '{0}/Current/{1}_{2}'.format(
                                            projectPath, memberId, memberName)
                                        # make Folders
                                        if not os.path.exists(userPath):
                                            os.makedirs(userPath)
                                    except Exception:
                                        dao.rollback()
                                        error = LanguageResources(
                                        ).const.DBFailed
                                else:
                                    error = LanguageResources(
                                    ).const.FormValidation
            else:
                error = LanguageResources().const.GetOutHere

        # Get Users
        try:
            members = select_members().subquery()
            # Filter Case
            if filterCondition\
               and filterCondition != ' ':
                if not keyWord:
                    keyWord = ' '
                members = search_members(
                    members,
                    FilterFindParameter(filterCondition=filterCondition,
                                        keyWord=(keyWord if keyWord != ' ' else
                                                 ''))).subquery()
            count = select_count(members.c.memberIdIndex).first().\
                                                          count
            memberRecords = get_page_record(members_sorted(
                members, sortCondition),
                                            pageNum=pageNum)
        except Exception:
            count = 0
            memberRecords = []

        return render_template(
            '/manage_user.html',
            # 검색시 FilterCondition List
            Filters=[
                LanguageResources().const.All,
                LanguageResources().const.ID,
                LanguageResources().const.Name
            ],
            sortCondition=sortCondition,
            filterCondition=filterCondition,
            keyWord=keyWord,
            memberRecords=memberRecords,
            pages=get_page_pointed(pageNum, count),
            count=count,
            error=error)
    except Exception as e:
        return unknown_error(e)