def _notify_error_user(email_user, original_filename, recid, submission_title, ln=invenio.config.CFG_SITE_LANG): """Sends an error notification to the specified address of the user. Is called by process_batch_job() if an error occured during the processing. @param email_user: email address of the user @type email_user: string @param email_admin: email address of the admin @type email_admin: string """ if not email_user: return uid = emailUnique(email_user) if uid != -1 and uid != 0: language = getval(get_user_preferences(uid), "language") if language: ln = language _ = gettext_set_language(ln) rec_url = invenio.config.CFG_SITE_URL + "/record/" + str(recid) template = ( "<br/>" + _("We are sorry, a problem has occured during the processing of" " your video upload%(submission_title)s.") + "<br/><br/>" + _("The file you uploaded was %(input_filename)s.") + "<br/><br/>" + _("Your video might not be fully available until intervention.") + "<br/>" + _("You can check the status of your video here: %(record_url)s.") + "<br/>" + _("You might want to take a look at " " %(guidelines_url)s" " and modify or redo your submission.")) text = template % { "input_filename": "%s" % original_filename, "submission_title": " %s" % submission_title, "record_url": "%s" % rec_url, "guidelines_url": "localhost" } text = text.replace("<br/>", "\n") html_text = template % { "input_filename": "<strong>%s</strong>" % original_filename, "submission_title": " <strong>%s</strong>" % submission_title, "record_url": "<a href=\"%s\">%s</a>" % (rec_url, rec_url), "guidelines_url": "<a href=\"locahost\">%s</a>" % _("the video guidelines") } send_email(fromaddr=invenio.config.CFG_SITE_ADMIN_EMAIL, toaddr=email_user, subject="Problem during the processing of your video", content=text, html_content=html_text)
def _notify_error_user(email_user, original_filename, recid, submission_title, ln=invenio.config.CFG_SITE_LANG): """Sends an error notification to the specified address of the user. Is called by process_batch_job() if an error occured during the processing. @param email_user: email address of the user @type email_user: string @param email_admin: email address of the admin @type email_admin: string """ if not email_user: return uid = emailUnique(email_user) if uid != -1 and uid != 0: language = getval(get_user_preferences(uid), "language") if language: ln = language _ = gettext_set_language(ln) rec_url = invenio.config.CFG_SITE_URL + "/record/" + str(recid) template = ( "<br/>" + _("We are sorry, a problem has occured during the processing of" " your video upload%(submission_title)s.") + "<br/><br/>" + _("The file you uploaded was %(input_filename)s.") + "<br/><br/>" + _("Your video might not be fully available until intervention.") + "<br/>" + _("You can check the status of your video here: %(record_url)s.") + "<br/>" + _("You might want to take a look at " " %(guidelines_url)s" " and modify or redo your submission.") ) text = template % { "input_filename": "%s" % original_filename, "submission_title": " %s" % submission_title, "record_url": "%s" % rec_url, "guidelines_url": "localhost", } text = text.replace("<br/>", "\n") html_text = template % { "input_filename": "<strong>%s</strong>" % original_filename, "submission_title": " <strong>%s</strong>" % submission_title, "record_url": '<a href="%s">%s</a>' % (rec_url, rec_url), "guidelines_url": '<a href="locahost">%s</a>' % _("the video guidelines"), } send_email( fromaddr=invenio.config.CFG_SITE_ADMIN_EMAIL, toaddr=email_user, subject="Problem during the processing of your video", content=text, html_content=html_text, )
def _notify_success_user(email_user, original_filename, recid, submission_title, ln=invenio.config.CFG_SITE_LANG): """Sends an success notification to the specified address of the user. Is called by process_batch_job() if the processing was successful. @param email_user: email address of the user @type email_user: string @param email_admin: email address of the admin @type email_admin: string """ uid = emailUnique(email_user) if uid != -1 and uid != 0: language = getval(get_user_preferences(uid), "language") if language: ln = language _ = gettext_set_language(ln) rec_url = invenio.config.CFG_SITE_URL + "/record/" + str(recid) template = ( "<br/>" + _("Your video submission%(submission_title)s was successfully processed.") + "<br/><br/>" + _("The file you uploaded was %(input_filename)s.") + "<br/><br/>" + _("Your video is now available here: %(record_url)s.") + "<br/>" + _( "If the videos quality is not as expected, you might want to take " "a look at %(guidelines_url)s" " and modify or redo your submission." ) ) text = template % { "input_filename": "%s" % original_filename, "submission_title": " %s" % submission_title, "record_url": "%s" % rec_url, "guidelines_url": "localhost", } text = text.replace("<br/>", "\n") html_text = template % { "input_filename": "<strong>%s</strong>" % original_filename, "submission_title": " <strong>%s</strong>" % submission_title, "record_url": '<a href="%s">%s</a>' % (rec_url, rec_url), "guidelines_url": '<a href="locahost">%s</a>' % _("the video guidelines"), } send_email( fromaddr=invenio.config.CFG_SITE_ADMIN_EMAIL, toaddr=email_user, subject="Your video submission is now complete", content=text, html_content=html_text, )
def _notify_success_user(email_user, original_filename, recid, submission_title, ln=invenio.config.CFG_SITE_LANG): """Sends an success notification to the specified address of the user. Is called by process_batch_job() if the processing was successful. @param email_user: email address of the user @type email_user: string @param email_admin: email address of the admin @type email_admin: string """ uid = emailUnique(email_user) if uid != -1 and uid != 0: language = getval(get_user_preferences(uid), "language") if language: ln = language _ = gettext_set_language(ln) rec_url = invenio.config.CFG_SITE_URL + "/record/" + str(recid) template = ( "<br/>" + _("Your video submission%(submission_title)s was successfully processed." ) + "<br/><br/>" + _("The file you uploaded was %(input_filename)s.") + "<br/><br/>" + _("Your video is now available here: %(record_url)s.") + "<br/>" + _("If the videos quality is not as expected, you might want to take " "a look at %(guidelines_url)s" " and modify or redo your submission.")) text = template % { "input_filename": "%s" % original_filename, "submission_title": " %s" % submission_title, "record_url": "%s" % rec_url, "guidelines_url": "localhost" } text = text.replace("<br/>", "\n") html_text = template % { "input_filename": "<strong>%s</strong>" % original_filename, "submission_title": " <strong>%s</strong>" % submission_title, "record_url": "<a href=\"%s\">%s</a>" % (rec_url, rec_url), "guidelines_url": "<a href=\"locahost\">%s</a>" % _("the video guidelines") } send_email(fromaddr=invenio.config.CFG_SITE_ADMIN_EMAIL, toaddr=email_user, subject="Your video submission is now complete", content=text, html_content=html_text)
def send_email(self, req, form): # set all the declared query fields as local variables args = wash_urlargd(form, {'p_email': (str, None)}) uid = webuser.getUid(req) # load the right message language _ = gettext_set_language(args['ln']) if uid == -1 or CFG_ACCESS_CONTROL_LEVEL_SITE >= 1: return webuser.page_not_authorized(req, "../youraccount/send_email", navmenuid='youraccount') user_prefs = webuser.get_user_preferences(webuser.emailUnique(args['p_email'])) if user_prefs: if user_prefs['login_method'] in CFG_EXTERNAL_AUTHENTICATION and \ CFG_EXTERNAL_AUTHENTICATION[user_prefs['login_method']] is not None: eMsg = _("Cannot send password reset request since you are using external authentication system.") return page(title=_("Your Account"), body=webaccount.perform_emailMessage(eMsg, args['ln']), description="%s Personalize, Main page" % CFG_SITE_NAME_INTL.get(args['ln'], CFG_SITE_NAME), keywords=_("%(x_name)s, personalize", x_name=CFG_SITE_NAME_INTL.get(args['ln'], CFG_SITE_NAME)), uid=uid, req=req, secure_page_p = 1, language=args['ln'], lastupdated='', navmenuid='youraccount') try: reset_key = mail_cookie_create_pw_reset(args['p_email'], cookie_timeout=timedelta(days=CFG_WEBSESSION_RESET_PASSWORD_EXPIRE_IN_DAYS)) except InvenioWebAccessMailCookieError: reset_key = None if reset_key is None: eMsg = _("The entered email address does not exist in the database.") return page(title=_("Your Account"), body=webaccount.perform_emailMessage(eMsg, args['ln']), description="%s Personalize, Main page" % CFG_SITE_NAME_INTL.get(args['ln'], CFG_SITE_NAME), keywords=_("%(x_name)s, personalize", x_name=CFG_SITE_NAME_INTL.get(args['ln'], CFG_SITE_NAME)), uid=uid, req=req, secure_page_p = 1, language=args['ln'], lastupdated='', navmenuid='youraccount') ip_address = req.remote_host or req.remote_ip if not send_email(CFG_SITE_SUPPORT_EMAIL, args['p_email'], "%s %s" % (_("Password reset request for"), CFG_SITE_NAME_INTL.get(args['ln'], CFG_SITE_NAME)), websession_templates.tmpl_account_reset_password_email_body( args['p_email'],reset_key, ip_address, args['ln'])): eMsg = _("The entered email address is incorrect, please check that it is written correctly (e.g. [email protected]).") return page(title=_("Incorrect email address"), body=webaccount.perform_emailMessage(eMsg, args['ln']), description="%s Personalize, Main page" % CFG_SITE_NAME_INTL.get(args['ln'], CFG_SITE_NAME), keywords=_("%(x_name)s, personalize", x_name=CFG_SITE_NAME_INTL.get(args['ln'], CFG_SITE_NAME)), uid=uid, req=req, secure_page_p = 1, language=args['ln'], lastupdated='', navmenuid='youraccount') return page(title=_("Reset password link sent"), body=webaccount.perform_emailSent(args['p_email'], args['ln']), description="%s Personalize, Main page" % CFG_SITE_NAME_INTL.get(args['ln'], CFG_SITE_NAME), keywords=_("%(x_name)s, personalize", x_name=CFG_SITE_NAME_INTL.get(args['ln'], CFG_SITE_NAME)), uid=uid, req=req, secure_page_p = 1, language=args['ln'], lastupdated='', navmenuid='youraccount')