コード例 #1
0
def compare_user_stats():
    """Finds safety, match, stretch, and split schools for logged-in user"""
    # Pull out gpa and lsat datapoints for user currently logged in
    user_stats = find_user_gpa_lsat()
    user_gpa = user_stats[0]
    user_lsat = user_stats[1]

    # return results by gpa and lsat, gpa only, or lsat only, depending on user stats
    if user_gpa and user_lsat:
        # return query match for gpa and lsat score
        safety_schools = School.id_safety_schools(user_gpa, user_lsat)
        match_schools = School.id_match_schools(user_gpa, user_lsat)
        stretch_schools = School.id_stretch_schools(user_gpa, user_lsat)
        split_schools = School.id_split_schools(user_gpa, user_lsat)

    elif user_gpa and not user_lsat:
        # return query results for gpa alone
        safety_schools = School.id_safety_schools_gpa(user_gpa)
        match_schools = School.id_match_schools_gpa(user_gpa)
        stretch_schools = School.id_stretch_schools_gpa(user_gpa)
        split_schools = []

    elif user_lsat and not user_gpa:
        # return query results for lsat score alone
        safety_schools = School.id_safety_schools_lsat(user_lsat)
        match_schools = School.id_match_schools_lsat(user_lsat)
        stretch_schools = School.id_stretch_schools_lsat(user_lsat)
        split_schools = []

    return [safety_schools, match_schools, stretch_schools, split_schools]
コード例 #2
0
ファイル: Team.py プロジェクト: vmm86/younoshi
def listTeam(cityid, schoolid):
    # Список городов и их дочерних школ, название текущего города и школы
    listCity   = City.select().order_by(City.cityName)
    listSchool = School.select().join(City).where(City.city_ID == cityid).order_by(School.schoolName)
    try:
        cityname   = City.get(city_ID = cityid).cityName
        schoolname = School.get(school_ID = schoolid).schoolName
    except DoesNotExist:
        cityname   = None
        schoolname = None

    # Список команд в выбранной школе
    listTeam = Team.select().join(School).where(School.school_ID == schoolid).join(City).where(City.city_ID == cityid).switch(Team).join(Age).order_by(Team.teamName)
    for lt in listTeam:
        lt.age_ID.ageName = int(date.today().year) - int(lt.age_ID.ageName)

    # Список возрастов по состоянию на текущий год
    listAge  = Age.select().order_by(Age.ageName)
    for age in listAge:
        age.ageName = int(date.today().year) - int(age.ageName)

    # Переменные для автозаполнения модальной формы добавления/обновления данных в JS-скрипте шаблона
    ## Список полей
    modifyFields = ['teamName', 'filterAge', 'ageName']
    ## Список групп радиокнопок
    modifyRadios = ['filterAge']
    ## Заголовки модального окна
    createHeader = ['"Создать новую юношескую команду"']
    updateHeader = ['"Изменить "', 'teamName', '" (возраст "', 'ageName', '")"']
    ## Действия формы
    createAction = ['"/city/"', cityid, '"/school/"', schoolid, '"/team/create"']
    updateAction = ['"/city/"', cityid, '"/school/"', schoolid, '"/team/"', 'PK_ID', '"/update"']
    deleteAction = ['"/city/"', cityid, '"/school/"', schoolid, '"/team/"', 'PK_ID', '"/delete"']

    # Вывод шаблона
    return render_template(
        'Team.jinja.html', 
        listCity     = listCity, 
        cityid       = cityid, 
        cityname     = cityname, 
        listSchool   = listSchool, 
        schoolid     = schoolid, 
        schoolname   = schoolname,
        listTeam     = listTeam,
        listAge      = listAge, 
        modifyFields = modifyFields,
        modifyRadios = modifyRadios,
        createHeader = createHeader,
        updateHeader = updateHeader,
        createAction = createAction,
        updateAction = updateAction,
        deleteAction = deleteAction)
