Skip to content
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 51 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: build

on: [push, pull_request]

jobs:
build:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: [3.6, 3.7, 3.8]
django-version: [1.9]
drf-version: [3.9, '3.10', 3.11]
include:
- python-version: 2.7
django-version: 1.11
drf-version: 3.9
- python-version: 2.7
django-version: 1.9
drf-version: 3.9
steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v1
with:
python-version: ${{ matrix.python-version }}
- name: Install Dependencies
run: |
python -m pip install --upgrade pip
echo "Python ${{ matrix.python-version }} -> Django ${{ matrix.django-version }} -> DRF ${{ matrix.drf-version }}"
python -m pip install "Django~=${{ matrix.django-version }}.0"
python -m pip install "djangorestframework~=${{ matrix.drf-version }}.0"
echo "Django: `django-admin --version`"
python --version
- name: Run Tests
run: |
python example/manage.py test tests -v 1 --noinput

flake8-linter:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- uses: grantmcconnaughey/lintly-flake8-github-action@v1.0
if: github.event_name == 'pull_request'
with:
# The GitHub API token to create reviews with
token: ${{ secrets.GITHUB_TOKEN }}
# Fail if "new" violations detected or "any", default "new"
failIf: new
# Additional arguments to pass to flake8, default "." (current directory)
args: "--extend-exclude=migrations ."
26 changes: 26 additions & 0 deletions .github/workflows/codecov.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: codecov
on: [push, pull_request]
jobs:
run:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- name: Setup Python
uses: actions/setup-python@master
with:
python-version: 3.8
- name: Generate coverage report
run: |
pip install -r requirements.txt
pip install coverage
pip install -q -e .
coverage run example/manage.py test tests -v 1 --noinput
coverage xml
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v1
with:
token: ${{ secrets.CODECOV_TOKEN }}
file: ./coverage.xml
flags: unittests
name: codecov-umbrella
fail_ci_if_error: true
30 changes: 30 additions & 0 deletions .github/workflows/pythonpublish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# This workflow will upload a Python Package using Twine when a release is created

name: Upload Python Package

on:
release:
types: [published]

