<commit_before>{{> HEADER}}

<section>
{{#if statusMessages}}
    <ul class="status">
        {{#each statusMessages}}<li>{{this}}</li>{{/each}}
    </ul>
{{/if}}

{{#if me.isFullAdmin}}
    {{#if serverLogs}}
    <h2>Server Logs</h2>
    <p><a href="{{HTTP_PREFIX}}/server-logs/">View Server Logs</a></p>
    {{/if}}
    <form action="" method="POST">
        <input type="hidden" name="action" value="create-organization">
        <h2>Create Organization</h2>
        <table class="noborder"><tbody>
            <tr><td>Organization Name: </td><td><input name="organization" type="text" required></td></tr>
            <tr><td>&nbsp;</td><td><input type="submit" value="Create Organization"></td></tr>
        </tbody></table>
    </form>
{{/if}}

    <form action="" method="POST">
        <input type="hidden" name="action" value="create-user">
        <h2>Create User{{#if organization}} in {{organization}}{{/if}}</h2>
        <table class="noborder"><tbody>
            <tr><td>Username: </td><td><input type="text" name="username" required pattern="{{usernamePattern}}"><br><small>Must be unique, consisting only of letters, digits, and the characters: <code>{{usernameCharacters}}</code></small></td></tr>
            <tr><td>Display Name: </td><td><input type="text" name="name" required></td></tr>
            <tr><td>Password: </td><td><input type="text" id="new-user-password" name="password" autocomplete="off" required> <button class="password-generator" data-input-elem="new-user-password" data-message-elem="new-user-password-message" style="display: none;">Generate Password</button><br><small id="new-user-password-message"></small></td></tr>
{{#if me.isFullAdmin}}
            <tr><td>Organization: </td><td><select name="organization">
                <option value="" selected>(none)</option>
                {{#each organizations}}<option value="{{this._id}}">{{this.name}}</option>{{/each}}
            </select> <small>(optional)</small></td></tr>
            <tr><td>Admin Status: </td><td><select name="admin">
                <option value="nope" selected>Not Admin</option>
                <option value="kinda">Organization Admin</option>
                <option value="yup">Full Admin</option>
            </select></td></tr>
{{/if}}
            <tr><td>&nbsp;</td><td><input type="submit" value="Create User"></td></tr>
        </tbody></table>
    </form>

    <h2>Existing Users{{#if organization}} in {{organization}}{{/if}}</h2>
{{#unless users}}
    <p>No users! Create one above.</p>
{{else}}
{{#if me.isFullAdmin}}
    <form action="">
        <input type="hidden" name="sort" value="{{sort}}">
        <p>Filter by Organization: <select name="filter" class="formcheckers-select-auto-submit">
            <option value="">(none)</option>
            {{#each organizations}}<option value="{{this._id}}"{{#eq ../filter this._id}} selected{{/eq}}>{{this.name}}</option>{{/each}}
        </select> <input type="submit" value="Go"></p>
    </form>
{{/if}}
    <table>
    <thead>
    <tr>
        <th><a href="?sort=username{{#if filter}}&amp;filter={{filter}}{{/if}}">Username</a></th>
        <th><a href="?sort=name{{#if filter}}&amp;filter={{filter}}{{/if}}">Display Name</a></th>
{{#if me.isFullAdmin}}
        <th><a href="?sort=organization{{#if filter}}&amp;filter={{filter}}{{/if}}">Organization</a></th>
{{/if}}
        <th><a href="?sort=admin{{#if filter}}&amp;filter={{filter}}{{/if}}">Admin Status</a></th>
    </tr>
    </thead>

    <tbody>
{{#each users}}
    <tr>
        <td><a href="{{../HTTP_PREFIX}}/account/admin/{{this.username}}"><i>{{this.username}}</i></a><br><a href="{{../HTTP_PREFIX}}/games/{{this.username}}">View Games</a></td>
        <td>{{this.name}}</td>
{{#if ../me.isFullAdmin}}
        <td>
            <form action="" method="POST">
                <input type="hidden" name="action" value="set-user-organization">
                <input type="hidden" name="user" value="{{this._id}}">
                <select name="organization" class="formcheckers-select-auto-submit">
                    <option value="">(none)</option>
                    {{#each organizations}}<option value="{{this._id}}"{{#if this.selected}} selected{{/if}}>{{this.name}}</option>{{/each}}
                </select>
                <input type="submit" value="Update">
            </form>
        </td>
{{/if}}
{{#or3way this.isMe this.isFullAdmin ../me.isOrganizationAdmin}}
        <td>{{#if ../this.isFullAdmin}}Full Admin{{else}}{{#if ../this.isOrganizationAdmin}}Organization Admin{{else}}Not Admin{{/if}}{{/if}}</td>
{{else}}
        <td>
            <form action="" method="POST">
                <input type="hidden" name="action" value="set-user-admin">
                <input type="hidden" name="user" value="{{this._id}}">
                <select name="admin" class="formcheckers-select-auto-submit">
                    <option value="nope">Not Admin</option>
                    <option value="kinda"{{#if this.isOrganizationAdmin}} selected{{/if}}>Organization Admin</option>
                    <option value="yup"{{#if this.isFullAdmin}} selected{{/if}}>Full Admin</option>
                </select>
                <input type="submit" value="Update">
            </form>
{{/or3way}}
        </td>
{{#unless this.isMe}}{{#unless this.isFullAdmin}}
        <td>
            <form action="" method="POST" class="formcheckers-delete-check" data-name="{{this.name}}">
                <input type="hidden" name="action" value="delete-user">
                <input type="hidden" name="user" value="{{this._id}}">
                <input type="submit" value="Delete">
            </form>
        </td>
{{/unless}}{{/unless}}
    </tr>
{{/each}}
    </tbody>
    </table>
{{/unless}}

{{#if me.isFullAdmin}}
    <h2>Existing Author Games</h2>
    <table>
    <thead>
    <tr>
        <th>Game Name</th>
        <th>Game Owner</th>
    </tr>
    </thead>
    <tbody>
{{#each authorgames}}
    <tr>
        <td>{{this.name}}</td>
        <td>{{this.owner.username}}</td>
        <td>
            <form action="{{../HTTP_PREFIX}}/author/preview" method="POST" target="_blank">
                <input type="hidden" name="id" value="{{this._id}}">
                <input type="submit" value="Preview">
            </form>
        </td>
        <td>
            <form action="" method="POST">
                <input type="hidden" name="action" value="download-author-game">
                <input type="hidden" name="authorgame" value="{{this._id}}">
                <input type="submit" value="Download JSON">
            </form>
        </td>
    </tr>
{{/each}}
    </tbody>
    </table>
{{/if}}
</section>

{{> FOOTER}}
<commit_msg>Added last modified to all author games list<commit_after>{{> HEADER}}

<section>
{{#if statusMessages}}
    <ul class="status">
        {{#each statusMessages}}<li>{{this}}</li>{{/each}}
    </ul>
{{/if}}

{{#if me.isFullAdmin}}
    {{#if serverLogs}}
    <h2>Server Logs</h2>
    <p><a href="{{HTTP_PREFIX}}/server-logs/">View Server Logs</a></p>
    {{/if}}
    <form action="" method="POST">
        <input type="hidden" name="action" value="create-organization">
        <h2>Create Organization</h2>
        <table class="noborder"><tbody>
            <tr><td>Organization Name: </td><td><input name="organization" type="text" required></td></tr>
            <tr><td>&nbsp;</td><td><input type="submit" value="Create Organization"></td></tr>
        </tbody></table>
    </form>
{{/if}}

    <form action="" method="POST">
        <input type="hidden" name="action" value="create-user">
        <h2>Create User{{#if organization}} in {{organization}}{{/if}}</h2>
        <table class="noborder"><tbody>
            <tr><td>Username: </td><td><input type="text" name="username" required pattern="{{usernamePattern}}"><br><small>Must be unique, consisting only of letters, digits, and the characters: <code>{{usernameCharacters}}</code></small></td></tr>
            <tr><td>Display Name: </td><td><input type="text" name="name" required></td></tr>
            <tr><td>Password: </td><td><input type="text" id="new-user-password" name="password" autocomplete="off" required> <button class="password-generator" data-input-elem="new-user-password" data-message-elem="new-user-password-message" style="display: none;">Generate Password</button><br><small id="new-user-password-message"></small></td></tr>
{{#if me.isFullAdmin}}
            <tr><td>Organization: </td><td><select name="organization">
                <option value="" selected>(none)</option>
                {{#each organizations}}<option value="{{this._id}}">{{this.name}}</option>{{/each}}
            </select> <small>(optional)</small></td></tr>
            <tr><td>Admin Status: </td><td><select name="admin">
                <option value="nope" selected>Not Admin</option>
                <option value="kinda">Organization Admin</option>
                <option value="yup">Full Admin</option>
            </select></td></tr>
{{/if}}
            <tr><td>&nbsp;</td><td><input type="submit" value="Create User"></td></tr>
        </tbody></table>
    </form>

    <h2>Existing Users{{#if organization}} in {{organization}}{{/if}}</h2>
{{#unless users}}
    <p>No users! Create one above.</p>
{{else}}
{{#if me.isFullAdmin}}
    <form action="">
        <input type="hidden" name="sort" value="{{sort}}">
        <p>Filter by Organization: <select name="filter" class="formcheckers-select-auto-submit">
            <option value="">(none)</option>
            {{#each organizations}}<option value="{{this._id}}"{{#eq ../filter this._id}} selected{{/eq}}>{{this.name}}</option>{{/each}}
        </select> <input type="submit" value="Go"></p>
    </form>
{{/if}}
    <table>
    <thead>
    <tr>
        <th><a href="?sort=username{{#if filter}}&amp;filter={{filter}}{{/if}}">Username</a></th>
        <th><a href="?sort=name{{#if filter}}&amp;filter={{filter}}{{/if}}">Display Name</a></th>
{{#if me.isFullAdmin}}
        <th><a href="?sort=organization{{#if filter}}&amp;filter={{filter}}{{/if}}">Organization</a></th>
{{/if}}
        <th><a href="?sort=admin{{#if filter}}&amp;filter={{filter}}{{/if}}">Admin Status</a></th>
    </tr>
    </thead>

    <tbody>
{{#each users}}
    <tr>
        <td><a href="{{../HTTP_PREFIX}}/account/admin/{{this.username}}"><i>{{this.username}}</i></a><br><a href="{{../HTTP_PREFIX}}/games/{{this.username}}">View Games</a></td>
        <td>{{this.name}}</td>
{{#if ../me.isFullAdmin}}
        <td>
            <form action="" method="POST">
                <input type="hidden" name="action" value="set-user-organization">
                <input type="hidden" name="user" value="{{this._id}}">
                <select name="organization" class="formcheckers-select-auto-submit">
                    <option value="">(none)</option>
                    {{#each organizations}}<option value="{{this._id}}"{{#if this.selected}} selected{{/if}}>{{this.name}}</option>{{/each}}
                </select>
                <input type="submit" value="Update">
            </form>
        </td>
{{/if}}
{{#or3way this.isMe this.isFullAdmin ../me.isOrganizationAdmin}}
        <td>{{#if ../this.isFullAdmin}}Full Admin{{else}}{{#if ../this.isOrganizationAdmin}}Organization Admin{{else}}Not Admin{{/if}}{{/if}}</td>
{{else}}
        <td>
            <form action="" method="POST">
                <input type="hidden" name="action" value="set-user-admin">
                <input type="hidden" name="user" value="{{this._id}}">
                <select name="admin" class="formcheckers-select-auto-submit">
                    <option value="nope">Not Admin</option>
                    <option value="kinda"{{#if this.isOrganizationAdmin}} selected{{/if}}>Organization Admin</option>
                    <option value="yup"{{#if this.isFullAdmin}} selected{{/if}}>Full Admin</option>
                </select>
                <input type="submit" value="Update">
            </form>
{{/or3way}}
        </td>
{{#unless this.isMe}}{{#unless this.isFullAdmin}}
        <td>
            <form action="" method="POST" class="formcheckers-delete-check" data-name="{{this.name}}">
                <input type="hidden" name="action" value="delete-user">
                <input type="hidden" name="user" value="{{this._id}}">
                <input type="submit" value="Delete">
            </form>
        </td>
{{/unless}}{{/unless}}
    </tr>
{{/each}}
    </tbody>
    </table>
{{/unless}}

{{#if me.isFullAdmin}}
    <h2>Existing Author Games</h2>
    <table>
    <thead>
    <tr>
        <th>Game Name</th>
        <th>Game Owner</th>
        <th>Last Modified</th>
    </tr>
    </thead>
    <tbody>
{{#each authorgames}}
    <tr>
        <td>{{this.name}}</td>
        <td>{{this.owner.username}}</td>
        <td>{{formatDate this.lastModified}}</td>
        <td>
            <form action="{{../HTTP_PREFIX}}/author/preview" method="POST" target="_blank">
                <input type="hidden" name="id" value="{{this._id}}">
                <input type="submit" value="Preview">
            </form>
        </td>
        <td>
            <form action="" method="POST">
                <input type="hidden" name="action" value="download-author-game">
                <input type="hidden" name="authorgame" value="{{this._id}}">
                <input type="submit" value="Download JSON">
            </form>
        </td>
    </tr>
{{/each}}
    </tbody>
    </table>
{{/if}}
</section>

{{> FOOTER}}

{'fraction_non_alphanumeric': 0.2275693311582382, 'fraction_numerical': 0.0017796233130654012, 'mean_word_length': 2.8131184619734237, 'pattern_counts': {'":': 0, '<': 473, '<?xml version=': 0, '>': 477, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '605177', 'n_tokens_mistral': 4285, 'n_tokens_neox': 4099, 'n_words': 749}