Exemplo n.º 1
0
 def makecongrat(why, amount, winners):
     if len(winners) == 0:
         return ''
     elif len(winners) == 1:
         return '<p><b>Congratulations</b> to %s for earning %s in District Credit by %s.' % (
             tmutil.getClubBlock(winners), amount, why)
     else:
         return '<p><b>Congratulations</b> to these clubs for earning %s in District Credit by %s: %s.</p>\n' % (
             amount, why, tmutil.getClubBlock(winners))
Exemplo n.º 2
0
            (area, division, clubname, asof) = curs.fetchone() 
        except:
            print(row)
        if (clubname.strip() != row.clubname):
            print(f'Wrong club name for {row.clubnumber}: "{row.clubname}" should be "{clubname.strip()}"')
        if 'alignment' in row.fieldnames:
            alignment = division+area        
            if alignment != row.alignment:
                print(f'Wrong alignment for {row.clubname}: should be {row.alignment}, not {alignment}')
        club = myclub(row.clubnumber, clubname, row.values[renewalcol], row.base, division, area)
        for each in levels:
            if club.pct >= each.pct:
                each.winners.append(club)
                break  # We only have to add a club to the best level it reaches


    # Now, write the results for each level
    outfile = open(os.path.join(parms.workdir, parms.outfileprefix + '.html'), 'w')

    for each in levels:
        if len(each.winners) > 0:
            winners = getClubBlock(each.winners)
            res = '<p><b>Congratulations</b> to\n' + winners + '\n for renewing' + (' at least' if each.pct < 100.0 else '') + ' %d%% ' % each.pct + 'of their base membership and earning ' + (parms.format % each.earns)
            if each.name:
                res += '. Welcome to <b>' + each.name + '</b> status'
            res += '!</p>\n'
            outfile.write(res)

    outfile.close()
    
Exemplo n.º 3
0
        except KeyError:
            pass

    # Now, compute results
    leapers = [[], [], [], []]  # For 0-3 levels
    for club in list(clubs.values()):
        club.delta = max(0, club.thisyear - club.lastyear)
        if club.delta > 0:
            leapers[club.delta].append(club)

    # And create the output file
    outfile = open(parms.outfile, 'w')
    for i in range(1, 4):
        if leapers[i]:
            outfile.write('<p>Congratulations to ')
            outfile.write(tmutil.getClubBlock(leapers[i]))
            outfile.write(' for earning $%d for leaping %d level%s.<p>\n' %
                          (40 * i, i, 's' if i > 1 else ''))
    outfile.close()

    csvfile = open(parms.csvfile, 'w')
    csvwriter = csv.DictWriter(csvfile,
                               fieldnames=columnsforcsv,
                               extrasaction="ignore")
    csvwriter.writeheader()
    for club in sorted(list(clubs.values()),
                       key=lambda c: '%s%s%.8d' %
                       (c.division, c.area, c.clubnumber)):
        csvwriter.writerow(club.__dict__)
    csvfile.close()
Exemplo n.º 4
0
 def makecongrat(why, amount, winners):
     if len(winners) == 0:
         return ''
     elif len(winners) == 1:
         return '<p><b>Congratulations</b> to %s for earning %s in District Credit by %s.' % (tmutil.getClubBlock(winners), amount, why)
     else:
         return '<p><b>Congratulations</b> to these clubs for earning %s in District Credit by %s: %s.</p>\n' % (amount, why, tmutil.getClubBlock(winners))
Exemplo n.º 5
0
outfile.write("""<h3 id="early">Early Achievers</h3>
<p>
Clubs achieving 5 or more Distinguished Club Program (DCP) goals by October 31 earn $100 in District Credit.  This report is %s.</p>
""" % status)

if len(winners) > 0:
    outfile.write("<h4>Early Achievers</h4>\n")
    showclubswithvalues(winners, "Goals", outfile)

if len(almost) > 0 and not final:
    outfile.write("<p>&nbsp;</p>")
    outfile.write(
        "<p>These clubs have achieved 4 of the 5 DCP goals needed to join the Early Achievers.</p>"
    )
    showclubswithvalues(almost, "Goals", outfile)

outfile.close()

# Write the text block version

outfile = open(os.path.join(parms.workdir, parms.outfileprefix + '.text'), 'w')
if len(winners) > 0:
    outfile.write(
        "<b>Congratulations to our first Early Achiever Club%s</b>:  " %
        ('s' if len(winners) > 1 else ''))
    outfile.write(getClubBlock(winners))
    outfile.write('.')
    outfile.write('\n')
