本文整理汇总了Python中soc.modules.gsoc.models.proposal.GSoCProposal.all方法的典型用法代码示例。如果您正苦于以下问题:Python GSoCProposal.all方法的具体用法?Python GSoCProposal.all怎么用?Python GSoCProposal.all使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类soc.modules.gsoc.models.proposal.GSoCProposal
的用法示例。
在下文中一共展示了GSoCProposal.all方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: acceptProposals
# 需要导入模块: from soc.modules.gsoc.models.proposal import GSoCProposal [as 别名]
# 或者: from soc.modules.gsoc.models.proposal.GSoCProposal import all [as 别名]
def acceptProposals(self):
"""Set student proposals' acceptance state and make sure the organization
has slots available.
"""
self.student1 = self.createStudent('[email protected]',
n_proposals=2)
self.student1_proposals = GSoCProposal.all().ancestor(
self.student1.profile)
self.student2 = self.createStudent('[email protected]',
n_proposals=3)
self.student2_proposals = GSoCProposal.all().ancestor(
self.student2.profile)
self.assertEqual(self.student1_proposals.count(), 2)
self.assertEqual(self.student2_proposals.count(), 3)
#accept 1 of 2 proposal of student1
proposal1 = self.student1_proposals[0]
proposal1.accept_as_project = True
proposal1.put()
proposal2 = self.student1_proposals[1]
proposal2.accept_as_project = False
proposal2.put()
#reject all proposals of student2
for proposal in self.student2_proposals:
proposal.accept_as_project = False
proposal.put()
self.org.slots = 5
self.org.put()
self.timeline.studentsAnnounced()
示例2: testAcceptProposalButton
# 需要导入模块: from soc.modules.gsoc.models.proposal import GSoCProposal [as 别名]
# 或者: from soc.modules.gsoc.models.proposal.GSoCProposal import all [as 别名]
def testAcceptProposalButton(self):
student = GSoCProfileHelper(self.gsoc, self.dev_test)
student.createOtherUser('[email protected]')
student.createStudent()
proposal = self.createProposal({'scope': student.profile,
'parent': student.profile})
suffix = "%s/%s/%d" % (
self.gsoc.key().name(),
student.user.key().name(),
proposal.key().id())
self.data.createMentor(self.org)
url = '/gsoc/proposal/accept/' + suffix
postdata = {'value': 'unchecked'}
response = self.post(url, postdata)
# fail if mentor tries to accept the proposal
self.assertResponseForbidden(response)
proposal = GSoCProposal.all().get()
self.assertFalse(proposal.accept_as_project)
# accept the proposal as project when the org admin tries to accept
# the proposal
self.data.createOrgAdmin(self.org)
response = self.post(url, postdata)
self.assertResponseOK(response)
proposal = GSoCProposal.all().get()
self.assertTrue(proposal.accept_as_project)
示例3: getProposalsToBeAcceptedForOrg
# 需要导入模块: from soc.modules.gsoc.models.proposal import GSoCProposal [as 别名]
# 或者: from soc.modules.gsoc.models.proposal.GSoCProposal import all [as 别名]
def getProposalsToBeAcceptedForOrg(org_entity, step_size=25):
"""Returns all StudentProposals which will be accepted into the program
for the given organization.
params:
org_entity: the Organization for which the proposals should be checked
step_size: optional parameter to specify the amount of Student Proposals
that should be retrieved per roundtrip to the datastore
returns:
List with all StudentProposal which will be accepted into the program
"""
# check if there are already slots taken by this org
q = GSoCProposal.all()
q.filter('org', org_entity)
q.filter('status', 'accepted')
slots_left_to_assign = max(0, org_entity.slots - q.count())
if slots_left_to_assign == 0:
# no slots left so return nothing
return []
q = GSoCProposal.all()
q.filter('org', org_entity)
q.filter('status', 'pending')
q.filter('accept_as_project', True)
q.filter('has_mentor', True)
q.order('-score')
# We are not putting this into the filter because order and != do not mix
# in GAE.
proposals = q.fetch(slots_left_to_assign)
offset = slots_left_to_assign
# retrieve as many additional proposals as needed in case the top
# N do not have a mentor assigned
while len(proposals) < slots_left_to_assign:
new_proposals = q.fetch(step_size, offset=offset)
if not new_proposals:
# we ran out of proposals`
break
proposals += new_proposals
offset += step_size
# cut off any superfluous proposals
return proposals[:slots_left_to_assign]
示例4: getListData
# 需要导入模块: from soc.modules.gsoc.models.proposal import GSoCProposal [as 别名]
# 或者: from soc.modules.gsoc.models.proposal.GSoCProposal import all [as 别名]
def getListData(self):
idx = lists.getListIndex(self.data.request)
if idx != 0:
return None
program = self.data.program
# Hold all the accepted projects for orgs where this user is a member of
accepted = []
# Hold all duplicates for either the entire program or the orgs of the user.
duplicates = []
dupQ = GSoCProposalDuplicate.all()
dupQ.filter('is_duplicate', True)
dupQ.filter('org', self.data.url_ndb_org.key.to_old_key())
dupQ.filter('program', program)
accepted.extend(
p.key() for p in getProposalsToBeAcceptedForOrg(self.data.url_ndb_org))
duplicate_entities = dupQ.fetch(1000)
for dup in duplicate_entities:
duplicates.extend(dup.duplicates)
q = GSoCProposal.all()
q.filter('org', self.data.url_ndb_org.key.to_old_key())
q.filter('program', program)
starter = lists.keyStarter
# TODO(daniel): enable prefetching from ndb models ('org', 'parent')
# prefetcher = lists.ModelPrefetcher(GSoCProposal, [], parent=True)
response_builder = lists.RawQueryContentResponseBuilder(
self.data.request, self._list_config, q, starter, prefetcher=None)
return response_builder.build(accepted, duplicates)
示例5: testAssignMentor
# 需要导入模块: from soc.modules.gsoc.models.proposal import GSoCProposal [as 别名]
# 或者: from soc.modules.gsoc.models.proposal.GSoCProposal import all [as 别名]
def testAssignMentor(self):
student = profile_utils.seedSOCStudent(self.program)
proposal = proposal_utils.seedProposal(
student.key, self.program.key(), org_key=self.org.key, mentor=None)
suffix = "%s/%s/%d" % (
self.gsoc.key().name(),
student.profile_id,
proposal.key().id())
user = profile_utils.seedNDBUser()
profile_utils.loginNDB(user)
mentor = profile_utils.seedNDBProfile(
self.program.key(), user=user, mentor_for=[self.org.key])
url = '/gsoc/proposal/assign_mentor/' + suffix
postdata = {'assign_mentor': mentor.key}
response = self.post(url, postdata)
self.assertResponseForbidden(response)
proposal = GSoCProposal.all().get()
mentor_key = GSoCProposal.mentor.get_value_for_datastore(proposal)
self.assertIsNone(mentor_key)
示例6: getListData
# 需要导入模块: from soc.modules.gsoc.models.proposal import GSoCProposal [as 别名]
# 或者: from soc.modules.gsoc.models.proposal.GSoCProposal import all [as 别名]
def getListData(self):
idx = lists.getListIndex(self.request)
if idx != 0:
return None
org = self.data.organization
program = self.data.program
# Hold all the accepted projects for orgs where this user is a member of
accepted = []
# Hold all duplicates for either the entire program or the orgs of the user.
duplicates = []
dupQ = GSoCProposalDuplicate.all()
dupQ.filter('is_duplicate', True)
dupQ.filter('org', org)
dupQ.filter('program', program)
accepted.extend([p.key() for p in getProposalsToBeAcceptedForOrg(org)])
duplicate_entities = dupQ.fetch(1000)
for dup in duplicate_entities:
duplicates.extend(dup.duplicates)
q = GSoCProposal.all()
q.filter('org', org)
q.filter('program', program)
starter = lists.keyStarter
prefetcher = lists.modelPrefetcher(GSoCProposal, ['org'], parent=True)
response_builder = lists.RawQueryContentResponseBuilder(
self.request, self._list_config, q, starter, prefetcher=prefetcher)
return response_builder.build(accepted, duplicates)
示例7: rejectProposals
# 需要导入模块: from soc.modules.gsoc.models.proposal import GSoCProposal [as 别名]
# 或者: from soc.modules.gsoc.models.proposal.GSoCProposal import all [as 别名]
def rejectProposals(self, request, *args, **kwargs):
"""Reject proposals for an single organization.
"""
params = request.POST
# Setup an artifical request deadline
timekeeper = Timekeeper(20000)
# Query proposals
org = soc_org_model.SOCOrganization.get_by_id(params['org_key'])
q = GSoCProposal.all()
q.filter('org', org.key.to_old_key())
q.filter('status', 'pending')
# Reject proposals
try:
for remain, proposal in timekeeper.iterate(q):
logging.info("reject %s %s %s", remain, org.key.id(), proposal.key())
self.rejectProposal(proposal)
# Requeue this task for continuation
except DeadlineExceededError:
taskqueue.add(url=request.path, params=params)
# Exit this task successfully
return responses.terminateTask()
示例8: testSubmitProposal
# 需要导入模块: from soc.modules.gsoc.models.proposal import GSoCProposal [as 别名]
# 或者: from soc.modules.gsoc.models.proposal.GSoCProposal import all [as 别名]
def testSubmitProposal(self):
mentor = GSoCProfileHelper(self.gsoc, self.dev_test)
mentor.createOtherUser('[email protected]')
mentor.createMentor(self.org)
mentor.notificationSettings(
new_proposals=True, public_comments=True, private_comments=True)
other_mentor = GSoCProfileHelper(self.gsoc, self.dev_test)
other_mentor.createOtherUser('[email protected]')
other_mentor.createMentor(self.org)
other_mentor.notificationSettings()
self.data.createStudent()
self.data.notificationSettings()
self.timeline.studentSignup()
url = '/gsoc/proposal/submit/' + self.org.key().name()
response = self.get(url)
self.assertProposalTemplatesUsed(response)
# test proposal POST
override = {
'program': self.gsoc, 'score': 0, 'nr_scores': 0, 'mentor': None,
'org': self.org, 'status': 'pending', 'accept_as_project': False,
'is_editable_post_deadline': False, 'extra': None, 'has_mentor': False,
}
response, properties = self.modelPost(url, GSoCProposal, override)
self.assertResponseRedirect(response)
self.assertEmailSent(to=mentor.profile.email, n=1)
self.assertEmailNotSent(to=other_mentor.profile.email)
proposal = GSoCProposal.all().get()
self.assertPropertiesEqual(properties, proposal)
示例9: testResubmitProposal
# 需要导入模块: from soc.modules.gsoc.models.proposal import GSoCProposal [as 别名]
# 或者: from soc.modules.gsoc.models.proposal.GSoCProposal import all [as 别名]
def testResubmitProposal(self):
"""Tests that a proposal is successfully resubmitted if possible."""
old_number_of_proposals = self.profile.student_data.number_of_proposals
self.kwargs = {
'sponsor': self.sponsor.link_id,
'program': self.program.program_id,
'user': self.profile.profile_id,
'id': self.proposal.key().id()
}
request = http.HttpRequest()
data = request_data.RequestData(request, None, self.kwargs)
handler = proposal_review_view.ResubmitProposalHandler(None)
with mock.patch.object(
proposal_logic, 'canProposalBeResubmitted', return_value=True):
response = handler.handle(data, None, None)
self.assertEqual(response.status_code, httplib.OK)
# check that the proposal is withdrawn
proposal = GSoCProposal.all().get()
self.assertEqual(proposal.status, proposal_model.STATUS_PENDING)
# check that number of proposals is updated
profile = self.profile.key.get()
self.assertEqual(
old_number_of_proposals, profile.student_data.number_of_proposals - 1)
示例10: postHandler
# 需要导入模块: from soc.modules.gsoc.models.proposal import GSoCProposal [as 别名]
# 或者: from soc.modules.gsoc.models.proposal.GSoCProposal import all [as 别名]
def postHandler(self, data, withdraw=True):
program = self.data.program
for properties in data:
if "full_project_key" not in properties:
logging.warning("Missing key in '%s'" % properties)
continue
project_key = properties["full_project_key"]
project = db.get(db.Key(project_key))
if not project:
logging.warning("Project '%s' doesn't exist" % project_key)
continue
if withdraw and project.status == "withdrawn":
logging.warning("Project '%s' already withdrawn" % project_key)
continue
if not withdraw and project.status == "accepted":
logging.warning("Project '%s' already accepted" % project_key)
continue
profile = project.parent()
profile_key = profile.key()
qp = GSoCProposal.all()
qp.ancestor(profile_key)
qp.filter("org", project.org)
# FIXME: ??? Mentors can change overtime so how does this work???
qp.filter("mentor IN", project.mentors)
if withdraw:
qp.filter("status", "accepted")
else:
qp.filter("status", "withdrawn")
proposal = qp.get()
def withdraw_or_accept_project_txn():
if withdraw:
new_status = "withdrawn"
new_number = 0
else:
new_status = "accepted"
new_number = 1
project.status = new_status
proposal.status = new_status
profile.number_of_projects = new_number
db.put([proposal, project, profile])
db.run_in_transaction(withdraw_or_accept_project_txn)
return True
示例11: testWishToMentorButton
# 需要导入模块: from soc.modules.gsoc.models.proposal import GSoCProposal [as 别名]
# 或者: from soc.modules.gsoc.models.proposal.GSoCProposal import all [as 别名]
def testWishToMentorButton(self):
student = GSoCProfileHelper(self.gsoc, self.dev_test)
student.createOtherUser('[email protected]')
student.createStudent()
self.data.createMentor(self.org)
other_mentor = self.createMentorWithSettings('[email protected]')
proposal = self.createProposal({'scope': student.profile,
'parent': student.profile})
suffix = "%s/%s/%d" % (
self.gsoc.key().name(),
student.user.key().name(),
proposal.key().id())
url = '/gsoc/proposal/wish_to_mentor/' + suffix
postdata = {'value': 'unchecked'}
response = self.post(url, postdata)
proposal = GSoCProposal.all().get()
self.assertTrue(self.data.profile.key() in proposal.possible_mentors)
postdata = {'value': 'checked'}
response = self.post(url, postdata)
proposal = GSoCProposal.all().get()
self.assertFalse(self.data.profile.key() in proposal.possible_mentors)
other_mentor.profile.mentor_for = []
other_mentor.profile.put()
proposal.possible_mentors.append(other_mentor.profile.key())
proposal.put()
url = '/gsoc/proposal/review/' + suffix
response = self.get(url)
proposal = GSoCProposal.all().get()
self.assertFalse(other_mentor.profile.key() in proposal.possible_mentors)
示例12: createStudent
# 需要导入模块: from soc.modules.gsoc.models.proposal import GSoCProposal [as 别名]
# 或者: from soc.modules.gsoc.models.proposal.GSoCProposal import all [as 别名]
def createStudent(self):
"""Creates two new students the first one has a duplicate the second one has
none.
"""
profile_helper = GSoCProfileHelper(self.gsoc, self.dev_test)
profile_helper.createOtherUser('[email protected]')
self.student1 = profile_helper.createStudentWithProposals(
self.org, self.mentor, 3)
proposals = GSoCProposal.all().ancestor(self.student1).fetch(2)
for p in proposals:
p.accept_as_project = True
p.put()
profile_helper = GSoCProfileHelper(self.gsoc, self.dev_test)
profile_helper.createOtherUser('[email protected]')
self.student2 = profile_helper.createStudentWithProposals(
self.org, self.mentor, 1)
proposal = GSoCProposal.all().ancestor(self.student2).get()
proposal.accept_as_project = True
proposal.put()
示例13: canStudentPropose
# 需要导入模块: from soc.modules.gsoc.models.proposal import GSoCProposal [as 别名]
# 或者: from soc.modules.gsoc.models.proposal.GSoCProposal import all [as 别名]
def canStudentPropose(self):
"""Checks if the student is eligible to submit a proposal.
"""
# check if the timeline allows submitting proposals
self.studentSignupActive()
# check how many proposals the student has already submitted
query = GSoCProposal.all()
query.filter('scope = ', self.data.profile).ancestor(self.data.user)
if query.count() >= self.data.program.apps_tasks_limit:
# too many proposals access denied
raise AccessViolation(DEF_MAX_PROPOSALS_REACHED)
示例14: testUpdateProposal
# 需要导入模块: from soc.modules.gsoc.models.proposal import GSoCProposal [as 别名]
# 或者: from soc.modules.gsoc.models.proposal.GSoCProposal import all [as 别名]
def testUpdateProposal(self):
"""Test update proposals.
"""
mentor = GSoCProfileHelper(self.gsoc, self.dev_test)
mentor.createOtherUser('[email protected]')
mentor.createMentor(self.org)
mentor.notificationSettings(proposal_updates=True)
self.data.createStudentWithProposal(self.org, mentor.profile)
self.data.notificationSettings()
self.timeline.studentSignup()
proposal = GSoCProposal.all().get()
url = '/gsoc/proposal/update/%s/%s' % (
self.gsoc.key().name(), proposal.key().id())
response = self.get(url)
self.assertProposalTemplatesUsed(response)
override = {
'program': self.gsoc, 'score': 0, 'nr_scores': 0, 'has_mentor': True,
'mentor': mentor.profile, 'org': self.org, 'status': 'pending',
'action': 'Update', 'is_publicly_visible': False, 'extra': None,
'accept_as_project': False, 'is_editable_post_deadline': False
}
response, properties = self.modelPost(url, GSoCProposal, override)
self.assertResponseRedirect(response)
properties.pop('action')
proposal = GSoCProposal.all().get()
self.assertPropertiesEqual(properties, proposal)
# after update last_modified_on should be updated which is not equal
# to created_on
self.assertNotEqual(proposal.created_on, proposal.last_modified_on)
self.assertEmailSent(to=mentor.profile.email, n=1)
示例15: testWithdrawProposalButton
# 需要导入模块: from soc.modules.gsoc.models.proposal import GSoCProposal [as 别名]
# 或者: from soc.modules.gsoc.models.proposal.GSoCProposal import all [as 别名]
def testWithdrawProposalButton(self):
self.data.createStudent()
proposal = self.createProposal({'scope': self.data.profile,
'parent': self.data.profile})
suffix = "%s/%s/%d" % (
self.gsoc.key().name(),
self.data.user.key().name(),
proposal.key().id())
url = '/gsoc/proposal/withdraw/' + suffix
postdata = {'value': 'unchecked'}
response = self.post(url, postdata)
self.assertResponseOK(response)
proposal = GSoCProposal.all().get()
self.assertEqual(proposal.status, 'withdrawn')
url = '/gsoc/proposal/withdraw/' + suffix
postdata = {'value': 'unchecked'}
response = self.post(url, postdata)
self.assertResponseBadRequest(response)
proposal = GSoCProposal.all().get()
self.assertEqual(proposal.status, 'withdrawn')
url = '/gsoc/proposal/withdraw/' + suffix
postdata = {'value': 'checked'}
response = self.post(url, postdata)
self.assertResponseOK(response)
proposal = GSoCProposal.all().get()
self.assertEqual(proposal.status, 'pending')