Example #1
0
File: board.py Project: onetera/sp
	def remove(self, id, id2):
		# [SH] -------------------------------
		board_attach_q = Session.query(BoardAttach)
		board_attach = board_attach_q.filter_by(article_idx = id2).all()
		
		# 파일이 있을때만 삭제하도록 변경
		for attach_item in board_attach:
			if os.path.exists(attach_item.new_path):
				os.unlink(attach_item.new_path)
				Session.delete(attach_item)
		
		Session.commit()
		# ---------------------- [SH] 
		Archive("Board").Remove( id2 )
		return okMessage("삭제되었습니다.")
Example #2
0
	def unit_remove(self):
		unit_idx = request.params["idx"]
		print unit_idx
		
		if unit_idx != None:
			query = Session.query(Task_Unit).filter(Task_Unit.idx == unit_idx)
			
			fetchrow = query.first()
			
			Session.delete(fetchrow)
			Session.commit()
			
			return "{success: true}"
		else:
			return "{success: false, errorMessage: \"none data\"}"
Example #3
0
def removeSendMessage(sendidx):

	# 메시지 정보를 가져온다.
	msg_q = Session.query(Msg).filter(Msg.idx == sendidx)
	if msg_q.count() == 0:
		raise SpartaUserError("존재하지 않는 쪽지입니다")

	msg = msg_q.first()

	if msg.SenderID != Login.getID() and (not CheckAdmin()):
		raise SpartaAccessError("메시지를 삭제할 수 있는 권한이 없습니다") 

	# 수신자 지우기
	receiver_q = Session.query(MsgReceiver).filter(MsgReceiver.Msg_IDX == sendidx)
	if receiver_q.count() > 0:
		# 수신자중에 한명이라도 메시지를 읽지 않았다면 쪽지를 삭제하지 못하게 한다.
		for receiver_user in receiver_q.all():
			if receiver_user.IsDelete == u"0":
				return u"%s 사용자가 아직 쪽지를 읽지 않았습니다" % receiver_user.ReceiverID
		
		receiver_q.delete()
		Session.commit()

	# 우선 첨부파일 정보를 가져온다.
	attach_q = Session.query(MsgAttach).filter(MsgAttach.Msg_IDX == sendidx).all()
	if len(attach_q) > 0:
		for attach_info in attach_q:
			# File Exists
			if os.path.exists(attach_info.NewFileName):
				os.unlink(attach_info.NewFileName)
		Session.delete(attach_info)
		Session.commit()

	# 본 메시지 삭제
	msg_q = Session.delete(msg)
	Session.commit()
	
	return 1
Example #4
0
File: board.py Project: onetera/sp
	def write(self, id, id2=None):
		""" 게시물 작성 처리 """
		
		dSave = {}
		bData = Archive("AdminBoard").getValues("AdminBoard.BCode == "+str(id), "IDX,AccessWrite" )
		
		if bData:
			if bData["AccessWrite"] == "" or bData["AccessWrite"].find(session["UserType"]) > -1:
				
				CopyDict( srcDic=request.params, destDic=dSave, keyList="IDX,Category,Status")#, prefix="Board.")
				
				dSave["BoardID"] = str(id)
				dSave["BoardIDX"] = bData["IDX"]
				dSave["Title"] = request.params["Title"]
				dSave["Content"] = request.params["Content"]
				
# [SH] 이 아래줄 부터 쭈욱 
				article_id = Archive("Board").New( **dSave )
				
				# File Upload
				objUpload = Upload()
				objUpload.BoardDir(dSave["BoardID"])
				upload_files = request.params.getall("bf_file")
				
				# 업로드한 파일 목록 가져오기(수정 모드일때)
				if dSave.has_key("IDX"):
					
					# File Delete
					selDeletedCheck = request.params.getall("delete_file")
					
					from sqlalchemy import and_
					
					board_attach_q = Session.query(BoardAttach)
					board_attach = board_attach_q.filter(
						and_(
							BoardAttach.article_idx == dSave["IDX"],
							BoardAttach.id.in_(selDeletedCheck)
						)
					).all()
					
					# 파일이 있을때만 삭제하도록 변경
					for attach_item in board_attach:
						if os.path.exists(attach_item.new_path):
							os.unlink(attach_item.new_path)
							Session.delete(attach_item)
					
					Session.commit()
				
				for upload_file in upload_files:
					if type(upload_file) == unicode:
						# 빈 문자열이 넘어온 경우 처리를 건너뛴다.
						continue
					
					# 실제 파일 업로드를 여기에서 수행한다.
					new_file = objUpload.upload_file_move(upload_file)
					
					board_attach_row = BoardAttach()
					board_attach_row.board_code = unicode(dSave["BoardID"])
					if dSave.has_key("IDX"):
						board_attach_row.article_idx = dSave["IDX"]
					else:
						board_attach_row.article_idx = article_id
					board_attach_row.org_path = unicode(new_file["O_PATH"])
					board_attach_row.new_path = new_file["D_PATH"]
					board_attach_row.filesize = unicode(new_file["SIZE"])
					
					Session.add(board_attach_row)
					Session.commit()
# ------------------------------------------------------------				  
				return okMessage("작성되었습니다.")
			else:
				return errMessage("작성 권한이 없습니다.")
		else:
			return errMessage("게시판 구분아이디가 잘못 전달되었습니다")