Skip to content

Commit

Permalink
Merge pull request #1 from City-of-Helsinki/YM-470-add-initial-separa…
Browse files Browse the repository at this point in the history
…ted-library

YM-470 | Add initial separated GDPR library
  • Loading branch information
charn committed Mar 15, 2021
2 parents 3044bf0 + a1cbb4b commit 4e52d73
Show file tree
Hide file tree
Showing 30 changed files with 1,201 additions and 2 deletions.
16 changes: 16 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
root = true

[*]
charset = utf-8
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true
max_line_length = 120

[*.py]
indent_style = space
indent_size = 4

[*.{json,toml,yaml,yml}]
indent_style = space
indent_size = 2
106 changes: 106 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
name: Continuous integration

on:
push:
branches: [main]
pull_request:

jobs:
test:
name: Tests
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v2

- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: 3.8

- name: Cache pip packages
uses: actions/cache@v2
env:
cache-name: cache-pip-modules
with:
path: ~/.pip-cache
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/requirements-dev.txt') }}
restore-keys: |
${{ runner.os }}-build-${{ env.cache-name }}-
${{ runner.os }}-build-
${{ runner.os }}-
- name: Install dependencies
run: |
pip install -r requirements-dev.txt codecov
pip install -e .
- name: Run tests
run: pytest -ra -vv --doctest-modules --cov=.

- name: Coverage
run: codecov

build:
name: Build package
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v1
with:
python-version: 3.8

- name: Install dependencies
run: pip install -U setuptools wheel build
- name: Build
run: python -m build .

black:
name: Coding style - black
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Run black
uses: psf/black@stable
with:
args: ". --check"

flake8:
name: Coding style - flake8
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: 3.8

- name: Install dependencies
run: pip install flake8 pep8-naming flake8-bugbear
- name: Run flake8
uses: liskin/gh-problem-matcher-wrap@v1
with:
linters: flake8
run: flake8

isort:
name: Coding style - isort
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: 3.8

- name: Install dependencies
run: pip install isort
- name: Run isort
uses: liskin/gh-problem-matcher-wrap@v1
with:
linters: isort
run: isort -c .
28 changes: 28 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: Publish to PyPI

on:
push:
tags:
- 'release-*'

jobs:
build-and-publish:
name: Build and publish
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v1
with:
python-version: 3.8

- name: Install dependencies
run: pip install -U setuptools wheel build
- name: Build
run: python -m build .
- name: Publish
uses: pypa/gh-action-pypi-publish@release/v1
with:
user: __token__
password: ${{ secrets.PYPI_API_TOKEN }}
29 changes: 29 additions & 0 deletions .github/workflows/staging.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: Publish to TestPyPI

on:
push:
branches: [main]

jobs:
build-and-publish:
name: Build and publish
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v1
with:
python-version: 3.8

- name: Install dependencies
run: pip install -U setuptools wheel build
- name: Build
run: python -m build .
- name: Publish
uses: pypa/gh-action-pypi-publish@release/v1
with:
user: __token__
password: ${{ secrets.TEST_PYPI_API_TOKEN }}
repository_url: https://test.pypi.org/legacy/
skip_existing: true
12 changes: 12 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -127,3 +127,15 @@ dmypy.json

# Pyre type checker
.pyre/

# Editors
*.stTheme.cache
*.sublime-workspace
*.tmlanguage.cache
*.tmPreferences.cache
._*
.AppleDouble
.DS_Store
.LSOverride
.idea
.vscode/settings.json
16 changes: 16 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
default_language_version:
python: python3
repos:
- repo: https://github.com/psf/black
rev: 20.8b1
hooks:
- id: black
- repo: https://gitlab.com/pycqa/flake8
rev: 3.8.4
hooks:
- id: flake8
additional_dependencies: [pep8-naming, flake8-bugbear]
- repo: https://github.com/timothycrosley/isort
rev: 5.7.0
hooks:
- id: isort
11 changes: 11 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
Contributions are accepted as pull requests. Contributions should be in line with
the best practices described in this repo. Please also observe our coding
practices at https://dev.hel.fi/.
Please make your pull requests short, elegant and only handling one
issue at a time!

If you make a pull request, you may also want to notify our developers on
[Gitter](https://gitter.im/City-of-Helsinki/heldev) to tell about your contribution.

Please also observe our [contribution handling guidelines](https://dev.hel.fi/accepting-contributions)
for contributing to City of Helsinki open source projects in general.
2 changes: 2 additions & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
include LICENSE
include README.md
53 changes: 51 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,51 @@
# helsinki-profile-gdpr-api
Django app for implementing Helsinki profile GDPR API
# Helsinki profile GDPR API

Django app for implementing Helsinki profile GDPR API.

This library will allow a service using Helsinki profile to implement the GDPR
functionality required by [open-city-profile](https://github.com/City-of-Helsinki/open-city-profile)
backend.

## Installation

1. `pip install helsinki-profile-gdpr-api`

## Usage

1. Authentication needs to be configured for the required `django-heluser`

2. Model which is to be used for GDPR operations should inherit `SerializableMixin` and
include the required `serialize_fields` property.

3. Define the following settings in your Django configuration.

| Setting | Example | Description |
|---|---|---|
| GDPR_API_MODEL | "youths.YouthProfile" | GDPR profile model in the form `app_label.model_name`. model_name is case-insensitive. |
| GDPR_API_QUERY_SCOPE | "jassariapi.gdprquery" | API scope required for the query operation. |
| GDPR_API_DELETE_SCOPE | "jassariapi.gdprdelete" | API scope required for the delete operation. |

4. Add the GDPR API urls into your url config:

```python
urlpatterns = [
...
path("gdpr-api/", include("helsinki_gdpr.urls")),
]
```

## Code format

This project uses
[`black`](https://github.com/ambv/black),
[`flake8`](https://gitlab.com/pycqa/flake8) and
[`isort`](https://github.com/timothycrosley/isort)
for code formatting and quality checking. Project follows the basic black config, without any modifications.

Basic `black` commands:

* To let `black` do its magic: `black .`
* To see which files `black` would change: `black --check .`

[`pre-commit`](https://pre-commit.com/) can be used to install and run all the formatting tools as git hooks
automatically before a commit.
Empty file added helsinki_gdpr/__init__.py
Empty file.
Loading

0 comments on commit 4e52d73

Please sign in to comment.