def retrieveAccountDetails(self): try: temp = Reference() # Temporary field to store Account Details if not(self.account_details == self.undefined): temp = Reference.get(self.account_details) if temp.isValid: return temp else: return self.undefined else: return self.undefined except: return self.undefined
def retrieveAccountHolder(self): try: if not(self.clsAccountHolder == self.undefined): temp = Reference.get(self.clsAccountHolder) if temp.isValid(): return temp else: return self.undefined else: return self.undefined except: return self._generalError
def returnAccountDetailsByReference(self, strinput): try: strinput = str(strinput) strinput = strinput.strip() temp = Reference() if temp.writeReference(strinput): findquery = db.Query(Reference).filter('strReferenceNum =', strinput) results = findquery.fetch(self._maxQResults) if len(results) > 0: temp = results[0] if temp.isValid(): return temp else: return self.undefined else: return self._ReferenceDonotExist else: return self._ReferenceDonotExist except: return self._generalError
def retrievePBidder(self): try: temp = self.pBidder if not (self.pBidder == self.undefined): temp = Reference.get(self.pBidder) if temp.readIsValid(): return temp else: return self.undefined else: return self.undefined except: return self._generalError
def update_json(self, json): self.value_type = parse(json, 'type') if self.value_type == 'TIMESTAMP': timestamp = parse(json, 'value') timestamp = float(timestamp) / 1000 # Timestamp with nanoseconds self.value = datetime.datetime.utcfromtimestamp(timestamp) elif self.value_type == 'REFERENCE_LIST': item_list = parse(json, 'value') references = [] for item in item_list: reference = Reference(item) references.append(reference) self.value = references else: self.value = parse(json, 'value')
def findMyProfile(self, myReference): try: Uref = Reference.get(myReference) User._pkeyvalue = Uref.key() if not (User._pkeyvalue == self.undefined): findquery = db.Query(Profiles).filter('indexReference =', User._pkeyvalue) results = findquery.fetch(limit=1) if len(results) > 0: tProfile = results[0] return tProfile else: return self.undefined else: return self.undefined except: return self._generalError
class Company(db.Expando): _minCompanyNameLen = 2 _maxCompanyNameLen = 256 _minDepartmentNameLen = 2 _maxDepartmentNameLen = 256 _minBranchNameLen = 2 _maxBranchNameLen = 256 #System Constants _maxQResults = 50 _UserNameDonotExist = 10001 _generalError = 10002 _ReferenceDonotExist = 10003 #Temporary variables to hold each instance present values _account_details = Reference() _company_contacts = ContactDetails() _physical_address = PhysicalAddress() _contact_person_names = Names() _contact_person_private_inf = Private_info # include the preferences class here account_details = db.ReferenceProperty(Reference, collection_name='company_collection') # Reference Class for login details of the company company_name = db.StringProperty() company_contacts = db.ReferenceProperty(ContactDetails, collection_name='company_collection') physical_address = db.ReferenceProperty(PhysicalAddress, collection_name='company_collection') # The Physical Address used for Company must be linked to the relevant # Reference Class department_name = db.StringProperty() branch_name = db.StringProperty() # The Name of the branch the specified company address is for. contact_person_names = db.ReferenceProperty(Names, collection_name='company_collection') # This Class contains the names of the person who is a contact person for this company #This names class should also be linked to the Reference Class for Company Login contact_person_private_inf = db.ReferenceProperty(Private_info, collection_name='company_collection') isValid = False #This function returns the reference for the Reference Class the calling function should then create a temporary #Reference Class to be able to read the actual Reference Class Details. def returnAccoutDetailsByUsername(self, strinput): try: strinput = str(strinput) strinput = strinput.strip() temp = Reference() if temp.writeUsername(strinput): findquery = db.Query(Reference).filter('strUsername ='******'strReferenceNum =', strinput) results = findquery.fetch(self._maxQResults) if len(results) > 0: temp = results[0] if temp.isValid(): return temp else: return self.undefined else: return self._ReferenceDonotExist else: return self._ReferenceDonotExist except: return self._generalError def readAccountDetails(self): try: if not(self.account_details == self.undefined): return self.account_details else: return self.undefined except: return self.undefined # This class actually writes the referenceproperty to the Reference Class teh actuall Reference Class must have been # already written using a temporary Reference Class variable def writeAccountDetails(self, strinput): try: strinput = str(strinput) strinput = strinput.strip() if not(strinput == self.undefined): self.account_details = strinput return True else: self.account_details = self.undefined return False except: return False def readCompanyName(self): try: if not(self.company_name == self.undefined): return self.company_name else: return self.undefined except: return self.undefined def writeCompanyName(self, strinput): try: strinput = str(strinput) strinput = strinput.strip() strinput = strinput.lower() if (strinput.isalnum() or strinput.isalpha()) and (len(strinput) <= self._minCompanyNameLen) and (len(strinput) >= self._maxCompanyNameLen): self.company_name = strinput return True else: self.company_name = self.undefined return False except: return False def readCompanyContacts(self): try: if not(self.company_contacts == self.undefined): return self.company_contacts() else: return self.undefined except: return self.undefined def writeCompanyContacts(self, strinput): try: strinput = str(strinput) strinput = strinput.strip() if not(strinput == self.undefined): self.company_contacts = strinput return True else: self.company_contacts = self.undefined return False except: return False def readPhysicalAddress(self): try: if not(self.physical_address == self.undefined): return self.physical_address() else: return self.undefined except: return self.undefined def writePhysicalAddress(self, strinput): try: strinput = str(strinput) strinput = strinput.strip() if not(strinput == self.undefined): self.physical_address = strinput return True else: self.physical_address = self.undefined return False except: return False def readDepartmentName(self): try: if not(self.department_name == self.undefined): return self.department_name else: return self.undefined except: return self.undefined def writeDepartmentName(self, strinput): try: strinput = str(strinput) strinput = strinput.strip() strinput = strinput.lower() if (strinput.isalnum() or strinput.isalpha()) and (len(strinput) <= self._minDepartmentNameLen) and (len(strinput) >= self._maxDepartmentNameLen): self.department_name = strinput return True else: self.department_name = self.undefined return False except: return False def readBranchName(self): try: if not(self.branch_name == self.undefined): return self.branch_name else: return self.undefined except: return self.undefined def writeBranchName(self, strinput): try: strinput = str(strinput) strinput = strinput.strip() strinput = strinput.lower() if (strinput.isalnum() or strinput.isalpha()) and (len(strinput) <= self._minBranchNameLen) and (len(strinput) >= self._maxBranchNameLen): self.branch_name = strinput return True else: self.branch_name = self.undefined return False except: return False def readContactPersonNames(self): try: if not(self.contact_person_names == self.undefined): return self.contact_person_names() else: return self.undefined except: return self.undefined def writeContactPersonNames(self, strinput): try: strinput = str(strinput) strinput = strinput.strip() if not(strinput == self.undefined): self.contact_person_names = strinput return True else: self.contact_person_names = self.undefined return False except: return False def readContactPersonPrivateInfo(self): try: if not(self.contact_person_private_inf == self.undefined): return self.contact_person_private_inf else: return self.undefined except: return self.undefined def writeContactPersonPrivateInf(self, strinput): try: strinput = str(strinput) strinput = strinput.strip() if not(strinput == self.undefined): self._contact_person_private_inf = strinput return True else: self._contact_person_private_inf = self.undefined return False except: return False def retrieveAccountDetails(self): try: temp = Reference() # Temporary field to store Account Details if not(self.account_details == self.undefined): temp = Reference.get(self.account_details) if temp.isValid: return temp else: return self.undefined else: return self.undefined except: return self.undefined def retrieveCompanyContacts(self): try: temp = ContactDetails() if not(self.company_contacts == self.undefined): temp = ContactDetails.get(self.company_contacts) if temp.isValid: return temp else: return self.undefined else: return self.undefined except: return self.undefined def retrievePhysicalAddress(self): try: temp = PhysicalAddress() if not(self.physical_address == self.undefined): temp = PhysicalAddress.get(self.physical_address) if temp.isValid: return temp else: return self.undefined else: return self.undefined except: return self.undefined def retrieveContactPersonNames(self): try: temp = Names() if not(self.contact_person_names == self.undefined): temp = Names.get(self.contact_person_names) if temp.isValid: return temp else: return self.undefined else: return self.undefined except: return self.undefined def retrieveContactPersonPrivateinf(self): try: temp = Private_info() if not(self._contact_person_private_inf == self.undefined): temp = Private_info.get(self._contact_person_private_inf()) if temp.isValid(): return temp else: return self.undefined else: return self.undefined except: return self.undefined def setIsValid(self): pass def readisValid(self): try: if self.setIsValid(): return True else: return False except: return False
def createBid(self, inBidAmount, inBidNotes, inBidOnThisJob, inMilestone, inMilestoneMarker, inSponsorCredit): try: Guser = users.get_current_user() if Guser: if isGoogleServer: reference = Guser.user_id() else: reference = self._tempCode findrequest = db.Query(Job).filter('strJobReference =', inBidOnThisJob) results = findrequest.fetch(limit=1) if len(results) > 0: tjob = results[0] logging.info('FREELANCE JOB REFERENCE FOUND :' + inBidOnThisJob) findrequest = db.Query(Reference).filter( 'strReferenceNum =', reference) results = findrequest.fetch(limit=1) if len(results) > 0: UReference = results[0] else: UReference = Reference() logging.info('UREFERENCE KEY:' + str(UReference.key())) if not (reference == tjob.strOwnerReference) or ( reference == self._tempCode): logging.info('IN BID AMOUNT :' + inBidAmount) self._bidJobPkey = inBidOnThisJob # this helps the active bids sub to show the relevant bids findrequest = db.Query(Bids).filter( 'BidonThisJob =', inBidOnThisJob).filter('pBidder =', reference) results = findrequest.fetch(limit=self._maxQResults) if len(results) == 0: if self.writeBidAmount( inBidAmount) and self.writeBidOnThisJob( inBidOnThisJob): self.writeBidNotes(inBidNotes) self.writeMilestonePayment(inMilestone) self.writeMilestoneMarker(inMilestoneMarker) self.writeSponsorCredit(inSponsorCredit) self.writePBidder(reference) logging.info( 'WRITE BID AMOUNT AND OTHERS SUCCEEDED') self.CurrencySymbol = self._defaultCurrency self._bidPkey = self.put() self.BidReference = str(self._bidPkey) self.put() return True else: logging.info('FAILURE CREATING BID ++++') return self._ErrorCreatingBid else: logging.info('BID ALREADY PLACE') return results else: logging.info('YOU ARE THE JOB OWNER BITCH') return self._CannotBidOnOwnJob else: return self._userNotLoggedin except: logging.info('EXCEPTIONS ARE BEING THROWN ON CREATING BIDS') return self._generalError