コード例 #1
0
def action():
    if utils.button_pressed('add'):
        return add()
    if utils.button_pressed('edit'):
        return edit()
    if utils.button_pressed('delete'):
        return delete()
    return redirect(url_for('settings.replacements.show'))
コード例 #2
0
def action():
    if utils.button_pressed('add'):
        return add()
    if utils.button_pressed('edit'):
        return edit()
    if utils.button_pressed('delete'):
        return delete()
    if utils.button_pressed('change-password'):
        return change_password()
    return redirect(url_for('user.show'))
コード例 #3
0
def action_done(action=None, id=-1):
    try:
        if utils.button_pressed('save'):
            if action == 'add':
                teacher_id, day_hour, grade_id, lesson_id, changed_item = db_user.session_get_grade_filter()
                if current_user.teacher and current_user.is_strict_user:
                    teacher = current_user.teacher
                else:
                    teacher = Teacher.query.filter(Teacher.id == teacher_id, Teacher.school == db_utils.school()).first()
                lesson = db_lesson.db_lesson(lesson_id)
                measure_note = request.form['measure_note']
                subject_note = request.form['subject_note']
                extra_attention = 'chkb_extra_attention' in request.form
                subjects = request.form.getlist('subject')
                measures = request.form.getlist('measure')
                timestamp = datetime.datetime.strptime('{} {}:{}:{}'.format(request.form['txt-date'], 23, 59, int(request.form['hour'])), '%d-%m-%Y %H:%M:%S')
                duplicate_remarks = False
                # iterate over all students involved.  Create an remark per student.
                # link the measures and remark-subjects to the remark
                for s in request.form.getlist('student_id'):
                    student = Student.query.get(int(s))
                    if student:
                        if db_remark.check_if_duplicate(student, timestamp, measure_note, subject_note, extra_attention, measures, subjects):
                            duplicate_remarks = True
                        else:
                            # save new remark
                            remark = Remark(student=student, lesson=lesson, teacher=teacher, timestamp=timestamp,
                                            measure_note=measure_note, subject_note=subject_note,
                                            grade=student.classgroup.grade, extra_attention=extra_attention,
                                            school=db_utils.school(), academic_year=db_utils.academic_year())
                            for s in subjects:
                                subject = RemarkSubject(topic=SubjectTopic.query.get(int(s)), remark=remark)
                                db.session.add(subject)
                            for m in measures:
                                measure = RemarkMeasure(topic=MeasureTopic.query.get(int(m)), remark=remark)
                                db.session.add(measure)
                            db.session.add(remark)
                db.session.commit()
            if duplicate_remarks:
                utils.flash_plus('Er bestaat al een opmerking voor deze leerling(en) op dit tijdstip.<br>De opmerkingen worden samengevoegd')
            return redirect(url_for('grade.show'))
        if utils.button_pressed('hide'):
            for s in request.form.getlist('student_id'):
                student = Student.query.get(int(s))
                if student:
                    student.hidden = True
            db.session.commit()
    except Exception as e:
        utils.flash_plus(u'Kan opmerking niet opslaan', e)
        log.error(u'Cannot save remarks {}'.format(e))
    return redirect(url_for('grade.show'))
コード例 #4
0
def action():
    try:
        if utils.button_pressed('add'):
            d, h = Schedule.decode_dayhour(request.form['dayhour'])
            ts_d, ts_h = db_utils.time_to_timeslot(include_zero_hour=True)
            delta_d = ts_d - d
            if d * 10 + h > ts_d * 10 + ts_h:
                delta_d += 7
            now = datetime.datetime.now()
            if db_setting.get_global_setting_sim_dayhour_state():
                try:
                    now = datetime.datetime.strptime(db_setting.get_global_setting_sim_dayhour(), '%d-%m-%Y %H:%M')
                except Exception as e:
                    log.error('bad sim dayhour string : {}'.format(e))
            date = (now - datetime.timedelta(days=delta_d)).strftime('%d-%m-%Y')
            students = []
            for s in request.form.getlist('student_id'):
                student = Student.query.get(s)
                if student:
                    students.append(student)
            form = RemarkForm()
            prime_data = {}
            prime_data['hour'] = h
            prime_data['date'] = date

            return render_template('remark/remark.html', subject='grade', action='add', form=form, students=students, prime_data=prime_data)
    except Exception as e:
        utils.flash_plus(u'Kan opmerking niet opslaan', e)
        log.error(u'Cannot save remarks {}'.format(e))
    return redirect(url_for('grade.show'))
コード例 #5
0
def action_done(action=None, id=-1):
    if utils.button_pressed('save'):
        if action == 'add':
            return add(action_done=True)
        if action == 'edit':
            return edit(action_done=True)
    return redirect(url_for('settings.replacements.show'))
コード例 #6
0
def action_done(action=None, id=-1):
    if utils.button_pressed('save'):
        if action == 'add':
            return add(action_done=True)
        if action == 'edit':
            return edit(action_done=True, id=id)
        if action == 'change-password':
            return change_password(action_done=True, id=id)

    return redirect(url_for('user.show'))
コード例 #7
0
def action():
    if utils.button_pressed('add'):
        return add_replacement()
    return redirect(url_for('settings.show_replacements'))