Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update supported Django versions #54

Open
wants to merge 13 commits into
base: master
Choose a base branch
from
71 changes: 44 additions & 27 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,66 +2,65 @@ name: lint and test

on:
push:
tags:
- '*'
pull_request:
branches:
- master
- develop

jobs:
lint-and-test:
runs-on: ubuntu-18.04
runs-on: ubuntu-20.04
strategy:
# By default, GitHub will maximize the number of jobs run in parallel
# depending on the available runners on GitHub-hosted virtual machines.
# max-parallel: 8
fail-fast: false
matrix:
python-version:
- "3.4"
- "3.5"
- "3.6"
- "3.7"
- "3.8"
- "3.9"
- "3.10"
django-version:
- "2.0"
- "2.1"
- "2.2" # LTS
- "3.0"
- "3.1"
- "3.2" # LTS
- "4.0"
- "4.1"
exclude:
# Python 3.4 is not compatible with Django 2.0+
- python-version: "3.4"
django-version: "2.1"
- python-version: "3.4"
django-version: "2.2"
- python-version: "3.4"
django-version: "3.0"
- python-version: "3.4"
django-version: "3.1"
- python-version: "3.4"
django-version: "3.2"
# Python 3.5 is not compatible with Django 2.2+
- python-version: "3.5"
django-version: "3.0"
- python-version: "3.5"
django-version: "3.1"
- python-version: "3.5"
django-version: "3.2"
# Python 3.8 is compatible with Django 2.2+
- python-version: "3.8"
django-version: "2.0"
- python-version: "3.8"
django-version: "2.1"
# Python 3.9 is compatible with Django 3.1+
- python-version: "3.9"
django-version: "2.0"
- python-version: "3.9"
django-version: "2.1"
- python-version: "3.9"
- python-version: "3.5"
django-version: "4.0"
- python-version: "3.5"
django-version: "4.1"
# Python 3.6 is not compatible with Django 4.0+
- python-version: "3.6"
django-version: "4.0"
- python-version: "3.6"
django-version: "4.1"
# Python 3.7 is not compatible with Django 4.0+
- python-version: "3.7"
django-version: "4.0"
- python-version: "3.7"
django-version: "4.1"
# Python 3.10 is compatible with Django 3.2+
- python-version: "3.10"
django-version: "2.2"
- python-version: "3.9"
- python-version: "3.10"
django-version: "3.0"
- python-version: "3.10"
django-version: "3.1"

steps:
- uses: actions/checkout@v2
Expand Down Expand Up @@ -98,3 +97,21 @@ jobs:
with:
file: coverage.xml
flags: unittests

create-release:
needs: lint-and-test
runs-on: ubuntu-latest
steps:
- name: checkout
uses: actions/checkout@v2
with:
fetch-depth: 0 # need this for all history for all branches and tags
- name: Create Release
id: create_release
uses: nickatnight/releases-action@v3
if: startsWith(github.ref, 'refs/tags/')
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

outputs:
ReleaseTag: ${{ steps.create_release.outputs.release_tag }}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ var/
demo/django_spam
.vscode
*.sqlite3
pyvenv.cfg

# Installer logs
pip-log.txt
Expand Down
21 changes: 14 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,14 @@ solution for your django application. django_spam simply adds common admin urls
for that matter) try and access them, they will get redirected...


| | Django 2.0 | Django 2.1 | Django 2.2 | Django 3.0 | Django 3.1 | Django 3.2 |
| | Django 2.2 | Django 3.0 | Django 3.1 | Django 3.2 | Django 4.0 | Django 4.1 |
| -- | -- | -- | -- | -- | -- | -- |
| Python 3.4 | :heavy_check_mark: | | | | | |
| Python 3.5 | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | | | |
| Python 3.6 | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: |
| Python 3.7 | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: |
| Python 3.8 | | | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: |
| Python 3.9 | | | | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: |
| Python 3.5 | :heavy_check_mark: | | | | | |
| Python 3.6 | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | | |
| Python 3.7 | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | | |
| Python 3.8 | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: |
| Python 3.9 | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: |
| Python 3.10| | | | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: |


