'Record creation post-processing
Update the percentages of all the Project\'s Locations.'

@staticmethod
def project_theme_project_onaccept(form):

    project_id = form.vars.get('project_id', None)
    if ((not project_id) and form.request_vars):
        project_id = form.request_vars.get('project_id', None)
    if (not project_id):
        return
    percentages = {}
    db = current.db
    table = db.project_theme_project
    query = ((table.deleted == False) & (table.project_id == project_id))
    rows = db(query).select(table.theme_id, table.percentage)
    for row in rows:
        percentages[row.theme_id] = row.percentage
    s3db = current.s3db
    table = s3db.project_location
    ltable = s3db.project_theme_location
    update_or_insert = ltable.update_or_insert
    query = ((table.deleted == False) & (table.project_id == project_id))
    rows = db(query).select(table.id)
    for row in rows:
        for theme_id in percentages:
            update_or_insert(project_location_id=row.id, theme_id=theme_id, percentage=percentages[theme_id])
