Toolchain/Dependency Upgrade (#418)

* Upgrade to heroku-20 stack

* Move some gulp deps to dev rather than prod

* npm upgrade

* Fix audit time check in asset audit test

* Attempt at parallelising tests where possible

* Add basic calendar button test

Mainly to pickup on FullCalendar loading errors

* Upgrade python deps

* Tends to help if I push valid yaml

* You valid now?

* Fix whoops in requirements.txt

* Change python ver

* Define service in coveralls task

* Run parallelised RIGS tests as one matrix job

* Update python version in tests

* Cache python dependencies

Should majorly speedup parallelillelelised testing

* Purge old vagrant config

* No Ruby compass bodge, no need for rubocop!

* Purge old .idea config

* Switch to gh-a artifact uploading instead of imgur 'hack'

For test failure screenshots. Happy now @mattysmith22? ;p

* Oops, remove unused import

* Exclude tests from the coverage stats

Seems to be artifically deflating our stats

* Refactor asset audit tests with better selectors

Also fixed a silly title error with the modal

* Add title checking to the slightly insane assets test

* Fix unauth test to not just immediately pass out

* Upload failure screenshots as individual artifacts not a zip

Turns out I can't unzip things from my phone, which is a pain

* Should fix asset test on CI

* What about this?

* What about this?

Swear I spend my life jiggerypokerying the damn test suite...

* Does this help the coverage be less weird?

* Revert "Does this help the coverage be less weird?"

This reverts commit 39ab9df836.

* Use pytest as our test runner for better parallelism

Also rewrote some asset tests to be in the pytest style. May do some more. Some warnings cleaned up in the process.

* Bah, codestyle

* Oops, remove obsolete if check

* Fix screenshot uploading on CI (again)

* Try this way of parallel coverage

* Add codeclimate maintainability badge

* Remove some unused gulp dependencies

* Run asset building serverside

* Still helps if I commit valid YAML

* See below

* Different approach to CI dependencies

* Exclude node_modules from codestyle

* Does this work?

* Parallel parallel builds were giving me a headache, try this

* Update codeclimate settings, purge some config files

* Well the YAML was *syntactically* valid....

* Switch back to old coveralls method

* Fix codeclimate config, mark 2

* Attempt to bodge asset test

* Oops, again

Probably bedtime..

* Might fix heroku building

* Attempt #2 at fixing heroku

* Belt and braces approach to coverage

* Github, you need a Actions YAML validator!

* Might fix actions?

* Try ignoring some third party deprecation warnings

* Another go at making coverage show up

* Some template cleanup

* Minor python cleanup

* Import optimisation

* Revert "Minor python cleanup"

This reverts commit 6a4620a2e5.

* Add format arg to coverage command

* Ignore test directories from Heroku slug

* Maybe this works to purge deps postbuild

* Bunch of test refactoring

* Restore signals import, screw you import optimisation

* Further template refactoring

* Add support for running tests with geckodriver, do this on CI

* Screw you codestyle

* Disable firefox tests for now

That was way more errors than I expected

* Run cleanup script from the right location

* Plausibly fix tests

* Helps if I don't delete the pipeline folder prior to collectstatic

* Enable whitenoise

* Can I delete pipeline here?

* Allow seconds difference in assert_times_equal

* Disable codeclimate

* Remove not working rm command

* Maybe this fixes coverage?

* Try different coverage reporter

* Fix search_help to need login

* Made versioning magic a bit less expansive

We have more apps than I thought...

* Fix IDI0T error in Assets URLS

* Refactor 'no access to unauthed' test to cover all of PyRIGS

* Add RAs/Checklists to sample data generator

* Fix some HTML errors in templates

Which apparently only Django's HTML parser cares about, browsers DGAF...

* Port title test to project level

* Fix more HTML

* Fix cable type detail
This commit is contained in:
2021-01-31 04:05:33 +00:00
committed by GitHub
parent 8ad629a47e
commit 2bf0175786
157 changed files with 9507 additions and 44028 deletions

View File

@@ -1,13 +1,9 @@
import simplejson
from captcha.fields import ReCaptchaField
from django import forms
from django.conf import settings
from django.contrib.auth.forms import (AuthenticationForm, PasswordResetForm,
UserChangeForm, UserCreationForm)
from django.core import serializers
from django.core.mail import EmailMessage, EmailMultiAlternatives
from django.utils import formats
from registration.forms import RegistrationFormUniqueEmail
from RIGS import models

View File

@@ -1,7 +1,7 @@
from RIGS.models import Profile
from users.forms import ProfileRegistrationFormUniqueEmail
from registration.signals import user_registered
from users.forms import ProfileRegistrationFormUniqueEmail
def user_created(sender, user, request, **kwargs):
form = ProfileRegistrationFormUniqueEmail(request.POST)

View File

@@ -9,26 +9,26 @@
<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');
$('#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);
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);
});
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
});
$('#urlParamForm').change(); //Do the initial setting
});
var clipboard = new ClipboardJS('.btn');
@@ -37,124 +37,124 @@
window.setTimeout(function () {$(e.trigger).popover('hide')}, 3000);
e.clearSelection();
});
</script>
</script>
{% endblock %}
{% block content %}
{% if not request.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 <i class="fas fa-edit"></i>
</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-12">
<div class="card">
<div class="row no-gutters">
<div class="col-md-3">
<img src="{{object.profile_picture}}" class="card-img img-fluid" />
{% if not request.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 class="col-md-9">
<div class="card-body">
<dl class="row">
<dt class="col-5">First Name</dt>
<dd class="col-7">{{object.first_name}}</dd>
</div>
</div>
{% endif %}
<div class="row">
<div class="col-12">
<div class="card">
<div class="row no-gutters">
<div class="col-md-3">
<img src="{{object.profile_picture}}" class="card-img img-fluid" />
</div>
<div class="col-md-9">
<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">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">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">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">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">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>
<dt class="col-5">Phone</dt>
<dd class="col-7">{{object.phone|linkornone:'tel'}}</dd>
</dl>
</div>
</div>
</div>
</div>
</div>
</div>
{% if not request.is_ajax and object.pk == user.pk %}
<div class="col-12 my-2">
<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" 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">
{% 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>
</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" 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>
{% if not request.is_ajax and object.pk == user.pk %}
<div class="col-12 my-2">
<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" 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">
{% 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>
</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" 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>
</div>
</div>
{% endif %}
</div>
<h4>Events</h4>
{% with object.latest_events as events %}
{% include 'partials/event_table.html' %}
{% endwith %}
{% endif %}
</div>
<h4>Events</h4>
{% with object.latest_events as events %}
{% include 'partials/event_table.html' %}
{% endwith %}
{% endblock %}

View File

@@ -1,31 +1,12 @@
import os
import re
from datetime import date, time, datetime, timedelta
import pytz
from django.conf import settings
from django.core import mail, signing
from django.db import transaction
from django.http import HttpResponseBadRequest
from django.test import LiveServerTestCase, TestCase
from django.test.client import Client
from django.urls import reverse
from reversion import revisions as reversion
from selenium import webdriver
from selenium.common.exceptions import StaleElementReferenceException
from selenium.webdriver.support import expected_conditions
from django.core import mail
from django.test import LiveServerTestCase
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.support.ui import WebDriverWait
from RIGS import models
from reversion import revisions as reversion
from django.urls import reverse
from django.core import mail, signing
from PyRIGS.tests.base import create_browser
from django.conf import settings
import sys
from RIGS import models
# Functional Tests

View File

@@ -1,14 +1,12 @@
from django.urls import path
from django.conf.urls import include, url
from django.contrib import admin
from django.contrib.staticfiles.urls import staticfiles_urlpatterns
from django.conf.urls import include
from django.contrib.auth.decorators import login_required
from django.conf import settings
from django.views.decorators.clickjacking import xframe_options_exempt
from django.contrib.auth.views import LoginView
from django.urls import path
from django.views.decorators.clickjacking import xframe_options_exempt
from registration.backends.default.views import RegistrationView
from PyRIGS.decorators import permission_required_with_403
from users import regbackend, forms, views
from users import forms, views
urlpatterns = [
path('user/register/', RegistrationView.as_view(form_class=forms.ProfileRegistrationFormUniqueEmail),

View File

@@ -1,24 +1,10 @@
from django.core.exceptions import PermissionDenied
from django.http.response import HttpResponseRedirect
from django.http import HttpResponse
from django.urls import reverse_lazy, reverse, NoReverseMatch
from django.views import generic
from django.contrib.auth.views import LoginView
from django.db.models import Q
from django.shortcuts import get_object_or_404
from django.core import serializers
from django.conf import settings
import simplejson
from django.contrib import messages
import datetime
import pytz
import operator
from registration.views import RegistrationView
from django.contrib.auth.views import LoginView
from django.urls import reverse_lazy
from django.views import generic
from django.views.decorators.csrf import csrf_exempt
from RIGS import models, forms
from assets import models as asset_models
from functools import reduce
from RIGS import models
# This view should be exempt from requiring CSRF token.