init
This commit is contained in:
@@ -0,0 +1,45 @@
|
||||
{% extends "admin/base.html" %}
|
||||
|
||||
{% block content %}
|
||||
<div class="jumbotron">
|
||||
<div class="container">
|
||||
<h1>CTFd Affiliations</h1>
|
||||
</div>
|
||||
</div>
|
||||
<div class="container">
|
||||
<div class="row">
|
||||
<div class="col-md-3">
|
||||
<ul class="nav nav-pills flex-column">
|
||||
<li class="nav-item">
|
||||
<a class="nav-link rounded-0 {% if active_page == 'codes' %}active{% endif %}"
|
||||
href="{{ url_for('ctfd-affiliations.admin_codes') }}">Codes</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link rounded-0 {% if active_page == 'users' %}active{% endif %}"
|
||||
href="{{ url_for('ctfd-affiliations.admin_users') }}">Users</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="col-md-9">
|
||||
{% for error in errors %}
|
||||
<div class="alert alert-danger alert-dismissable" role="alert">
|
||||
{{ error }}
|
||||
<button type="button" class="close" data-dismiss="alert" aria-label="Close">
|
||||
<span aria-hidden="true">×</span>
|
||||
</button>
|
||||
</div>
|
||||
{% endfor %}
|
||||
{% for info in infos %}
|
||||
<div class="alert alert-success alert-dismissable" role="alert">
|
||||
{{ info }}
|
||||
<button type="button" class="close" data-dismiss="alert" aria-label="Close">
|
||||
<span aria-hidden="true">×</span>
|
||||
</button>
|
||||
</div>
|
||||
{% endfor %}
|
||||
|
||||
{% block page %}{% endblock %}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endblock %}
|
||||
@@ -0,0 +1,79 @@
|
||||
{% extends "affiliations/base.html" %}
|
||||
{% set active_page = "codes" %}
|
||||
|
||||
{% block page %}
|
||||
<h4>New code</h4>
|
||||
<form method="POST" action="{{ url_for('ctfd-affiliations.admin_create_code') }}" class="form-row align-items-end">
|
||||
<input type="hidden" name="nonce" value="{{ Session.nonce }}">
|
||||
<div class="form-group col-md-4">
|
||||
<label for="new-affiliation"><b>Affiliation</b></label>
|
||||
<input id="new-affiliation" name="affiliation" class="form-control" maxlength="127" required>
|
||||
</div>
|
||||
<div class="form-group col-md-3">
|
||||
<label for="new-code"><b>Code</b></label>
|
||||
<input id="new-code" name="code" class="form-control" maxlength="128" placeholder="Random if empty">
|
||||
</div>
|
||||
<div class="form-group col-md-3">
|
||||
<label for="new-max-uses"><b>Max uses</b></label>
|
||||
<input id="new-max-uses" name="max_uses" type="number" min="0" class="form-control" placeholder="Unlimited">
|
||||
</div>
|
||||
<div class="form-group col-md-2">
|
||||
<button type="submit" class="btn btn-primary w-100">Create</button>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
<h4 class="mt-4">Codes</h4>
|
||||
{% if codes %}
|
||||
<table class="table table-striped border">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Affiliation</th>
|
||||
<th>Code</th>
|
||||
<th class="text-center">Uses</th>
|
||||
<th>Max uses</th>
|
||||
<th class="text-center">Enabled</th>
|
||||
<th></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for code in codes %}
|
||||
<tr>
|
||||
<td>
|
||||
<form id="edit-{{ code.id }}" method="POST" action="{{ url_for('ctfd-affiliations.admin_update_code', code_id=code.id) }}">
|
||||
<input type="hidden" name="nonce" value="{{ Session.nonce }}">
|
||||
</form>
|
||||
<input form="edit-{{ code.id }}" name="affiliation" class="form-control form-control-sm" value="{{ code.affiliation }}" maxlength="127" required>
|
||||
</td>
|
||||
<td>
|
||||
<input form="edit-{{ code.id }}" name="code" class="form-control form-control-sm text-monospace" value="{{ code.code }}" maxlength="128" required>
|
||||
</td>
|
||||
<td class="text-center align-middle">
|
||||
<a href="{{ url_for('ctfd-affiliations.admin_users', affiliation=code.affiliation) }}" title="Show users">{{ code.uses }}</a>
|
||||
</td>
|
||||
<td>
|
||||
<input form="edit-{{ code.id }}" name="max_uses" type="number" min="0" class="form-control form-control-sm" value="{{ code.max_uses or '' }}" placeholder="∞">
|
||||
</td>
|
||||
<td class="text-center align-middle">
|
||||
<input form="edit-{{ code.id }}" name="enabled" type="checkbox" value="y" {% if code.enabled %}checked{% endif %}>
|
||||
{% if code.exhausted %}<br><small class="text-danger">limit reached</small>{% endif %}
|
||||
</td>
|
||||
<td class="text-right text-nowrap">
|
||||
<button form="edit-{{ code.id }}" type="submit" class="btn btn-sm btn-outline-primary" title="Save">
|
||||
<i class="fas fa-save"></i>
|
||||
</button>
|
||||
<form method="POST" action="{{ url_for('ctfd-affiliations.admin_delete_code', code_id=code.id) }}" class="d-inline"
|
||||
onsubmit="return confirm('Delete code {{ code.code }}? Its users keep the affiliation but will be able to change it.');">
|
||||
<input type="hidden" name="nonce" value="{{ Session.nonce }}">
|
||||
<button type="submit" class="btn btn-sm btn-outline-danger" title="Delete">
|
||||
<i class="fas fa-times"></i>
|
||||
</button>
|
||||
</form>
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
{% else %}
|
||||
<p class="text-muted">No codes yet.</p>
|
||||
{% endif %}
|
||||
{% endblock %}
|
||||
@@ -0,0 +1,85 @@
|
||||
{% extends "affiliations/base.html" %}
|
||||
{% set active_page = "users" %}
|
||||
|
||||
{% block page %}
|
||||
{% if affiliations %}
|
||||
<form method="GET" action="{{ url_for('ctfd-affiliations.admin_users') }}" class="mb-4">
|
||||
<label for="affiliation-select"><b>Affiliation</b></label>
|
||||
<select id="affiliation-select" name="affiliation" class="form-control custom-select" onchange="this.form.submit()">
|
||||
<option value="" disabled {% if selected is none %}selected{% endif %}>Select affiliation</option>
|
||||
{% for affiliation, count in affiliations.items() %}
|
||||
<option value="{{ affiliation }}" {% if affiliation == selected %}selected{% endif %}>
|
||||
{{ affiliation }} ({{ count }})
|
||||
</option>
|
||||
{% endfor %}
|
||||
</select>
|
||||
</form>
|
||||
{% else %}
|
||||
<p class="text-muted">
|
||||
No affiliations yet. Create a code on the
|
||||
<a href="{{ url_for('ctfd-affiliations.admin_codes') }}">Codes</a> page.
|
||||
</p>
|
||||
{% endif %}
|
||||
|
||||
{% if selected is not none %}
|
||||
<form method="POST" action="{{ url_for('ctfd-affiliations.admin_add_user') }}" class="form-row align-items-end mb-3">
|
||||
<input type="hidden" name="nonce" value="{{ Session.nonce }}">
|
||||
<div class="form-group col-md-4">
|
||||
<label for="add-user-id"><b>User ID</b></label>
|
||||
<input id="add-user-id" name="user_id" type="number" min="1" class="form-control" required>
|
||||
</div>
|
||||
{% if codes | length > 1 %}
|
||||
<div class="form-group col-md-4">
|
||||
<label for="add-code"><b>Code</b></label>
|
||||
<select id="add-code" name="code_id" class="form-control custom-select">
|
||||
{% for code in codes %}
|
||||
<option value="{{ code.id }}">{{ code.code }}</option>
|
||||
{% endfor %}
|
||||
</select>
|
||||
</div>
|
||||
{% else %}
|
||||
<input type="hidden" name="code_id" value="{{ codes[0].id }}">
|
||||
{% endif %}
|
||||
<div class="form-group col-md-2">
|
||||
<button type="submit" class="btn btn-primary w-100">Add</button>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
{% if members %}
|
||||
<table class="table table-striped border">
|
||||
<thead>
|
||||
<tr>
|
||||
<th class="text-center">ID</th>
|
||||
<th>User</th>
|
||||
<th>Email</th>
|
||||
<th>Code</th>
|
||||
<th>Added</th>
|
||||
<th></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for member in members %}
|
||||
<tr>
|
||||
<td class="text-center">{{ member.user.id }}</td>
|
||||
<td><a href="{{ url_for('admin.users_detail', user_id=member.user.id) }}">{{ member.user.name }}</a></td>
|
||||
<td>{{ member.user.email }}</td>
|
||||
<td class="text-monospace">{{ member.code.code }}</td>
|
||||
<td>{{ member.created.strftime('%Y-%m-%d %H:%M') if member.created else '' }} UTC</td>
|
||||
<td class="text-right">
|
||||
<form method="POST" action="{{ url_for('ctfd-affiliations.admin_remove_user', user_id=member.user_id) }}" class="d-inline"
|
||||
onsubmit="return confirm('Remove {{ member.user.name }} from {{ selected }}? Their affiliation will be cleared.');">
|
||||
<input type="hidden" name="nonce" value="{{ Session.nonce }}">
|
||||
<button type="submit" class="btn btn-sm btn-outline-danger" title="Remove">
|
||||
<i class="fas fa-times"></i>
|
||||
</button>
|
||||
</form>
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
{% else %}
|
||||
<p class="text-muted">No users in this affiliation yet.</p>
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
{% endblock %}
|
||||
Reference in New Issue
Block a user