コード例 #3
0
ファイル: School.py プロジェクト: vmm86/younoshi
def deleteSchool(cityid, schoolid):
    # Удаление текущей записи в БД
    if session['demo']:
        pass
    else:
        # Ограничение по внешнему ключу FK_Team_School 
        # не позволяет удалить спортивную школу при наличии связанных с ней команд
        try:
            School.get(city_ID = cityid, school_ID = schoolid).delete_instance()
        except IntegrityError:
            flash('Вы не можете удалить эту спортивную школу, пока в неё добавлена хотя бы одна команда', 'danger')

    # Редирект на вид list
    return redirect(
        url_for('listSchool', 
            cityid = cityid))
コード例 #4
0
ファイル: School.py プロジェクト: vmm86/younoshi
def listSchool(cityid):
    # Список городов, название текущего города
    listCity = City.select().order_by(City.cityName)
    try:
        cityname = City.get(city_ID = cityid).cityName
    except DoesNotExist:
        cityname = None

    # Список школ и количества их дочерних команд
    listSchool = School.select(School, fn.Count(Team.school_ID).alias('countTeams')).join(Team, JOIN_LEFT_OUTER).switch(School).join(City).where(City.city_ID == cityid).group_by(School).order_by(School.schoolName)

    # Переменные для автозаполнения модальной формы добавления/обновления данных в JS-скрипте шаблона
    ## Список полей
    modifyFields = ['schoolName', 'cityName']
    ## Заголовки модального окна
    createHeader = ['"Создать новую спортивную школу"']
    updateHeader = ['"Изменить "', 'schoolName', '" ("', 'cityName', '")"']
    ## Действия формы
    createAction = ['"/city/"', cityid, '"/school/create"']
    updateAction = ['"/city/"', cityid, '"/school/"', 'PK_ID', '"/update"']
    deleteAction = ['"/city/"', cityid, '"/school/"', 'PK_ID', '"/delete"']

    # Вывод шаблона
    return render_template(
        'School.jinja.html', 
        listCity   = listCity, 
        cityid     = cityid, 
        cityname   = cityname, 
        listSchool = listSchool,
        modifyFields = modifyFields,
        createHeader = createHeader,
        updateHeader = updateHeader,
        createAction = createAction,
        updateAction = updateAction,
        deleteAction = deleteAction)
コード例 #5
0
ファイル: School.py プロジェクト: vmm86/younoshi
def createSchool(cityid):
    # Получение полей формы из шаблона
    schoolname = request.form['schoolName']

    # Сохранение новой записи в БД
    if session['demo']:
        pass
    else:
        School.create(
            city_ID = cityid, 
            schoolName = schoolname
        )

    # Редирект на вид list
    return redirect(
        url_for('listSchool', 
            cityid = cityid))
コード例 #6
0
 def test_new_school_minimal(self):
     lghs = School(name="Los Gatos High School", code="LOGA")
     db.session.add(lghs)
     db.session.commit()
     self.assertEqual(School.query.count(), 1)
     s = School.query.first()
     self.assertEqual(s.name, "Los Gatos High School")
     self.assertEqual(s.code, "LOGA")
コード例 #7
0
    def setUp(self):
        setup_test_app_db()
        db.create_all()
        self.client = app.test_client()

        TmsApp()
        self.meet = Meet.init_meet(EXAMPLE_MEETS[0])

        self.school = School(name="Hackbright", code="HBRT")
        db.session.add(self.school)
        db.session.commit()
コード例 #8
0
ファイル: crud.py プロジェクト: laniludwick/beanstalksquare
def create_schools():
    """Add the list of schools for use in a child questionnaire form."""

    schools = ["McKinley Elementary School", "Washington Elementary School", "Lincoln Elementary School", "Eldorado Elementary School", 
                "Canyon Elementary School", "Roosevelt Elementary School", "Hoover Elementary School", 
                "La Mirada Elementary School", "El Modena Elementary School", "Orange Elementary School"] #Replace with greatschools API data

    for school in schools:
        school_name = school
        sch = School(school_name=school_name)
        db.session.add(sch)
        db.session.commit()
コード例 #9
0
 def test_generic_repr_for_school(self):
     lghs = School(name="Los Gatos High School", code="LOGA")
     print("BEFORE ADD\n", lghs)
     db.session.add(lghs)
     print("BEFORE COMMIT\n", lghs)
     # db.session.flush()
     # print("AFTER FLUSH\n", lghs)
     # Note that things don't show up the way we want after
     # in a generic_repr if we commit, but they do if we flush
     # But actual changes to the DB seem to get written even
     # after a db commit.
     db.session.commit()
     print("AFTER COMMIT\n", lghs)
