Skip to content

Commit

Permalink
Merge pull request #51 from Tivix/develop
Browse files Browse the repository at this point in the history
merging 'develop' into master
  • Loading branch information
nickatnight authored Sep 27, 2021
2 parents 1cba02d + 2ce47b7 commit edbdd79
Show file tree
Hide file tree
Showing 29 changed files with 1,332 additions and 312 deletions.
4 changes: 4 additions & 0 deletions .flake8
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[flake8]
max-line-length=110
ignore=F403,F405,W605,W503,E203,E231
exclude=setup.py,__init__.py,.eggs,runtests.py
100 changes: 100 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
name: lint and test

on:
push:
branches:
- master
- develop

jobs:
lint-and-test:
runs-on: ubuntu-18.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"
django-version:
- "2.0"
- "2.1"
- "2.2" # LTS
- "3.0"
- "3.1"
- "3.2" # LTS
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"
django-version: "2.2"
- python-version: "3.9"
django-version: "3.0"

steps:
- uses: actions/checkout@v2

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}

- name: Upgrade pip version
run: |
python -m pip install -U pip
- name: Upgrade django version
run: |
python -m pip install "Django~=${{ matrix.django-version }}.0"
- name: Python and Django versions
run: |
echo "Python ${{ matrix.python-version }} -> Django ${{ matrix.django-version }}"
python --version
echo "Django: `django-admin --version`"
- name: run tests
run: |
python -m pip install coverage
coverage run --source=django_spam setup.py test
coverage report
coverage xml -o coverage.xml
- name: Codecov
if: success()
uses: codecov/codecov-action@v2
with:
file: coverage.xml
flags: unittests
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
.coverage

# Distribution / packaging
.Python
Expand All @@ -9,7 +10,7 @@ bin/
build/
develop-eggs/
dist/
eggs/
*eggs/
lib/
lib64/
parts/
Expand Down
46 changes: 0 additions & 46 deletions .travis.yml

This file was deleted.

46 changes: 20 additions & 26 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,14 @@ django-spam
===========

<p align="center">
<a href="https://travis-ci.org/nickatnight/django-spam"><img alt="Build Status" src="https://travis-ci.org/nickatnight/django-spam.svg?branch=master"></a>
<a href="https://coveralls.io/github/nickatnight/django-spam?branch=master"><img alt="Coverage Status" src="https://coveralls.io/repos/github/nickatnight/django-spam/badge.svg?branch=master"></a>
<a href="https://github.com/Tivix/django-spam"><img alt="Build Status" src="https://github.com/Tivix/django-spam/workflows/lint%20and%20test/badge.svg?branch=master"></a>
<a href="https://codecov.io/gh/Tivix/django-spam"><img alt="Actions Status" src="https://codecov.io/gh/Tivix/django-spam/branch/master/graph/badge.svg"></a>
<a href="https://github.com/Tivix/django-spam/releases"><img alt="Release Status" src="https://img.shields.io/github/v/release/Tivix/django-spam"></a>
</p>

