mirror of
https://github.com/jazzband/django-authority.git
synced 2026-05-01 20:24:44 +00:00
commit
bcb3216dd1
9 changed files with 137 additions and 33 deletions
53
.github/workflows/release.yml
vendored
Normal file
53
.github/workflows/release.yml
vendored
Normal file
|
|
@ -0,0 +1,53 @@
|
|||
name: Release
|
||||
|
||||
on:
|
||||
push:
|
||||
tags:
|
||||
- '*'
|
||||
|
||||
jobs:
|
||||
build:
|
||||
if: github.repository == 'jazzband/django-authority'
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Set up Python
|
||||
uses: actions/setup-python@v2
|
||||
with:
|
||||
python-version: 3.8
|
||||
|
||||
- name: Get pip cache dir
|
||||
id: pip-cache
|
||||
run: |
|
||||
echo "::set-output name=dir::$(pip cache dir)"
|
||||
|
||||
- name: Cache
|
||||
uses: actions/cache@v2
|
||||
with:
|
||||
path: ${{ steps.pip-cache.outputs.dir }}
|
||||
key: release-${{ hashFiles('**/setup.py') }}
|
||||
restore-keys: |
|
||||
release-
|
||||
|
||||
- name: Install dependencies
|
||||
run: |
|
||||
python -m pip install -U pip
|
||||
python -m pip install -U setuptools twine wheel
|
||||
|
||||
- name: Build package
|
||||
run: |
|
||||
python setup.py --version
|
||||
python setup.py sdist --format=gztar bdist_wheel
|
||||
twine check dist/*
|
||||
|
||||
- name: Upload packages to Jazzband
|
||||
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags')
|
||||
uses: pypa/gh-action-pypi-publish@master
|
||||
with:
|
||||
user: jazzband
|
||||
password: ${{ secrets.JAZZBAND_RELEASE_KEY }}
|
||||
repository_url: https://jazzband.co/projects/django-authority/upload
|
||||
48
.github/workflows/test.yml
vendored
Normal file
48
.github/workflows/test.yml
vendored
Normal file
|
|
@ -0,0 +1,48 @@
|
|||
name: Test
|
||||
|
||||
on: [push, pull_request]
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
fail-fast: false
|
||||
max-parallel: 5
|
||||
matrix:
|
||||
python-version: ['2.7', '3.6', '3.7', '3.8']
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
|
||||
- name: Set up Python ${{ matrix.python-version }}
|
||||
uses: actions/setup-python@v2
|
||||
with:
|
||||
python-version: ${{ matrix.python-version }}
|
||||
|
||||
- name: Get pip cache dir
|
||||
id: pip-cache
|
||||
run: |
|
||||
echo "::set-output name=dir::$(pip cache dir)"
|
||||
|
||||
- name: Cache
|
||||
uses: actions/cache@v2
|
||||
with:
|
||||
path: ${{ steps.pip-cache.outputs.dir }}
|
||||
key:
|
||||
${{ matrix.python-version }}-v1-${{ hashFiles('**/setup.py') }}
|
||||
restore-keys: |
|
||||
${{ matrix.python-version }}-v1-
|
||||
|
||||
- name: Install dependencies
|
||||
run: |
|
||||
python -m pip install --upgrade pip
|
||||
python -m pip install --upgrade tox tox-gh-actions
|
||||
|
||||
- name: Tox tests
|
||||
run: |
|
||||
tox -v
|
||||
|
||||
- name: Upload coverage
|
||||
uses: codecov/codecov-action@v1
|
||||
with:
|
||||
name: Python ${{ matrix.python-version }}
|
||||
24
.travis.yml
24
.travis.yml
|
|
@ -1,24 +0,0 @@
|
|||
language: python
|
||||
dist: xenial
|
||||
python:
|
||||
- 2.7
|
||||
- 3.7
|
||||
cache: pip
|
||||
install: pip install tox-travis codecov
|
||||
script: tox -v
|
||||
after_success: codecov
|
||||
jobs:
|
||||
fast_finish: true
|
||||
include:
|
||||
- stage: deploy
|
||||
python: 3.7
|
||||
deploy:
|
||||
provider: pypi
|
||||
user: jazzband
|
||||
server: https://jazzband.co/projects/django-authority/upload
|
||||
distributions: sdist bdist_wheel
|
||||
password:
|
||||
secure: TZJdf9naBzdkE+HDyhtoCIIc0ddEXLWW/VUD975gJUWQpOA69h4ZjCCQ6z21AZdrWczCUh6/cOLYYSoC9OeaHqF+Jzunn3iEomvdVRsW7SX7MAxTFUENQHF3S3j8fYlqIPWvNDOgxJ/AERisMUSZkRKWIYjEInYo31RoJ1ySN0w=
|
||||
on:
|
||||
tags: true
|
||||
repo: jazzband/django-authority
|
||||
12
README.rst
12
README.rst
|
|
@ -6,8 +6,9 @@ django-authority
|
|||
:target: https://jazzband.co/
|
||||
:alt: Jazzband
|
||||
|
||||
.. image:: https://travis-ci.org/jazzband/django-authority.svg?branch=master
|
||||
:target: https://travis-ci.org/jazzband/django-authority
|
||||
.. image:: https://github.com/jazzband/django-authority/workflows/Test/badge.svg
|
||||
:target: https://github.com/jazzband/django-authority/actions
|
||||
:alt: GitHub Actions
|
||||
|
||||
.. image:: https://codecov.io/gh/jazzband/django-authority/branch/master/graph/badge.svg
|
||||
:target: https://codecov.io/gh/jazzband/django-authority
|
||||
|
|
@ -57,6 +58,13 @@ html version using the setup.py::
|
|||
Changelog:
|
||||
==========
|
||||
|
||||
0.15 (unreleased):
|
||||
------------------
|
||||
|
||||
* Moved CI to GitHub Actions.
|
||||
* Add Django 3.0 and 3.1 support.
|
||||
* Add Python 3.6 and 3.8 support.
|
||||
|
||||
0.14 (2020-02-07):
|
||||
------------------
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
from django import forms
|
||||
from django.http import HttpResponseRedirect
|
||||
from django.utils.translation import ugettext, ungettext, ugettext_lazy as _
|
||||
from django.shortcuts import render_to_response
|
||||
from django.shortcuts import render
|
||||
from django.utils.safestring import mark_safe
|
||||
from django.forms.formsets import all_valid
|
||||
from django.contrib import admin
|
||||
|
|
@ -127,7 +127,7 @@ def edit_permissions(modeladmin, request, queryset):
|
|||
"admin/permission_change_form.html",
|
||||
],
|
||||
)
|
||||
return render_to_response(template_name, context, request)
|
||||
return render(request, template_name, context)
|
||||
|
||||
|
||||
edit_permissions.short_description = _(
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@ import inspect
|
|||
from django.http import HttpResponseRedirect
|
||||
from django.utils.http import urlquote
|
||||
from django.utils.functional import wraps
|
||||
from django.utils.six import string_types
|
||||
from django.db.models import Model
|
||||
from django.apps import apps
|
||||
from django.shortcuts import get_object_or_404
|
||||
|
|
@ -13,6 +12,12 @@ from authority.utils import get_check
|
|||
from authority.views import permission_denied
|
||||
|
||||
|
||||
try:
|
||||
basestring
|
||||
except NameError:
|
||||
basestring = str
|
||||
|
||||
|
||||
def permission_required(perm, *lookup_variables, **kwargs):
|
||||
"""
|
||||
Decorator for views that checks whether a user has a particular permission
|
||||
|
|
@ -27,7 +32,7 @@ def permission_required(perm, *lookup_variables, **kwargs):
|
|||
if request.user.is_authenticated:
|
||||
params = []
|
||||
for lookup_variable in lookup_variables:
|
||||
if isinstance(lookup_variable, string_types):
|
||||
if isinstance(lookup_variable, basestring):
|
||||
value = kwargs.get(lookup_variable, None)
|
||||
if value is None:
|
||||
continue
|
||||
|
|
@ -37,7 +42,7 @@ def permission_required(perm, *lookup_variables, **kwargs):
|
|||
value = kwargs.get(varname, None)
|
||||
if value is None:
|
||||
continue
|
||||
if isinstance(model, string_types):
|
||||
if isinstance(model, basestring):
|
||||
model_class = apps.get_model(*model.split("."))
|
||||
else:
|
||||
model_class = model
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
from django.shortcuts import render_to_response, get_object_or_404
|
||||
from django.shortcuts import render, get_object_or_404
|
||||
from django.http import HttpResponseRedirect, HttpResponseForbidden
|
||||
from django.apps import apps
|
||||
from django.utils.translation import ugettext as _
|
||||
|
|
@ -78,7 +78,7 @@ def add_permission(
|
|||
}
|
||||
if extra_context:
|
||||
context.update(extra_context)
|
||||
return render_to_response(template_name, context, request)
|
||||
return render(request, template_name, context)
|
||||
|
||||
|
||||
@login_required
|
||||
|
|
|
|||
2
setup.py
2
setup.py
|
|
@ -30,7 +30,9 @@ setup(
|
|||
"Programming Language :: Python :: 2",
|
||||
"Programming Language :: Python :: 2.7",
|
||||
"Programming Language :: Python :: 3",
|
||||
"Programming Language :: Python :: 3.6",
|
||||
"Programming Language :: Python :: 3.7",
|
||||
"Programming Language :: Python :: 3.8",
|
||||
"Framework :: Django",
|
||||
],
|
||||
install_requires=["django"],
|
||||
|
|
|
|||
12
tox.ini
12
tox.ini
|
|
@ -5,6 +5,7 @@ minversion = 1.8
|
|||
envlist =
|
||||
py27-dj111
|
||||
py37-dj{111,22}
|
||||
{py36,py37,py38}-dj{30,31}
|
||||
py37-check
|
||||
|
||||
[testenv]
|
||||
|
|
@ -12,10 +13,13 @@ usedevelop = true
|
|||
commands =
|
||||
coverage run -a example/manage.py test authority exampleapp
|
||||
coverage report
|
||||
coverage xml
|
||||
deps =
|
||||
coverage
|
||||
dj111: Django>=1.11,<2.0
|
||||
dj22: Django>=2.2,<2.3
|
||||
dj30: Django>=3.0,<3.1
|
||||
dj31: Django>=3.1,<3.2
|
||||
|
||||
|
||||
[testenv:py37-check]
|
||||
|
|
@ -25,3 +29,11 @@ deps =
|
|||
commands =
|
||||
python setup.py sdist bdist_wheel
|
||||
twine check dist/*
|
||||
|
||||
|
||||
[gh-actions]
|
||||
python =
|
||||
2.7: py27
|
||||
3.6: py36
|
||||
3.7: py37
|
||||
3.8: py38
|
||||
|
|
|
|||
Loading…
Reference in a new issue