app/soc/views/models/student_proposal.py
changeset 1482 5229a40d4792
parent 1469 d69b00439d59
child 1484 6b00a2a43eaf
equal deleted inserted replaced
1481:0ccf92d073e8 1482:5229a40d4792
    63     rights['show'] = [
    63     rights['show'] = [
    64         ('checkRoleAndStatusForStudentProposal',
    64         ('checkRoleAndStatusForStudentProposal',
    65             [['proposer', 'org_admin', 'mentor', 'host'], 
    65             [['proposer', 'org_admin', 'mentor', 'host'], 
    66             ['active', 'inactive'], ['new', 'pending', 'accepted', 'rejected']])]
    66             ['active', 'inactive'], ['new', 'pending', 'accepted', 'rejected']])]
    67     rights['list'] = ['checkIsDeveloper']
    67     rights['list'] = ['checkIsDeveloper']
       
    68     rights['list_orgs'] = [
       
    69         ('checkIsStudent', ['scope_path', ['active']]),
       
    70         ('checkCanStudentPropose', 'scope_path')]
    68     rights['list_self'] = [
    71     rights['list_self'] = [
    69         ('checkIsStudent', ['scope_path', ['active', 'inactive']])]
    72         ('checkIsStudent', ['scope_path', ['active', 'inactive']])]
    70     rights['apply'] = [
    73     rights['apply'] = [
    71         ('checkIsStudent', ['scope_path', ['active']]),
    74         ('checkIsStudent', ['scope_path', ['active']]),
    72         ('checkCanStudentPropose', 'scope_path')]
    75         ('checkCanStudentPropose', 'scope_path')]
    87         (r'^%(url_name)s/(?P<access_type>apply)/%(scope)s$',
    90         (r'^%(url_name)s/(?P<access_type>apply)/%(scope)s$',
    88         'soc.views.models.%(module_name)s.create',
    91         'soc.views.models.%(module_name)s.create',
    89         'Create a new %(name)s'),
    92         'Create a new %(name)s'),
    90         (r'^%(url_name)s/(?P<access_type>list_self)/%(scope)s$',
    93         (r'^%(url_name)s/(?P<access_type>list_self)/%(scope)s$',
    91         'soc.views.models.%(module_name)s.list_self',
    94         'soc.views.models.%(module_name)s.list_self',
       
    95         'List my %(name_plural)s'),
       
    96         (r'^%(url_name)s/(?P<access_type>list_orgs)/%(scope)s$',
       
    97         'soc.views.models.%(module_name)s.list_org',
    92         'List my %(name_plural)s')
    98         'List my %(name_plural)s')
    93     ]
    99     ]
    94 
   100 
    95     new_params['extra_django_patterns'] = patterns
   101     new_params['extra_django_patterns'] = patterns
    96 
   102 
   164       context['mentor_name'] = entity.mentor.name()
   170       context['mentor_name'] = entity.mentor.name()
   165     else:
   171     else:
   166       context['mentor_name'] = "No mentor assigned"
   172       context['mentor_name'] = "No mentor assigned"
   167 
   173 
   168   @decorators.merge_params
   174   @decorators.merge_params
       
   175   @decorators.check_access
       
   176   def listOrg(self, request, access_type,
       
   177              page_name=None, params=None, **kwargs):
       
   178     """Lists all organization which the given student can propose to.
       
   179 
       
   180     For params see base.View.public().
       
   181     """
       
   182 
       
   183     from soc.views.models import organization as org_view
       
   184 
       
   185     student_entity = student_logic.logic.getFromKeyName(kwargs['scope_path'])
       
   186 
       
   187     filter = {'scope' : student_entity.scope,
       
   188               'status': 'active'}
       
   189 
       
   190     list_params = org_view.view.getParams().copy()
       
   191     list_params['list_description'] = ('List of %(name_plural)s you can send '
       
   192         'your proposal to.') % list_params
       
   193     list_params['list_action'] = (redirects.getStudentProposalRedirect,
       
   194         {'student_key': student_entity.key().name(),
       
   195             'url_name': params['url_name']})
       
   196 
       
   197     return self.list(request, access_type=access_type, page_name=page_name,
       
   198                      params=list_params, filter=filter, **kwargs)
       
   199 
       
   200   @decorators.merge_params
       
   201   @decorators.check_access
   169   def listSelf(self, request, access_type,
   202   def listSelf(self, request, access_type,
   170              page_name=None, params=None, **kwargs):
   203              page_name=None, params=None, **kwargs):
   171     """Lists all proposals from the current logged-in user.
   204     """Lists all proposals from the current logged-in user for the given student.
   172 
   205 
   173     For params see base.View.public().
   206     For params see base.View.public().
   174     """
   207     """
   175 
   208 
   176     user_entity = user_logic.logic.getForCurrentAccount()
   209     student_entity = student_logic.logic.getFromKeyName(kwargs['scope_path'])
   177     filter = {'user': user_entity}
       
   178     student_entity = student_logic.logic.getForFields(filter, unique=True)
       
   179 
   210 
   180     filter = {'scope' : student_entity,
   211     filter = {'scope' : student_entity,
   181               'status': ['new', 'pending', 'accepted', 'rejected']}
   212               'status': ['new', 'pending', 'accepted', 'rejected']}
   182 
   213 
   183     list_params = params.copy()
   214     list_params = params.copy()
   191 admin = view.admin
   222 admin = view.admin
   192 create = view.create
   223 create = view.create
   193 delete = view.delete
   224 delete = view.delete
   194 edit = view.edit
   225 edit = view.edit
   195 list = view.list
   226 list = view.list
       
   227 list_org = view.listOrg
   196 list_self = view.listSelf
   228 list_self = view.listSelf
   197 public = view.public
   229 public = view.public
   198 export = view.export
   230 export = view.export
   199 pick = view.pick
   231 pick = view.pick