Revision 19eb3ee6 snf-astakos-app/astakos/im/functions.py

b/snf-astakos-app/astakos/im/functions.py
71 71
from astakos.im.project_notif import (
72 72
    membership_change_notify,
73 73
    application_submit_notify, application_approve_notify,
74
    application_deny_notify,
74 75
    project_termination_notify, project_suspension_notify)
75 76
from astakos.im.endpoints.qh import qh_register_user
76 77

  
......
412 413
        raise IOError(
413 414
            _(astakos_messages.UNKNOWN_PROJECT_ID) % project_id)
414 415

  
416
def get_application_for_update(application_id):
417
    try:
418
        objects = ProjectApplication.objects.select_for_update()
419
        return objects.get(id=application_id)
420
    except ProjectApplication.DoesNotExist:
421
        m = _(astakos_messages.UNKNOWN_PROJECT_APPLICATION_ID) % application_id
422
        raise IOError(m)
423

  
415 424
def get_user_by_id(user_id):
416 425
    try:
417 426
        return AstakosUser.objects.get(id=user_id)
......
653 662
    app.resource_policies = resource_policies
654 663
    return app.id
655 664

  
665
def deny_application(application_id):
666
    application = get_application_for_update(application_id)
667
    if application.state != ProjectApplication.PENDING:
668
        raise PermissionDenied()
669

  
670
    application.deny()
671
    application_deny_notify(application)
672

  
656 673
def approve_application(app):
657 674

  
658 675
    app_id = app if isinstance(app, int) else app.id

Also available in: Unified diff