def send_password_reset_info(self, username, email=False, keep_password=False): if email: username = get_username_from_email(username) if not get_user_id(username): return if keep_password: new_password = '******' else: new_password = reset_user_password(username) if not new_password: return user_email = get_user_email(username) with open('./app/templates/email_templates/password-reset.template', 'r') as file: data = file.read() email_body = data % (username, new_password) request = requests.post(app.config['MAILGUN_URL'], auth=('api', app.config['MAILGUN_APIKEY']), data={ 'from': 'Cloudbot <*****@*****.**>', 'to': user_email, 'subject': 'Cloud Password Reset', 'html': email_body })
def send_image_download_link(username, file_name): instructor_email = get_user_email(username) with open('./app/templates/email_templates/image-download.template', 'r') as file: data = file.read() email_body = data % file_name request = requests.post(app.config['MAILGUN_URL'], auth=('api', app.config['MAILGUN_APIKEY']), data={ 'from': 'Cloudbot <*****@*****.**>', 'to': instructor_email, 'subject': 'Image Download Request', 'html': email_body })
def send_ta_info(self, username, course): user_email = get_user_email(username) with open('./app/templates/email_templates/ta-course-info.template', 'r') as file: data = file.read() email_body = data % (course, username) request = requests.post(app.config['MAILGUN_URL'], auth=('api', app.config['MAILGUN_APIKEY']), data={ 'from': 'Cloudbot <*****@*****.**>', 'to': user_email, 'subject': 'Added as TA to Cloud Course', 'html': email_body })
def image_management(): image_list = glance.list_instructor_images(current_user.project, current_user.course) from app.forms import create_image_checkbox_list form = create_image_checkbox_list(image_list) if form.validate_on_submit(): if form.change_visibility.data is True: for submitted in form: if submitted.type == "BooleanField": if submitted.data is True: glance.set_visibility(image_list[clean_html_tags( str(submitted.label))]) flash("Image visibility updated") return redirect(url_for('image_management')) elif form.download_image.data is True: # Check if only one box is checked, there is a jquery check for this on the webpage itself but it's good to have a backup plan form_dict = form.data boolean_list = [] for key in form_dict: if 'image_' in key: boolean_list.append(form_dict[key]) if boolean_list.count(True) > 1: flash("You can only select one image at a time for download.") return redirect(url_for('image_management')) else: for submitted in form: if submitted.type == "BooleanField" and submitted.data is True: glance.download_image( current_user.id, current_user.course, clean_html_tags(str(submitted.label))) flash( "A download link will be sent to your email (%s) shortly" % keystone.get_user_email(current_user.id)) return redirect(url_for('image_management')) return render_template('image_management.html', title='Image Management', image_list=image_list, form=form, navbar_text='Images: ' + current_user.course)