# HG changeset patch # User Daniel Hans # Date 1253618133 -7200 # Node ID 676c0ca67e21ab7f28b37b8ecfe6f3b3e34752f4 # Parent 9ae1ee28e4389752ca923be7f0c326b4b1c5b2d3 Add a script to generate a kml file with all active GSoC participants Only the students, mentors, and organization admins that are 'active' are exported. Students that do not have a project are not exported. Reviewed-by: Sverre Rabbelier diff -r 9ae1ee28e438 -r 676c0ca67e21 scripts/export_kml.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/scripts/export_kml.py Tue Sep 22 13:15:33 2009 +0200 @@ -0,0 +1,743 @@ +#!/usr/bin/python2.5 +# +# Copyright 2009 the Melange authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +"""The script which generates KML file for Google Summer of Code 2009 program. +""" + +__authors__ = [ + '"Daniel Hans" ', +] + + +import sys +import codecs +import interactive + + +from xml.dom.minidom import Document + + +def _getMentoredProjects(mentor): + """Returns a list of projects which are mentored by a given mentor. + """ + + from soc.logic.models.student_project import logic as project_logic + + filter = { + 'mentor': mentor + } + + return project_logic.getForFields(filter=filter) + + +def _getAcceptedOrgs(): + """Returns a list of organizations which got accepted. + """ + + from soc.logic.models.organization import logic as org_logic + + filter = { + 'status': 'active' + } + + entities = org_logic.getForFields(filter=filter) + + filter = { + 'status': 'new' + } + + entities += org_logic.getForFields(filter=filter) + + return entities + + +def _getStudentProject(entity): + """Returns a project for a given student. + """ + + from soc.logic.models.student_project import logic as project_logic + + filter = { + 'student': entity, + 'status': 'accepted', + } + + return project_logic.getForFields(filter=filter, unique=True) + + +def _getAllUsers(): + """Returns a list of all valid users. + """ + + from soc.models.user import User + + gen = lambda: User.all().filter('status =', 'valid') + return interactive.deepFetch(gen) + + +def _getAllOrgAdmins(): + """Returns a generator of all active mentors. + """ + + from soc.models.org_admin import OrgAdmin + + gen = lambda: OrgAdmin.all().filter('status = ', 'active') + return interactive.deepFetch(gen) + + +def _getAllMentors(): + """Returns a generator of all active mentors. + """ + + from soc.models.mentor import Mentor + + gen = lambda: Mentor.all().filter('status = ', 'active') + return interactive.deepFetch(gen) + + +def _getAllStudents(): + """Returns a generator of all active students. + """ + + from soc.models.student import Student + + gen = lambda: Student.all().filter('status = ', 'active') + return interactive.deepFetch(gen) + + +def _getPersonStyle(doc, type): + """Returns