コード例 #10
0
    def test_host_school(self):
        TmsApp()
        lghs = School(name="Los Gatos High School", code="LOGA")
        db.session.add(lghs)
        db.session.commit()

        meet1 = Meet.init_meet({"name": "Meet #1", "date": "October 28, 2018"})
        meet1.host_school = lghs
        meet2 = Meet.init_meet({"name": "Meet #2", "date": "November 5, 2018"})
        meet2.host_school = lghs

        self.assertIn(meet1, lghs.meets_hosted)
        self.assertIn(meet2, lghs.meets_hosted)
        self.assertEqual(len(lghs.meets_hosted), 2)

        self.assertEqual(lghs.meets_hosted[0].name, "Meet #1")
        self.assertEqual(lghs.meets_hosted[1].name, "Meet #2")
コード例 #11
0
 def test_new_school_all_info(self):
     lghs = School(name="Los Gatos High School",
                   code="LOGA",
                   city="Los Gatos",
                   state="CA",
                   league="BVAL",
                   section="SCC")
     db.session.add(lghs)
     db.session.commit()
     self.assertEqual(School.query.count(), 1)
     s = School.query.first()
     self.assertEqual(s.name, "Los Gatos High School")
     self.assertEqual(s.code, "LOGA")
     self.assertEqual(s.city, "Los Gatos")
     self.assertEqual(s.state, "CA")
     self.assertEqual(s.league, "BVAL")
     self.assertEqual(s.section, "SCC")
コード例 #12
0
def _get_user_details_and_school(request):
    new_email = request.form.get("email")
    new_password = request.form.get("password")
    school_id = request.form.get("school_id")

    if school_id:
        school = School.query.get(school_id)
    else:
        # user is entering a new school in the form.
        # So, create the new school
        new_school_name = request.form.get('new_school_name')
        new_school_code = request.form.get('new_school_code')

        school = School(name=new_school_name, code=new_school_code)
        db.session.add(school)
        db.session.flush()

    return (new_email, new_password, school)
コード例 #13
0
    def test_create_meet_with_host_school(self):
        meet1 = Meet(name="WVAL League Practice Meet #1",
                     date="April 15, 2019")
        school1 = School(name="RJ Fisher Middle School",
                         code="RJFM",
                         city="Los Gatos",
                         state="CA")
        meet1.host_school = school1
        db.session.add(meet1)
        db.session.commit()

        m = Meet.query.first()
        self.assertEqual(m.status, "Unpublished")
        # test relationship from meet to host_school
        self.assertEqual(m.host_school.code, "RJFM")

        sch = School.query.filter_by(code="RJFM").one()
        self.assertTrue(sch)
        self.assertEqual(sch.city, "Los Gatos")
        self.assertEqual(sch.state, "CA")
コード例 #14
0
ファイル: crud.py プロジェクト: smitajani/HB-SCool-Carpool
def create_school(school_name, office_email, office_phone, 
                    address1, address2, city, state, 
                    zipcode, school_district, school_website, 
                    mon_start_am, mon_end_pm,
                    tue_start_am, tue_end_pm, 
                    wed_start_am, wed_end_pm, 
                    thu_start_am, thu_end_pm, 
                    fri_start_am, fri_end_pm):

    """Create and return a new SCHOOL """

    school = School(school_name = school_name,
                    office_email = office_email,
                    office_phone = office_phone,
                    address1 = address1,
                    address2 = address2,
                    city = city,
                    state = state,
                    zipcode = zipcode,
                    school_district = school_district,
                    school_website = school_website,
                    mon_start_am = mon_start_am,
                    mon_end_pm = mon_end_pm,
                    tue_start_am = tue_start_am,
                    tue_end_pm = tue_end_pm,
                    wed_start_am = wed_start_am,
                    wed_end_pm = wed_end_pm,
                    thu_start_am = thu_start_am,
                    thu_end_pm = thu_end_pm,
                    fri_start_am = fri_start_am,
                    fri_end_pm = fri_end_pm
                    )

    db.session.add(school)
    db.session.commit()

    return school
