'Create teams if needed and associate them with the packages.'

def finish_package_claims(self, cursor, nonce, *packages):

    if (not packages):
        raise NoPackages()
    (package_ids, teams, team_ids) = ([], [], [])
    for package in packages:
        package_ids.append(package.id)
        team = package.get_or_create_linked_team(cursor, self)
        teams.append(team)
        team_ids.append(team.id)
    review_url = self.app.project_review_process.start(*teams)
    cursor.run(u'DELETE    FROM    claims    WHERE    nonce=%s', (nonce,))
    cursor.run(u'UPDATE    teams    SET    review_url=%s    WHERE    id=ANY(%s)', (review_url, team_ids))
    self.app.add_event(cursor, u'participant', dict(id=self.id, action=u'finish-claim', values=dict(package_ids=package_ids)))
