Skip to content

Commit

Permalink
Merge branch 'master' into dockerfile-deploy-poetry
Browse files Browse the repository at this point in the history
  • Loading branch information
jbothma committed Aug 18, 2023
2 parents 9ea303e + 09eb666 commit 63b6e6e
Show file tree
Hide file tree
Showing 233 changed files with 9,504 additions and 2,055 deletions.
2 changes: 1 addition & 1 deletion .buildpacks
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
https://github.com/heroku/heroku-buildpack-nodejs.git#v175
https://github.com/heroku/heroku-buildpack-python.git#v192
https://github.com/heroku/heroku-buildpack-python.git#v224
23 changes: 9 additions & 14 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,13 @@ jobs:

steps:
- uses: actions/checkout@v2
- name: Set up Python 3.6
uses: actions/setup-python@v2
with:
python-version: 3.6


- uses: actions/setup-node@v2
with:
node-version: "13.14.0"
- name: Install test dependencies

- name: Build frontend assets
run: |
python -m pip install --upgrade pip
pip install black==19.10b0
npm install -g [email protected]
yarn
yarn build
Expand All @@ -38,10 +32,11 @@ jobs:

- name: Run tests
run: |
docker-compose run --rm test python manage.py collectstatic --no-input
docker-compose run --rm test
black --check --diff budgetportal manage.py discourse
docker-compose run --rm app python manage.py collectstatic --no-input
docker-compose run --rm -e DJANGO_Q_SYNC=TRUE app python manage.py test
docker-compose run --rm app black --check --diff budgetportal manage.py discourse performance iym
- name: Dump dependency logs for debugging
if: ${{ failure() }}
run: |
docker-compose logs db solr minio
docker-compose logs db solr minio selenium
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,6 @@ ghostdriver.log
.idea/
.DS_Store
dbdump

.env
/*.csv
13 changes: 0 additions & 13 deletions Dockerfile-test

This file was deleted.

9 changes: 6 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,10 @@ docker-compose run --rm app python manage.py makemigrations
#### Python/Django

* Get better debugging with ``python manage.py runserver_plus``
* Format your code using Black: `budgetportal manage.py discours --exclude budgetportal/bulk_upload.py`
* Format your code using Black (See version in github actions):

docker-compose run --rm app black budgetportal manage.py discourse performance


#### React stuff (package.json and packages/webapp/package.json)

Expand Down Expand Up @@ -307,13 +310,13 @@ Running tests
All tests

```
docker-compose run --rm test
docker-compose run --rm app python manage.py test
```

Specific tests, e.g.

```
docker-compose run --rm test python manage.py test budgetportal.tests.test_bulk_upload.BulkUploadTestCase
docker-compose run --rm app python manage.py test budgetportal.tests.test_bulk_upload.BulkUploadTestCase
```

Production deployment
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { h, Component } from 'preact';
import React from 'react';
import Chart from 'chart.js';
import PropTypes from 'prop-types';

Expand All @@ -7,120 +7,124 @@ import downloadChart from './services/downloadChart/index.js';


const buildDownloadButton = downloadAction => (
<div className="BarChart-button">
<button
className="Button is-small is-inline is-secondary"
onClick={downloadAction}
>
Download chart
</button>
</div>
<div className="BarChart-button">
<button
className="Button is-small is-inline is-secondary"
onClick={downloadAction}
>
Download chart
</button>
</div>
);


const Markup = ({ renderChart, height, downloadAction, rotated }) => {
return (
<div className="BarChart">
<div className="BarChart-chart">
<canvas ref={renderChart} style={{ width: '100%', height: `${rotated ? 350 : height}px` }} />
</div>
{/* {buildDownloadButton(downloadAction)} */}
</div>
);
const Markup = ({renderChart, height, downloadAction, rotated}) => {
return (
<div className="BarChart">
<div className="BarChart-chart">
<canvas ref={renderChart} style={{width: '100%', height: `${rotated ? 350 : height}px`}}/>
</div>
{/* {buildDownloadButton(downloadAction)} */}
</div>
);
};