outfile.close()
Exemplo n.º 6
0
    
        # See if WHQ has posted any President's Distinguished Clubs; if so,
        #   use their information.  If not, calculate on our own.

        curs.execute("SELECT clubnumber, clubname FROM clubperf WHERE clubdistinguishedstatus = 'P' AND asof = %s", (targetdate,))

        for c in curs.fetchall():
            winners.append(myclub(*c))

        if not winners:
            print('No President\'s Distinguished Clubs from WHQ.', file=sys.stderr)
            # Either WHQ hasn't posted or no one qualifies.  Use our calculation.
            curs.execute("SELECT c.clubnumber, c.clubname FROM clubperf c INNER JOIN distperf d ON c.clubnumber = d.clubnumber AND c.entrytype = 'L' AND d.entrytype = 'L' AND ((d.aprrenewals > 20) OR (d.aprrenewals - c.membase) >= 5) WHERE c.goalsmet >= 9")
            for c in curs.fetchall():
                winners.append(myclub(*c))

    else:
        # We only care about clubs with at least 9 goals.
        curs.execute("SELECT clubnumber, clubname FROM clubperf WHERE goalsmet >= 9 AND asof = %s", (targetdate,))
        for c in curs.fetchall():
            winners.append(myclub(*c))

    if len(winners) > 0:
        outfile.write('<p><b>Congratulations</b> to %s for earning %s!</p>' % (getClubBlock(winners), parms.earning))
        print("%d clubs have qualified" % len(winners), file=sys.stderr)
    outfile.close()


    

Exemplo n.º 7
0
            prevnum = 0
        prevgrowth = prevnum - startnum

        if growth >= 5:
            winners.append(
                myclub(clubnumber, clubname, division, area, endnum, startnum,
                       growth))
            if prevgrowth < 5:
                todays.append(clubname)

    # Open the output file
    clubfile = open(parms.outfile, 'w')
    if winners:
        clubfile.write(
            r'<b>Congratulations</b> to %s for qualifying for "Five for 5"!' %
            getClubBlock(winners))
    clubfile.close()

    # Open the email file
    emailfile = open(parms.emailfile, 'w')
    if todays:
        emailfile.write('<p>Clubs earning Five for 5 today:\n<ul>\n')
        for club in sorted(todays):
            emailfile.write('<li>%s</li>\n' % club)
        emailfile.write('</ul>\n')
    else:
        emailfile.write('<p>No clubs earned Five for 5 today.\n')
    emailfile.write('\n')

    if winners:
        emailfile.write('<p>All clubs which have earned Five for 5:\n<ul>\n')
Exemplo n.º 8
0
        curs.execute(
            "SELECT clubnumber, clubname FROM clubperf WHERE clubdistinguishedstatus = 'P' AND asof = %s",
            (targetdate, ))

        for c in curs.fetchall():
            winners.append(myclub(*c))

        if not winners:
            print('No President\'s Distinguished Clubs from WHQ.',
                  file=sys.stderr)
            # Either WHQ hasn't posted or no one qualifies.  Use our calculation.
            curs.execute(
                "SELECT c.clubnumber, c.clubname FROM clubperf c INNER JOIN distperf d ON c.clubnumber = d.clubnumber AND c.entrytype = 'L' AND d.entrytype = 'L' AND ((d.aprrenewals > 20) OR (d.aprrenewals - c.membase) >= 5) WHERE c.goalsmet >= 9"
            )
            for c in curs.fetchall():
                winners.append(myclub(*c))

    else:
        # We only care about clubs with at least 9 goals.
        curs.execute(
            "SELECT clubnumber, clubname FROM clubperf WHERE goalsmet >= 9 AND asof = %s",
            (targetdate, ))
        for c in curs.fetchall():
            winners.append(myclub(*c))

    if len(winners) > 0:
        outfile.write('<p><b>Congratulations</b> to %s for earning %s!</p>' %
                      (getClubBlock(winners), parms.earning))
        print("%d clubs have qualified" % len(winners), file=sys.stderr)
    outfile.close()
