def notify_users(cursor, document_id):
return<EOL>registry = get_current_registry()<EOL>accounts = registry.getUtility(IOpenstaxAccounts)<EOL>cursor.execute("""<STR_LIT>"""CT user_id, array_agg(role_type)::text[]<EOL>role_acceptances AS ra<EOL>E<EOL>.uuid = (SELECT uuid FROM pending_documents WHERE id = %s)<EOL>D ra.notified IS NULL AND (NOT ra.accepted or ra.accepted IS UNKNOWN)<EOL>P BY user_id<EOL>(document_id,))<EOL>roles = {u: r for u, r in cursor.fetchall()}<EOL>needs_notified = set(licensors + list(roles.keys()))<EOL>for user_id in needs_notified:<EOL><INDENT>data = {<EOL>'<STR_LIT>': user_id,<EOL>'<STR_LIT>': None,  <EOL>'<STR_LIT>': user_id in licensors,<EOL>'<STR_LIT>': roles.get(user_id, []),<EOL>}<EOL>message = NOTIFICATION_TEMPLATE.render(**data)<EOL>accounts.send_message(user_id, NOFIFICATION_SUBJECT, message)<EOL><DEDENT>cursor.execute("""<STR_LIT>""", (document_id, licensors,))<EOL>cursor.execute("""<STR_LIT>""", (document_id, list(roles.keys()),))<EOL>
Notify all users about their role and/or license acceptance
    for a piece of content associated with the given ``document_id``.