def activity_update(activity_id): db = DBOpera() if request.method == 'GET': activity = db.get_activityAttach(activity_id) time = activity.activity_time.strftime("%Y-%m-%dT%H:%M:%S") return render_template('manage_activityupdate.html', activity=activity, time=time) if request.method == 'POST': activity_name = request.form['activity_name'] activity_guest = request.form['activity_guest'] activity_num = request.form['activity_num'] activity_message = request.form['activity_message'] activity_datetime = request.form['activity_datetime'] activity_num = int(activity_num) activity_id = db.update_activity(activity_id, activity_name, activity_guest, activity_num, activity_message, activity_datetime) #TODO(caoyue):when add a new activity,we send a email to user who have confirm users = db.get_confirmUser() for user in users: send_email(user.user_email, 'A new activity looks forward to your participation.', 'user/activity_update', user=user, activity_name=activity_name, activity_id=activity_id) return redirect(url_for('activity_list'))
def aws_error(subject, key, traceback): message = get_basic_infos(key) message += traceback signature = md5() signature.update(traceback) subject += ' (%s)' % signature.hexdigest()[0:10] send_email(app.config['BUG_NOTIFICATION_EMAIL'], subject, message, False)
def re_confirm(): ''' 用户再次发送激活邮件 ''' token = current_user.get_confirmation() send_email(current_user.user_email, 'Confirm Your Account', 'user/confirm_1', user=current_user, token=token) flash("plese check in your email!", 'again') return redirect(url_for('home'))
def new_round_notification(grade): round = CurrentRound.query.filter_by(grade=grade).first().round for user in User.query.filter_by(grade=grade): msg = Message(subject='Начался новый раунд', recipients=[user.email], reply_to=mail_config.ADMINS[0], html=render_template('new_round_notification.html', username=user.name, ends_at=round.next[0].starts_at if len(round.next) == 1 else None)) send_email(msg)
def remind(grade): grade_round = CurrentRound.query.filter_by(grade=grade).first() if grade_round is None: return round = grade_round.round for user in User.query.filter_by(grade=grade): has_participated = False for colors in ComparingColors.query.filter_by(round=round): has_participated = has_participated or \ Choices.query.filter_by(comparing_colors=colors, user=user).first() is not None if not has_participated: msg = Message(subject='Конец раунда близко', recipients=[user.email], reply_to=mail_config.ADMINS[0], html=render_template( 'end_round_notification.html', username=user.name, ends_at=round.next[0].starts_at)) send_email(msg)
def send_feedback(form, headers): if feedback_available() and (form.usability.data.strip() != '' or form.usefulness.data.strip() != '' or form.designing.data.strip() != '' or form.comment.data.strip() != ''): msg = Message( '{} - tape-choose feedback'.format(g.user.name), recipients=app.config['ADMINS'], reply_to=g.user.email, html=render_template_string( open('modules/feedback/templates/feedback_mail.html').read(), name=g.user.name, grade=g.user.grade, usability=form.usability.data, usefulness=form.usefulness.data, designing=form.designing.data, comment=form.comment.data, headers=str(headers), version=request.form.get('version'))) send_email(msg) g.user.feedback_count += 1
def activity_add(): ''' 活动发布 ''' db = DBOpera() if request.method == 'GET': return render_template('manage_activityAdd.html') if request.method == 'POST': activity_name = request.form['activity_name'] activity_guest = request.form['activity_guest'] activity_num = request.form['activity_num'] activity_message = request.form['activity_message'] activity_datetime = request.form['activity_datetime'] print activity_datetime activity_num = int(activity_num) activity_id = db.add_activity(activity_name, activity_guest, activity_num, activity_message, activity_datetime) #TODO(caoyue):when add a new activity,we send a email to user who have confirm users = db.get_confirmUser() for user in users: send_email(user.user_email,'A new activity looks forward to your participation.','user/activity',user=user,\ time=activity_datetime,guest=activity_guest,activity_id=activity_id) return redirect(url_for('activity_add'))
async def generate_bulk_summary(task: Job, modelname: str, file: UploadFile, email: str, full_name: str, length: str) -> None: summary_process = SummarizerProcessor(model=modelname) df = pd.read_excel(file.file.read(), index_col=None, header=0) # df1 = df.iloc[1:] # logger.info(len(df)) for index, row in df.iterrows(): url = str(row['URL']) timeframe = str(row['MM/YY']) topic = str(row['Topic']) category = str(row['Category']) # url = df1.iat[ind, 0] # log.info(url) if isNaN(url) is False: log.info(url) try: summary_id = await crud.create(url, timeframe, topic, category, task.uid) summary = await summary_process.inference(input_url=url, length=length) await asyncio.sleep(1) await TextSummary.filter(id=summary_id).update(summary=summary) task.processed_ids[summary_id] = url except: log.exception("url errored " + url) pass finally: pass log.info(await (send_email(email, str(task.uid), full_name))) task.status = "Completed"
def azure_commerce_userpasscredentials_error_email(traceback): send_email(app.config['BUG_NOTIFICATION_EMAIL'], "Error during azure UserPassCredentials instantiation", traceback, False)
def onboarding_email(email, firstname): content_mime = _render_onboarding_email(email, firstname) send_raw_email("*****@*****.**" , email, content_mime) send_email(app.config['NEW_USER_EMAIL'], "New user sign up", "%s: %s" % (firstname, email), False)
def startTracking(): products = fetchProductsData() for product in products: current_track = Tracking.query.filter_by(id=product['id']).first() user = User.query.filter_by(id=current_track.user_id).first() if (product['name'] == "Woolsworth"): price = woolsworth(product['url']) print(price) new_price = price['price'].split("$") if (float(new_price[1]) < product['current_price']): current_track.current_price = float(new_price[1]) send_email( user.email, "Congratulations ! Price Has Come Down Low ", f"Hi {user.name} the price has come down for the product {product['name']} from {product['current_price']} to {new_price[1]}.Please Visit Store {product['url']} to buy the product" ) elif (float(new_price[1]) == product['set_price']): current_track.current_price = float(new_price[1]) send_email( user.email, "Congratulations ! Price Has Come Down To Your Desired Price ", f"Hi {user.name} the price has come down for the product {product['name']} from {product['current_price']} to {new_price[1]}.Please Visit Store {product['url']} to buy the product" ) elif (float(new_price[1]) < product['set_price']): current_track.current_price = float(new_price[1]) send_email( user.email, "Congratulations ! Price Has Come Down Even Below Your Desired Price ", f"Hi {user.name} the price has come down for the product {product['name']} from {product['current_price']} to {new_price[1]}.Please Visit Store {product['url']} to buy the product" ) else: current_track.current_price = product['current_price'] else: price = officeWorks(product['url']) print(price) new_price = price['price'].split("$") if (float(new_price[1]) < product['current_price']): current_track.current_price = float(new_price[1]) send_email( user.email, "Congratulations ! Price Has Come Down Low ", f"Hi {user.name} the price has come down for the product {product['name']} from {product['current_price']} to {new_price[1]}.Please Visit Store {product['url']} to buy the product" ) elif (float(new_price[1]) == product['set_price']): current_track.current_price = float(new_price[1]) send_email( user.email, "Congratulations ! Price Has Come Down To Your Desired Price ", f"Hi {user.name} the price has come down for the product {product['name']} from {product['current_price']} to {new_price[1]}.Please Visit Store {product['url']} to buy the product" ) elif (float(new_price[1]) < product['set_price']): current_track.current_price = float(new_price[1]) send_email( user.email, "Congratulations ! Price Has Come Down Even Below Your Desired Price ", f"Hi {user.name} the price has come down for the product {product['name']} from {product['current_price']} to {new_price[1]}.Please Visit Store {product['url']} to buy the product" ) else: current_track.current_price = product['current_price'] db.session.commit()
def sign_up_save(): # need to trim the user name username = request.form.get('username', "") password1 = request.form.get('password1', "") password2 = request.form.get('password2', "") email = request.form.get('email', "") error = False # connect to database cnx = get_database() cursor = cnx.cursor() query = "SELECT COUNT(user_name) FROM user_info WHERE user_name = %s " cursor.execute(query, (username, )) results = cursor.fetchall() numberOfExistUser = results[0][0] if numberOfExistUser != 0: error = True error_msg = "Error: User name already exist!" if username == "" or password1 == "" or password2 == "" or email == "": error = True error_msg = "Error: All fields are required!" if not error and not re.match( r"^[A-Za-z0-9\.\+_-]+@[A-Za-z0-9\._-]+\.[a-zA-Z]*$", email): error = True error_msg = "Error: Not a correct email address!" if not (password1 == password2): error = True error_msg = "Error: Two passwords not matching!" if error: return render_template("account/sign_up_form.html", title="Join Us!", error_msg=error_msg, username=username, email=email, password1=password1, password2=password2) ts = time.time() timestamp = datetime.datetime.fromtimestamp(ts).strftime( '%Y-%m-%d %H:%M:%S') query = ''' INSERT INTO user_info (user_name,user_key,user_email,user_create_date) VALUES (%s,%s, %s,%s) ''' cursor.execute(query, (username, password1, email, timestamp)) cnx.commit() # Add error catch here for sql # Send Email send_email.send_email(email, username, password1) return render_template("/account/register_succeed.html", title="You are In!", name=username, password=password1)
def onboarding_email(email, firstname): message = ONBOARD_TPL.render(firstname=firstname) send_email(email, "Welcome to Trackit.IO", message, True) send_email(app.config['NEW_USER_EMAIL'], "New user sign up", "%s: %s" % (firstname, email), False)