Exemplo n.º 9
0
                myclub(clubnumber, clubname, division, area, endnum, startnum,
                       growth, amount))
            wincount += 1
    # Open the output file
    clubfile = open(parms.outfile, 'w')

    # Only write data if at least one club has qualified

    if len(winners) > 0:
        if wincount == 1:
            # There's only one club to congratulate
            theclub = winners[min(winners.keys())][0]
            clubfile.write(
                "<p>Congratulations to <b>%s</b> for earning $%d for adding %d member%s.</p>\n"
                % (theclub.clubname, theclub.amount, theclub.growth,
                   "s" if theclub.growth > 1 else ""))
        else:
            clubfile.write(
                "<p><b>Congratulations to these clubs for adding new members:</b></p>\n"
            )
            for amount in sorted(winners.keys(), reverse=True):
                tranche = winners[amount]
                growth = tranche[0].growth
                clubfile.write(
                    "<p><b>Earning $%d for adding %d member%s:</b> " %
                    (amount, growth, "s" if growth > 1 else ""))
                clubfile.write(getClubBlock(tranche))
                clubfile.write(".</p>\n")

    clubfile.close()
Exemplo n.º 10
0
        c = list(c)
        if c[0] in specials:
            c[3] = specials[c[0]]
        rawdata.append(c+[asof])
        club = myclub(*c)
        for each in levels:
            if club.pct >= each.pct:
                each.winners.append(myclub(*c))
                break  # We only have to add a club to the best level it reaches

    # Write the raw data
    outfile = open(parms.outfileprefix + '.csv', 'w')
    csvwriter = csv.writer(outfile, quoting=csv.QUOTE_MINIMAL)
    csvwriter.writerows(rawdata)
    outfile.close()

    # Now, write the results for each level
    outfile = open(parms.outfileprefix + '.text', 'w')

    for each in levels:
        if len(each.winners) > 0:
            winners = getClubBlock(each.winners)
            res = '<p><b>Congratulations</b> to\n' + winners + '\n for renewing' + (' at least' if each.pct < 100.0 else '') + ' %d%% ' % each.pct + 'of their base membership and earning ' + (parms.format % each.earns)
            if each.name:
                res += '. Welcome to <b>' + each.name + '</b> status'
            res += '!</p>\n'
            outfile.write(res)

    outfile.close()
    
Exemplo n.º 11
0
    for (clubnumber, status) in curs.fetchall():
        try:
            clubs[clubnumber].laststatus = status
            clubs[clubnumber].lastyear = levels[(status+' ')[0]]
        except KeyError:
            pass
            
    # Now, compute results
    leapers = [[],[],[],[]]    # For 0-3 levels
    for club in list(clubs.values()):
        club.delta = max(0,club.thisyear - club.lastyear)
        if club.delta > 0:
            leapers[club.delta].append(club)
            
    # And create the output file
    outfile = open(parms.outfile, 'w')
    for i in range(1,4):
        if leapers[i]:
            outfile.write('<p>Congratulations to ')
            outfile.write(tmutil.getClubBlock(leapers[i]))
            outfile.write(' for earning $%d for leaping %d level%s.<p>\n' % (40*i, i, 's' if i > 1 else ''))
    outfile.close()
    
    csvfile = open(parms.csvfile, 'wb')
    csvwriter = csv.DictWriter(csvfile, fieldnames=columnsforcsv, extrasaction="ignore")
    csvwriter.writeheader()
    for club in sorted(list(clubs.values()), key=lambda c:'%s%s%.8d' % (c.division, c.area, c.clubnumber)):
        csvwriter.writerow(club.__dict__)
    csvfile.close()
    
Exemplo n.º 12
0
                else:
                    onlylucky.append(club)
            lucky = onlylucky

    # Set up to use getClubBlock
    class localclub:
        def __init__(self, club):
            self.clubname = club[2]

    if parms.bonus9a and parms.lastmonth == 'February':
     
        #outfile.write('<p>Clubs which have all 7 Officers attend <a href="/training">Club Officer Training</a> during the December-February training period and which trained at least 4 Officers during June-August earn <b>%s</b> and join the <b>%s</b>.</p>\n' % (parms.bonusreward, parms.phase2name))
        if bonus:
            luckyclubs = [localclub(club) for club in bonus]
            outfile.write('<p><b>Congratulations</b> to ')
            outfile.write(tmutil.getClubBlock(luckyclubs))
            outfile.write(' for earning %s and joining the %s.</p>\n' % (parms.bonusreward, parms.phase2name))

        #outfile.write('<p>Clubs which have all 7 Officers attend <a href="/training">Club Officer Training</a> during the December-February training period but trained fewer than 4 Officers during June-August earn <b>%s</b>.</p>\n' % parms.reward)

    elif parms.require9a and parms.lastmonth == 'February':
        outfile.write('<p>Clubs which have all 7 Officers attend <a href="/training">Club Officer Training</a> during the December-February training period and which trained at least 4 Officers during June-August earn <b>%s</b>.</p>\n' % parms.reward)

    else:
        outfile.write('<p>Join the <b>%s</b> and earn <b>%s</b> by having all seven Club Officers attend <a href="/training">Club Officer Training</a> in the %s period.</p>\n' % (parms.phase1name, parms.reward, parms.period))
 


    if lucky:
        luckyclubs = [localclub(club) for club in lucky]
        outfile.write('<p><b>Congratulations</b> to ')
