Пример #1
0
def court_page(key=None,operation=None,error=None):
    if request.method == 'GET':
        if request.args.get('operation') == 'delete':
            store = court_operations()
            result=store.delete_court(request.args.get('key'))
            return redirect(url_for('admin.court_page', error=result))
        else:
            store = court_operations()
            courts=store.get_courts()
            now = datetime.datetime.now()
            error = request.args.get('error')
            return render_template('admin_courts.html', courts=courts, error=error, current_time=now.ctime())
    else:
        if request.form['submit']=='cancel':
            return redirect(url_for('admin.court_page'))

        else:
            if request.form['key_value']=='':
                name = request.form['name']
                address = request.form['address']
                capacity = request.form['capacity']
                court = Court(None ,name, address,capacity,0)
                store = court_operations()
                result=store.add_court(court)
                return redirect(url_for('admin.court_page', error=result))
            else:
                name = request.form['name']
                address = request.form['address']
                capacity = request.form['capacity']
                key = request.form['key_value']
                store = court_operations()
                result=store.update_court(key, name, address, capacity)
                return redirect(url_for('admin.court_page', error=result))
Пример #2
0
def team_edit_page(key=None):
    store = team_operations()
    storeCourt = court_operations()
    storeCountry = country_operations()
    team = store.get_team(key) if key is not None else None
    courts = storeCourt.get_courts()
    countries = storeCountry.get_countries()
    now = datetime.datetime.now()
    return render_template('team_edit.html', team=team, courts=courts, countries=countries, current_time=now.ctime())
Пример #3
0
def match_edit_page(key=None):
    store = match_operations()
    storeTeam = team_operations()
    storeCourt = court_operations()

    match = store.get_match(key) if key is not None else None
    teams = storeTeam.get_teams()
    courts = storeCourt.get_courts()

    now = datetime.datetime.now()
    return render_template('match_edit.html', match=match, teams=teams, courts=courts, current_time=now.ctime())
Пример #4
0
 def get_team(self, key):
     global connection
     try:
         connection = dbapi2.connect(dsn)
         cursor = connection.cursor()
         statement = """SELECT objectid, name, shirtcolour, foundationdate, countryid, courtid FROM team where (objectid=%s and deleted=0)"""
         cursor.execute(statement, (key,))
         id,name,color,date,countryid,courtid=cursor.fetchone()
         cursor.close()
         storeCountry = country_operations()
         storeCourt = court_operations()
     except dbapi2.DatabaseError:
         if connection:
             connection.rollback()
     finally:
         if connection:
             connection.close()
     return Team(id,name, color, date, countryid, storeCountry.get_country(countryid), courtid, storeCourt.get_court(courtid),0)
Пример #5
0
 def get_teams(self):
     teams=[]
     global connection
     storeCountry = country_operations()
     storeCourt = court_operations()
     try:
         connection = dbapi2.connect(dsn)
         cursor = connection.cursor()
         statement = """SELECT team.objectid, team.name, team.shirtcolour, team.foundationdate, team.countryid,team.courtid FROM team WHERE team.deleted = 0 ORDER BY objectid """
         cursor.execute(statement)
         teams = [(key, Team(key,name,color,date,countryid, storeCountry.get_country(countryid),courtid,storeCourt.get_court(courtid) , 0)) for key, name, color, date, countryid, courtid in cursor]
         cursor.close()
     except dbapi2.DatabaseError:
         if connection:
             connection.rollback()
     finally:
         if connection:
             connection.close()
     return teams
Пример #6
0
    def get_match(self, key):
        global connection
        storeCourt = court_operations()
        storeTeam = team_operations()
        try:
            connection = dbapi2.connect(dsn)
            cursor = connection.cursor()
            statement = """SELECT objectid, hometeamid, awayteamid, courtid, matchdate FROM match WHERE (objectid=%s and deleted=0)"""
            cursor.execute(statement, (key,))
            id,hometeamid,awayteamid,courtid,matchdate=cursor.fetchone()
            cursor.close()
        except dbapi2.DatabaseError:
            if connection:
                connection.rollback()
        finally:
            if connection:
                connection.close()

        return Match(id, hometeamid, storeTeam.get_team(hometeamid), awayteamid, storeTeam.get_team(awayteamid), courtid, storeCourt.get_court(courtid), matchdate, 0)
Пример #7
0
 def get_matches(self):
     matches=[]
     global connection
     storeCourt = court_operations()
     storeTeam = team_operations()
     try:
         connection = dbapi2.connect(dsn)
         cursor = connection.cursor()
         statement = """SELECT objectid, hometeamid, awayteamid, courtid, matchdate FROM match WHERE deleted = 0 ORDER BY objectid"""
         cursor.execute(statement)
         matches = [(key, Match(key, hometeamid, storeTeam.get_team(hometeamid), awayteamid, storeTeam.get_team(awayteamid), courtid, storeCourt.get_court(courtid), matchdate, 0)) for key, hometeamid, awayteamid, courtid, matchdate in cursor]
         cursor.close()
     except dbapi2.DatabaseError:
         if connection:
             connection.rollback()
     finally:
         if connection:
             connection.close()
     return matches
Пример #8
0
def court_edit_page(key=None):
    store = court_operations()
    court = store.get_court(key) if key is not None else None
    now = datetime.datetime.now()
    return render_template('court_edit.html', court=court, current_time=now.ctime())