# HG changeset patch # User Daniel Hans # Date 1257264430 -3600 # Node ID bd001e9ab9d42139dddc11b9f5247d2dd10a5782 # Parent 6d77028ab8952d9ef77a54fdc8dc9219a7b7b886 Lists of student tasks view does not use pagination. Also some minor stylish issues fixed. diff -r 6d77028ab895 -r bd001e9ab9d4 app/soc/modules/ghop/views/helper/redirects.py --- a/app/soc/modules/ghop/views/helper/redirects.py Tue Nov 03 02:16:51 2009 +0100 +++ b/app/soc/modules/ghop/views/helper/redirects.py Tue Nov 03 17:07:10 2009 +0100 @@ -54,7 +54,7 @@ def getListStudentTasksRedirect(entity, params): - """Returns the redirect for the List Projects page for the given entity. + """Returns the redirect for the List Student Tasks page for the given entity. """ result = '/%s/list_student_tasks/%s' % ( diff -r 6d77028ab895 -r bd001e9ab9d4 app/soc/modules/ghop/views/models/program.py --- a/app/soc/modules/ghop/views/models/program.py Tue Nov 03 02:16:51 2009 +0100 +++ b/app/soc/modules/ghop/views/models/program.py Tue Nov 03 17:07:10 2009 +0100 @@ -440,7 +440,7 @@ 'student_signup_start'): # add a link to show all projects items += [(ghop_redirects.getListStudentTasksRedirect( - student_entity, {'url_name':'ghop/student'}), + ghop_program_entity, {'url_name':'ghop/student'}), "List my Tasks", 'any_access')] items += [(redirects.getEditRedirect(student_entity, diff -r 6d77028ab895 -r bd001e9ab9d4 app/soc/modules/ghop/views/models/student.py --- a/app/soc/modules/ghop/views/models/student.py Tue Nov 03 02:16:51 2009 +0100 +++ b/app/soc/modules/ghop/views/models/student.py Tue Nov 03 17:07:10 2009 +0100 @@ -27,14 +27,14 @@ from django.utils.translation import ugettext from soc.logic import dicts +from soc.logic.models import user as user_logic + from soc.views.helper import decorators from soc.views.helper import dynaform from soc.views.helper import lists from soc.views.helper import redirects from soc.views.models import student -from soc.logic.models import user as user_logic - from soc.modules.ghop.logic.models import mentor as ghop_mentor_logic from soc.modules.ghop.logic.models import organization as ghop_org_logic from soc.modules.ghop.logic.models import org_admin as ghop_org_admin_logic @@ -43,6 +43,7 @@ from soc.modules.ghop.logic.models import task as ghop_task_logic from soc.modules.ghop.views.helper import access as ghop_access from soc.modules.ghop.views.models import program as ghop_program_view +from soc.modules.ghop.views.models import task as ghop_task_view import soc.modules.ghop.logic.models.student @@ -63,7 +64,7 @@ patterns = [] patterns += [ - (r'^%(url_name)s/(?Plist_student_tasks)/%(key_fields)s$', + (r'^%(url_name)s/(?Plist_student_tasks)/%(scope)s$', '%(module_package)s.%(module_name)s.list_student_tasks', 'List Student tasks')] @@ -77,7 +78,7 @@ ghop_mentor_logic.logic]), 'checkCanApply'] rights['manage'] = [('checkIsMyActiveRole', ghop_student_logic.logic)] - rights['list_student_tasks'] = [('checkIsMyActiveRole', + rights['list_student_tasks'] = [('checkHasActiveRoleForScope', ghop_student_logic.logic)] new_params = {} @@ -126,32 +127,41 @@ tasks_by_orgs = {} for task in tasks: - if task.scope.name in tasks_by_orgs: - tasks_by_orgs[task.scope.name].append(task) + key = task.scope.key().id_or_name() + if key in tasks_by_orgs: + tasks_by_orgs[key][1].append(task) else: - tasks_by_orgs[task.scope.name] = [task] + tasks_by_orgs[key] = (task.scope.name, [task]) contents = [] context = {} - sp_params = params.copy() - sp_params['list_template'] = 'soc/models/list.html' - sp_params['list_heading'] = 'modules/ghop/task/list/heading.html' - sp_params['list_row'] = 'modules/ghop/task/list/row.html' - sp_params['pagination'] = 'soc/list/no_pagination.html' - sp_params['list_action'] = (redirects.getPublicRedirect, sp_params) + st_params = ghop_task_view.view.getParams().copy() + st_params['list_template'] = 'soc/models/list.html' + st_params['list_heading'] = 'modules/ghop/task/list/heading.html' + st_params['list_row'] = 'modules/ghop/task/list/row.html' + st_params['list_action'] = (redirects.getPublicRedirect, st_params) + + st_org_params = st_params.copy() + for k, v in tasks_by_orgs.iteritems(): + st_org_params['list_description'] = self.DEF_STUDENT_TASKS_MSG_FMT % v[0] + + st_org_list = self._listStudentTasks(tasks_by_orgs[k][1], st_org_params) - sp_org_params = sp_params.copy() - for org in tasks_by_orgs.keys(): - sp_org_params['list_description'] = self.DEF_STUDENT_TASKS_MSG_FMT % org + contents.append(st_org_list) + + return self._list(request, st_params, contents, page_name, context) - sp_org_list = lists.getListContentForData(request, sp_org_params, - data=tasks_by_orgs[org], idx=1, need_content=True) + def _listStudentTasks(self, data, params): + """Returns a list with all entities specified in data. + """ - contents.append(sp_org_list) + result = dicts.rename(params, params['list_params']) + result['action'] = (redirects.getPublicRedirect, params) + result['data'] = data + result['pagination'] = 'soc/list/no_pagination.html' - return self._list(request, sp_params, contents, page_name, context) - + return result view = View()