Ejemplo n.º 1
0
 def raw(self, db, username, password, latitude, longitude, orientation,
         uploadedFile, uploadedThumbFile, filetype, thoroughfare,
         subThoroughfare, locality, subLocality, adminArea, subAdminArea,
         postalcode, country):
     response = None
     result, fault = util.getResponseTemplates(False, False)
     return fault
     if (util.checkNulls(fault, username, password, latitude, longitude,
                         orientation, uploadedFile, uploadedThumbFile,
                         filetype)):
         return fault
     photoFileLocation = util.upload(uploadedFile, filetype)
     thumbFileLocation = util.upload(uploadedThumbFile, filetype)
     if (not photoFileLocation):
         util.setFaultCodeAndMessage(fault, faults.UPLOAD_ERROR,
                                     faults.UPLOAD_ERROR_MESSAGE)
         return fault
     if (not thumbFileLocation):
         util.setFaultCodeAndMessage(fault, faults.UPLOAD_ERROR,
                                     faults.UPLOAD_ERROR_MESSAGE)
         return fault
     published = db.publishTag(username, password, latitude, longitude,
                               orientation, photoFileLocation,
                               thumbFileLocation, thoroughfare,
                               subThoroughfare, locality, subLocality,
                               adminArea, subAdminArea, postalcode, country)
     if (not published):
         util.setFaultCodeAndMessage(fault, faults.PUBLISH_ERROR,
                                     faults.PUBLISH_ERROR_MESSAGE)
         response = fault
     else:
         util.setResult(result, True)
         result['large'] = photoFileLocation
         response = result
     return response
Ejemplo n.º 2
0
 def raw(self, db, email, username, password):
     response = None
     result, fault = util.getResponseTemplates(False, False)
     if (util.checkNulls(fault, username, password, email)): return fault
     if (not util.checkUsername(username)):
         util.setFaultCodeAndMessage(fault, faults.INVALID_USERNAME,
                                     faults.INVALID_USERNAME_MESSAGE)
         return fault
     if (not util.checkEmail(email)):
         util.setFaultCodeAndMessage(fault, faults.INVALID_EMAIL,
                                     faults.INVALID_EMAIL_MESSAGE)
         return fault
     if (db.doesUsernameExist(username)):
         util.setFaultCodeAndMessage(fault, faults.USERNAME_EXISTS,
                                     faults.USERNAME_EXISTS_MESSAGE)
         response = fault
     elif (db.doesEmailExist(email)):
         util.setFaultCodeAndMessage(fault, faults.EMAIL_EXISTS,
                                     faults.EMAIL_EXISTS_MESSAGE)
         response = fault
     if (response): return response
     reg = db.registerUser(email, username, password)
     if (not reg):
         util.setFaultCodeAndMessage(fault, faults.DB_REGISTRATION_ERROR,
                                     faults.DB_REGISTRATION_ERROR_MESSAGE)
         response = fault
     else:
         util.setResult(result, True)
         response = result
     return response
Ejemplo n.º 3
0
	def raw(self,db,email,username,password):
		response = None
		result,fault = util.getResponseTemplates(False,False)
		if(util.checkNulls(fault,username,password,email)): return fault
		if(not util.checkUsername(username)):
			util.setFaultCodeAndMessage(fault,faults.INVALID_USERNAME,faults.INVALID_USERNAME_MESSAGE)
			return fault
		if(not util.checkEmail(email)):
			util.setFaultCodeAndMessage(fault,faults.INVALID_EMAIL,faults.INVALID_EMAIL_MESSAGE)
			return fault
		if(db.doesUsernameExist(username)):
			util.setFaultCodeAndMessage(fault,faults.USERNAME_EXISTS,faults.USERNAME_EXISTS_MESSAGE)
			response = fault
		elif(db.doesEmailExist(email)):
			util.setFaultCodeAndMessage(fault,faults.EMAIL_EXISTS,faults.EMAIL_EXISTS_MESSAGE)
			response = fault
		if(response): return response
		reg = db.registerUser(email,username,password)
		if(not reg):
			util.setFaultCodeAndMessage(fault,faults.DB_REGISTRATION_ERROR,faults.DB_REGISTRATION_ERROR_MESSAGE)
			response = fault
		else:
			util.setResult(result,True)
			response = result
		return response
Ejemplo n.º 4
0
	def raw(self,db,stickers):
		response = None
		result,fault = util.getResponseTemplates(False,False)
		if(util.checkNulls(fault,stickers)): return fault
		res = db.uploadStickers(stickers)
		if(not res):
			util.setFaultCodeAndMessage(fault,faults.STICKER_UPLOAD_ERROR,faults.STICKER_UPLOAD_ERROR_MESSAGE)
			return fault
		util.setResult(result,True)
		return result
