code: def get_next_action(self, request, application, roles):
          
          # Check for serious errors in submission.
          # Should only happen in rare circumstances.
          errors = application.check_valid()
          if len(errors) > 0:
              for error in errors:
                  messages.error(request, error)
              return 'error'
  
          # approve application
          approved_by = request.user
          created_person, created_account = application.approve(approved_by)
  
          # send email
          application.extend()
          link, is_secret = base.get_email_link(application)
          emails.send_approved_email(
              application, created_person, created_account, link, is_secret)
  
          if created_person or created_account:
              return 'password_needed'
          else:
              return 'password_ok'
docs: Retrieve the next state.