def serveIndex(request, force_mcf=None): currentuser = getCurrentUser(request) mcf = 'dashboard' params = '' if currentuser.is_authenticated(): #only clear if we were logged in. urlstate = getCurrentURLState(request, andClear=True) else: urlstate = getCurrentURLState(request) if force_mcf: mcf = force_mcf elif urlstate.redirectMainContentFunction: mcf = urlstate.redirectMainContentFunction if urlstate.params: params = urlstate.params if params: sendparams = params[1] else: sendparams = '' jsonparams = simplejson.dumps(sendparams) return render_to_response('index.html', { 'APP_SECURE_URL': siteurl(request), 'user': request.user, 'mainContentFunction': mcf, 'wh': webhelpers, 'params': jsonparams, }, context_instance=RequestContext(request))
def serveIndex(request, force_mcf=None): currentuser = getCurrentUser(request) mcf = 'dashboard' params = '' if currentuser.is_authenticated(): #only clear if we were logged in. urlstate = getCurrentURLState(request, andClear=True) else: urlstate = getCurrentURLState(request) if force_mcf: mcf = force_mcf elif urlstate.redirectMainContentFunction: mcf = urlstate.redirectMainContentFunction if urlstate.params: params = urlstate.params if params: sendparams = params[1] else: sendparams = '' jsonparams = json.dumps(sendparams) return render_to_response('index.html', { 'APP_SECURE_URL': siteurl(request), 'user': request.user, 'mainContentFunction': mcf, 'wh': webhelpers, 'params': jsonparams, }, context_instance=RequestContext(request))
def viewFormalRedirect(request, *args): urlstate = getCurrentURLState(request) urlstate.redirectMainContentFunction = 'quote:viewformal' urlstate.params = [ 'quote:viewformal', { 'qid': int(request.REQUEST.get('quoterequestid', 0)) } ] return HttpResponseRedirect(siteurl(request))
def sendPasswordChangedEmail(request, toemail, fromemail=settings.RETURN_EMAIL): subject = 'Mastr-MS Password Changed' body = 'Your Mastr-MS password was changed.\r\n\r\n' body += 'Your password has been changed using the "Forgot Password" feature in Mastr-MS.\r\n\r\n' body += 'Please click the following link to login to Mastr-MS.\r\n\r\n' body += siteurl(request) + '\r\n\r\n' makeAndSendMail(subject, body, fromemail, [toemail], fail_silently=False)
def sendAccountModificationEmail(request, toemail, fromemail=settings.RETURN_EMAIL): subject = 'Mastr-MS Account Change' body = 'Your Mastr-MS account has been modified\r\n\r\n' body += 'Either you, or an administrator has modified your account details or status\r\n\r\n' body += 'Please click the following link to login to Mastr-MS:\r\n' body += '%s\r\n\r\n' % (siteurl(request)) makeAndSendMail(subject, body, fromemail, [toemail], fail_silently=False)
def forgotPasswordRedirect(request, *args): u = request.user try: urlstate = getCurrentURLState(request) urlstate.redirectMainContentFunction = 'login:resetpassword' urlstate.resetPasswordEmail = request.REQUEST['em'] urlstate.resetPasswordValidationKey = request.REQUEST['vk'] return HttpResponseRedirect(siteurl(request)) except Exception, e: logger.warning('Exception in forgot password redirect: %s' % (str(e)))
def sendRegistrationToAdminEmail(request, email, toemail, fromemail=settings.RETURN_EMAIL): #This email should always come from 'the system' - i.e. the RETURN_EMAIL #The request goes 'TO' an admin or node rep, which is passed in in 'toemail'. subject = 'New Mastr-MS Registration' body = 'A new user has registered for Mastr-MS. Please follow the link below to review this request.\r\n\r\n' body += "Their e-mail address is %s.\r\n\r\n" % email body += "Please click the following link to login to Mastr-MS.\r\n\r\n" body += "%s" % (siteurl(request)) makeAndSendMail(subject, body, fromemail, [toemail], fail_silently=False)
def sendForgotPasswordEmail(request, toemail, vk, fromemail=settings.RETURN_EMAIL): subject = 'Mastr-MS Forgot Password Link' body = "Use the following link to change your Mastr-MS password.\r\n\r\n" body += "Either you, or someone specifying your email address, has requested a new password for Mastr-MS.\r\n\r\n" body += "If this was not you, please ignore this email.\r\n\r\n" body += "Please click the following link to go to Mastr-MS and change your password.\r\n" body += "<%slogin/forgotPassword?em=%s&vk=%s>\r\n\r\n" % (siteurl(request), toemail, vk) makeAndSendMail(subject, body, fromemail, [toemail], fail_silently=False)
def sendFormalStatusEmail(request, qid, status, toemail, fromemail=settings.RETURN_EMAIL): #Goes TO an admin or node rep, and comes FROM the default return email subject = 'MA Formal Quote Status: %s' % (status) body = '%s has changed the formal quote status to %s\r\n\r\n' % (fromemail, status) body += "Please click the following link to view this formal quote on Mastr-MS.\r\n\r\n" body += "%s%s%s" % (siteurl(request), "quote/viewformal?quoterequestid=", str(qid)) makeAndSendMail(subject, body, fromemail, [toemail], fail_silently=False)
def sendQuoteRequestToAdminEmail(request, qid, firstname, lastname, toemail, fromemail=settings.RETURN_EMAIL): #This email should always come from 'the system' - i.e. the RETURN_EMAIL #The request goes 'TO' an admin or node rep, which is passed in in 'toemail'. subject = 'Mastr-MS Quote Request Requires Attention' body = 'A new Mastr-MS Quote Request has been added to the system. Please follow the link below to read this request.\r\n\r\n' body += "Please click the following link to login to Mastr-MS.\r\n\r\n" body += "%s" % (siteurl(request)) body += "\r\n\r\nSender's name or email: %s %s" % (firstname, lastname) makeAndSendMail(subject, body, fromemail, [toemail], fail_silently=False)
def sendApprovedRejectedEmail(request, toemail, status, fromemail=settings.RETURN_EMAIL): if status == MADAS_USER_GROUP: status = 'Approved' subject = 'Mastr-MS Account ' + status body = 'Your Mastr-MS account was ' + status + '\r\n\r\n' if status == 'Approved': body += 'Please click the following link to login to Mastr-MS:\r\n' body += '%s\r\n\r\n' % (siteurl(request)) else: body += 'Sorry, no reason was provided\r\n' makeAndSendMail(subject, body, fromemail, [toemail], fail_silently=False)
def sendFormalQuoteEmail(request, qid, attachmentname, toemail, cclist=None, fromemail=settings.RETURN_EMAIL): #The email is sent TO whoever the quote was requested by, #and should come FROM the webuser who was logged in and clicked the 'send formal quote' button subject = 'MA Formal Quote' body = 'Formal Quote details:\r\n\r\n%s\r\n\r\n' % (attachmentname) body += "Please click the following link to view this formal quote on Mastr-MS.\r\n\r\n" body += "%s%s%s" % (siteurl(request), "quote/viewformal?quoterequestid=", str(qid)) e = FixedEmailMessage(subject=subject, body=body, from_email=fromemail, to=[toemail], cc=cclist) e.sendMail()
def processLogout(request, *args): logger.debug( '*** processLogout : enter***') logout(request) #let Django log the user out logger.debug('*** processLogout : exit***') return HttpResponseRedirect(siteurl(request))
def processLoginView(request, *args): success = processLogin(request, args) return HttpResponseRedirect(siteurl(request))
def processLogout(request, *args): logger.debug('*** processLogout : enter***') logout(request) #let Django log the user out logger.debug('*** processLogout : exit***') return HttpResponseRedirect(siteurl(request))
def viewFormalRedirect(request, *args): urlstate = getCurrentURLState(request) urlstate.redirectMainContentFunction = 'quote:viewformal' urlstate.params = ['quote:viewformal', {'qid':int(request.REQUEST.get('quoterequestid', 0))}] return HttpResponseRedirect(siteurl(request))