Markup.propTypes = {
renderChart: PropTypes.func.isRequired,
height: PropTypes.number.isRequired,
downloadAction: PropTypes.func.isRequired,
renderChart: PropTypes.func.isRequired,
height: PropTypes.number.isRequired,
downloadAction: PropTypes.func.isRequired,
};


class BarChart extends Component {
constructor(...props) {
super(...props);
const { items, color, rotated, viewportWidth, barTypes } = this.props;
class BarChart extends React.Component {
constructor(...props) {
super(...props);
const {items, color, rotated, viewportWidth, barTypes} = this.props;

const calcHeight = (scale) => {
const config = createChartJsConfig({ items, color, rotated, viewportWidth, barTypes });
return (config.data.datasets[0].data.length * (25 * scale)) + 55;
};
const calcHeight = (scale) => {
const config = createChartJsConfig({items, color, rotated, viewportWidth, barTypes});
return (config.data.datasets[0].data.length * (25 * scale)) + 55;
};


this.values = {
node: null,
chartInstance: null,
};
this.values = {
node: null,
chartInstance: null,
};

this.events = {
renderChart: this.renderChart.bind(this),
downloadAction: this.downloadAction.bind(this),
calcHeight,
};
}
this.events = {
renderChart: this.renderChart.bind(this),
downloadAction: this.downloadAction.bind(this),
calcHeight,
};

componentDidUpdate() {
const { chartInstance } = this.values;
const { items, color, rotated, barTypes } = this.props;

const viewportWidth = window.innerWidth;
const config = createChartJsConfig({ items, color, rotated, viewportWidth, barTypes });
this.state = {
node: null
}
}

config.data.datasets.forEach(({ data }, index) => {
chartInstance.data.datasets[index].data = data;
});
componentDidUpdate() {
const {chartInstance} = this.values;
const {items, color, rotated, barTypes} = this.props;

return chartInstance.update();
}
const viewportWidth = window.innerWidth;
const config = createChartJsConfig({items, color, rotated, viewportWidth, barTypes});

downloadAction(event) {
event.preventDefault();
const { items, color, rotated, downloadText, barTypes, source } = this.props;
const config = createChartJsConfig({ items, color, rotated, barTypes });
const { calcHeight } = this.events;
const height = calcHeight(2);
config.data.datasets.forEach(({data}, index) => {
chartInstance.data.datasets[index].data = data;
});

const canvas = document.createElement('canvas');
const container = document.createElement('div');
container.appendChild(canvas);
document.body.appendChild(container);
return chartInstance.update();
}

container.style.position = 'fixed';
container.style.top = '200%';
container.style.width = '800px';
canvas.height = height;
canvas.style.height = `${height}px`;
downloadAction(event) {
event.preventDefault();
const {items, color, rotated, downloadText, barTypes, source} = this.props;
const config = createChartJsConfig({items, color, rotated, barTypes});
const {calcHeight} = this.events;
const height = calcHeight(2);

const canvas = document.createElement('canvas');
const container = document.createElement('div');
container.appendChild(canvas);
document.body.appendChild(container);

container.style.position = 'fixed';
container.style.top = '200%';
container.style.width = '800px';
canvas.height = height;
canvas.style.height = `${height}px`;

new Chart(canvas, config);
downloadChart({canvas, height, downloadText, source});
}

new Chart(canvas, config);
downloadChart({ canvas, height, downloadText, source });
}
renderChart(newNode) {
const {items, color, rotated, barTypes} = this.props;
const {node} = this.values;

renderChart(newNode) {
const { items, color, rotated, barTypes } = this.props;
const { node } = this.values;
const viewportWidth = window.innerWidth;
const config = createChartJsConfig({items, color, rotated, viewportWidth, barTypes});
this.values.chartInstance = new Chart(node || newNode, config);

const viewportWidth = window.innerWidth;
const config = createChartJsConfig({ items, color, rotated, viewportWidth, barTypes });
this.values.chartInstance = new Chart(node || newNode, config);
if (!node) {
this.values.node = newNode;
}

if (!node) {
this.values.node = newNode;
return null;
}

return null;
}

render() {
const {renderChart, downloadAction} = this.events;
const {node} = this.state;
const {scale, rotated} = this.props;
const {calcHeight} = this.events;

render() {
const { renderChart, downloadAction } = this.events;
const { node } = this.state;
const { scale, rotated } = this.props;
const { calcHeight } = this.events;

const height = calcHeight(scale);
return <Markup button {...{ downloadAction, renderChart, height, node, rotated }} />;
}
const height = calcHeight(scale);
return <Markup button {...{downloadAction, renderChart, height, node, rotated}} />;
}
}


Expand Down
4 changes: 2 additions & 2 deletions assets/js/components/ChartSourceController/index.jsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { h, Component } from 'preact';
import React from 'react';
import uuid from 'uuid/v4';
import BarChart from './components/BarChart/index.jsx';

Expand Down Expand Up @@ -49,7 +49,7 @@ const Markup = ({ items, toggle, styling, changeSource, source, downloadText, ba
};


class ChartSourceController extends Component {
class ChartSourceController extends React.Component {
constructor(...props) {
super(...props);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { h, Component, render } from 'preact';
import React from 'react';

function skeletonResources() {
return (
Expand Down Expand Up @@ -87,7 +87,7 @@ function isCollapsable(resources) {
return resources.length > 3;
}

export default class GovernmentResources extends Component {
export default class GovernmentResources extends React.Component {
constructor(props) {
super(props);

Expand Down
2 changes: 1 addition & 1 deletion assets/js/components/Icon/index.jsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { h } from 'preact';
import React from 'react';
import Close from './partials/Close.jsx';
import Download from './partials/Download.jsx';
import Facebook from './partials/Facebook.jsx';
Expand Down
2 changes: 1 addition & 1 deletion assets/js/components/Icon/partials/Close.jsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { h } from 'preact';
import React from 'react';
import createSizeModifier from './createSizeModifier.js';


Expand Down
2 changes: 1 addition & 1 deletion assets/js/components/Icon/partials/Dataset.jsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { h } from 'preact';
import React from 'react';
import createSizeModifier from './createSizeModifier.js';


Expand Down
2 changes: 1 addition & 1 deletion assets/js/components/Icon/partials/Date.jsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { h } from 'preact';
import React from 'react';
import createSizeModifier from './createSizeModifier.js';


Expand Down
2 changes: 1 addition & 1 deletion assets/js/components/Icon/partials/Download.jsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { h } from 'preact';
import React from 'react';
import createSizeModifier from './createSizeModifier.js';


Expand Down
2 changes: 1 addition & 1 deletion assets/js/components/Icon/partials/Facebook.jsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { h } from 'preact';
import React from 'react';
import createSizeModifier from './createSizeModifier.js';


Expand Down
2 changes: 1 addition & 1 deletion assets/js/components/Icon/partials/Guide.jsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { h } from 'preact';
import React from 'react';
import createSizeModifier from './createSizeModifier.js';


Expand Down
2 changes: 1 addition & 1 deletion assets/js/components/Icon/partials/Hamburger.jsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { h } from 'preact';
import React from 'react';
import createSizeModifier from './createSizeModifier.js';


Expand Down
2 changes: 1 addition & 1 deletion assets/js/components/Icon/partials/Home.jsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { h } from 'preact';
import React from 'react';
import createSizeModifier from './createSizeModifier.js';


Expand Down
Loading

0 comments on commit 63b6e6e

Please sign in to comment.