jobs:
deploy:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v1
with:
python-version: '3.x'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install setuptools wheel twine
- name: Build and publish
env:
TWINE_USERNAME: '__token__'
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
run: |
python setup.py sdist bdist_wheel
twine upload --repository testpypi dist/*
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,6 @@ dist/
*.egg-info/
MANIFEST
docs/_build
/.idea
/.idea
/venv*
/env*
22 changes: 0 additions & 22 deletions .travis.yml

This file was deleted.

Empty file added example/__init__.py
Empty file.
14 changes: 9 additions & 5 deletions example/albums/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@
from rest_framework.response import Response

from rest_framework_datatables_editor.filters import DatatablesFilterBackend
from rest_framework_datatables_editor.pagination import DatatablesPageNumberPagination
from rest_framework_datatables_editor.renderers import DatatablesRenderer
from rest_framework_datatables_editor.viewsets import DatatablesEditorModelViewSet
from rest_framework_datatables_editor.pagination import (
DatatablesPageNumberPagination)
from rest_framework_datatables_editor.renderers import (DatatablesRenderer)
from rest_framework_datatables_editor.viewsets import (
DatatablesEditorModelViewSet)
from .models import Album, Artist, Genre
from .serializers import AlbumSerializer, ArtistSerializer

Expand All @@ -16,8 +18,10 @@ def index(request):

def get_album_options():
return "options", {
"artist.id": [{'label': obj.name, 'value': obj.pk} for obj in Artist.objects.all()],
"genre": [{'label': obj.name, 'value': obj.pk} for obj in Genre.objects.all()]
"artist.id": [{'label': obj.name, 'value': obj.pk}
for obj in Artist.objects.all()],
"genre": [{'label': obj.name, 'value': obj.pk}
for obj in Genre.objects.all()]
}


Expand Down
13 changes: 8 additions & 5 deletions example/example/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,18 +64,20 @@
}
}

validation = 'django.contrib.auth.password_validation'

AUTH_PASSWORD_VALIDATORS = [
{
'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
'NAME': '%s.UserAttributeSimilarityValidator' % validation,
},
{
'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
'NAME': '%s.MinimumLengthValidator' % validation,
},
{
'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
'NAME': '%s.CommonPasswordValidator' % validation,
},
{
'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
'NAME': '%s.NumericPasswordValidator' % validation,
},
]

Expand Down Expand Up @@ -105,6 +107,7 @@
'DEFAULT_FILTER_BACKENDS': (
'rest_framework_datatables_editor.filters.DatatablesFilterBackend',
),
'DEFAULT_PAGINATION_CLASS': 'rest_framework_datatables_editor.pagination.DatatablesPageNumberPagination',
'DEFAULT_PAGINATION_CLASS': 'rest_framework_datatables_editor.pagination.'
'DatatablesPageNumberPagination',
'PAGE_SIZE': 50,
}
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
django>=1.9
djangorestframework>=3.9.1
120 changes: 62 additions & 58 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,46 +1,31 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import re
import os
import sys
from setuptools import setup
import re
import subprocess
from pathlib import Path

from setuptools import setup

name = 'djangorestframework-datatables-editor'
package = 'rest_framework_datatables_editor'
description = 'Seamless integration between Django REST framework and Datatables (https://datatables.net) with supporting Datatables editor'
package_name = 'djangorestframework-datatables-editor'
folder_name = 'rest_framework_datatables_editor'
description = ('Seamless integration between Django REST framework and '
'Datatables (https://datatables.net) with supporting '
'Datatables editor')
url = 'https://github.com/VVyacheslav/django-rest-framework-datatables-editor'
author = 'Vyacheslav V.V.'
author_email = 'vvvyacheslav23@gmail.com'
license = 'MIT'


def get_version(package):
"""
Return package version as listed in `__version__` in `init.py`.
"""
with open(os.path.join(package, '__init__.py')) as fh:
return re.search(
"^__version__ = ['\"]([^'\"]+)['\"]",
fh.read(),
re.MULTILINE
).group(1)
init_py = open(os.path.join(package, '__init__.py')).read()
version_re = re.compile('^Version: (.+)$', re.M)


def get_long_description():
"""
Return rst formatted readme and changelog.
"""
ret = []
with open('README.rst') as fh:
ret.append(fh.read())
try:
with open('docs/changelog.rst') as fh:
ret.append(fh.read())
except IOError:
pass
return '\n\n'.join(ret)
""" Return rst formatted readme and changelog. """
files_to_join = ['README.rst', 'changelog.rst']
description = []
for file in files_to_join:
with open('README.rst') as f:
description.append(f.read())
return '\n\n'.join(description)


def get_packages(package):
Expand All @@ -52,43 +37,62 @@ def get_packages(package):
if os.path.exists(os.path.join(dirpath, '__init__.py'))]


def get_package_data(package):
"""
Return all files under the root package, that are not in a
package themselves.
def get_version():
"""
walk = [(dirpath.replace(package + os.sep, '', 1), filenames)
for dirpath, dirnames, filenames in os.walk(package)
if not os.path.exists(os.path.join(dirpath, '__init__.py'))]

filepaths = []
for base, filenames in walk:
filepaths.extend([os.path.join(base, filename)
for filename in filenames])
return {package: filepaths}
Reads version from git status or PKG-INFO


version = get_version(package)

if sys.argv[-1] == 'publish':
os.system("python setup.py sdist upload")
os.system("python setup.py bdist_wheel upload")
print("You probably want to also tag the version now:")
print(" git tag -a {0} -m 'version {0}'".format(version))
print(" git push --tags")
sys.exit()
https://gist.github.com/pwithnall/7bc5f320b3bdf418265a
"""
d: Path = Path(__file__).absolute().parent
git_dir = d.joinpath('.git')
if git_dir.is_dir():
# Get the version using "git describe".
cmd = 'git describe --tags --match [0-9]*'.split()
try:
version = subprocess.check_output(cmd).decode().strip()
except subprocess.CalledProcessError:
return None

# PEP 386 compatibility
if '-' in version:
version = '.post'.join(version.split('-')[:2])

# Don't declare a version "dirty" merely because a time stamp has
# changed. If it is dirty, append a ".dev1" suffix to indicate
# a development revision after the release.
with open(os.devnull, 'w') as fd_devnull:
subprocess.call(['git', 'status'],
stdout=fd_devnull, stderr=fd_devnull)

cmd = 'git diff-index --name-only HEAD'.split()
try:
dirty = subprocess.check_output(cmd).decode().strip()
except subprocess.CalledProcessError:
return None

if dirty != '':
version += '.dev1'
else:
# Extract the version from the PKG-INFO file.
try:
with open('PKG-INFO') as v:
version = version_re.search(v.read()).group(1)
except FileNotFoundError:
version = None

return version


setup(
name=name,
version=version,
name=package_name,
version=get_version() or 'dev',
url=url,
license=license,
description=description,
long_description=get_long_description(),
author=author,
author_email=author_email,
packages=get_packages(package),
packages=get_packages(folder_name),
install_requires=[
'djangorestframework>=3.9.1',
],
Expand Down
Loading