Exemplo n.º 13
0
                else:
                    onlylucky.append(club)
            lucky = onlylucky

    # Set up to use getClubBlock
    class localclub:
        def __init__(self, club):
            self.clubname = club[2]

    if parms.bonus9a and parms.lastmonth == 'February':
     
        #outfile.write('<p>Clubs which have all 7 Officers attend <a href="/training">Club Officer Training</a> during the December-February training period and which trained at least 4 Officers during June-August earn <b>%s</b> and join the <b>%s</b>.</p>\n' % (parms.bonusreward, parms.phase2name))
        if bonus:
            luckyclubs = [localclub(club) for club in bonus]
            outfile.write('<p><b>Congratulations</b> to ')
            outfile.write(tmutil.getClubBlock(luckyclubs))
            outfile.write(' for earning %s and joining the %s.</p>\n' % (parms.bonusreward, parms.phase2name))

        #outfile.write('<p>Clubs which have all 7 Officers attend <a href="/training">Club Officer Training</a> during the December-February training period but trained fewer than 4 Officers during June-August earn <b>%s</b>.</p>\n' % parms.reward)

    elif parms.require9a and parms.lastmonth == 'February':
        outfile.write('<p>Clubs which have all 7 Officers attend <a href="/training">Club Officer Training</a> during the December-February training period and which trained at least 4 Officers during June-August earn <b>%s</b>.</p>\n' % parms.reward)

    else:
        outfile.write('<p>Join the <b>%s</b> and earn <b>%s</b> by having all seven Club Officers attend <a href="/training">Club Officer Training</a> in the %s period.</p>\n' % (parms.phase1name, parms.reward, parms.period))
 


    if lucky:
        luckyclubs = [localclub(club) for club in lucky]
        outfile.write('<p><b>Congratulations</b> to ')
Exemplo n.º 14
0
        growth = endnum - startnum
        if not prevnum:
            prevnum = 0
        prevgrowth = prevnum - startnum

        if growth >= 5:
            winners.append(myclub(clubnumber, clubname, division, area, endnum, startnum, growth))
            if prevgrowth < 5:
                todays.append(clubname)
        
    

    # Open the output file
    clubfile = open(parms.outfile, 'w')
    if winners:
        clubfile.write(r'<b>Congratulations</b> to %s for qualifying for "Five for 5"!' % getClubBlock(winners))
    clubfile.close()

    # Open the email file
    emailfile = open(parms.emailfile, 'w')
    if todays:
        emailfile.write('<p>Clubs earning Five for 5 today:\n<ul>\n')
        for club in sorted(todays):
            emailfile.write('<li>%s</li>\n' % club)
        emailfile.write('</ul>\n')
    else:
        emailfile.write('<p>No clubs earned Five for 5 today.\n')
    emailfile.write('\n')
        
    if winners:
        emailfile.write('<p>All clubs which have earned Five for 5:\n<ul>\n')
Exemplo n.º 15
0
# Write the HTML version
outfile = open(parms.outfileprefix + '.html', 'w')

outfile.write("""<h3 id="early">Early Achievers</h3>
<p>
Clubs achieving 5 or more Distinguished Club Program (DCP) goals by October 31 earn $100 in District Credit.  This report is %s.</p>
""" % status)

if len(winners) > 0:
    outfile.write("<h4>Early Achievers</h4>\n")
    showclubswithvalues(winners, "Goals", outfile)
    
if len(almost) > 0 and not final:
    outfile.write("<p>&nbsp;</p>")
    outfile.write("<p>These clubs have achieved 4 of the 5 DCP goals needed to join the Early Achievers.</p>")
    showclubswithvalues(almost, "Goals", outfile)

outfile.close()

# Write the text block version

outfile = open(parms.outfileprefix + '.text', 'w')
if len(winners) > 0:
    outfile.write("<b>Congratulations to our Early Achiver Club%s</b>:  " % ('s' if len(winners) > 1 else ''))
    outfile.write(getClubBlock(winners))
    outfile.write('.')
    outfile.write('\n')
outfile.close()