Skip to content

Commit

Permalink
Peripheral: expanding django compatibility (#18)
Browse files Browse the repository at this point in the history
* Peripheral: expanding django compatibility

* Peripheral: remove django debug toolbar from example

* Peripheral: remove django debug toolbar from example

* Version: 0.7.0 -> 0.8.0

* Peripheral: Remove travis.ci
  • Loading branch information
madisona authored Jan 23, 2023
1 parent 0800034 commit faa4ccc
Show file tree
Hide file tree
Showing 10 changed files with 94 additions and 50 deletions.
40 changes: 40 additions & 0 deletions .github/workflows/django.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: Django CI

on:
push:
branches: [ master ]
pull_request:
branches: [ master ]

jobs:
build:

runs-on: ubuntu-latest
strategy:
fail-fast: false
max-parallel: 4
matrix:
python-version: ['3.8', '3.9', '3.10']
django-version: ['2.2', '3.2', '4.0']
include:
- python-version: '3.7'
django-version: '2.2'
- python-version: '3.7'
django-version: '3.2'

steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Install Dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements/test.txt
pip install -q Django==${{ matrix.django-version }}
- name: Run Tests
run: |
coverage run --source=contact_form example/manage.py test
coverage report --show-missing
flake8 contact_form --max-line-length=120 --max-complexity=4
31 changes: 31 additions & 0 deletions .github/workflows/python-publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# This workflow will upload a Python Package using Twine when a release is created
# For more information see: https://help.github.com/en/actions/language-and-framework-guides/using-python-with-github-actions#publishing-to-package-registries

name: Upload Python Package

on:
release:
types: [created]

jobs:
deploy:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
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: ${{ secrets.PYPI_USERNAME }}
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
run: |
python setup.py sdist bdist_wheel
twine upload dist/*
32 changes: 0 additions & 32 deletions .travis.yml

This file was deleted.

2 changes: 1 addition & 1 deletion contact_form/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@

VERSION = '0.7.0'
VERSION = '0.8.0'
8 changes: 7 additions & 1 deletion contact_form/forms.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
import django

from django import forms
from django.conf import settings
from django.core.mail.message import EmailMessage
from django.template import loader
from django.utils.translation import ugettext_lazy as _

if django.get_version() >= '3.0.0':
from django.utils.translation import gettext_lazy as _
else:
from django.utils.translation import ugettext_lazy as _


class BaseEmailFormMixin(object):
Expand Down
7 changes: 6 additions & 1 deletion contact_form/urls.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
from django.conf.urls import url
import django

if django.get_version() >= '2.0.0':
from django.urls import re_path as url
else:
from django.conf.urls import url

from contact_form import views, forms

Expand Down
9 changes: 0 additions & 9 deletions example/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,6 @@
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'debug_toolbar.middleware.DebugToolbarMiddleware',
)

ROOT_URLCONF = 'example.urls'
Expand Down Expand Up @@ -132,7 +131,6 @@

'django.contrib.admin',

'debug_toolbar',
'contact_form',
)

Expand All @@ -158,10 +156,3 @@
},
}
}

# debug_toolbar
INTERNAL_IPS = ('127.0.0.1',)

DEBUG_TOOLBAR_CONFIG = {
'INTERCEPT_REDIRECTS': False,
}
11 changes: 8 additions & 3 deletions example/urls.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@

import debug_toolbar
from django.conf.urls import url, include
import django

if django.get_version() >= '2.0.0':
from django.urls import re_path as url
from django.urls import include
else:
from django.conf.urls import url, include

from django.contrib import admin
admin.autodiscover()


urlpatterns = [
url(r'^contact/', include('contact_form.urls', namespace='contact_form')),
url(r'^admin/', admin.site.urls),
url(r'^__debug__/', include(debug_toolbar.urls)),
]
1 change: 0 additions & 1 deletion requirements/test.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@

coverage
django-debug-toolbar
flake8
mock
3 changes: 1 addition & 2 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
from setuptools import setup, find_packages

REQUIREMENTS = (
'django>=1.11,<3',
'django>=2.2',
)
TEST_REQUIREMENTS = (
'mock',
'django-debug-toolbar',
)

from contact_form import VERSION
Expand Down

0 comments on commit faa4ccc

Please sign in to comment.