def approve_application(app_id, request_user=None, reason=""): get_chain_of_application_for_update(app_id) application = get_application(app_id) checkAllowed(application, request_user, admin_only=True) if not application.can_approve(): m = _(astakos_messages.APPLICATION_CANNOT_APPROVE % (application.id, application.state_display())) raise PermissionDenied(m) project = check_conflicting_projects(application) # Pre-lock members and owner together in order to impose an ordering # on locking users members = members_to_sync(project) if project is not None else [] uids_to_sync = [member.id for member in members] owner = application.owner uids_to_sync.append(owner.id) get_users_for_update(uids_to_sync) qh_release_pending_app(owner, locked=True) application.approve(reason) qh_sync_locked_users(members) logger.info("%s has been approved." % (application.log_display)) application_approve_notify(application)
def approve_application(app_id, request_user=None, reason=""): get_project_lock() project = get_project_of_application_for_update(app_id) application = get_application(app_id) app_check_allowed(application, request_user, level=ADMIN_LEVEL) if not application.can_approve(): m = _(astakos_messages.APPLICATION_CANNOT_APPROVE % (application.id, application.state_display())) raise ProjectConflict(m) check_conflicting_projects(application) # Pre-lock members and owner together in order to impose an ordering # on locking users members = members_to_sync(project) uids_to_sync = [member.id for member in members] owner = application.owner uids_to_sync.append(owner.id) get_users_for_update(uids_to_sync) qh_release_pending_app(owner, locked=True) application.approve(actor=request_user, reason=reason) project.application = application project.name = application.name project.save() if project.is_deactivated(): project.resume(actor=request_user, reason="APPROVE") qh_sync_locked_users(members) logger.info("%s has been approved." % (application.log_display)) application_approve_notify(application)