# Do global setup myglobals.setup(parms, sections='alignment') conn = myglobals.conn curs = myglobals.curs # Get all defined clubs from the database. clubs = Club.getClubsOn(curs) # Get coordinates setClubCoordinatesFromGEO(clubs, curs, removeNotInGeo=False) # If there are overrides to club positioning, handle them now if parms.mapoverride: print(('Processing general overrides from %s' % parms.mapoverride)) overrideClubPositions(clubs, parms.mapoverride, parms.googlemapsapikey, log=True, createnewclubs=True) # Now, add info from clubperf (and create club.oldarea for each club) # We use the 'lastfor' table to get information for all clubs, even those which Toastmasters dropped from # the list because they were suspended for two renewal cycles. curs.execute( '''SELECT clubnumber, clubname, division, area, color, goalsmet, activemembers, clubstatus FROM clubperf WHERE id in (SELECT clubperf_id FROM lastfor WHERE tmyear = %s)''', (myglobals.tmyear, )) for (clubnumber, clubname, division, area, color, goalsmet, activemembers, clubstatus) in curs.fetchall(): try: c = clubs[str(clubnumber)] except KeyError:
clubs = removeSuspendedClubs(clubs, curs) # Remove clubs from outside our District for c in list(clubs.keys()): try: if int(clubs[c].district) != parms.district: del clubs[c] except ValueError: print((clubs[c])) # Add current coordinates and remove clubs without coordinates (unless there's a new alignment) setClubCoordinatesFromGEO(clubs, curs, removeNotInGeo=not parms.newAlignment) # If there are overrides to club positioning, handle them now if parms.mapoverride: overrideClubPositions(clubs, parms.mapoverride, parms.googlemapsapikey) # Now, assign clubs to Areas and Divisions for c in sorted(clubs): club = clubs[c] Area.find(club.division, club.area).addclub(club) # OK, now we have the club info. Let's get the Area Director/Division Director information. for row in GSheet(parms.officers, apikey=parms.googlesheetsapikey): for k in row.fieldnames: setattr(row, k, ' '.join(str(getattr(row, k))).split()) if row.title and row.first: Director(row) # And now we go through the Divisions and Areas and build the output.
# Get the club information for the specified date clubs = Club.getClubsOn(curs, parms.date) # And remove suspended clubs. clubs = removeSuspendedClubs(clubs, curs) # And override it if needed. if parms.newAlignment: overrideClubs(clubs, parms.newAlignment, exclusive=False) # If there are overrides to club positioning, handle them now if parms.mapoverride: overrideClubPositions(clubs, parms.mapoverride, parms.googlemapsapikey) cities = {} for c in clubs: club = clubs[c] club.city = club.city.title() if club.city not in cities: cities[club.city] = [] cities[club.city].append(club) outfile = open('clublist.html', 'w') headfile = open('clublist.css', 'w') bodyfile = open('clublist.body', 'w') narrowfile = open('narrowclublist.html', 'w')
# Get the clubs clubs = Club.getClubsOn(curs) # Remove suspended clubs unless there's a test alignment if not parms.testalign: clubs = removeSuspendedClubs(clubs, curs) # Get coordinates setClubCoordinatesFromGEO(clubs, curs, removeNotInGeo=False) # If there are overrides to club positioning, handle them now # This will also add secret clubs if they exist if parms.mapoverride: overrideClubPositions(clubs, parms.mapoverride, parms.googlemapsapikey, createnewclubs=True) # Process new grouping if parms.testalign: clubs = overrideClubs(clubs, parms.testalign) # Delete clubs at (0.0, 0.0) for cnum in clubs: c = clubs[cnum] if c.latitude == 0.0 and c.longitude == 0.0: print('Deleting', c) del clubs[cnum] # Force all clubs to be included in the alignment map unless they are online-only for cnum in clubs:
parms.add_argument('--includeprecharter', dest='includeprecharter', action='store_true', help='Specify this to include "pre-charter" clubs (ones with negative club numbers in the newAlignment file)') # Do global setup globals.setup(parms) conn = globals.conn curs = globals.curs # Get all defined clubs from the database. clubs = Club.getClubsOn(curs) # Get coordinates setClubCoordinatesFromGEO(clubs, curs, removeNotInGeo=False) # If there are overrides to club positioning, handle them now if parms.mapoverride: print(('Processing general overrides from %s' % parms.mapoverride)) overrideClubPositions(clubs, parms.mapoverride, parms.googlemapsapikey,log=True, createnewclubs=True) # Now, add info from clubperf (and create club.oldarea for each club) # We use the 'lastfor' table to get information for all clubs, even those which Toastmasters dropped from # the list because they were suspended for two renewal cycles. curs.execute('''SELECT clubnumber, color, goalsmet, activemembers, clubstatus FROM clubperf WHERE id in (SELECT clubperf_id FROM lastfor WHERE tmyear = %s)''', (globals.tmyear,)) for (clubnumber, color, goalsmet, activemembers, clubstatus) in curs.fetchall(): c = clubs[str(clubnumber)] c.color = color c.goalsmet = goalsmet c.activemembers = activemembers try: c.oldarea = c.division + c.area except AttributeError: c.oldarea = '0D0A'