## Installation / Usage
Expand Down Expand Up @@ -82,3 +82,10 @@ This project uses [Poetry](https://python-poetry.org/docs/#osx--linux--bashonwin
3. black `poetry run black .`
4. flake8 `poetry run flake8`
5. test `poetry run coverage run --source=django_spam setup.py test`

## Releasing
1. Be sure to checkout master: `$ git checkout master`
2. Create tag: `$ git tag <tag_name>`
3. Push tag: `$ git push origin <tag_name>`

GitHub Action pipeline will automatically create release c:
6 changes: 3 additions & 3 deletions demo/demo/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
Generated by 'django-admin startproject' using Django 1.11.8.

For more information on this file, see
https://docs.djangoproject.com/en/1.11/topics/settings/
https://docs.djangoproject.com/en/4.1/topics/settings/

For the full list of settings and their values, see
https://docs.djangoproject.com/en/1.11/ref/settings/
https://docs.djangoproject.com/en/4.1/ref/settings/
"""

import os
Expand All @@ -25,7 +25,7 @@
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True

ALLOWED_HOSTS = []
ALLOWED_HOSTS = ["*"]


# Application definition
Expand Down
28 changes: 14 additions & 14 deletions demo/poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions demo/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
name = "django-spam demo"
version = "1.0.0"
description = "A demo using django-spam."
authors = ["nick.kelly@tivix.com"]
authors = ["nickkelly.858@gmail.com"]

[tool.poetry.dependencies]
python = "3.9"
python = "^3.9"
django = "^3.0"
django_spam = { path = "../", develop = true}

Expand Down
47 changes: 25 additions & 22 deletions django_spam/enums.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
class SpamBase:
import abc


class AbstractSpam(abc.ABC):
name = ""
url = ""

Expand All @@ -10,77 +13,77 @@ def to_readable(cls) -> str:
return cls.name.lower().replace(" ", "_")


class VaderBreathing(SpamBase):
class VaderBreathing(AbstractSpam):
name = "Darth Vader Breathing"
url = "https://www.youtube.com/watch?v=un8FAjXWOBY"


class Yodelling(SpamBase):
name = "Yodelling"
url = "https://www.youtube.com/watch?v=Lxt0_YrQs0M"
class BouncingDVDLogo(AbstractSpam):
name = "Bouncing DVD Logo"
url = "https://www.youtube.com/watch?v=5mGuCdlCcNM"


class MulletGuy(SpamBase):
class MulletGuy(AbstractSpam):
name = "Whistling Mullet Guy"
url = "https://www.youtube.com/watch?v=Sbhoym9yzVQ"


class ScreamingGuy(SpamBase):
class ScreamingGuy(AbstractSpam):
name = "Screaming Guy"
url = "https://www.youtube.com/watch?v=CRcYlE3i_-4"


class FaceSong(SpamBase):
class FaceSong(AbstractSpam):
name = "Awesome Face Song"
url = "https://www.youtube.com/watch?v=WNeni1lbzgY"


class ScreamingSheep(SpamBase):
class ScreamingSheep(AbstractSpam):
name = "Screaming Sheep"
url = "https://www.youtube.com/watch?v=SjHUb7NSrNk"


class SaxGuy(SpamBase):
class SaxGuy(AbstractSpam):
name = "Epic Sax Guy"
url = "https://www.youtube.com/watch?v=kxopViU98Xo"


class CrabRave(SpamBase):
class CrabRave(AbstractSpam):
name = "Crab Rave"
url = "https://www.youtube.com/watch?v=-50NdPawLVY"


class WiiMusic(SpamBase):
class WiiMusic(AbstractSpam):
name = "Wii Theme Music"
url = "https://www.youtube.com/watch?v=Twi92KYddW4"


class NyonCat(SpamBase):
name = "Nyon Cat"
url = "https://www.youtube.com/watch?v=wZZ7oFKsKzY"
class Nothing(AbstractSpam):
name = "Nothing"
url = "https://www.youtube.com/watch?v=fx2Z5ZD_Rbo"


class Asmr(SpamBase):
class Asmr(AbstractSpam):
name = "ASMR"
url = "https://www.youtube.com/watch?v=jbAy9MwBR-I"


class HeMan(SpamBase):
name = "He-man Heyeayea"
url = "https://www.youtube.com/watch?v=eh7lp9umG2I"
class JoePera(AbstractSpam):
name = "Joe Pera Talks You To Sleep"
url = "https://www.youtube.com/watch?v=91wX0NRjJqg"


SPAM_ENUMS = [
VaderBreathing,
Yodelling,
Nothing,
MulletGuy,
ScreamingGuy,
FaceSong,
ScreamingSheep,
SaxGuy,
CrabRave,
WiiMusic,
NyonCat,
BouncingDVDLogo,
Asmr,
HeMan,
JoePera,
]
20 changes: 10 additions & 10 deletions django_spam/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@
from django_spam import SPAM_ENUMS


urlpatterns = list()

for spam_route in SPAM_ROUTES:
enum = random.choice(SPAM_ENUMS)
urlpatterns.append(
path(
spam_route,
RedirectView.as_view(url=enum.url),
name=enum.to_readable(),
)
def get_spam_path(route: str) -> path:
u = random.choice(SPAM_ENUMS)
p = path(
route,
RedirectView.as_view(url=u.url),
name=u.to_readable(),
)
return p


urlpatterns = [get_spam_path(spam_route) for spam_route in SPAM_ROUTES]
Loading