app/soc/views/models/student_proposal.py
changeset 1469 d69b00439d59
parent 1467 c5f99265a680
child 1482 5229a40d4792
equal deleted inserted replaced
1468:fa794d29cbae 1469:d69b00439d59
    29 
    29 
    30 from soc.logic import cleaning
    30 from soc.logic import cleaning
    31 from soc.logic import dicts
    31 from soc.logic import dicts
    32 from soc.logic.models import organization as org_logic
    32 from soc.logic.models import organization as org_logic
    33 from soc.logic.models import student as student_logic
    33 from soc.logic.models import student as student_logic
       
    34 from soc.logic.models import user as user_logic
    34 from soc.views.helper import access
    35 from soc.views.helper import access
    35 from soc.views.helper import decorators
    36 from soc.views.helper import decorators
    36 from soc.views.helper import redirects
    37 from soc.views.helper import redirects
    37 from soc.views.helper import widgets
    38 from soc.views.helper import widgets
    38 from soc.views.models import base
    39 from soc.views.models import base
    62     rights['show'] = [
    63     rights['show'] = [
    63         ('checkRoleAndStatusForStudentProposal',
    64         ('checkRoleAndStatusForStudentProposal',
    64             [['proposer', 'org_admin', 'mentor', 'host'], 
    65             [['proposer', 'org_admin', 'mentor', 'host'], 
    65             ['active', 'inactive'], ['new', 'pending', 'accepted', 'rejected']])]
    66             ['active', 'inactive'], ['new', 'pending', 'accepted', 'rejected']])]
    66     rights['list'] = ['checkIsDeveloper']
    67     rights['list'] = ['checkIsDeveloper']
       
    68     rights['list_self'] = [
       
    69         ('checkIsStudent', ['scope_path', ['active', 'inactive']])]
    67     rights['apply'] = [
    70     rights['apply'] = [
    68         ('checkIsStudent', ['scope_path', ['active']]),
    71         ('checkIsStudent', ['scope_path', ['active']]),
    69         ('checkCanStudentPropose', 'scope_path')]
    72         ('checkCanStudentPropose', 'scope_path')]
    70 
    73 
    71     new_params = {}
    74     new_params = {}
    82 
    85 
    83     patterns = [
    86     patterns = [
    84         (r'^%(url_name)s/(?P<access_type>apply)/%(scope)s$',
    87         (r'^%(url_name)s/(?P<access_type>apply)/%(scope)s$',
    85         'soc.views.models.%(module_name)s.create',
    88         'soc.views.models.%(module_name)s.create',
    86         'Create a new %(name)s'),
    89         'Create a new %(name)s'),
       
    90         (r'^%(url_name)s/(?P<access_type>list_self)/%(scope)s$',
       
    91         'soc.views.models.%(module_name)s.list_self',
       
    92         'List my %(name_plural)s')
    87     ]
    93     ]
    88 
    94 
    89     new_params['extra_django_patterns'] = patterns
    95     new_params['extra_django_patterns'] = patterns
    90 
    96 
    91     new_params['extra_dynaexclude'] = ['org', 'program', 'score',
    97     new_params['extra_dynaexclude'] = ['org', 'program', 'score',
   157     if entity.mentor:
   163     if entity.mentor:
   158       context['mentor_name'] = entity.mentor.name()
   164       context['mentor_name'] = entity.mentor.name()
   159     else:
   165     else:
   160       context['mentor_name'] = "No mentor assigned"
   166       context['mentor_name'] = "No mentor assigned"
   161 
   167 
       
   168   @decorators.merge_params
       
   169   def listSelf(self, request, access_type,
       
   170              page_name=None, params=None, **kwargs):
       
   171     """Lists all proposals from the current logged-in user.
       
   172 
       
   173     For params see base.View.public().
       
   174     """
       
   175 
       
   176     user_entity = user_logic.logic.getForCurrentAccount()
       
   177     filter = {'user': user_entity}
       
   178     student_entity = student_logic.logic.getForFields(filter, unique=True)
       
   179 
       
   180     filter = {'scope' : student_entity,
       
   181               'status': ['new', 'pending', 'accepted', 'rejected']}
       
   182 
       
   183     list_params = params.copy()
       
   184     list_params['list_description'] = 'List of my %(name_plural)s' % list_params
       
   185 
       
   186     return self.list(request, access_type=access_type, page_name=page_name,
       
   187                      params=list_params, filter=filter, **kwargs)
       
   188 
   162 view = View()
   189 view = View()
   163 
   190 
   164 admin = view.admin
   191 admin = view.admin
   165 create = view.create
   192 create = view.create
   166 delete = view.delete
   193 delete = view.delete
   167 edit = view.edit
   194 edit = view.edit
   168 list = view.list
   195 list = view.list
       
   196 list_self = view.listSelf
   169 public = view.public
   197 public = view.public
   170 export = view.export
   198 export = view.export
   171 pick = view.pick
   199 pick = view.pick