Ejemplo n.º 1
0
    help='Google spreadsheet with overriding address and coordinate information'
)

# Do global setup
globals.setup(parms)
conn = globals.conn
curs = globals.curs

# Get all clubs
clubs = Club.getClubsOn(curs)

if parms.newAlignment:
    overrideClubs(clubs, parms.newAlignment, exclusive=False)

# Remove suspended clubs
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)
Ejemplo n.º 2
0
    if parms.fromdate:
        fromdate = cleandate(parms.fromdate,usetmyear=False)
        # Go backwards to the last date with data on or before the date specified 
        curs.execute("SELECT MAX(loadedfor) FROM loaded where tablename = 'clubs' AND loadedfor <= %s", (fromdate,))
        fromdate = stringify(curs.fetchone()[0])
    else:
        # We want the most recent date with data before the todate
        curs.execute("SELECT MAX(loadedfor) FROM loaded WHERE tablename = 'clubs' AND loadedfor < %s", ((todate,)))
        fromdate = stringify(curs.fetchone()[0])
    
  
    namestocompare = ['place', 'address', 'city', 'state', 'zip', 'country', 'meetingday', 'meetingtime', 'area', 'division', 'district']
    # Get information for clubs as of the "from" date:
    oldclubs = Club.getClubsOn(curs, date=fromdate, goodnames=namestocompare)
    oldclubs = removeSuspendedClubs(oldclubs, curs, date=fromdate)
    newclubs = {}   # Where clubs created during the period go
    changedclubs = {}  # Where clubs changed during the period go

    
    # And compare to the the list of clubs at the end of the period
    allclubs = Club.getClubsOn(curs, date=todate)
    allclubs = removeSuspendedClubs(allclubs, curs, date=todate)
    
    for club in list(allclubs.values()):
        if club.clubnumber not in oldclubs:
            club.info = 'New Club'
            newclubs[club.clubnumber] = club
        elif club == oldclubs[club.clubnumber]:
            # Club is unchanged; just remove it
            del oldclubs[club.clubnumber]
Ejemplo n.º 3
0
parms.add_argument('--newAlignment', dest='newAlignment', default=None, help='Overrides area/division data from the CLUBS table.')
parms.add_argument('--officers', dest='officers', help='URL of the CSV export form of a Google Spreadsheet with Area/Division Directors')
parms.parse()

# Connect to the database
conn = dbconn.dbconn(parms.dbhost, parms.dbuser, parms.dbpass, parms.dbname)
curs = conn.cursor()
    
# Get all clubs
clubs = Club.getClubsOn(curs)

if parms.newAlignment:
    overrideClubs(clubs, parms.newAlignment)
    
# Remove suspended clubs
clubs = removeSuspendedClubs(clubs, curs)


# 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.
officers = urllib2.urlopen(parms.officers)
Ejemplo n.º 4
0
    if parms.fromdate:
        fromdate = cleandate(parms.fromdate,usetmyear=False)
        # Go backwards to the last date with data on or before the date specified 
        curs.execute("SELECT MAX(loadedfor) FROM loaded where tablename = 'clubs' AND loadedfor <= %s", (fromdate,))
        fromdate = stringify(curs.fetchone()[0])
    else:
        # We want the most recent date with data before the todate
        curs.execute("SELECT MAX(loadedfor) FROM loaded WHERE tablename = 'clubs' AND loadedfor < %s", ((todate,)))
        fromdate = stringify(curs.fetchone()[0])
    
  
    namestocompare = ['place', 'address', 'city', 'state', 'zip', 'country', 'meetingday', 'meetingtime', 'area', 'division', 'district']
    # Get information for clubs as of the "from" date:
    oldclubs = Club.getClubsOn(curs, date=fromdate, goodnames=namestocompare)
    oldclubs = removeSuspendedClubs(oldclubs, curs, date=fromdate)
    newclubs = {}   # Where clubs created during the period go
    changedclubs = {}  # Where clubs changed during the period go

    
    # And compare to the the list of clubs at the end of the period
    allclubs = Club.getClubsOn(curs, date=todate)
    allclubs = removeSuspendedClubs(allclubs, curs, date=todate)
    
    for club in list(allclubs.values()):
        if club.clubnumber not in oldclubs:
            club.info = 'New Club'
            newclubs[club.clubnumber] = club
        elif club == oldclubs[club.clubnumber]:
            # Club is unchanged; just remove it
            del oldclubs[club.clubnumber]