38 from soc.views import helper |
39 from soc.views import helper |
39 from soc.views import out_of_band |
40 from soc.views import out_of_band |
40 from soc.views.helper import access |
41 from soc.views.helper import access |
41 from soc.views.helper import decorators |
42 from soc.views.helper import decorators |
42 from soc.views.helper import dynaform |
43 from soc.views.helper import dynaform |
|
44 from soc.views.helper import lists |
43 from soc.views.helper import params as params_helper |
45 from soc.views.helper import params as params_helper |
44 from soc.views.helper import redirects |
46 from soc.views.helper import redirects |
45 from soc.views.helper import responses |
47 from soc.views.helper import responses |
46 from soc.views.helper import widgets |
48 from soc.views.helper import widgets |
47 from soc.views.models import base |
49 from soc.views.models import base |
64 |
66 |
65 rights = access.Checker(params) |
67 rights = access.Checker(params) |
66 rights['create'] = ['checkIsDeveloper'] |
68 rights['create'] = ['checkIsDeveloper'] |
67 rights['edit'] = [('checkCanStudentPropose', ['scope_path', False]), |
69 rights['edit'] = [('checkCanStudentPropose', ['scope_path', False]), |
68 ('checkRoleAndStatusForStudentProposal', |
70 ('checkRoleAndStatusForStudentProposal', |
69 [['proposer'], ['active'], ['new', 'pending']])] |
71 [['proposer'], ['active'], ['new', 'pending', 'invalid']])] |
70 rights['delete'] = ['checkIsDeveloper'] |
72 rights['delete'] = ['checkIsDeveloper'] |
71 rights['show'] = [ |
73 rights['show'] = [ |
72 ('checkRoleAndStatusForStudentProposal', |
74 ('checkRoleAndStatusForStudentProposal', |
73 [['proposer', 'org_admin', 'mentor', 'host'], |
75 [['proposer', 'org_admin', 'mentor', 'host'], |
74 ['active', 'inactive'], |
76 ['active', 'inactive'], |
75 ['new', 'pending', 'accepted', 'rejected']])] |
77 ['new', 'pending', 'accepted', 'rejected', 'invalid']])] |
76 rights['list'] = ['checkIsDeveloper'] |
78 rights['list'] = ['checkIsDeveloper'] |
77 rights['list_orgs'] = [ |
79 rights['list_orgs'] = [ |
78 ('checkIsStudent', ['scope_path', ['active']]), |
80 ('checkIsStudent', ['scope_path', ['active']]), |
79 ('checkCanStudentPropose', ['scope_path', False])] |
81 ('checkCanStudentPropose', ['scope_path', False])] |
80 rights['list_self'] = [ |
82 rights['list_self'] = [ |
551 params=list_params, filter=filter, **kwargs) |
553 params=list_params, filter=filter, **kwargs) |
552 |
554 |
553 @decorators.merge_params |
555 @decorators.merge_params |
554 @decorators.check_access |
556 @decorators.check_access |
555 def listSelf(self, request, access_type, |
557 def listSelf(self, request, access_type, |
556 page_name=None, params=None, **kwargs): |
558 page_name=None, params=None, **kwargs): |
557 """Lists all proposals from the current logged-in user |
559 """Lists all proposals from the current logged-in user |
558 for the given student. |
560 for the given student. |
559 |
561 |
560 For params see base.View.public(). |
562 For params see base.View.public(). |
561 """ |
563 """ |
562 |
564 |
|
565 context = {} |
563 student_entity = student_logic.logic.getFromKeyName(kwargs['scope_path']) |
566 student_entity = student_logic.logic.getFromKeyName(kwargs['scope_path']) |
564 |
567 |
565 filter = {'scope' : student_entity, |
568 filter = {'scope' : student_entity, |
566 'status': ['new', 'pending', 'accepted', 'rejected']} |
569 'status': ['new', 'pending', 'accepted', 'rejected']} |
567 |
570 |
568 list_params = params.copy() |
571 list_params = params.copy() |
569 list_params['list_description'] = 'List of my %(name_plural)s' % list_params |
572 list_params['list_description'] = 'List of my %(name_plural)s.' % list_params |
570 list_params['list_action'] = (redirects.getPublicRedirect, list_params) |
573 list_params['list_action'] = (redirects.getPublicRedirect, list_params) |
571 |
574 |
572 return self.list(request, access_type=access_type, page_name=page_name, |
575 valid_list = lists.getListContent( |
573 params=list_params, filter=filter, **kwargs) |
576 request, list_params, filter, idx=0) |
|
577 |
|
578 ip_params = list_params.copy() # ineligible proposals |
|
579 |
|
580 description = ugettext('List of my ineligible/withdrawn %s.') % ( |
|
581 ip_params['name_plural']) |
|
582 |
|
583 ip_params['list_description'] = description |
|
584 ip_params['list_action'] = (redirects.getPublicRedirect, ip_params) |
|
585 |
|
586 filter = {'scope' : student_entity, |
|
587 'status': 'invalid'} |
|
588 |
|
589 ip_list = lists.getListContent( |
|
590 request, ip_params, filter, idx=1, need_content=True) |
|
591 |
|
592 contents = [] |
|
593 # fill contents with all the needed lists |
|
594 contents.append(valid_list) |
|
595 |
|
596 if ip_list != None: |
|
597 contents.append(ip_list) |
|
598 |
|
599 # call the _list method from base to display the list |
|
600 return self._list(request, list_params, contents, page_name, context) |
574 |
601 |
575 @decorators.merge_params |
602 @decorators.merge_params |
576 @decorators.check_access |
603 @decorators.check_access |
577 def review(self, request, access_type, |
604 def review(self, request, access_type, |
578 page_name=None, params=None, **kwargs): |
605 page_name=None, params=None, **kwargs): |