![alt text](https://media.giphy.com/media/Mr8Gr9ejR0OpW/giphy.gif "django_spam")
<p align="center">
<a href="https://media.giphy.com/media/Mr8Gr9ejR0OpW/giphy.gif"><img alt="spam" src="https://media.giphy.com/media/Mr8Gr9ejR0OpW/giphy.gif"></a>
</p>

Inspired by this Nick Craver tweet https://twitter.com/nick_craver/status/720062942960623616

Expand All @@ -16,17 +18,17 @@ 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 |
| -- | -- | -- | -- | -- | -- |
| 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: |
| Python 3.7 | :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: |
| Python 3.9 | | | | :heavy_check_mark: | :heavy_check_mark: |
| | Django 2.0 | Django 2.1 | Django 2.2 | Django 3.0 | Django 3.1 | Django 3.2 |
| -- | -- | -- | -- | -- | -- | -- |
| 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: |


To install:
## Installation / Usage
```python
pip install django-spam
```
Expand All @@ -53,23 +55,11 @@ SPAM_ROUTES = [
]
```

The same goes for ``SPAM_URLS`` you would like traffic to get forwarded to. Add some fun urls:

```python
SPAM_URLS = [
# 10 hours of Donald Trump saying bing bing bong
'https://www.youtube.com/watch?v=UKbOqEk6rsk',
# 10 hours of Darth Vader breathing
'https://www.youtube.com/watch?v=un8FAjXWOBY',
'...',
]
```

Include ``django_spam.urls`` to root url file:
```python

'...'
url(r'', include('django_spam.urls')), # for Django >= 2.0: path('', include('django_spam.urls')),
path('', include('django_spam.urls')),
'...',
```

Expand All @@ -82,4 +72,8 @@ EXCLUDED_ROUTES = [
]
```

@Tivix
## Demo
See [here](demo/README.md)

## Development
TODO
25 changes: 25 additions & 0 deletions demo/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
## Demo using django-spam

This demo is provided as a convenience feature to allow potential users to try the app straight from the app repo without having to create a django project.

It can also be used to develop the app in place.

To run this example, follow these instructions:

1. Navigate to the `demo` directory

2. Install required packages with Poetry.

poetry install

3. Make and apply migrations

poetry run python manage.py makemigrations
poetry run python manage.py migrate
4. Run the server

poetry run python manage.py runserver
4. Access from the browser at `http://127.0.0.1:8000`
66 changes: 32 additions & 34 deletions demo/demo/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
# See https://docs.djangoproject.com/en/1.11/howto/deployment/checklist/

# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = 'demo-key'
SECRET_KEY = "demo-key"

# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True
Expand All @@ -31,65 +31,63 @@
# Application definition

INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',

'django_spam',
"django.contrib.admin",
"django.contrib.auth",
"django.contrib.contenttypes",
"django.contrib.sessions",
"django.contrib.messages",
"django.contrib.staticfiles",
"django_spam",
]

MIDDLEWARE = [
'django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
"django.middleware.security.SecurityMiddleware",
"django.contrib.sessions.middleware.SessionMiddleware",
"django.middleware.common.CommonMiddleware",
"django.middleware.csrf.CsrfViewMiddleware",
"django.contrib.auth.middleware.AuthenticationMiddleware",
"django.contrib.messages.middleware.MessageMiddleware",
"django.middleware.clickjacking.XFrameOptionsMiddleware",
]

ROOT_URLCONF = 'demo.urls'
ROOT_URLCONF = "demo.urls"

TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [],
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
'django.template.context_processors.debug',
'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
"BACKEND": "django.template.backends.django.DjangoTemplates",
"DIRS": ["templates"],
"APP_DIRS": True,
"OPTIONS": {
"context_processors": [
"django.template.context_processors.debug",
"django.template.context_processors.request",
"django.contrib.auth.context_processors.auth",
"django.contrib.messages.context_processors.messages",
],
},
},
]

WSGI_APPLICATION = 'demo.wsgi.application'
WSGI_APPLICATION = "demo.wsgi.application"


# Database
# https://docs.djangoproject.com/en/1.11/ref/settings/#databases

DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
"default": {
"ENGINE": "django.db.backends.sqlite3",
"NAME": os.path.join(BASE_DIR, "db.sqlite3"),
}
}



# Internationalization
# https://docs.djangoproject.com/en/1.11/topics/i18n/

LANGUAGE_CODE = 'en-us'
LANGUAGE_CODE = "en-us"

TIME_ZONE = 'UTC'
TIME_ZONE = "UTC"

USE_I18N = True

Expand All @@ -101,4 +99,4 @@
# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/1.11/howto/static-files/

STATIC_URL = '/static/'
STATIC_URL = "/static/"
Loading

0 comments on commit edbdd79

Please sign in to comment.