コード例 #15
0
ファイル: School.py プロジェクト: vmm86/younoshi
def updateSchool(cityid, schoolid):
    # Получение полей формы из шаблона
    schoolname = request.form['schoolName']

    # Обновление текущей записи в БД
    if session['demo']:
        pass
    else:
        school            = School()
        school.school_ID  = schoolid
        school.city_ID    = cityid
        school.schoolName = schoolname
        school.save()

    # Редирект на вид list
    return redirect(
        url_for('listSchool', 
            cityid = cityid))
コード例 #16
0
def load_school_data():
    """Load school data to db from aba-data-2013.txt"""

    print "Schools"

    # Eliminate any previously seeded data
    School.query.delete()

    geocoder_requests = 0
    geocoder = Geocoder()

    # For each row in file, split, strip, assign to row instance, and add to db
    for row in open("seed-data/aba-data-2013.txt"):
        row = row.strip().split("|")

        school_name = row[0].strip().title()

        # find and replace capitalzation exceptions in school_name
        if "Of" in school_name:
            school_name = school_name.replace("Of", "of")
        if "'S" in school_name:
            school_name = school_name.replace("'S", "'s")
        if "And" in school_name:
            school_name = school_name.replace("And", "and")
        if " At " in school_name:
            school_name = school_name.replace(" At ", " at ")
        if "Suny" in school_name:
            school_name = school_name.replace("Suny", "SUNY")
        if "Mcgeorge" in school_name:
            school_name = school_name.replace("Mcgeorge", "McGeorge")

        applications = row[1].strip()
        admit_rate = row[3].strip()
        gpa_75 = row[5].strip()
        gpa_50 = row[6].strip()
        gpa_25 = row[7].strip()
        lsat_75 = row[8].strip()
        lsat_50 = row[9].strip()
        lsat_25 = row[10].strip()
        resident_tuition = row[11].strip()
        nonresident_tuition = row[12].strip()
        living_expense = row[13].strip()
        url = row[14].strip()
        address = row[15].strip()

        if geocoder_requests >= MAX_GEOCODER_REQUESTS_PER_SEC:
            geocoder_requests = 0
            time.sleep(1)
        else:
            geocoder_requests += 1

        latitude, longitude = geocoder.get(address)

        school_data = School(school_name=school_name,
                             applications=applications,
                             admit_rate=admit_rate,
                             gpa_75=gpa_75,
                             gpa_50=gpa_50,
                             gpa_25=gpa_25,
                             lsat_75=lsat_75,
                             lsat_50=lsat_50,
                             lsat_25=lsat_25,
                             resident_tuition=resident_tuition,
                             nonresident_tuition=nonresident_tuition,
                             living_expense=living_expense,
                             url=url,
                             address=address,
                             latitude=latitude,
                             longitude=longitude
                             )
        print school_data

        db.session.add(school_data)

    # commit all new adds to db
    db.session.commit()
