本文整理汇总了Python中soc.views.helper.lists.getListIndex函数的典型用法代码示例。如果您正苦于以下问题:Python getListIndex函数的具体用法?Python getListIndex怎么用?Python getListIndex使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了getListIndex函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: getManageStatisticsData
def getManageStatisticsData(self, request, params_collection, program):
"""Returns the list data for manageStats.
Args:
request: HTTPRequest object
params_collection: List of list Params indexed with the idx of the list
program: program entity for which the lists are generated
"""
idx = lists.getListIndex(request)
args = order = []
visibility = 'public'
if idx == self.DEF_EACH_GSOC_LIST_IDX:
fields = {
'access_for_other_programs': ['visible', 'collectable']
}
elif idx == self.DEF_ONE_GSOC_LIST_IDX:
fields = {
'scope': program,
'access_for_other_programs' : 'invisible'
}
else:
return lists.getErrorResponse(request, "idx not valid")
params = params_collection[idx]
contents = helper.lists.getListData(request, params, fields)
return lists.getResponse(request, contents)
开发者ID:SRabbelier,项目名称:Melange,代码行数:31,代码来源:statistic.py
示例2: getListData
def getListData(self):
"""Returns the list data as requested by the current request.
If the lists as requested is not supported by this component None is
returned.
"""
if lists.getListIndex(self.request) != 0:
return None
q = OrgAppRecord.all()
q.filter("survey", self.survey)
q.filter("main_admin", self.data.user)
records = q.fetch(1000)
q = OrgAppRecord.all()
q.filter("survey", self.survey)
q.filter("backup_admin", self.data.user)
records.extend(q.fetch(1000))
response = lists.ListContentResponse(self.request, self._list_config)
for record in records:
response.addRow(record)
response.next = "done"
return response
开发者ID:adviti,项目名称:melange,代码行数:28,代码来源:dashboard.py
示例3: getListData
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)
开发者ID:adviti,项目名称:melange,代码行数:33,代码来源:admin.py
示例4: getRequestsListData
def getRequestsListData(self, request, uh_params, ar_params):
"""Returns the list data for getRequestsList.
"""
idx = lists.getListIndex(request)
# get the current user
user_entity = user_logic.getCurrentUser()
# only select the Invites for this user that haven't been handled yet
# pylint: disable=E1103
filter = {'user': user_entity}
if idx == 0:
filter['status'] = 'group_accepted'
params = uh_params
elif idx == 1:
filter['status'] = 'new'
params = ar_params
else:
return lists.getErrorResponse(request, "idx not valid")
contents = helper.lists.getListData(request, params, filter,
visibility='public')
return lists.getResponse(request, contents)
开发者ID:SRabbelier,项目名称:Melange,代码行数:26,代码来源:user_self.py
示例5: post
def post(self):
"""POST handler for the list actions.
Returns:
True if the data is successfully modified; False otherwise.
"""
idx = lists.getListIndex(self.data.request)
if idx != 0:
return False
data = self.data.POST.get('data')
if not data:
raise exception.BadRequest(message="Missing data")
parsed = json.loads(data)
for key_id, properties in parsed.iteritems():
note = properties.get('note')
slot_allocation = properties.get('slot_allocation')
is_veteran = properties.get('is_veteran')
if ('note' not in properties and 'slot_allocation' not in properties and
'is_veteran' not in properties):
logging.warning(
'Neither note nor slots nor is_veteran present in "%s"', properties)
continue
if 'slot_allocation' in properties:
if not slot_allocation.isdigit():
logging.warning('Non-int value for slots: "%s', slot_allocation)
properties.pop('slot_allocation')
else:
slot_allocation = int(slot_allocation)
if is_veteran:
if not is_veteran in ['New', 'Veteran']:
logging.warning('Invalid value for new_org: "%s"', is_veteran)
properties.pop('is_veteran')
else:
is_veteran = True if is_veteran == 'Veteran' else False
def update_org_txn():
org = soc_org_model.SOCOrganization.get_by_id(key_id)
if not org:
logging.warning('Invalid org_key "%s"', key_id)
elif 'note' in properties:
pass
# TODO(daniel): add note to organization model
#org.note = note
elif 'slot_allocation' in properties:
org.slot_allocation = slot_allocation
if 'is_veteran' in properties:
org.is_veteran = is_veteran
org.put()
db.run_in_transaction(update_org_txn)
return True
开发者ID:rhyolight,项目名称:nupic.son,代码行数:60,代码来源:slot_allocation.py
示例6: getListData
def getListData(self):
"""Returns the list data as requested by the current request.
If the lists as requested is not supported by this component None is
returned.
"""
idx = lists.getListIndex(self.data.request)
if idx == 0:
list_query = proposal_logic.getProposalsQuery(program=self.data.program)
starter = lists.keyStarter
# TODO(daniel): support prefetching of NDB organizations
#prefetcher = lists.ModelPrefetcher(
# proposal_model.GSoCProposal, ['org'], parent=True)
# Since ModelPrefetcher doesn't work with NDB, pass an empty list
# for the field parameter to prevent __init__() exception.
prefetcher = lists.ModelPrefetcher(
proposal_model.GSoCProposal, [], parent=True)
response_builder = lists.RawQueryContentResponseBuilder(
self.data.request, self._list_config, list_query,
starter, prefetcher=prefetcher)
return response_builder.build()
else:
return None
开发者ID:rhyolight,项目名称:nupic.son,代码行数:26,代码来源:accept_withdraw_projects.py
示例7: getListData
def getListData(self):
idx = lists.getListIndex(self.request)
if idx != self.idx:
return None
q = GCIScore.all()
q.filter('program', self.data.program)
starter = lists.keyStarter
def prefetcher(entities):
keys = []
for entity in entities:
key = entity.parent_key()
if key:
keys.append(key)
entities = db.get(keys)
sp = dict((i.key(), i) for i in entities if i)
return ([sp], {})
response_builder = lists.RawQueryContentResponseBuilder(
self.request, self._list_config, q, starter, prefetcher=prefetcher)
return response_builder.build()
开发者ID:adviti,项目名称:melange,代码行数:29,代码来源:students_info.py
示例8: getListData
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)
开发者ID:rhyolight,项目名称:nupic.son,代码行数:35,代码来源:admin.py
示例9: getListParticipantsData
def getListParticipantsData(self, request, params, program_entity):
"""Returns the list data.
"""
from django.utils import simplejson
from soc.views.models.role import ROLE_VIEWS
idx = lists.getListIndex(request)
participants_logic = params['participants_logic']
if idx == -1 or idx > len(participants_logic):
return lists.getErrorResponse(request, "idx not valid")
# get role params that belong to the given index
(role_logic, query_field) = participants_logic[idx]
role_view = ROLE_VIEWS[role_logic.role_name]
role_params = role_view.getParams().copy()
# construct the query for the specific list
fields = {query_field: program_entity}
# return getListData
contents = lists.getListData(request, role_params, fields,
visibility='admin')
return lists.getResponse(request, contents)
开发者ID:SRabbelier,项目名称:Melange,代码行数:28,代码来源:program.py
示例10: getListMentorTasksData
def getListMentorTasksData(self, request, params, filter):
"""Returns the list data for Organization Tasks list.
Args:
request: HTTPRequest object
params: params of the task entity for the list
filter: properties on which the tasks must be listed
"""
idx = lists.getListIndex(request)
# default list settings
visibility = 'public'
if idx == 0:
all_d = gci_task_model.TaskDifficultyTag.all().fetch(100)
all_t = gci_task_model.TaskTypeTag.all().fetch(100)
args = [all_d, all_t]
contents = lists.getListData(request, params, filter,
visibility=visibility, args=args)
else:
return lists.getErrorResponse(request, "idx not valid")
return lists.getResponse(request, contents)
开发者ID:SRabbelier,项目名称:Melange,代码行数:25,代码来源:mentor.py
示例11: post
def post(self):
"""Processes the form post data by checking what buttons were pressed."""
idx = lists.getListIndex(self.data.request)
if idx != self.IDX:
return None
data = self.data.POST.get('data')
if not data:
raise exception.BadRequest(message='Missing data')
parsed = json.loads(data)
button_id = self.data.POST.get('button_id')
if not button_id:
raise exception.BadRequest(message='Missing button_id')
if button_id == self.PUBLISH_BUTTON_ID:
return self.postPublish(parsed, True)
if button_id == self.UNPUBLISH_BUTTON_ID:
return self.postPublish(parsed, False)
raise exception.BadRequest(message="Unknown button_id")
开发者ID:rhyolight,项目名称:nupic.son,代码行数:25,代码来源:dashboard.py
示例12: _getManageData
def _getManageData(self, request, gps_params, ps_params, entity):
"""Returns the JSONResponse for the Manage page.
Args:
request: HTTPRequest object
gps_params: GradingProjectSurvey list params
ps_params: ProjectSurvey list params
entity: StudentProject entity
"""
idx = lists.getListIndex(request)
if idx == 0:
params = gps_params
elif idx == 1:
params = ps_params
else:
return lists.getErrorResponse(request, "idx not valid")
fields = {'project': entity}
record_logic = params['logic'].getRecordLogic()
record_entities = record_logic.getForFields(fields)
record_dict = dict((i.survey.key(), i) for i in record_entities if i.survey)
record_getter = lambda entity: record_dict.get(entity.key())
args = [record_getter]
fields = {'scope': entity.program,
'prefix': 'gsoc_program'}
contents = lists.getListData(request, params, fields, args=args)
return lists.getResponse(request, contents)
开发者ID:SRabbelier,项目名称:Melange,代码行数:31,代码来源:student_project.py
示例13: getListData
def getListData(self):
"""Returns the list data as requested by the current request.
If the lists as requested is not supported by this component None is
returned.
"""
if lists.getListIndex(self.data.request) != 1:
return None
q = GCITask.all()
q.filter('program', self.data.program)
q.filter(
'org IN',
map(lambda org_key: org_key.to_old_key(),
self.data.ndb_profile.mentor_for))
starter = lists.keyStarter
# TODO(daniel): enable prefetching
#prefetcher = lists.ListModelPrefetcher(
# GCITask, ['org', 'student', 'created_by', 'modified_by'], ['mentors'])
response_builder = lists.RawQueryContentResponseBuilder(
self.data.request, self._list_config, q, starter,
prefetcher=None)
return response_builder.build()
开发者ID:rhyolight,项目名称:nupic.son,代码行数:26,代码来源:dashboard.py
示例14: getAcceptedOrgsData
def getAcceptedOrgsData(self, request, aa_params, ap_params, org_app_logic, program_entity):
"""Get acceptedOrgs data.
"""
idx = lists.getListIndex(request)
if idx == 0:
params = ap_params
fields = {
'scope': program_entity,
'status': ['new', 'active', 'inactive']
}
elif idx == 1:
params = aa_params
org_app = org_app_logic.getForProgram(program_entity)
fields = {
'survey': org_app,
'status': 'accepted',
}
else:
return lists.getErrorResponse(request, "idx not valid")
contents = lists.getListData(request, params, fields)
return lists.getResponse(request, contents)
开发者ID:SRabbelier,项目名称:Melange,代码行数:27,代码来源:program.py
示例15: getListMyTasksData
def getListMyTasksData(self, request, task_params, subscription_params,
program, user):
"""Returns the list data for the starred tasks of the current user.
Args:
request: HTTPRequest object
task_params: params of the task entity for the list
subscription_params: params for the task subscription entity for the list
program: the GCIProgram to show the tasks for
user: The user entity to show the tasks for
"""
idx = lists.getListIndex(request)
all_d = gci_task_model.TaskDifficultyTag.all().fetch(100)
all_t = gci_task_model.TaskTypeTag.all().fetch(100)
args = [all_d, all_t]
if idx == 0:
filter = {
'program': program,
'user': user,
'status': ['ClaimRequested', 'Claimed', 'ActionNeeded',
'Closed', 'AwaitingRegistration', 'NeedsWork',
'NeedsReview']
}
contents = lists.getListData(request, task_params, filter, args=args)
elif idx == 1:
filter = {'subscribers': user}
contents = lists.getListData(request, subscription_params, filter,
args=args)
else:
return lists.getErrorResponse(request, 'idx not valid')
return lists.getResponse(request, contents)
开发者ID:SRabbelier,项目名称:Melange,代码行数:35,代码来源:program.py
示例16: getListTasksData
def getListTasksData(self, request, params, tasks_filter):
"""Returns the list data for all tasks list for program host and
all public tasks for others.
Args:
request: HTTPRequest object
params: params of the task entity for the list
tasks_filter: dictionary that must be passed to obtain the tasks data
"""
idx = lists.getListIndex(request)
# default list settings
visibility = 'public'
if idx == 0:
all_d = gci_task_model.TaskDifficultyTag.all().fetch(100)
all_t = gci_task_model.TaskTypeTag.all().fetch(100)
args = [all_d, all_t]
contents = lists.getListData(request, params, tasks_filter,
visibility=visibility, args=args)
else:
return lists.getErrorResponse(request, "idx not valid")
return lists.getResponse(request, contents)
开发者ID:SRabbelier,项目名称:Melange,代码行数:26,代码来源:program.py
示例17: getRolesListData
def getRolesListData(self, request, lists_params):
"""Returns the list data for roles.
"""
user = user_logic.getCurrentUser()
# only select the roles for the current user
# pylint: disable=E1103
fields = {
'link_id': user.link_id,
'status': ['active', 'inactive']
}
idx = lists.getListIndex(request)
if not 0 <= idx < len(lists_params):
return lists.getErrorResponse(request, 'idx not valid')
list_params = lists_params[idx]
if list_params is None:
return lists.getErrorResponse(
request, 'idx not valid (list not in roles overview)')
contents = helper.lists.getListData(request, list_params, fields)
return lists.getResponse(request, contents)
开发者ID:SRabbelier,项目名称:Melange,代码行数:27,代码来源:user_self.py
示例18: jsonContext
def jsonContext(self):
"""Handler for JSON requests.
"""
idx = lists.getListIndex(self.request)
if idx == 0:
return GradingRecordsList(self.request, self.data).listContent().content()
else:
super(GradingRecordsOverview, self).jsonContext()
开发者ID:adviti,项目名称:melange,代码行数:8,代码来源:grading_record_details.py
示例19: jsonContext
def jsonContext(self, data, check, mutator):
"""Handler for JSON requests."""
idx = lists.getListIndex(data.request)
if idx == 0:
return GradingRecordsList(data).listContent().content()
else:
# TODO(nathaniel): Should this be a return statement?
super(GradingRecordsOverview, self).jsonContext(data, check, mutator)
开发者ID:rhyolight,项目名称:nupic.son,代码行数:8,代码来源:grading_record_details.py
示例20: jsonContext
def jsonContext(self, data, check, mutator):
"""See base.GSoCRequestHandler.jsonContext for specification."""
idx = lists.getListIndex(data.request)
if idx == 0:
list_data = OrgApplicationList(data, data.org_app).getListData()
return list_data.content()
else:
raise exception.BadRequest(message="Invalid ID has been specified.")
开发者ID:rhyolight,项目名称:nupic.son,代码行数:8,代码来源:org_app.py
注:本文中的soc.views.helper.lists.getListIndex函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论