def JoinProcessing(objHere): strEmailAddress = GetParameter(objHere, "EmailAddress") strEmailAddress = strEmailAddress.lower().replace(" ", "") if strEmailAddress and ValidEmailAddress(strEmailAddress): if not GetMemberForEmailAddress(objHere, strEmailAddress): objMember = RegisterNewMember(objHere, strEmailAddress) LoginMember(objMember) objMember.SendPasswordReminder() return objMember.Username return ""
def ShopAt(objHere): # http://www.MentorCoaches.com/ShopAt?BookId=....&ShopId=1 strLink = "http://www.MentorCoaches.com/" strBookId = GetParameter(objHere.REQUEST, 'Id') strShopId = GetParameter(objHere.REQUEST, 'ShopId') if strShopId.isdigit(): intShopId = int(strShopId) else: intShopId = 0 if strBookId and intShopId: LogShopAt(objHere, strBookId, intShopId) strLink = GetShopLink(objHere, strBookId, intShopId) return strLink
def ConfirmEmailAddress(objHere): strId = GetParameter(objHere.REQUEST, 'Id') # print "ConfirmEmailAddress, id = ", strId strId = strId.replace('"', '') if not strId: return "<p>No confirmation string specified. Confirmation failed. Please try again</p>" objEmailAddress = SearchOne(objHere, 'E3EmailAddress', 'ConfirmationString', strId) if not objEmailAddress: return "<p>Confirmation string incorrect. Confirmation failed. Please try again</p>" dtmConfirmationSent = objEmailAddress.GetConfirmationStringSent() objEmailAddress.Confirm() strConfirmationMessage = """ <p>Email address %s confirmed</p> <p>You can now use this email address to send and receive Euro Coach List messages</p>""" % objEmailAddress.EmailAddress return strConfirmationMessage
def ListForTextSearch(objRequest, objHere): strSearchFor = GetParameter(objHere.REQUEST, 'SearchFor') if not strSearchFor: return "No search criteria entered" lstWords = strSearchFor.split() dictBooks = {} for strWord in lstWords: for strLocation in ('Title', 'SubTitle', 'ISBN', 'Authors'): objBooks = SearchMany(objHere, 'MCIBook', strLocation, strWord) dictBooks = CountBooks(dictBooks, objBooks) strResult = GetBooklistFromDictionary(dictBooks, len(lstWords), "words", objHere) if not strResult: strResult = "No books found" return """<span class = "PageTitle2">All books for "%s"</span><br>%s""" % (strSearchFor, strResult)
def GetWhen(objRequest): strMonth = GetParameter(objRequest, 'Month') strYear = GetParameter(objRequest, 'Year') strDate = GetParameter(objRequest, 'Date') if strMonth and strYear and strMonth.isdigit() and strYear.isdigit(): intMonth = int(strMonth) intYear = int(strYear) if strDate: intDate = int(strDate) else: intDate = 0 else: intMonth = 0 intYear = 0 intDate = 0 return (intYear, intMonth, intDate)
def Unbounce(objMember): strEmailAddress = GetParameter(objMember.REQUEST, "SubmitButton") strEmailAddress = strEmailAddress.split()[1] objMember.Unbounce(strEmailAddress) SetMessage(objMember, '', '%s resumed' % strEmailAddress)
def JoiningPage(objHere): # If doesn't have a form, or blank email address, assume they got to this page directly strStep = GetParameter(objHere, "JoinStep") if not strStep: strStep = "JoinNow" strEmailAddress = GetParameter(objHere, "EmailAddress") strEmailAddress = strEmailAddress.lower().replace(" ", "") strCallingURL = GetParameter(objHere, "CallingURL") if not strCallingURL: strCallingURL = objHere.REQUEST.HTTP_REFERER strCallingURL = RemoveAction(strCallingURL) if strStep == "JoinNow": if not strEmailAddress: return JoiningForm(objHere, strCallingURL, strEmailAddress) if strEmailAddress.lower().replace(" ", "") == "emailaddress": return JoiningForm(objHere, strCallingURL, strEmailAddress) if not ValidEmailAddress(strEmailAddress): return JoiningForm(objHere, strCallingURL, strEmailAddress, "Warning: Invalid email address entered. Please submit a correct email address") objMember = GetCurrentMember(objHere) if not objMember: objMember = GetMemberForEmailAddress(objHere, strEmailAddress) if objMember: objMember.SendPasswordReminder("someone just tried to register using your email address: %s" % strEmailAddress) strErrorMessage = "Warning: This email address is already registered. Please log in (using the form on the left hand side) instead of (re-)joining or enter the correct email address. A reminder of your log in details has been sent to %s" % strEmailAddress else: strErrorMessage = """An unknown error occurred. Please try again or <a href="/ContactDetails">contact the list owner</a>""" return JoiningForm(objHere, strCallingURL, strEmailAddress, strErrorMessage) # Note: Actual creating of new member happens in E3StartStop.JoinProcessing dictLoginDetails = LoadDataFromObject(objMember, ("Username", )) return WelcomeScreen(objMember, strCallingURL, dictLoginDetails) elif strStep == "UpdateLoginDetails": objMember = GetCurrentMember(objHere) lstFields = ("Username", "Password", "PasswordConfirmation") dictLoginDetails = GetDataFromForm(objHere, objHere.REQUEST.form, lstFields) dictErrors = ValidLoginDetails(objMember, dictLoginDetails) if dictErrors: return WelcomeScreen(objMember, strCallingURL, dictLoginDetails, dictErrors = dictErrors) SaveLoginDetails(objMember, dictLoginDetails) dictLoginDetails = LoadDataFromObject(objMember, ("Username", )) objMember.SendPasswordReminder() return WelcomeScreen(objMember, strCallingURL, dictLoginDetails, strLoginMessage = "Log in details updated") elif "SwitchTo" in strStep: objMember = GetCurrentMember(objHere) if strStep == "SwitchToDirectListDelivery": objMember.EmailFrequency_ECL = "Direct" elif strStep == "SwitchToDailyListDigest": objMember.EmailFrequency_ECL = "Daily" elif strStep == "SwitchToDirectAdvertDelivery": objMember.EmailFrequency_ECL_Advert = "Direct" elif strStep == "SwitchToDailyAdvertDigest": objMember.EmailFrequency_ECL_Advert = "Daily" dictLoginDetails = LoadDataFromObject(objMember, ("Username", )) return WelcomeScreen(objMember, strCallingURL, dictLoginDetails, strDeliveryMessage = "Email delivery updated") return "<p>This is the joining page</p>"