Ejemplo n.º 5
0
 def raw(self, db, stickers):
     response = None
     result, fault = util.getResponseTemplates(False, False)
     if (util.checkNulls(fault, stickers)): return fault
     res = db.uploadStickers(stickers)
     if (not res):
         util.setFaultCodeAndMessage(fault, faults.STICKER_UPLOAD_ERROR,
                                     faults.STICKER_UPLOAD_ERROR_MESSAGE)
         return fault
     util.setResult(result, True)
     return result
Ejemplo n.º 6
0
	def raw(self,db,email,username,password):
		response = None
		result,fault = util.getResponseTemplates(False,False)
		if(util.checkNulls(fault,username,password,email)): return fault
		unreg = db.unregisterUser(email,username,password)
		if(not unreg):
			util.setFaultCodeAndMessage(fault,faults.DB_UNREGISTER_ERROR,faults.DB_UNREGISTER_ERROR_MESSAGE)
			response = fault
		else:
			util.setResult(result,True)
			response = result
		return response
Ejemplo n.º 7
0
	def raw(self,db,username,password,newPassword):
		response = None
		result,fault = util.getResponseTemplates(False,False)
		if(util.checkNulls(fault,username,password,newPassword)): return fault
		cp = db.changePassword(username,password,newPassword)
		if(not cp):
			util.setFaultCodeAndMessage(fault,faults.DB_CHANGE_PASSWORD_ERROR,faults.DB_CHANGE_PASSWORD_ERROR_MESSAGE)
			response = fault
		else:
			util.setResult(result,True)
			response = result
		return response
Ejemplo n.º 8
0
	def raw(self,db,username):
		response = None
		result,fault = util.getResponseTemplates(False,False)
		if(util.checkNulls(fault,username)): return fault
		data = db.getProfileInfo(username)
		if(not data):
			util.setFaultCodeAndMessage(fault,faults.PROFILE_INFO_ERROR,faults.PROFILE_INFO_ERROR_MESSAGE)
			response = fault
		else:
			util.setResultWithData(result,True,data)
			response = result
		return response
Ejemplo n.º 9
0
	def raw(self,db,username,offset,limit):
		response = None
		result,fault = util.getResponseTemplates(False,False)
		if(util.checkNulls(fault,username)): return fault
		data,totalRows = db.getTagsForUserWithTotalRows(username,offset,limit)
		if(not data):
			util.setFaultCodeAndMessage(fault,faults.TAGS_ERROR,faults.TAGS_ERROR_MESSAGE)
			response = fault
		else:
			util.setResultWithDataAndTotalRows(result,True,data,totalRows)
			response = result
		return response
Ejemplo n.º 10
0
	def raw(self,db,tagId,username,password):
		response = None
		result,fault = util.getResponseTemplates(False,False)
		if(util.checkNulls(fault,tagId,username,password)): return fault
		dt = db.deleteTag(tagId,username,password)
		if(not dt):
			util.setFaultCodeAndMessage(fault,faults.DELETE_TAG_ERROR,faults.DELETE_TAG_ERROR_MESSAGE)
			response = fault
		else:
			util.setResult(result,True)
			response = result
		return response
Ejemplo n.º 11
0
	def raw(self,db,query,offset,limit):
		response = None
		result,fault = util.getResponseTemplates(False,False)
		if(util.checkNulls(fault,query,offset,limit)): return fault
		se,totalRows = db.searchWithTotalRows(query,offset,limit)
		if(not se):
			util.setFaultCodeAndMessage(fault,faults.DB_SEARCH_ERROR,faults.DB_SEARCH_ERROR_MESSAGE)
			response = fault
		else:
			util.setResultWithDataAndTotalRows(result,True,se,totalRows)
			response = result
		return response
Ejemplo n.º 12
0
	def raw(self,db,latitude,longitude,offset,limit):
		response = None
		result,fault = util.getResponseTemplates(False,False)
		if(util.checkNulls(fault,latitude,longitude,offset,limit)): return fault
		data,totalRows = db.getARNearbyWithTotalRows(latitude,longitude,offset,limit)
		if(not data):
			util.setFaultCodeAndMessage(fault,faults.NEARBY_ERROR,faults.NEARBY_ERROR_MESSAGE)
			response = fault
		else:
			util.setResultWithDataAndTotalRows(result,True,data,totalRows)
			response = result
		return response
