from utils import (get_items_from_python_file, get_submissions_path, get_config_file) def create_app(): app = Flask(__name__) app.config.from_pyfile(get_config_file(app.root_path)) Bootstrap(app) app.extensions['bootstrap']['cdns']['jquery'] = WebCDN( '//cdnjs.cloudflare.com/ajax/libs/jquery/2.1.1/') app.secret_key = app.config['SECRET_KEY'] return app app = create_app() allcourses = get_items_from_python_file(trainings) allworkshops = get_items_from_python_file(workshops) @app.route('/') def homepage(): return render_template('index.html', courses=allcourses, workshops=allworkshops) @app.route('/learn/<coursename>') def learningpage(coursename): coursename = coursename.replace('-', '_') if coursename in workshops.__dict__: course = getattr(workshops, coursename)
from flask_wtf import Form from wtforms import StringField, TextAreaField, SelectField, DecimalField, BooleanField, SubmitField, FileField from wtforms.validators import DataRequired, Email, Regexp, InputRequired, ValidationError from Crypto.Hash import SHA256 from Crypto.PublicKey import RSA from utils import get_items_from_python_file from trainers import keys import trainings allcourses = get_items_from_python_file(trainings) course_choices = [(c['name'], c['title']) for c in allcourses] class EnrollmentForm(Form): trainer_email = StringField('Trainer Email:', validators=[DataRequired(), Email()]) trainer_keyfile = FileField('Trainer Keyfile:', validators=[DataRequired()]) student_name = StringField('Student Name:', validators=[DataRequired()]) student_email = StringField('Student Email:', validators=[DataRequired(), Email()]) student_phone = StringField('Student Phone Number:', validators=[DataRequired()]) student_address = TextAreaField('Student Address:', validators=[DataRequired()]) course_name = SelectField('Course Name:', choices=course_choices, validators=[DataRequired()]) course_fees = DecimalField('Course Fees:', validators=[DataRequired()]) byod_student = BooleanField('<strong>BYOD Student</strong>') payment_received = BooleanField('<strong>I have received the course fees in full amount.</strong>') submit = SubmitField('Enroll') def validate_payment_received (form, field): if not field.data:
get_submissions_path, get_config_file ) def create_app(): app = Flask(__name__) app.config.from_pyfile(get_config_file(app.root_path)) Bootstrap(app) app.extensions['bootstrap']['cdns']['jquery'] = WebCDN( '//cdnjs.cloudflare.com/ajax/libs/jquery/2.1.1/' ) app.secret_key = app.config['SECRET_KEY'] return app app = create_app() allcourses = get_items_from_python_file(trainings) allworkshops = get_items_from_python_file(workshops) @app.route('/') def homepage(): return render_template('index.html', courses=allcourses, workshops=allworkshops) @app.route('/learn/<coursename>') def learningpage(coursename): coursename = coursename.replace('-', '_') if coursename in workshops.__dict__: course = getattr(workshops, coursename) elif coursename in trainings.__dict__: course = getattr(trainings, coursename)
from flask_wtf import Form from wtforms import StringField, TextAreaField, SelectField, DecimalField, BooleanField, SubmitField, FileField from wtforms.validators import DataRequired, Email, Regexp, InputRequired, ValidationError from Crypto.Hash import SHA256 from Crypto.PublicKey import RSA from utils import get_items_from_python_file from trainers import keys import trainings allcourses = get_items_from_python_file(trainings) course_choices = [(c['name'], c['title']) for c in allcourses] class EnrollmentForm(Form): trainer_email = StringField('Trainer Email:', validators=[DataRequired(), Email()]) trainer_keyfile = FileField('Trainer Keyfile:', validators=[DataRequired()]) student_name = StringField('Student Name:', validators=[DataRequired()]) student_email = StringField('Student Email:', validators=[DataRequired(), Email()]) student_phone = StringField('Student Phone Number:', validators=[DataRequired()]) student_address = TextAreaField('Student Address:', validators=[DataRequired()]) course_name = SelectField('Course Name:',