Example #1
0
File: upload.py Project: onetera/sp
	def editor_upload(self):
		objUpload = Upload()
		objUpload.EditorInit()

		funcNum     = request.params["CKEditorFuncNum"]
		CKEditor    = request.params["CKEditor"]
		upload_file = request.params["upload"]
		
		new_file = objUpload.upload_file_move(upload_file, "Image")

		from os.path import basename

		if 200 == new_file["responseCode"]:
			public_path = "/editor/%s" % basename(new_file["D_PATH"])
			return u"<script type=\"text/javascript\">window.parent.CKEDITOR.tools.callFunction('%s', '%s', '업로드 성공');</script>" % (funcNum, public_path)
		else:
			return u"이미지만 업로드 가능합니다"
Example #2
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("게시판 구분아이디가 잘못 전달되었습니다")
Example #3
0
def sendMessage( receiver, receiverCC, receiverBCC, subject, content, attachments=None, withSMS=None ):
	""" 쪽지함에 쪽지를 발송"""
	
	#[TODO] IF not logined !!

	withEmail = True

	emailList = []
	smsList = []
	msgIDXs = []

	receiverTo = getReceiver(receiver)
	receiverCc = getReceiver(receiverCC)
	receiverBcc = getReceiver(receiverBCC)
	
	# 쪽지 내용 저장
	msg = Msg()
	msg.SenderID = unicode(Login.getID())
	msg.SenderName = unicode(Login.getName())
	msg.Subject = unicode(subject)
	msg.Content = unicode(content)
	msg.withSMS = unicode(withSMS)
	msg.CreateDate = datetime.datetime.now() 
	
	Session.add(msg)
	Session.commit()
	
	# To들에게 보내기
	setMsgReceiver(receiverTo, msg.idx, "0")
	# CC들에게 보내기
	setMsgReceiver(receiverCc, msg.idx, "1")
	# BCC들에게 보내기
	setMsgReceiver(receiverBcc, msg.idx, "2")

	# SMS 발송 관련 처리
	if withSMS:
		smsList = list()
		receiverList = receiverTo + receiverCc +receiverBcc
		for msg_receiver in receiverList:
			if type(msg_receiver) != dict:
				continue
			smsList.append(msg_receiver["HandPhone"])

		if len(smsList) > 0:
			SMS.send(sendMsg=u"[sparta] %s" % msg.Content[:70], recvList=smsList)
	
	if withEmail:
		senderData = getReceiver("<%s>" % Login.getID())[0]["GwID"]
		emailList = list()
		receiverList = receiverTo + receiverCc +receiverBcc
		for msg_receiver in receiverList:
			if type(msg_receiver) != dict:
				continue			
			if str(msg_receiver["GwID"]).startswith("D"):
				emailList.append( str(msg_receiver["GwID"])+"@idea.co.kr" )
		if len(emailList) > 0:
			sendEmail("*****@*****.**" % senderData, msg.Subject, msg.Content, recvList=emailList)
   
	if attachments:
		objUpload = Upload()
		objUpload.MsgInitialize()
		
		for attach_item in attachments:
			new_file = objUpload.upload_file_move(attach_item)

			rowMsgAttach = MsgAttach()
			rowMsgAttach.Msg_IDX = unicode(msg.idx)
			rowMsgAttach.OriginalFileName = unicode(new_file["O_PATH"])
			rowMsgAttach.NewFileName = unicode(new_file["D_PATH"])
			rowMsgAttach.FileSize = unicode(new_file["SIZE"])

			Session.add(rowMsgAttach)

		Session.commit()
	return len(receiverTo)