#!/usr/bin/python3

import database
import json
import Email

print("Content-Type: text/html")  # HTML is following
print()  # blank line, end of headers

db = database.Database()
emails = Email.LoadAll(db)

results = []
for email in emails:
    json_email = dict()
    json_email['id'] = email.ID()
    json_email['subject'] = email.Subject()
    results.append(json_email)

print(json.dumps(results))
コード例 #2
0
import BatchManager
import database
import participant
import Email
import time

database = database.Database()

emails = Email.LoadAll(database)
people = participant.LoadAll(database)

# hard coded the value of the reminder email, because I suck.
email = None
for candidate in emails:
    if candidate.ID() is 7:
        email = candidate

if email:
    timestamp = int(time.time())
    batch_id = database.ExecuteInsert(
        "INSERT INTO batch (email_id, datetime) VALUES (" + str(email.ID()) +
        ", " + str(timestamp) + ");")
    BatchManager.SendEmailToGroup(4, batch_id, email, people, database)
    BatchManager.SendEmailToGroup(3, batch_id, email, people, database)
    BatchManager.SendEmailToGroup(2, batch_id, email, people, database)
    BatchManager.SendEmailToGroup(1, batch_id, email, people, database)

database.Close()