示例#1
0
def add_rev(row):
    try:
        from models import DistributionRevision
        drev = DistributionRevision()
        drev.name = row[0]
        drev.relief_name = str(row[3])
        drev.destination = str(row[1])
        drev.num_of_packs = int(row[6])
        drev.description = str(row[5])
        drev.contacts = str(row[8])
        drev.date = str(row[7])
        drev.tag = str(row[4])
        drev.put()
    except Exception, e:
        return 'Failed (' + str(e) + ")"
示例#2
0
def add_distribution(data, instance_id=""):
    if instance_id:
        distribution = DistributionRevision.get_by_id(int(instance_id))
    else:
        distribution = DistributionRevision()

    if data["date_of_distribution"]:
        distribution.date = data["date_of_distribution"]

    if data["contact"]:
        distribution.contacts = data["contact"]

    if data["destinations"]:
        distribution.destination = data["destinations"]

    if data["supply_goal"]:
        distribution.supply_goal = data["supply_goal"]

    if data["actual_supply"]:
        distribution.actual_supply = data["actual_supply"]

    if data["images"]:
        distribution.images = data["images"]

    if data["status"]:
        distribution.status = data["status"]

    if data["info"]:
        distribution.info = data["info"]

    if data["fb_email"]:
        distribution.fb_email = data["fb_email"]

    if data["fb_id"]:
        distribution.fb_id = data["fb_id"]

    if data["fb_access_token"]:
        distribution.fb_access_token = data["fb_access_token"]

    if data["fb_username"]:
        distribution.fb_username = data["fb_username"]

    if data["fb_lastname"]:
        distribution.fb_lastname = data["fb_lastname"]

    if data["fb_middlename"]:
        distribution.fb_middlename = data["fb_middlename"]

    if data["fb_name"]:
        distribution.fb_name = data["fb_name"]

    if data["relief_name"]:
        distribution.relief_name = data["relief_name"]

    if data["num_of_packs"]:
        distribution.num_of_packs = data["num_of_packs"]

    if data["needs"]:
        distribution.needs = data["needs"]

    if data["tag"]:
        distribution.tag = data["tag"]

    if data["description"]:
        distribution.description = data["description"]

    distribution.put()

    return distribution