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)
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)
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)