Ejemplo n.º 13
0
 def raw(self, db, tagId, username, password):
     response = None
     result, fault = util.getResponseTemplates(False, False)
     if (util.checkNulls(fault, tagId, username, password)): return fault
     dt = db.deleteTag(tagId, username, password)
     if (not dt):
         util.setFaultCodeAndMessage(fault, faults.DELETE_TAG_ERROR,
                                     faults.DELETE_TAG_ERROR_MESSAGE)
         response = fault
     else:
         util.setResult(result, True)
         response = result
     return response
Ejemplo n.º 14
0
 def raw(self, db, username):
     response = None
     result, fault = util.getResponseTemplates(False, False)
     if (util.checkNulls(fault, username)): return fault
     data = db.getProfileInfo(username)
     if (not data):
         util.setFaultCodeAndMessage(fault, faults.PROFILE_INFO_ERROR,
                                     faults.PROFILE_INFO_ERROR_MESSAGE)
         response = fault
     else:
         util.setResultWithData(result, True, data)
         response = result
     return response
Ejemplo n.º 15
0
 def raw(self, db, offset, limit):
     response = None
     result, fault = util.getResponseTemplates(False, False)
     if (util.checkNulls(fault, offset, limit)): return fault
     data, totalRows = db.getTagsByRatingWithTotalRows(offset, limit)
     if (not data):
         util.setFaultCodeAndMessage(fault, faults.NEARBY_ERROR,
                                     faults.NEARBY_ERROR_MESSAGE)
         response = fault
     else:
         util.setResultWithDataAndTotalRows(result, True, data, totalRows)
         response = result
     return response
Ejemplo n.º 16
0
	def raw(self,db,username,password):
		response = None
		result,fault = util.getResponseTemplates(False,False)
		if(util.checkNulls(fault,username,password)): return fault
		auth = db.authenticate(username,password)
		if(not auth):
			util.setFaultCodeAndMessage(fault,faults.AUTH_ERROR,faults.AUTH_ERROR_MESSAGE)
			response = fault;
		else:
			util.setResult(result,True)
			result['id'] = auth['id']
			response = result
		return response
Ejemplo n.º 17
0
	def raw(self,db,tagId,rating):
		response = None
		tagId = int(tagId)
		result,fault = util.getResponseTemplates(False,False)
		if(util.checkNulls(fault,tagId)): return fault
		rated = db.rateTag(tagId,rating)
		if(not rated):
			util.setFaultCodeAndMessage(fault,faults.RATING_ERROR,faults.RATING_ERROR_MESSAGE)
			response = fault
		else:
			util.setResult(result,True)
			response = result
		return response
Ejemplo n.º 18
0
 def raw(self, db, query, offset, limit):
     response = None
     result, fault = util.getResponseTemplates(False, False)
     if (util.checkNulls(fault, query, offset, limit)): return fault
     se, totalRows = db.searchWithTotalRows(query, offset, limit)
     if (not se):
         util.setFaultCodeAndMessage(fault, faults.DB_SEARCH_ERROR,
                                     faults.DB_SEARCH_ERROR_MESSAGE)
         response = fault
     else:
         util.setResultWithDataAndTotalRows(result, True, se, totalRows)
         response = result
     return response
Ejemplo n.º 19
0
 def raw(self, db, email, username, password):
     response = None
     result, fault = util.getResponseTemplates(False, False)
     if (util.checkNulls(fault, username, password, email)): return fault
     unreg = db.unregisterUser(email, username, password)
     if (not unreg):
         util.setFaultCodeAndMessage(fault, faults.DB_UNREGISTER_ERROR,
                                     faults.DB_UNREGISTER_ERROR_MESSAGE)
         response = fault
     else:
         util.setResult(result, True)
         response = result
     return response
Ejemplo n.º 20
0
	def raw(self,db,username,password,latitude,longitude,orientation,filename,thumbFilename,filetype,thoroughfare,subThoroughfare,locality,subLocality,adminArea,subAdminArea,postalcode,country):
		response = None
		result,fault = util.getResponseTemplates(False,False)
		if(util.checkNulls(fault,username,password,latitude,longitude,orientation,filename,thumbFilename,filetype)): return fault
		published = db.publishTag(username,password,latitude,longitude,orientation,filename,thumbFilename,thoroughfare,subThoroughfare,locality,subLocality,adminArea,subAdminArea,postalcode,country)
		if(not published):
			util.setFaultCodeAndMessage(fault,faults.PUBLISH_ERROR,faults.PUBLISH_ERROR_MESSAGE)
			response = fault
		else:
			util.setResult(result,True)
			result['large'] = filename
			response = result
		return response
