ran precommit and ignoring html files with prettier since it has a hard time with jinja files w/ burnettk

This commit is contained in:
jasquat 2022-06-02 10:17:53 -04:00
parent 5b51030a40
commit 67a9ce68e7
13 changed files with 4124 additions and 167 deletions

View File

@ -60,3 +60,4 @@ repos:
rev: v2.4.1
hooks:
- id: prettier
exclude_types: [html]

View File

@ -10,17 +10,17 @@ services:
- MYSQL_DATABASE=spiffworkflow_backend_staging
- MYSQL_ROOT_PASSWORD=St4g3Th1515
ports:
- '7001:3306'
- "7001:3306"
volumes:
- spiffworkflow_backend:/var/lib/mysql
healthcheck:
test: mysql --user=root --password=St4g3Th1515 -e 'select 1' spiffworkflow_backend_staging
test: mysql --user=root --password=St4g3Th1515 -e 'select 1' spiffworkflow_backend_staging
spiffworkflow-backend:
container_name: spiffworkflow-backend
# command: tail -f /etc/hostname
depends_on:
- db
- db
# image: sartography/cr-connect-workflow:dev
build:
context: .

View File

@ -0,0 +1,49 @@
/*
* ATTENTION: The "eval" devtool has been used (maybe by default in mode: "development").
* This devtool is neither made for production nor for readable output files.
* It uses "eval()" calls to create a separate source file in the browser devtools.
* If you are trying to read the output file, select a different devtool (https://webpack.js.org/configuration/devtool/)
* or disable the default devtool with "devtool: false".
* If you are looking for production-ready output files, see mode: "production" (https://webpack.js.org/configuration/mode/).
*/
/******/ (() => { // webpackBootstrap
/******/ "use strict";
/******/ var __webpack_modules__ = ({
/***/ "./src/app.js":
/*!********************!*\
!*** ./src/app.js ***!
\********************/
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
eval("__webpack_require__.r(__webpack_exports__);\nObject(function webpackMissingModule() { var e = new Error(\"Cannot find module 'bpmn-js'\"); e.code = 'MODULE_NOT_FOUND'; throw e; }());\n\n\nvar viewer = new Object(function webpackMissingModule() { var e = new Error(\"Cannot find module 'bpmn-js'\"); e.code = 'MODULE_NOT_FOUND'; throw e; }())({\n container: '#canvas'\n});\n\n\nviewer.importXML(pizzaDiagram).then(function(result) {\n\n const { warnings } = result;\n\n console.log('success !', warnings);\n\n viewer.get('canvas').zoom('fit-viewport');\n}).catch(function(err) {\n\n const { warnings, message } = err;\n\n console.log('something went wrong:', warnings, message);\n});\n\n\n//# sourceURL=webpack:///./src/app.js?");
/***/ })
/******/ });
/************************************************************************/
/******/ // The require scope
/******/ var __webpack_require__ = {};
/******/
/************************************************************************/
/******/ /* webpack/runtime/make namespace object */
/******/ (() => {
/******/ // define __esModule on exports
/******/ __webpack_require__.r = (exports) => {
/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
/******/ }
/******/ Object.defineProperty(exports, '__esModule', { value: true });
/******/ };
/******/ })();
/******/
/************************************************************************/
/******/
/******/ // startup
/******/ // Load entry module and return exports
/******/ // This entry module can't be inlined because the eval devtool is used.
/******/ var __webpack_exports__ = {};
/******/ __webpack_modules__["./src/app.js"](0, __webpack_exports__, __webpack_require__);
/******/
/******/ })()
;

View File

@ -29,7 +29,9 @@ def create_app() -> flask.app.Flask:
app.config["SESSION_TYPE"] = "filesystem"
if os.environ.get("FLASK_SESSION_SECRET_KEY") is None:
raise KeyError("Cannot find the secret_key from the environment. Please set FLASK_SESSION_SECRET_KEY")
raise KeyError(
"Cannot find the secret_key from the environment. Please set FLASK_SESSION_SECRET_KEY"
)
app.secret_key = os.environ.get("FLASK_SESSION_SECRET_KEY")

