mirror of
https://github.com/nottinghamtec/PyRIGS.git
synced 2026-10-06 20:45:30 +00:00
* Port to Django 5.2 * Pin pluggy to 1.2.0 Any newer and the mystery importlib metadata error appears. Weird! >_> * Update for premailer changed default * Update view logic for is_ajax being changed to a template context processor * Port a few more tests to pytest proper Having two distinct test flavours is giving me a headache * Version 1 dockerfile Makes a VERY big image, I suspect we can optimise this a lot... * Optimise dockerfile a little lot a bit * fix(users): change logout link to POST request * fix(tests): fix some syntax errors in test code still got lots of failed tests :( * fix: replace deprecated Django APIs * ci: update Dockerfile * ci: update Dockerfile * fix(dependencies+tests): update EoL/vulnerable dependencies and improve test stability * Upgrade Python from 3.10 to 3.12 * Update frontend dependencies, replace node-sass with sass * chore(logging): ignore dangling obj reference warning from pypdf * ci: update compose.yml for prod deployment - Add Nginx as a reverse proxy - Add cert-selfsign.sh for generating self-signed certificates - Add certbot-issue.sh for Let's Encrypt certificate issuance and renewal - Add cron-install.sh and cron-uninstall.sh for system cron management - Add .env.example as an environment variable template * style: reformat code * ci: add more sleep trying to pass tests * ci: ignore browser-based tests during ci testing * fix: create home for the new user during Dockerfile building * chore: remove heroku conf file * fix: RIGS not franken anymore * fix: restore is_ajax as a boolean and split out the context processor * test: remove Selenium interaction tests and their CI workarounds * fix: harden production settings (CSRF origins, env casts, ADMINS) and drop dead debug toolbar code * deploy: serve static files from nginx, pin PGDATA, and make cert scripts loud on failure * build: switch .dockerignore to an allowlist * build: drop unused dependencies, soft-pin the rest and target Python 3.14 * build: move image to Python 3.14 / Node 24 and force DEBUG off * ci: add dependabot config for uv, npm, docker and actions * build: narrow Sass deprecation silencing to @import and require Node 24 * build: provide placeholder env for collectstatic now that DEBUG is off in the image * deploy: add plain-HTTP nginx config for local development and use it in compose * deploy: remove self-signed cert script * build: make the image multi-arch with official node and python base images * ci: lint and test on PRs, build the image on PRs and push it to GHCR on master * docs: add local running and sample data instructions * fix: report a form error instead of crashing when big power has no Power MIC * fix: upgrade pypdf and urllib3 to patched releases * fix: apply non-breaking npm audit fixes * fix: strip whitespace in ALLOWED_HOSTS and drop misleading HSTS preload * deploy: add a pyrigs healthcheck and make nginx wait for it * build: pin the uv image version * fix: correct the check-in person picker condition and use BeautifulSoup's string argument * refactor: replace unique_together with UniqueConstraint * build: replace pycodestyle with ruff and fix what it found Removes unused imports and variables, and fixes a few real problems it surfaced: - EventCheckIn.active() referenced an undefined name and raised NameError; it now returns whether the check-in has no end time - RIGS.admin defined EventChecklistAdmin twice; the second is now PowerTestRecordAdmin - RIGS/tests/conftest.py used date/timedelta without importing them - the signal-registering imports in apps.py are kept with noqa pycodestyle config in setup.cfg is dropped. * style: format the codebase with ruff * style: normalise line endings, trailing whitespace and end-of-file newlines * ci: run ruff and file hygiene through prek, and document it --------- Co-authored-by: Hang <me@hangxu.me> Co-authored-by: Joe Banks <joe@jb3.dev>
182 lines
9.3 KiB
HTML
182 lines
9.3 KiB
HTML
{% extends is_ajax|yesno:"base_ajax.html,base_rigs.html" %}
|
|
|
|
{% load static %}
|
|
{% load linkornone from filters %}
|
|
|
|
{% block js %}
|
|
<script src="{% static 'js/tooltip.js' %}"></script>
|
|
<script src="{% static 'js/popover.js' %}"></script>
|
|
<script src="{% static 'js/clipboard.min.js' %}"></script>
|
|
<script>
|
|
$(document).ready(function() {
|
|
$('#urlParamForm').change(function(){
|
|
url = "?";
|
|
$('#urlParamForm *').filter(':input').each(function(index, value){
|
|
defaultVal = $(value).data('default');
|
|
param = $(value).val();
|
|
val = $(value).prop('checked');
|
|
|
|
if(val !== defaultVal){
|
|
url = url+param+"="+val+"&";
|
|
}
|
|
});
|
|
ics_url = $('#cal-url').data('url') + url.substring(0, url.length - 1);
|
|
$('#cal-url').text(ics_url);
|
|
|
|
gcal_url = $('#gcal-link').data('url') + encodeURIComponent(url.substring(0, url.length - 1));
|
|
$('#gcal-link').attr('href',gcal_url);
|
|
});
|
|
|
|
$('#urlParamForm').change(); //Do the initial setting
|
|
});
|
|
|
|
var clipboard = new ClipboardJS('.btn');
|
|
|
|
clipboard.on('success', function(e) {
|
|
$(e.trigger).popover('show');
|
|
window.setTimeout(function () {$(e.trigger).popover('hide')}, 3000);
|
|
e.clearSelection();
|
|
});
|
|
</script>
|
|
{% endblock %}
|
|
|
|
{% block content %}
|
|
{% if not is_ajax and object.pk == user.pk %}
|
|
<div class="row py-3">
|
|
<div class="col text-right">
|
|
<div class="btn-group">
|
|
<a href="{% url 'profile_update_self' %}" class="btn btn-warning">
|
|
Edit Profile <span class="fas fa-edit"></span>
|
|
</a>
|
|
<a href="{% url 'password_change' %}" class="btn btn-light">
|
|
Change Password <span class="fas fa-lock"></span>
|
|
</a>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
{% endif %}
|
|
<div class="row">
|
|
<div class="col-lg-4 col-12 mb-2">
|
|
<div class="card">
|
|
<img src="{{object.profile_picture}}" class="card-img img-fluid" />
|
|
<div class="card-body">
|
|
<dl class="row">
|
|
<dt class="col-5">First Name</dt>
|
|
<dd class="col-7">{{object.first_name}}</dd>
|
|
|
|
<dt class="col-5">Last Name</dt>
|
|
<dd class="col-7">{{object.last_name}}</dd>
|
|
|
|
<dt class="col-5">Email</dt>
|
|
<dd class="col-7">{{object.email}}</dd>
|
|
|
|
<dt class="col-5">Last Login</dt>
|
|
<dd class="col-7">{{object.last_login|date:"d/m/Y H:i"}}</dd>
|
|
|
|
<dt class="col-5">Date Joined</dt>
|
|
<dd class="col-7">{{object.date_joined|date:"d/m/Y H:i"}}</dd>
|
|
|
|
<dt class="col-5">Initials</dt>
|
|
<dd class="col-7">{{object.initials}}</dd>
|
|
|
|
<dt class="col-5">Phone</dt>
|
|
<dd class="col-7">{{object.phone|linkornone:'tel'}}</dd>
|
|
</dl>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
{% if not is_ajax and object.pk == user.pk %}
|
|
<div class="col-lg-8 col-12">
|
|
<div class="card">
|
|
<div class="card-header">Personal iCal Details</div>
|
|
<div class="card-body">
|
|
<dl class="row">
|
|
<dt class="col-4">API Key</dt>
|
|
<dd class="col-8">
|
|
{% if user.api_key %}
|
|
<code id="api-key">{{user.api_key}}</code>
|
|
<button class="btn btn-secondary align-middle pr-1 btn-sm" data-clipboard-target="#api-key" data-content="Copied to clipboard!"><span class="fas fa-clipboard"></span></button>
|
|
{% else %}
|
|
<span id="api-key">No API Key Generated</span>
|
|
{% endif %}
|
|
<a href="{% url 'reset_api_key' %}" class="btn btn-secondary align-middle pr-1">
|
|
{% if user.api_key %}Reset API Key{% else %}Generate API Key{% endif %}
|
|
<span class="fas fa-redo"></span>
|
|
</a>
|
|
</dd>
|
|
<dt class="col-4">Calendar Options</dt>
|
|
<dd class="col-8">
|
|
<form id="urlParamForm">
|
|
<div class="form-group d-flex flex-column flex-lg-row">
|
|
<label class="checkbox-inline mr-lg-2">
|
|
<input type="checkbox" value="rig" data-default="true" checked> Rigs
|
|
</label>
|
|
<label class="checkbox-inline mx-lg-2">
|
|
<input type="checkbox" value="non-rig" data-default="true" checked> Non-Rigs
|
|
</label>
|
|
<label class="checkbox-inline mx-lg-2">
|
|
<input type="checkbox" value="dry-hire" data-default="true" checked> Dry-Hires
|
|
</label>
|
|
<label class="checkbox-inline mx-lg-2">
|
|
<input type="checkbox" value="cancelled" data-default="false" > Cancelled
|
|
</label>
|
|
<label class="checkbox-inline mx-lg-2">
|
|
<input type="checkbox" value="provisional" data-default="true" checked> Provisional
|
|
</label>
|
|
<label class="checkbox-inline ml-lg-2">
|
|
<input type="checkbox" value="confirmed" data-default="true" checked> Confirmed/Booked
|
|
</label>
|
|
<label class="checkbox-inline ml-lg-2">
|
|
<input type="checkbox" value="only_mic" data-default="false" > Only MIC
|
|
</label>
|
|
</div>
|
|
</form>
|
|
</dd>
|
|
<dt class="col-4">Calendar URL</dt>
|
|
<dd class="col-8">
|
|
{% if user.api_key %}
|
|
<code id="cal-url" data-url="http{{ request.is_secure|yesno:"s,"}}://{{ request.get_host }}{% url 'ics_calendar' api_pk=user.pk api_key=user.api_key %}"></code>
|
|
<button class="btn btn-secondary align-middle btn-sm pr-1" data-clipboard-target="#cal-url" data-content="Copied to clipboard!"><span class="fas fa-clipboard"></span></button>
|
|
<br>
|
|
<small><a id="gcal-link" data-url="https://support.google.com/calendar/answer/37100" href="">Click here</a> for instructions on adding to google calendar.<br/>
|
|
To sync from Google Calendar to mobile device, visit <a href="https://www.google.com/calendar/syncselect" target="_blank">this page</a> on your device and tick "RIGS Calendar".</small>
|
|
{% else %}
|
|
<pre>No API Key Generated</pre>
|
|
{% endif %}
|
|
</dd>
|
|
</dl>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
{% endif %}
|
|
|
|
</div>
|
|
<div class="row">
|
|
<div class="col col-lg-6 mb-2">
|
|
<div class="card">
|
|
<div class="card-header">Training Record</div>
|
|
<div class="card-body">
|
|
<a href="{% url 'trainee_detail' object.pk %}" class="btn btn-primary"><span class="fas fa-eye"></span> View Training Record</a>
|
|
{% include 'partials/add_qualification.html' %}
|
|
<ul class="list-group pt-3">
|
|
<li class="list-group-item active">Achieved Levels:</li>
|
|
{% for qual in completed_levels %}
|
|
<a href="{% url 'level_detail' qual.level.pk %}"class="list-group-item list-group-item-action d-flex justify-content-between align-items-center">{{ qual.level }}{{ qual.get_icon }}</a>
|
|
{% endfor %}
|
|
</ul>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="col-lg-6">
|
|
<div class="card">
|
|
<div class="card-header">Events</div>
|
|
<div style="container-type: size; height: 30vh; overflow-y: scroll;">
|
|
{% with object.latest_events as events %}
|
|
{% include 'partials/event_table.html' %}
|
|
{% endwith %}
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
{% endblock %}
|