コード例 #17
0
ファイル: SAST.py プロジェクト: vmm86/younoshi
def listSAST(seasonid, ageid, sasid):
    # Список сезонов и возрастов по состоянию на текущий год, название текущего сезона и возраста, название и тип игровой стадии текущего игрового этапа
    listSeason = Season.select().order_by(Season.season_ID.asc())
    listAge = Age.select().order_by(Age.ageName)
    for age in listAge:
        age.ageName = int(date.today().year) - int(age.ageName)
    try:
        seasonname = Season.get(season_ID = seasonid).seasonName
        agename    = Age.get(age_ID = ageid).ageName
        sasname    = SAS.get(SAS_ID = sasid).stage_ID.stageName
        sastype    = SAS.get(SAS_ID = sasid).stage_ID.stageType
    except DoesNotExist:
        seasonname = None
        agename    = None
        sasname    = None
        sastype    = None

    # Список игровых этапов по типам
    listSAS_Z = SAS.select().where(SAS.season_ID == seasonid, SAS.age_ID == ageid).join(Stage).where(Stage.stageType == "Z").order_by(Stage.stageName)
    listSAS_G = SAS.select().where(SAS.season_ID == seasonid, SAS.age_ID == ageid).join(Stage).where(Stage.stageType == "G").order_by(Stage.stageName)
    listSAS_P = SAS.select().where(SAS.season_ID == seasonid, SAS.age_ID == ageid).join(Stage).where(Stage.stageType == "P").order_by(Stage.stageName)

    # Список городов, спортивных школ и команд для фильтрации по связанным выпадающим спискам
    filterCity   =   City.select().order_by(City.cityName)
    filterSchool = School.select().order_by(School.schoolName)
    filterTeam   =   Team.select().order_by(Team.teamName)

    # Список команд в текущем игровом этапе
    listSAST  = SAST.select().where(SAST.SAS_ID == sasid).join(Stage, JOIN_LEFT_OUTER).order_by(SAST.SAST_ID)
    # Список игровых стадий
    listStage = Stage.select().order_by(Stage.stageType, Stage.stageName).order_by(Stage.stage_ID)

    # Есть ли в текущем игровом этапе подгруппы
    is_SASTsubstage  = SAST.select().where(SAST.SAS_ID == sasid).join(Stage).exists()
    # Список подгрупп текущего игрового этапа (если они есть)
    listSASTsubstage = SAST.select(SAST.substage_ID).distinct().where(SAST.SAS_ID == sasid).join(Stage, JOIN_LEFT_OUTER)

    # Переменные для автозаполнения формы добавления/обновления данных в JS-скрипте шаблона
    ## Список полей
    modifyFields = ['filterCity', 'filterSchool', 'filterTeam', 'substage_ID', 'stageType', 'stageName']
    ## Список групп радиокнопок
    modifyRadios = ['substage_ID']
    ## Список выпадающих списков
    modifySelect = ['filterCity', 'filterSchool', 'filterTeam']   
    ## Заголовки модального окна
    createHeader = ['"Добавить команду в "', 'stageType', '" "', 'stageName']
    updateHeader = ['"Изменить команду, участвующую в "', 'stageType', '" "', 'stageName']
    ## Действия формы
    createAction = ['"/season/"', seasonid, '"/age/"', ageid, '"/stage/"', sasid, '"/team/create"']
    updateAction = ['"/season/"', seasonid, '"/age/"', ageid, '"/stage/"', sasid, '"/team/"', 'PK_ID', '"/update"']
    deleteAction = ['"/season/"', seasonid, '"/age/"', ageid, '"/stage/"', sasid, '"/team/"', 'PK_ID', '"/delete"']

    # Вывод шаблона
    return render_template(
        'SAST.jinja.html', 
        listSeason       = listSeason,
        seasonid         = seasonid,
        seasonname       = seasonname,
        listAge          = listAge,
        ageid            = ageid,
        agename          = agename,
        listSAS_Z        = listSAS_Z,
        listSAS_G        = listSAS_G,
        listSAS_P        = listSAS_P,
        sasid            = sasid,
        sasname          = sasname,
        sastype          = sastype,
        filterCity       = filterCity,
        filterSchool     = filterSchool,
        filterTeam       = filterTeam,
        listSAST         = listSAST,
        listStage        = listStage,
        is_SASTsubstage  = is_SASTsubstage,
        listSASTsubstage = listSASTsubstage,
        modifyFields     = modifyFields,
        modifyRadios     = modifyRadios,
        modifySelect     = modifySelect,
        createHeader     = createHeader,
        updateHeader     = updateHeader,
        createAction     = createAction,
        updateAction     = updateAction,
        deleteAction     = deleteAction)
コード例 #18
0
 def test_unattached_school(self):
     School.init_unattached_school()
     unattachedSchool = School.query.get(1)
     self.assertEqual(unattachedSchool.name, "Unattached")
     self.assertEqual(unattachedSchool.code, "UNA")
コード例 #19
0
ファイル: edulogic.py プロジェクト: looopTools/MakeCV
 def CreateSchool(self, info_dic):
     s = School()
     s.assing_var(info_dic)
     s.printSchool()
     self.educations.append(s)
コード例 #20
0
def results():
    Subject = request.form["Subject"]
    Character = School(Subject)
    return render_template("results.html", Character=Character)