Ejemplo n.º 21
0
 def raw(self, db, username, password):
     response = None
     result, fault = util.getResponseTemplates(False, False)
     if (util.checkNulls(fault, username, password)): return fault
     auth = db.authenticate(username, password)
     if (not auth):
         util.setFaultCodeAndMessage(fault, faults.AUTH_ERROR,
                                     faults.AUTH_ERROR_MESSAGE)
         response = fault
     else:
         util.setResult(result, True)
         result['id'] = auth['id']
         response = result
     return response
Ejemplo n.º 22
0
 def raw(self, db, tagId, rating):
     response = None
     tagId = int(tagId)
     result, fault = util.getResponseTemplates(False, False)
     if (util.checkNulls(fault, tagId)): return fault
     rated = db.rateTag(tagId, rating)
     if (not rated):
         util.setFaultCodeAndMessage(fault, faults.RATING_ERROR,
                                     faults.RATING_ERROR_MESSAGE)
         response = fault
     else:
         util.setResult(result, True)
         response = result
     return response
Ejemplo n.º 23
0
 def raw(self, db, username, password, newPassword):
     response = None
     result, fault = util.getResponseTemplates(False, False)
     if (util.checkNulls(fault, username, password, newPassword)):
         return fault
     cp = db.changePassword(username, password, newPassword)
     if (not cp):
         util.setFaultCodeAndMessage(
             fault, faults.DB_CHANGE_PASSWORD_ERROR,
             faults.DB_CHANGE_PASSWORD_ERROR_MESSAGE)
         response = fault
     else:
         util.setResult(result, True)
         response = result
     return response
Ejemplo n.º 24
0
 def raw(self, db, imageName):
     global facebook_template, facebook_error_template, facebook_template_noloc
     response = None
     result, fault = util.getResponseTemplates(False, False)
     info = None
     info = db.getTagInfoFromImageName(imageName)
     if (not facebook_template_noloc):
         ft = open("templates/facebook_share_noloc.html", "r")
         facebook_template_noloc = ft.read()
         ft.close()
     if (not facebook_template):
         ft = open("templates/facebook_share.html", "r")
         facebook_template = ft.read()
         ft.close()
     if (not facebook_error_template):
         ft = open("templates/facebook_share_error.html", "r")
         facebook_error_template = ft.read()
         ft.close()
     s = ''
     if (not info):
         d = {}
         d['img'] = util.getAbsoluteImageURLInStorage("static/prince.jpg")
         s = util.replace_tokens(facebook_error_template, d, False)
         result['html'] = s
     else:
         d = info['createdAt']
         fdate = d.strftime("%m/%d/%Y")
         info['img'] = util.getAbsoluteImageURL(info["large"])
         info['fdate'] = fdate
         noloc = False
         if (info['thoroughfare'] == 'None'
                 or info['thoroughfare'] == None):
             noloc = True
         if (info['locality'] == "None" or info['locality'] == None):
             noloc = True
         if (noloc): s = util.replace_tokens(facebook_template_noloc, info)
         else: s = util.replace_tokens(facebook_template, info)
         result['html'] = s
     return result
Ejemplo n.º 25
0
	def raw(self,db,imageName):
		global facebook_template,facebook_error_template,facebook_template_noloc
		response = None
		result,fault = util.getResponseTemplates(False,False)
		info = None
		info = db.getTagInfoFromImageName(imageName)
		if(not facebook_template_noloc):
			ft = open("templates/facebook_share_noloc.html","r")
			facebook_template_noloc = ft.read()
			ft.close();
		if(not facebook_template):
			ft = open("templates/facebook_share.html","r")
			facebook_template = ft.read()
			ft.close();
		if(not facebook_error_template):
			ft = open("templates/facebook_share_error.html","r")
			facebook_error_template = ft.read()
			ft.close()
		s = ''
		if(not info):
			d = {}
			d['img'] = util.getAbsoluteImageURLInStorage("static/prince.jpg")
			s = util.replace_tokens(facebook_error_template,d,False)
			result['html'] = s
		else:
			d = info['createdAt']
			fdate = d.strftime("%m/%d/%Y")
			info['img'] = util.getAbsoluteImageURL(info["large"])
			info['fdate'] = fdate
			noloc = False
			if(info['thoroughfare'] == 'None' or info['thoroughfare'] == None): noloc = True
			if(info['locality'] == "None" or info['locality'] == None): noloc = True
			if(noloc): s = util.replace_tokens(facebook_template_noloc,info)
			else: s = util.replace_tokens(facebook_template,info)
			result['html'] = s
		return result