Commit e271b6cf authored by Mathias Stelzer's avatar Mathias Stelzer

init

parents
Pipeline #825 failed with stages
in 2 minutes and 20 seconds
[run]
branch = True
source = model_permissions
omit =
*/model_permissions/version.py
[paths]
source =
src/model_permissions
.tox/*/lib/python*/site-packages/model_permissions
.tox/pypy*/site-packages/model_permissions
[report]
# number of digits after the decimal point
precision = 2
ignore_errors = False
exclude_lines =
def __repr__
*.egg-info
*.log
*.pyc
*.sqlite3?
*.swp
.coverage
.eggs/
.idea/
.pybuild
.tox/
build/
debian/*.debhelper*
debian/*.substvars
debian/debhelper-build-stamp
debian/files
debian/django-model-permissions
debian/watch
dist/
docs/_build/
htmlcov/
venv/
stages:
- test
- test-built
- deploy
variables: &variables
PROJECT_NAME: django-model-permissions
NAMESPACE: knoppo
TERM: ansi
DEBIAN_FRONTEND: noninteractive
.py template: &py
image: python:3.6
tags:
- docker
before_script:
- pip install invoke
######################################################################
# test
.test-py template: &test-py
<<: *py
services:
- postgres
variables:
<<: *variables
POSTGRES_DB: postgres
POSTGRES_USER: postgres
POSTGRES_PASSWORD: ""
before_script:
- pip install tox
script:
- tox --skip-interpreters
artifacts:
paths:
- .coverage.*
test-py34:
<<: *test-py
image: python:3.4
test-py35:
<<: *test-py
image: python:3.5
test-py36:
<<: *test-py
image: python:3.6
test-py37:
<<: *test-py
image: python:3.7
lint:
<<: *py
script:
- inv lint
docs:
<<: *py
script:
- inv docs
artifacts:
paths:
- docs/_build/html
.build-deb template: &build-deb
tags:
- docker
dependencies: []
script:
- apt-get update -qqy
- apt-get install python3-pip
- pip3 install invoke
- inv build
artifacts:
name: '${PROJECT_NAME}_debian'
paths:
- 'build/${PROJECT_NAME}_*'
build-deb-oldstable:
<<: *build-deb
image: debian:oldstable
build-deb-stable:
<<: *build-deb
image: debian:stable
build-deb-testing:
<<: *build-deb
image: debian:testing
build-deb-unstable:
<<: *build-deb
image: debian:unstable
######################################################################
# test-built
coverage:
<<: *py
stage: test-built
dependencies:
- test-py34
- test-py35
- test-py36
- test-py37
script:
- cd tests
- pip install coverage
- coverage combine
- coverage html
- coverage report
artifacts:
paths:
- tests/htmlcov/
coverage: '/^TOTAL[\s\d]+\s+(\d+.\d+\%)\s*$/'
when: always
.test-built-deb template: &test-built-deb
stage: test-built
tags:
- docker
script:
- apt-get update -qqy
- apt-get install -qqy gdebi
- 'gdebi --non-interactive packaging/python-${PROJECT_NAME}_*.deb'
- apt-get purge -qqy python-${PROJECT_NAME}
- 'gdebi --non-interactive packaging/python3-${PROJECT_NAME}_*.deb'
- apt-get purge -qqy python3-${PROJECT_NAME}
test-deb-oldstable:
<<: *test-built-deb
image: debian:oldstable
dependencies:
- build-deb-oldstable
test-deb-stable:
<<: *test-built-deb
image: debian:stable
dependencies:
- build-deb-stable
test-deb-testing:
<<: *test-built-deb
image: debian:testing
dependencies:
- build-deb-testing
test-deb-unstable:
<<: *test-built-deb
image: debian:unstable
dependencies:
- build-deb-unstable
######################################################################
# deploy
meta:
stage: deploy
tags:
- docker
image: knoppo/docker-publisher
dependencies:
- docs
- coverage
script:
- eval $(ssh-agent -s)
- ssh-add <(echo "$SSH_PRIVATE_KEY")
- mkdir -p ~/.ssh
- '[[ -f /.dockerenv ]] && echo -e "Host rolln.de\n\tStrictHostKeyChecking no\n\n" > ~/.ssh/config'
- ssh publisher@rolln.de "mkdir -p ~/coverage/${NAMESPACE}/${PROJECT_NAME}/${CI_BUILD_REF_NAME}/"
- '[[ ! -d tests/htmlcov ]] || rsync -az --delete tests/htmlcov/ publisher@rolln.de:coverage/${NAMESPACE}/${PROJECT_NAME}/${CI_BUILD_REF_NAME}/'
- ssh publisher@rolln.de "mkdir -p ~/docs/${NAMESPACE}/${PROJECT_NAME}/${CI_BUILD_REF_NAME}/"
- '[[ ! -d docs/_build/html ]] || rsync -az --delete --exclude=test_files.tar.gz docs/_build/html/ publisher@rolln.de:docs/${NAMESPACE}/${PROJECT_NAME}/${CI_BUILD_REF_NAME}/'
when: always
deb:
stage: deploy
tags:
- docker
image: knoppo/docker-publisher
dependencies:
- build-deb-unstable
script:
- eval $(ssh-agent -s)
- ssh-add <(echo "$SSH_APT_KEY")
- mkdir -p ~/.ssh
- '[[ -f /.dockerenv ]] && echo -e "Host rolln.de\n\tStrictHostKeyChecking no\n\n" > ~/.ssh/config'
# - ssh apt@rolln.de "reprepro -b repos/debian remove unstable python3-${PROJECT_NAME}"
- scp packaging/python3-${PROJECT_NAME}_* apt@rolln.de:repos/debian/incoming/
- ssh apt@rolln.de "reprepro -b repos/debian processincoming default"
# # run this job for tags on master
# only:
# - tags # all tags
# except:
# - /^(?!(master)$).*$/ # except NOT master
This diff is collapsed.
include LICENSE.txt README.rst
recursive-include src/model_permissions *.py
########################
django-model-permissions
########################
|pipeline|_ |coverage|_
Code: https://rolln.de/knoppo/django-model-permissions/
Documentation: https://docs.rolln.de/knoppo/django-model-permissions/master/
.. |pipeline| image:: https://rolln.de/knoppo/django-model-permissions/badges/master/pipeline.svg
.. _pipeline: https://rolln.de/knoppo/django-model-permissions/pipelines
.. |coverage| image:: https://rolln.de/knoppo/django-model-permissions/badges/master/coverage.svg
.. _coverage: https://coverage.rolln.de/knoppo/django-model-permissions/master/
.. _license:
License
-------
Copyright (C) 2018 Mathias Stelzer
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
django-model-permissions (0.1~~pre20180713010612) experimental; urgency=low
* initial
-- Mathias Stelzer <knoppo@yuki.lan> Fri, 13 Jul 2018 01:06:12 +0200
#!/bin/sh
set -e
# source debconf stuff
. /usr/share/debconf/confmodule
if [ -f /usr/share/dbconfig-common/dpkg/config.pgsql ]; then
# source dbconfig-common stuff
. /usr/share/dbconfig-common/dpkg/config.pgsql
dbc_go django-model-permissions "$@"
fi
Source: django-model-permissions
Section: python
Priority: extra
Maintainer: Mathias Stelzer <knoppo@rolln.de>
Build-Depends: debhelper (>= 10), dh-systemd, dh-python, python3-all, python3-setuptools, python3-docutils, python3-sphinx
X-Python3-Version: >= 3.2
Standards-Version: 3.9.8
Homepage: https://rolln.de/knoppo/django-model-permissions
Package: django-model-permissions
Architecture: all
Depends: ${python3:Depends}, ${misc:Depends}, debconf (>= 0.2.2)
Description: django model object permissions
A Python/Django application that adds support for
object permissions.
Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
Upstream-Name: django-model-permissions
Source: https://www.rolln.de/knoppo/django-model-permissions
Files: *
Copyright: 2018 Mathias Stelzer <knoppo@rolln.de>
License: GPL-3.0+
License: GPL-3.0+
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
.
This package is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
.
On Debian systems, the complete text of the GNU General
Public License version 3 can be found in "/usr/share/common-licenses/GPL-3".
#!/usr/bin/make -f
include /usr/share/dpkg/pkg-info.mk
export DH_VERBOSE = 1
export PYBUILD_NAME=django-model-permissions
export PYBUILD_DISABLE=test
%:
dh "$@" --with python3 --buildsystem=pybuild
tar-ignore = ".coverage*"
tar-ignore = ".git"
tar-ignore = ".gitignore"
tar-ignore = ".gitlab-ci.yml"
tar-ignore = ".idea"
tar-ignore = ".pybuild"
tar-ignore = ".tox"
tar-ignore = "dist"
tar-ignore = "docs"
tar-ignore = "htmlcov"
tar-ignore = "node_modules"
tar-ignore = "tasks.py"
tar-ignore = "tox.ini"
tar-ignore = "venv"
/* Highlight active element */
.viewcode-block.hash-active {
background-color: #e9e9e9 !important;
}
dl.class>dt.hash-active {
background-color: #ff9900 !important;
}
dl.attribute>dt.hash-active {
background-color: #ff6d57 !important;
}
dl.method>dt.hash-active {
background-color: #ff6d57 !important;
}
/*
link reference color to distinguish nicely
*/
a.reference>code {
color: #2980B9 !important;
}
a.reference>code:hover {
text-decoration: underline;
}
function highlightHash() {
$('.hash-active').removeClass('hash-active');
var hash = location.hash.slice(1);
$("[id='" + hash + "'").addClass('hash-active');
}
$(document).ready(highlightHash);
$('a').on('click', function() {setTimeout(highlightHash, 10)});
This diff is collapsed.
.. _development:
###########
Development
###########
First, get a copy of the project:
.. code-block:: bash
cd ~/my_projects # or whatever
git clone https://rolln.de/knoppo/django-model-permissions.git
cd django-model-permissions
.. tip:: You don't need invoke_ or a virtualenv_ if you just want to run tox_. It runs each
environment in its own virtualenv. For anything else its highly recommended to create a
virtualenv!
invoke
------
The easiest way to manage your development environment is to use invoke_. Install it into your
global site-packages by running ``pip install invoke`` as root. Then use ``inv -l`` in the
git repository root to list available tasks.
virtualenv
----------
Install virtualenv_:
.. code-block:: bash
sudo pip install virtualenv
.. tabs::
.. group-tab:: invoke
.. code-block:: bash
inv develop
.. group-tab:: manual
.. code-block:: bash
virtualenv venv
. venv/bin/activate
python setup.py develop
virtualenvwrapper
-----------------
Install virtualenvwrappper_: http://virtualenvwrapper.readthedocs.io/en/latest/install.html#installation
.. tabs::
.. group-tab:: invoke
.. code-block:: bash
inv develop -w
.. group-tab:: manual
.. code-block:: bash
mkvirtualenv --python=/usr/bin/python3 django-model-permissions
setvirtualenvproject
python setup.py develop
Tests
=====
.. tabs::
.. group-tab:: invoke
.. code-block:: bash
inv test
.. group-tab:: tox
The tox_ test matrix is updated regularly and runs the test-suite against sqlite_,
postgresql_ and current django_ versions on all installed python interpreters
(except python2_). See `tox.ini` or run ``tox -l`` in the repository for the current
test matrix.
.. code-block:: bash
pip install tox
tox --skip-missing-interpreters
.. group-tab:: manual
.. note:: You'll want to create a virtualenv first! The tests have some dependencies which
will clutter your global site-packages, otherwise.
.. code-block:: bash
cd tests/
python manage.py test -v 2
Running specific tests
----------------------
* Use the ``-e`` argument to run only one of the environments in the test matrix:
.. code-block:: bash
tox -e py35-django21-sqlite
* Use the ``--tag`` argument to run only tests decorated with a specific :func:`django.test.tag`:
First, decorate a class or a test function:
.. code-block:: python
from django.test import tag
@tag('debug')
class SomeTestCase(unittest.TestCase):
@tag('debug')
def test_xyz(self):
pass
.. tabs::
.. group-tab:: invoke
.. code-block:: bash
inv test -a "--tag debug"
.. group-tab:: tox
.. code-block:: bash
tox -- --tag debug
.. group-tab:: manual
.. code-block:: bash
cd tests/
python manage.py test --tag debug
* Combine the two above to run one test in one *tox* environment:
.. code-block:: bash
tox -e py35-django21-sqlite -- --tag debug
lint
====
.. tabs::
.. group-tab:: invoke
.. code-block:: bash
inv lint
.. group-tab:: manual
.. code-block:: bash
pip install -r tests/lint_requirements.txt
flake8 --statistics --count
Render the documentation
========================
.. tabs::
.. group-tab:: invoke
.. code-block:: bash
inv docs
.. group-tab:: manual
.. code-block:: bash
cd docs/
pip install -r requirements.txt
sphinx-build -b html . _build/html
makemigrations
==============
To create new migrations for the app run:
.. tabs::
.. group-tab:: invoke
.. code-block:: bash
inv makemigrations
.. group-tab:: manual
The test project is used to create migrations:
.. code-block:: bash
cd tests/
python manage.py migrate
python manage.py makemigrations model_permissions
python manage.py migrate
.. _django: https://www.djangoproject.com/
.. _postgresql: https://www.postgresql.org/
.. _python2: https://docs.python.org/2/
.. _sqlite: https://www.sqlite.org/
.. _tox: https://tox.readthedocs.io/en/latest/
.. _virtualenv: https://virtualenv.pypa.io/en/stable/
.. _invoke: http://www.pyinvoke.org/
.. _virtualenvwrappper: http://virtualenvwrapper.readthedocs.io/en/latest/
.. _Python: https://python.org/
###################
|project| |version|
###################
.. include:: ../README.rst
:start-line: 4
:end-before: License
Documentation Contents
======================
.. toctree::
:maxdepth: 2
quickstart
manual
development
modules/index
Indices and tables
==================
* :ref:`genindex`
* :ref:`modindex`
* :ref:`search`