View File

@ -115,13 +115,13 @@ def process_model_edit(process_model_id, file_name):
)
@admin_blueprint.route("/process-models/<process_model_id>/save/<file_name>", methods=["POST"])
@admin_blueprint.route(
"/process-models/<process_model_id>/save/<file_name>", methods=["POST"]
)
def process_model_save(process_model_id, file_name):
"""Process_model_save."""
process_model = ProcessModelService().get_spec(process_model_id)
SpecFileService.update_file(
process_model, file_name, request.get_data()
)
SpecFileService.update_file(process_model, file_name, request.get_data())
bpmn_xml = SpecFileService.get_data(process_model, process_model.primary_file_name)
return render_template(
"process_model_edit.html",

View File

@ -0,0 +1,26 @@
import BpmnViewer from 'bpmn-js';
var viewer = new BpmnViewer({
container: '#canvas'
});
viewer.importXML(pizzaDiagram).then(function(result) {
const { warnings } = result;
console.log('success !', warnings);
viewer.get('canvas').zoom('fit-viewport');
}).catch(function(err) {
const { warnings, message } = err;
console.log('something went wrong:', warnings, message);
});
export function sayHello () {
console.log('hello')
}
window.foo = 'bar'

File diff suppressed because it is too large Load Diff

View File

@ -9,6 +9,10 @@
"author": "",
"license": "ISC",
"dependencies": {
"bpmn-js": "^9.1.0"
"bpmn-js": "^9.1.0",
"bpmn-js-properties-panel": "^1.1.1"
},
"devDependencies": {
"webpack-cli": "^4.9.2"
}
}

File diff suppressed because one or more lines are too long

View File

@ -1 +1,2 @@
.example { }
.example {
}

View File

