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 seed_student_proposal(request, i): """Returns the properties of a new student proposal. """ ensureUser() org = Organization.get_by_key_name('google/gsoc2009/org_%d' % i) mentor = Mentor.get_by_key_name('google/gsoc2009/org_%d/mentor' % i) user = User.get_by_key_name('user_%d' % i) student = Student.get_by_key_name('google/gsoc2009/student_%d' % i) if not user: raise Error('Run seed_many for at least %d users first.' % i) if not student: raise Error('Run seed_many for at least %d students first.' % i) if not org: raise Error('Run seed_many for at least %d orgs first.' % i) if not mentor: raise Error('Run seed_many for at least %d mentors first.' % i) all_properties = [] # pylint: disable-msg=E1103 for i in range(random.randint(5, 20)): link_id = 'proposal_%s_%d' % (org.link_id, i) scope_path = 'google/gsoc2009/' + user.link_id properties = { 'link_id': link_id, 'scope_path': scope_path, 'scope': student, 'key_name': '%s/%s' % (scope_path, link_id), 'title': 'The Awesome Proposal %s %d' % (user.link_id, i), 'abstract': 'This is an Awesome Proposal, look at its awesomeness!', 'content': 'Sorry, too Awesome for you to read!', 'additional_info': 'http://www.zipit.com', 'mentor': mentor, 'status': 'pending', 'org': org, 'program': org.scope, } all_properties.append(properties) return all_properties
def clear(*args, **kwargs): """Removes all entities from the datastore. """ # there no explicit ranker model anywhere, so make one for # our own convenience to delete all rankers class ranker(db.Model): """ranker model used with ranklist module. """ pass # TODO(dbentley): If there are more than 1000 instances of any model, # this method will not clear all instances. Instead, it should continually # call .all(), delete all those, and loop until .all() is empty. entities = itertools.chain(*[ Notification.all(), Mentor.all(), Student.all(), OrgAdmin.all(), ranker.all(), RankerRoot.all(), StudentProposal.all(), Organization.all(), OrgApplication.all(), Timeline.all(), Program.all(), Host.all(), Sponsor.all(), User.all(), Site.all(), Document.all(), ]) try: for entity in entities: entity.delete() except db.Timeout: return http.HttpResponseRedirect('#') # pylint: disable-msg=E1101 memcache.flush_all() return http.HttpResponse('Done')
def getDebugUser(self, survey, this_program): """Debugging method impersonates other roles. Tests taking survey, saving response, and grading. params: survey = survey entity this_program = program scope of survey """ if 'mentor' in survey.taking_access: from soc.models.mentor import Mentor role = Mentor.get_by_key_name( this_program.key().name() + "/org_1/test") if 'student' in survey.taking_access: from soc.models.student import Student role = Student.get_by_key_name( this_program.key().name() + "/test") if role: return role.user
def getDebugUser(self, survey, this_program): """Debugging method impersonates other roles. Tests taking survey, saving response, and grading. params: survey = survey entity this_program = program scope of survey """ if 'mentor' in survey.taking_access: from soc.models.mentor import Mentor role = Mentor.get_by_key_name(this_program.key().name() + "/org_1/test") if 'student' in survey.taking_access: from soc.models.student import Student role = Student.get_by_key_name(this_program.key().name() + "/test") if role: return role.user