def csv_import(cls, reader):
     for row in csv.DictReader(reader):
         teacher_id = row['teacher_id']
         student_id = row['student_id']
         start_time = make_local_dt(row['date'], row['start_time'])
         teacher = Teacher.key_for_sis_id(teacher_id)
         if teacher is None:
             logging.warn("no such teacher %s" % teacher_id)
             continue
         if student_id and Student.query(Student.sis_id == student_id).count == 0:
             logging.warn("no such student %s" % student_id)
             continue
         appointment = cls.query(cls.start_time == start_time, ancestor=teacher).get()
         if appointment is None:
             appointment = cls(
                 parent=teacher,
                 student_id=student_id,
                 start_time=start_time,
                 duration=int(row['duration']),
                 location=row['location'],
                 teacher_name=row['teacher_name'],
                 is_active=bool_from_string(row['active'])
             )
             appointment.put()
             logging.info("inserted appointment: %s" % row)
         else:
             appointment.student_id = student_id
             appointment.start_time = start_time
             appointment.duration = int(row['duration'])
             appointment.location = row['location']
             appointment.teacher_name = row['teacher_name']
             appointment.is_active = bool_from_string(row['active'])
             appointment.put()
             logging.info("updated appointment: %s" % row)
Exemple #2
0
 def csv_import(cls, reader):
     for row in csv.DictReader(reader):
         teacher_id = row['teacher_id']
         student_id = row['student_id']
         start_time = make_local_dt(row['date'], row['start_time'])
         teacher = Teacher.key_for_sis_id(teacher_id)
         if teacher is None:
             logging.warn("no such teacher %s" % teacher_id)
             continue
         if student_id and Student.query(
                 Student.sis_id == student_id).count == 0:
             logging.warn("no such student %s" % student_id)
             continue
         appointment = cls.query(cls.start_time == start_time,
                                 ancestor=teacher).get()
         if appointment is None:
             appointment = cls(parent=teacher,
                               student_id=student_id,
                               start_time=start_time,
                               duration=int(row['duration']),
                               location=row['location'],
                               teacher_name=row['teacher_name'],
                               is_active=bool_from_string(row['active']))
             appointment.put()
             logging.info("inserted appointment: %s" % row)
         else:
             appointment.student_id = student_id
             appointment.start_time = start_time
             appointment.duration = int(row['duration'])
             appointment.location = row['location']
             appointment.teacher_name = row['teacher_name']
             appointment.is_active = bool_from_string(row['active'])
             appointment.put()
             logging.info("updated appointment: %s" % row)
Exemple #3
0
def teacher_register():
    if current_user.is_authenticated:
        return redirect(url_for('course.teacher_index'))

    form = TeacherRegisterForm()

    if form.validate_on_submit():
        teacher = Teacher(name=form.name.data,
                          email=form.email.data,
                          phone=form.phone.data)

        teacher.generate_password_hash(form.password.data)

        db.session.add(teacher)
        db.session.commit()

        flash('Successful! You Can Login', 'success')

    return render_template('views/auth/teacher_register.html',
                           title='Teacher Register',
                           form=form)
 def csv_import(cls, reader):
     for row in csv.DictReader(reader):
         school = School.key_for_sis_id(row['school_id'])
         student_id = row['student_id']
         if Student.query(Student.sis_id == student_id).count() == 0:
             logging.warn("no such student %s" % student_id)
             continue
         teacher_id = row['teacher_id']
         if Teacher.query(Teacher.sis_id == teacher_id).count() == 0:
             logging.warn("no such teacher %s" % teacher_id)
             continue
         enrollment = cls(
             parent=school,
             student_id=student_id,
             teacher_id=teacher_id,
             course_id=row['course_id'],
             section_id=row['section_id'],
             period=row['period'],
             is_homeroom=bool_from_string(row['homeroom']),
             is_active=True
         )
         enrollment.put()
         logging.info("inserted enrollment: %s" % row)
Exemple #5
0
def signup():
    if g.user:
        return redirect('/')

    form = SignUpForm()

    # Check the captcha
    """
    captcha_passed = False
    if request.method == 'POST':
        lowered_titles = [x.lower() for x in session.get('captcha_title', [])]
        if request.form.get('cover','').lower() in lowered_titles:
            captcha_passed = True
        else:
            flash('The text in the image did not match.', 'error')
        # It's important to only allow one attempt for each session title
        if 'captcha_title' in session:
            session.pop('captcha_title')
    """

    valid_form = True

    # Check for the honey pot.
    if request.form.get('very_important_field'):
        # They filled in the honeypot. Most likely, they're a bot.
        # There can be some weird shit with autocompletes, so just
        # in case it's an actual user, let's flash a message.
        flash('Please do not use autocomplete on this form.', 'error')
        valid_form = False

    valid_form = valid_form and form.validate_on_submit()

    # Disabled captacha logic
    # valid_Form = valid_form and captcha_passed

    if request.method == 'POST' and valid_form:
        # Create the user in the database
        newuser = User()
        newuser.email = request.form['email'].lower()
        newuser.first_name = request.form['first_name']
        newuser.last_name = request.form['last_name']
        newuser.url_keyword = User.generate_url_keyword(newuser.first_name, newuser.last_name)
        newuser.set_password(request.form['pw'])
        db.session.add(newuser)

        # is this user a teacher? if so make a teacher
        if request.form['is-student'] == "false":
            db.session.flush()
            newteacher = Teacher()
            newteacher.uid = newuser.uid
            db.session.add(newteacher)

        db.session.commit()

        # Send the welcome email.
        mailer = Mailer()
        params = {
            'subject': 'Welcome to Peernote',
            'user': newuser
        }
        mailer.send(Welcome(), params, newuser.email)

        # Log this user in.
        session['uid'] = newuser.uid
        current_app.logger.debug('Logging in as uid = %d', session['uid'])
        return redirect('/')

    return render_template('users/signup.html', form=form,page_title="Welcome")
from app import create_app
from app import db
from datetime import date

app = create_app()
app.app_context().push()

from app.models.teacher import Teacher
from app.models.student import Student
from app.models.course import Course
from app.models.exam import Exam

db.drop_all()
db.create_all()

teacher = Teacher()
teacher.name = 'Ömer Çulha'
teacher.email = '*****@*****.**'
teacher.phone = '0000 000 00 00'
teacher.generate_password_hash('123456')
db.session.add(teacher)

student = Student()
student.name = 'Yunus Emre'
student.email = '*****@*****.**'
student.phone = '0000 000 00 00'
student.grade_level = 1
student.parent_code = "11111111111"
student.generate_password_hash('123456')
db.session.add(student)