413 } |
413 } |
414 error.message_fmt = error.message_fmt + msg |
414 error.message_fmt = error.message_fmt + msg |
415 return helper.responses.errorResponse( |
415 return helper.responses.errorResponse( |
416 error, request, context=context) |
416 error, request, context=context) |
417 |
417 |
418 user_account = user_logic.logic.getForCurrentAccount() |
|
419 |
|
420 filter = { |
|
421 'user': user_account, |
|
422 } |
|
423 |
|
424 # extend edit_form to include difficulty levels |
418 # extend edit_form to include difficulty levels |
425 params['edit_form'] = self._getTagsForProgram( |
419 params['edit_form'] = self._getTagsForProgram( |
426 'edit_form', params, **kwargs) |
420 'edit_form', params, **kwargs) |
427 |
421 |
428 org_admin_entities = ghop_org_admin_logic.logic.getForFields(filter) |
422 if entity.status == 'Unapproved': |
429 |
423 dynafields = [ |
430 if entity and entity.status == 'Unapproved': |
424 {'name': 'approved', |
431 approval_req = True |
425 'required': False, |
432 for org_admin_entity in org_admin_entities: |
426 'initial': False, |
433 if org_admin_entity.key().name() == entity.created_by.key().name(): |
427 'base': forms.fields.BooleanField, |
434 approval_req = False |
428 'label': 'Approve the task', |
435 break |
429 'help_text': 'By ticking this box, the task will be' |
436 |
430 'will be approved for publishing.', |
437 if approval_req: |
431 } |
438 dynafields = [ |
432 ] |
439 {'name': 'approved', |
433 |
440 'required': False, |
434 dynaproperties = params_helper.getDynaFields(dynafields) |
441 'initial': False, |
435 |
442 'base': forms.fields.BooleanField, |
436 edit_form = dynaform.extendDynaForm( |
443 'label': 'Approve the task', |
437 dynaform=params['edit_form'], |
444 'help_text': 'By ticking this box, the task will be' |
438 dynaproperties=dynaproperties) |
445 'will be approved for publishing.', |
439 |
446 } |
440 params['edit_form'] = edit_form |
447 ] |
|
448 |
|
449 dynaproperties = params_helper.getDynaFields(dynafields) |
|
450 |
|
451 edit_form = dynaform.extendDynaForm( |
|
452 dynaform=params['edit_form'], |
|
453 dynaproperties=dynaproperties) |
|
454 |
|
455 params['edit_form'] = edit_form |
|
456 |
441 |
457 if request.method == 'POST': |
442 if request.method == 'POST': |
458 return self.editPost(request, entity, context, params=params) |
443 return self.editPost(request, entity, context, params=params) |
459 else: |
444 else: |
460 return self.editGet(request, entity, context, params=params) |
445 return self.editGet(request, entity, context, params=params) |
640 |
625 |
641 logic = params['logic'] |
626 logic = params['logic'] |
642 if entity: |
627 if entity: |
643 entity = logic.updateEntityProperties(entity, fields) |
628 entity = logic.updateEntityProperties(entity, fields) |
644 else: |
629 else: |
|
630 # TODO: Redirect to standard edit page which already has the ability to |
|
631 # hide certain fields. |
645 entity = logic.updateOrCreateFromFields(fields) |
632 entity = logic.updateOrCreateFromFields(fields) |
646 |
633 |
647 page_params = params['edit_params'] |
634 page_params = params['edit_params'] |
648 |
635 |
649 redirect = ghop_redirects.getSuggestTaskRedirect( |
636 redirect = ghop_redirects.getSuggestTaskRedirect( |