@ -1,150 +1,168 @@
{% extends "layout.html" %} {% block title %}Process Model Edit: {{
process_model.id }}{% endblock %} {% block head %}
<meta charset="UTF-8" />
{% extends "layout.html" %} {% block title %}
Process Model Edit: {{ process_model.id }}
{% endblock %}
<!-- example styles -->
<!-- required modeler styles -->
<link
rel="stylesheet"
href="https://unpkg.com/bpmn-js@9.1.0/dist/assets/bpmn-js.css"
/>
<link
rel="stylesheet"
href="https://unpkg.com/bpmn-js@9.1.0/dist/assets/diagram-js.css"
/>
<link
rel="stylesheet"
href="https://unpkg.com/bpmn-js@9.1.0/dist/assets/bpmn-font/css/bpmn.css"
/>
{% block head %}
<meta charset="UTF-8" />
<!-- modeler distro -->
<script src="https://unpkg.com/bpmn-js@9.1.0/dist/bpmn-modeler.development.js"></script>
<!-- example styles -->
<!-- required modeler styles -->
<link rel="stylesheet" href="https://unpkg.com/bpmn-js@9.1.0/dist/assets/bpmn-js.css" />
<link rel="stylesheet" href="https://unpkg.com/bpmn-js@9.1.0/dist/assets/diagram-js.css" />
<link rel="stylesheet" href="https://unpkg.com/bpmn-js@9.1.0/dist/assets/bpmn-font/css/bpmn.css" />
<!-- needed for this example only -->
<script src="https://unpkg.com/jquery@3.3.1/dist/jquery.js"></script>
<link rel="stylesheet" href="https://unpkg.com/bpmn-js-properties-panel/dist/assets/properties-panel.css">
<link rel="stylesheet" href="https://unpkg.com/bpmn-js-properties-panel/dist/assets/element-templates.css">
<!-- example styles -->
<style>
html,
body,
#canvas {
height: 100%;
padding: 0;
margin: 0;
}
<!-- modeler distro -->
<script src="https://unpkg.com/bpmn-js@9.1.0/dist/bpmn-modeler.development.js"></script>
<script src="{{ url_for('admin.static', filename='public/app.bundled.js/main.js') }}"></script>
.diagram-note {
background-color: rgba(66, 180, 21, 0.7);
color: White;
border-radius: 5px;
font-family: Arial;
font-size: 12px;
padding: 5px;
min-height: 16px;
width: 50px;
text-align: center;
}
<!-- needed for this example only -->
<script src="https://unpkg.com/jquery@3.3.1/dist/jquery.js"></script>
.needs-discussion:not(.djs-connection) .djs-visual > :nth-child(1) {
stroke: rgba(66, 180, 21, 0.7) !important; /* color elements as red */
}
#save-button {
position: fixed;
bottom: 20px;
left: 20px;
}
</style>
{% endblock %} {% block content %}
<div id="result">{{ result }}</div>
<button
type="button"
onclick="window.location.href='{{ url_for( 'admin.process_model_show_file', process_model_id=process_model.id, file_name=file_name ) }}';"
>
Back
</button>
<button type="button" onclick="exportDiagram()">Save</button>
<div id="canvas"></div>
<meta id="bpmn_xml" data-name="{{bpmn_xml}}" />
<script>
// modeler instance
var bpmnModeler = new BpmnJS({
container: "#canvas",
keyboard: {
bindTo: window,
},
});
/**
* Save diagram contents and print them to the console.
*/
async function exportDiagram() {
try {
var data = await bpmnModeler.saveXML({ format: true });
//POST request with body equal on data in JSON format
fetch("/admin/process-models/{{ process_model.id }}/save/{{ file_name }}", {
method: "POST",
headers: {
"Content-Type": "text/xml",
},
body: data.xml,
})
.then((response) => response.json())
//Then with the data from the response in JSON...
.then((data) => {
console.log("Success:", data);
})
//Then with the error genereted...
.catch((error) => {
console.error("Error:", error);
});
alert("Diagram exported. Check the developer tools!");
} catch (err) {
console.error("could not save BPMN 2.0 diagram", err);
<!-- example styles -->
<style>
html, body, #canvas {
height: 100%;
padding: 0;
margin: 0;
}
}
/**
* Open diagram in our modeler instance.
*
* @param {String} bpmnXML diagram to display
*/
async function openDiagram(bpmnXML) {
// import diagram
try {
await bpmnModeler.importXML(bpmnXML);
.diagram-note {
background-color: rgba(66, 180, 21, 0.7);
color: White;
border-radius: 5px;
font-family: Arial;
font-size: 12px;
padding: 5px;
min-height: 16px;
width: 50px;
text-align: center;
}
// access modeler components
var canvas = bpmnModeler.get("canvas");
var overlays = bpmnModeler.get("overlays");
.needs-discussion:not(.djs-connection) .djs-visual > :nth-child(1) {
stroke: rgba(66, 180, 21, 0.7) !important; /* color elements as red */
}
// zoom to fit full viewport
canvas.zoom("fit-viewport");
#save-button {
position: fixed;
bottom: 20px;
left: 20px;
}
</style>
{% endblock %}
// attach an overlay to a node
overlays.add("SCAN_OK", "note", {
position: {
bottom: 0,
right: 0,
},
html: '<div class="diagram-note">Mixed up the labels?</div>',
{% block content %}
<div id="result">{{ result }}</div>
<button
type="button"
onclick="window.location.href='{{ url_for( 'admin.process_model_show_file', process_model_id=process_model.id, file_name=file_name ) }}';"
>
Back
</button>
<button type="button" onclick="exportDiagram()">Save</button>
<!-- <div class="modeler"> -->
<div id="canvas"></div>
<div id="properties"></div>
<!-- </div> -->
<meta id="bpmn_xml" data-name="{{bpmn_xml}}" />
<script>
// import BpmnModeler from '/admin/static/node_modules/bpmn-js/lib/Modeler.js';
// import {
// BpmnPropertiesPanelModule,
// BpmnPropertiesProviderModule,
// } from '/admin/static/node_modules/bpmn-js-properties-panel/dist/index.js';
//
// const bpmnModeler = new BpmnModeler({
// container: '#canvas',
// propertiesPanel: {
// parent: '#properties'
// },
// additionalModules: [
// BpmnPropertiesPanelModule,
// BpmnPropertiesProviderModule
// ]
// });
// modeler instance
var bpmnModeler = new BpmnJS({
container: "#canvas",
keyboard: {
bindTo: window,
},
});
// add marker
canvas.addMarker("SCAN_OK", "needs-discussion");
} catch (err) {
console.error("could not import BPMN 2.0 diagram", err);
/**
* Save diagram contents and print them to the console.
*/
async function exportDiagram() {
try {
var data = await bpmnModeler.saveXML({ format: true });
//POST request with body equal on data in JSON format
fetch("/admin/process-models/{{ process_model.id }}/save/{{ file_name }}", {
method: "POST",
headers: {
"Content-Type": "text/xml",
},
body: data.xml,
})
.then((response) => response.json())
//Then with the data from the response in JSON...
.then((data) => {
console.log("Success:", data);
})
//Then with the error genereted...
.catch((error) => {
console.error("Error:", error);
});
alert("Diagram exported. Check the developer tools!");
} catch (err) {
console.error("could not save BPMN 2.0 diagram", err);
}
}
}
// trying to use the python variable bpmn_xml directly causes the xml to have escape sequences
// and using the meta tag seems to help with that
var bpmn_xml = $("#bpmn_xml").data();
openDiagram(bpmn_xml.name);
/**
* Open diagram in our modeler instance.
*
* @param {String} bpmnXML diagram to display
*/
async function openDiagram(bpmnXML) {
// import diagram
try {
await bpmnModeler.importXML(bpmnXML);
// wire save button
$("#save-button").click(exportDiagram);
</script>
// access modeler components
var canvas = bpmnModeler.get("canvas");
var overlays = bpmnModeler.get("overlays");
// zoom to fit full viewport
canvas.zoom("fit-viewport");
// attach an overlay to a node
overlays.add("SCAN_OK", "note", {
position: {
bottom: 0,
right: 0,
},
html: '<div class="diagram-note">Mixed up the labels?</div>',
});
// add marker
canvas.addMarker("SCAN_OK", "needs-discussion");
} catch (err) {
console.error("could not import BPMN 2.0 diagram", err);
}
}
// trying to use the python variable bpmn_xml directly causes the xml to have escape sequences
// and using the meta tag seems to help with that
var bpmn_xml = $("#bpmn_xml").data();
openDiagram(bpmn_xml.name);
// wire save button
$("#save-button").click(exportDiagram);
</script>
{% endblock %}

View File

@ -1,12 +1,13 @@
"""Test Permissions."""
from flask.app import Flask
from flask_bpmn.models.db import db
# from tests.spiffworkflow_backend.helpers.test_data import find_or_create_process_group
from tests.spiffworkflow_backend.helpers.test_data import find_or_create_user
from spiffworkflow_backend.models.principal import PrincipalModel
# from tests.spiffworkflow_backend.helpers.test_data import find_or_create_process_group
# from spiffworkflow_backend.models.permission_assignment import PermissionAssignmentModel
# from spiffworkflow_backend.models.permission_target import PermissionTargetModel
from spiffworkflow_backend.models.principal import PrincipalModel
def test_user_can_be_given_permission_to_administer_process_group(app: Flask) -> None:

11
wsgi.py
View File

@ -7,19 +7,20 @@ from spiffworkflow_backend import create_app
app = create_app()
if __name__ == "__main__":
def no_app(environ, start_response):
return NotFound()(environ, start_response)
# Remove trailing slash, but add leading slash
base_url = '/' + app.config['APPLICATION_ROOT'].strip('/')
routes = {'/': app.wsgi_app}
base_url = "/" + app.config["APPLICATION_ROOT"].strip("/")
routes = {"/": app.wsgi_app}
if base_url != '/':
if base_url != "/":
routes[base_url] = app.wsgi_app
app.wsgi_app = DispatcherMiddleware(no_app, routes)
app.wsgi_app = ProxyFix(app.wsgi_app)
flask_port = app.config['FLASK_PORT']
flask_port = app.config["FLASK_PORT"]
app.run(host='0.0.0.0', port=flask_port)
app.run(host="0.0.0.0", port=flask_port)