equal
deleted
inserted
replaced
18 |
18 |
19 See soc.views.helper.access module. |
19 See soc.views.helper.access module. |
20 """ |
20 """ |
21 |
21 |
22 __authors__ = [ |
22 __authors__ = [ |
23 '"Madhusudan.C.S" <madhusudancs@gmail.com>' |
23 '"Madhusudan.C.S" <madhusudancs@gmail.com>', |
|
24 '"Lennard de Rijk" <ljvderijk@gmail.com>', |
24 ] |
25 ] |
25 |
26 |
26 |
27 |
27 from django.utils.translation import ugettext |
28 from django.utils.translation import ugettext |
28 |
29 |
32 from soc.views import out_of_band |
33 from soc.views import out_of_band |
33 from soc.views.helper import access |
34 from soc.views.helper import access |
34 |
35 |
35 from soc.modules.ghop.logic.models import mentor as ghop_mentor_logic |
36 from soc.modules.ghop.logic.models import mentor as ghop_mentor_logic |
36 from soc.modules.ghop.logic.models import org_admin as ghop_org_admin_logic |
37 from soc.modules.ghop.logic.models import org_admin as ghop_org_admin_logic |
|
38 from soc.modules.ghop.logic.models import program as ghop_program_logic |
37 from soc.modules.ghop.logic.models import task as ghop_task_logic |
39 from soc.modules.ghop.logic.models import task as ghop_task_logic |
38 |
40 |
39 |
41 |
40 DEF_CANT_EDIT_MSG = ugettext( |
42 DEF_CANT_EDIT_MSG = ugettext( |
41 'This task cannot be edited since it has been claimed at least ' |
43 'This task cannot be edited since it has been claimed at least ' |
42 'once before.') |
44 'once before.') |
|
45 |
|
46 DEF_CANT_REGISTER = ugettext( |
|
47 'You have not completed your first task to register as a student. ') |
43 |
48 |
44 DEF_MAX_TASKS_REACHED_MSG = ugettext( |
49 DEF_MAX_TASKS_REACHED_MSG = ugettext( |
45 'You have reached the maximum number of Tasks allowed ' |
50 'You have reached the maximum number of Tasks allowed ' |
46 'for your organization for this program.') |
51 'for your organization for this program.') |
47 |
52 |
240 |
245 |
241 if task_entity.status in ['Unapproved', 'Unpublished', 'Invalid']: |
246 if task_entity.status in ['Unapproved', 'Unpublished', 'Invalid']: |
242 # this proposal can not be task at the moment |
247 # this proposal can not be task at the moment |
243 raise out_of_band.AccessViolation( |
248 raise out_of_band.AccessViolation( |
244 message_fmt=DEF_NO_PUB_TASK_MSG) |
249 message_fmt=DEF_NO_PUB_TASK_MSG) |
|
250 |
|
251 def checkCanApply(self, django_args): |
|
252 """Checks if the user has the completed at least one task to register as |
|
253 a student. |
|
254 |
|
255 Args: |
|
256 django_args: a dictionary with django's arguments |
|
257 |
|
258 Raises: |
|
259 AccessViolationResponse: |
|
260 - If student has not completed even a single task |
|
261 """ |
|
262 |
|
263 self.checkIsUser(django_args) |
|
264 |
|
265 program_entity = ghop_program_logic.logic.getFromKeyNameOr404( |
|
266 django_args['scope_path']) |
|
267 |
|
268 filter = { |
|
269 'user': self.user, |
|
270 'program': program_entity, |
|
271 'status': 'AwaitingRegistration', |
|
272 } |
|
273 |
|
274 if ghop_task_logic.logic.getForFields(filter, unique=True): |
|
275 return |
|
276 |
|
277 # no completed tasks found, access denied |
|
278 raise out_of_band.AccessViolation( |
|
279 message_fmt=DEF_CANT_REGISTER) |