コード例 #1
0
ファイル: update.py プロジェクト: justinnhli/subitize
def main():
    semester_choices = sorted((semester.code for semester in Semester.all()), reverse=True)
    arg_parser = ArgumentParser()
    arg_parser.add_argument('semester', nargs='?', default=Semester.current_semester().code)
    arg_parser.add_argument('--raw', default=False, action='store_true')
    args = arg_parser.parse_args()
    response = update_db(Semester.from_code(args.semester))
    if args.raw:
        with open('response', 'w') as fd:
            fd.write(response)
コード例 #2
0
ファイル: subitize.py プロジェクト: justinnhli/subitize
def main():
    semester_choices = ('any', *sorted((semester.code for semester in Semester.all()), reverse=True))
    arg_parser = ArgumentParser()
    arg_parser.add_argument('terms', metavar='TERM', nargs='*')
    arg_parser.add_argument('--semester', default=Semester.current_semester().code, choices=semester_choices)
    arg_parser.add_argument('--sort', choices=('semester', 'number', 'title', 'instructors', 'meetings'))
    args = arg_parser.parse_args()
    if args.semester == 'any':
        offerings = OFFERINGS
    else:
        semester = Semester.from_code(args.semester)
        offerings = filter_by_semester(OFFERINGS, semester.code)
    search(offerings, ' '.join(args.terms), sort=args.sort)
コード例 #3
0
ファイル: SoftGreen.py プロジェクト: raghukhanal/SoftGreen
def day_time_selection():
    if request.method == "POST":
        final_selected = request.form.getlist("selected_course")
        session_user = session.get("user_id")

        for item in final_selected:
            new_record = SelectedCourseInfo.create(faculty_id=session_user, course_id=item)
            try:
                with db.atomic():
                    new_record.save()
                    print(new_record)
            except Exception as e:
                flash("Something went wrong.")
                return redirect(url_for("day_time_selection"))

        flash("Your selected course has been sent to Moderator for review")
        return redirect(url_for("faculty_selection"))

    if request.method == "GET":

        selected_courses = []
        for item in request.args.getlist("selected_courses"):
            selected_courses.append(Courses.get(id=item))
        selected_term = Semester.get(id=request.args['selected_term'])
        return render_template(
            "select_days_and_time.html",
            selected_term=selected_term,
            selected_courses=selected_courses
        )
コード例 #4
0
def add_semester_submission():
    try:
        grade_id=request.form['grade_id']
        new_semester = Semester(
            num=request.form['num'],
            grade_id=grade_id
        )
        Semester.insert(new_semester)
        flash('Semester ' + request.form['num'] + ' was successfully listed!')
    except:
        db.session.rollback()
        print(sys.exc_info())
        flash('An error occurred. Semester ' + request.form['num'] + ' could not be listed.')
    finally:
        db.session.close()
    query = Semester.query.filter_by(grade_id=grade_id).all()
    return render_template('pages/semesters.html', data=query, userinfo=session['profile'])
コード例 #5
0
ファイル: SoftGreen.py プロジェクト: raghukhanal/SoftGreen
def faculty_selection():
    if request.method == "POST":
        form_term = request.form.get("term_id")
        form_courses = request.form.getlist("course_ids")
        return redirect(url_for("day_time_selection", selected_term=form_term, selected_courses=form_courses))

    courses = Courses.select()
    semester = Semester.select()
    return render_template("selection.html", courses=courses, semester=semester)
コード例 #6
0
 def get_current_semester(self):
     query: str = f"SELECT SEMESTER, YEAR FROM SEMESTER WHERE " \
                  f"SEMESTER = "\
                  f"(SELECT SEMESTER FROM SEMESTER ORDER BY YEAR DESC, SEMESTER DESC LIMIT 1)" \
                  f"AND YEAR = (SELECT YEAR FROM SEMESTER ORDER BY YEAR DESC LIMIT 1)"
     response = self.db_manager.execute_query(query)
     [semester] = response
     current_semester = Semester(semester=semester[0], year=semester[1])
     if type(response) == Exception:
         return None
     else:
         return current_semester
コード例 #7
0
ファイル: app.py プロジェクト: Gellesh/CMP-Projects-Web-App
def semesters():
    if request.method == 'POST':
        data = request.get_json()
        year = data.get('year')
        semester = data.get('semester')
        new_semester = Semester(semester=semester, year=year)
        is_successful = query_factory.add_semester(new_semester)
        if is_successful:
            msg = 'Semester created successfully.'
        else:
            msg = 'Semester could not be created.'
        response = {'is_successful': is_successful, 'message': msg}
        return jsonify(response)
    if request.method == 'GET':
        current_semester = query_factory.get_current_semester()
        semester = {
            'semester': current_semester.semester,
            'year': current_semester.year
        }
        return jsonify(semester)
コード例 #8
0
ファイル: tests.py プロジェクト: league/l3ms
def create_semester(nm, y, sm, sd, em, ed):
    s = Semester(tag = '%s%02d' % (nm[0].lower(), y%100),
                 name = '%s %d' % (nm, y),
                 start_date = date(year=y, month=sm, day=sd),
                 end_date = date(year=y, month=em, day=ed))
    s.save()