-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
rename Alter naming
- Loading branch information
0 parents
commit c03b6a8
Showing
32 changed files
with
1,379 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
name: Tests | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
- develop | ||
|
||
pull_request: | ||
branches: | ||
- main | ||
- develop | ||
|
||
jobs: | ||
test-sqlite: | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
python: ['3.8', '3.9', '3.10'] | ||
django: ['3.1', '3.2', '4.0'] | ||
wagtail: ['2.14', '2.15', '2.16'] | ||
|
||
steps: | ||
- uses: actions/checkout@v2 | ||
- name: Set up Python ${{ matrix.python-version }} | ||
uses: actions/setup-python@v2 | ||
with: | ||
python-version: ${{ matrix.python-version }} | ||
- name: Install Dependencies | ||
run: | | ||
pip install -e ".[testing]" -U pip setuptools wheel | ||
- name: Flake8 | ||
run: | | ||
flake8 wagtail_honeypot | ||
- name: Isort | ||
run: | | ||
isort wagtail_honeypot --check | ||
- name: Black demo | ||
run: | | ||
black wagtail_honeypot --check | ||
- name: Run Tests | ||
run: | | ||
python testmanage.py test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
*.pyc | ||
/build | ||
/dist | ||
/wagtail_honeypot.egg-info | ||
/.coverage | ||
/htmlcov | ||
/.tox | ||
/venv | ||
/.vscode | ||
/site | ||
/test_wagtail_honeypot.db | ||
/node_modules | ||
/test-static | ||
/test-media |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
|
||
MIT License | ||
|
||
Copyright (c) 2022, Nick Moreton | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
include LICENSE *.rst *.txt *.md | ||
graft wagtail_honeypot | ||
global-exclude __pycache__ | ||
global-exclude *.py[co] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
# Wagtail Honeypot |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
{ | ||
"name": "wagtail-honeypot", | ||
"version": "1.0.0", | ||
"description": "", | ||
"main": "wagtail_honeypot/static_src/main.tsx", | ||
"scripts": { | ||
"build": "webpack --mode=production", | ||
"start": "webpack --mode=development --watch", | ||
"format": "prettier --write wagtail_honeypot/**/*.{ts,tsx,scss}", | ||
"lint": "prettier --check wagtail_honeypot/**/*.{ts,tsx,scss}" | ||
}, | ||
"author": "", | ||
"license": "ISC", | ||
"devDependencies": { | ||
"@svgr/webpack": "^5.4.0", | ||
"@types/react": "^16.8.19", | ||
"@types/react-dom": "^16.8.19", | ||
"@types/styled-components": "^5.1.2", | ||
"@typescript-eslint/eslint-plugin": "^1.12.0", | ||
"@typescript-eslint/parser": "^1.12.0", | ||
"css-loader": "^2.1.1", | ||
"eslint": "^5.16.0", | ||
"eslint-config-airbnb": "^17.1.1", | ||
"eslint-config-prettier": "^6.0.0", | ||
"eslint-config-torchbox": "^0.2.0", | ||
"eslint-plugin-import": "^2.18.0", | ||
"eslint-plugin-jsx-a11y": "^6.2.3", | ||
"eslint-plugin-react": "^7.14.2", | ||
"file-loader": "^3.0.1", | ||
"node-sass": "^4.13.1", | ||
"prettier": "1.18.2", | ||
"sass": "^1.20.3", | ||
"sass-loader": "^7.1.0", | ||
"style-loader": "^0.23.1", | ||
"ts-loader": "^6.0.2", | ||
"typescript": "^3.5.1", | ||
"webpack": "^4.32.2", | ||
"webpack-cli": "^3.3.2" | ||
}, | ||
"dependencies": { | ||
"react": "^16.13.1", | ||
"react-dom": "^16.13.1", | ||
"styled-components": "^5.1.1" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
[flake8] | ||
max-line-length = 120 | ||
extend-ignore = E203 | ||
exclude = **/migrations/** | ||
|
||
[isort] | ||
profile = black |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
#!/usr/bin/env python | ||
|
||
from os import path | ||
|
||
from setuptools import find_packages, setup | ||
|
||
from wagtail_honeypot import __version__ | ||
|
||
|
||
this_directory = path.abspath(path.dirname(__file__)) | ||
with open(path.join(this_directory, "README.md"), encoding="utf-8") as f: | ||
long_description = f.read() | ||
|
||
setup( | ||
name="wagtail-honeypot", | ||
version=__version__, | ||
description="wWagtail honeypot package", | ||
long_description=long_description, | ||
long_description_content_type='text/markdown', | ||
author="Nick Moreton", | ||
author_email="[email protected]", | ||
url="", | ||
packages=find_packages(), | ||
include_package_data=True, | ||
license="BSD", | ||
classifiers=[ | ||
"Development Status :: 3 - Alpha", | ||
"Intended Audience :: Developers", | ||
"License :: OSI Approved :: BSD License", | ||
"Operating System :: OS Independent", | ||
"Programming Language :: Python", | ||
"Programming Language :: Python :: 3", | ||
"Programming Language :: Python :: 3.7", | ||
"Programming Language :: Python :: 3.8", | ||
"Programming Language :: Python :: 3.9", | ||
"Framework :: Django", | ||
"Framework :: Django :: 3.0", | ||
"Framework :: Django :: 3.1", | ||
"Framework :: Django :: 3.2", | ||
"Framework :: Wagtail", | ||
"Framework :: Wagtail :: 2", | ||
], | ||
install_requires=["Django>=3.0,<4.0", "Wagtail>=2.14,<2.17"], | ||
extras_require={ | ||
"testing": ["flake8", "isort", "black"], | ||
}, | ||
zip_safe=False, | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
#!/usr/bin/env python | ||
|
||
import argparse | ||
import os | ||
import shutil | ||
import sys | ||
import warnings | ||
|
||
from django.core.management import execute_from_command_line | ||
|
||
|
||
os.environ["DJANGO_SETTINGS_MODULE"] = "wagtail_honeypot.test.settings" | ||
|
||
|
||
def make_parser(): | ||
parser = argparse.ArgumentParser() | ||
parser.add_argument( | ||
"--deprecation", | ||
choices=["all", "pending", "imminent", "none"], | ||
default="imminent", | ||
) | ||
return parser | ||
|
||
|
||
def parse_args(args=None): | ||
return make_parser().parse_known_args(args) | ||
|
||
|
||
def runtests(): | ||
args, rest = parse_args() | ||
|
||
only_wagtail = r"^wagtail(\.|$)" | ||
if args.deprecation == "all": | ||
# Show all deprecation warnings from all packages | ||
warnings.simplefilter("default", DeprecationWarning) | ||
warnings.simplefilter("default", PendingDeprecationWarning) | ||
elif args.deprecation == "pending": | ||
# Show all deprecation warnings from wagtail | ||
warnings.filterwarnings( | ||
"default", category=DeprecationWarning, module=only_wagtail | ||
) | ||
warnings.filterwarnings( | ||
"default", category=PendingDeprecationWarning, module=only_wagtail | ||
) | ||
elif args.deprecation == "imminent": | ||
# Show only imminent deprecation warnings from wagtail | ||
warnings.filterwarnings( | ||
"default", category=DeprecationWarning, module=only_wagtail | ||
) | ||
elif args.deprecation == "none": | ||
# Deprecation warnings are ignored by default | ||
pass | ||
|
||
argv = [sys.argv[0]] + rest | ||
|
||
try: | ||
execute_from_command_line(argv) | ||
finally: | ||
from wagtail.tests.settings import STATIC_ROOT, MEDIA_ROOT | ||
|
||
shutil.rmtree(STATIC_ROOT, ignore_errors=True) | ||
shutil.rmtree(MEDIA_ROOT, ignore_errors=True) | ||
|
||
|
||
if __name__ == "__main__": | ||
runtests() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
[tox] | ||
skipsdist = True | ||
usedevelop = True | ||
|
||
envlist = python{3.7,3.8,3.9}-django{3.0,3.1,3.2,4.0,master}-wagtail{2.14,2.15,2.16,master}-{sqlite} | ||
|
||
[flake8] | ||
# E501: Line too long | ||
# W503: line break before binary operator (superseded by W504 line break after binary operator) | ||
ignore = E501,W503 | ||
exclude = migrations,node_modules | ||
|
||
[testenv] | ||
install_command = pip install -e ".[testing]" -U {opts} {packages} | ||
commands = coverage run testmanage.py test --deprecation all | ||
|
||
basepython = | ||
python3.7: python3.7 | ||
python3.8: python3.8 | ||
python3.9: python3.9 | ||
|
||
deps = | ||
coverage | ||
|
||
django3.0: Django>=3.0,<3.1 | ||
django3.1: Django>=3.1,<3.2 | ||
django3.2: Django>=3.2,<4.0 | ||
django3.2: Django>=4.0,<4.1 | ||
|
||
djangomaster: git+https://github.com/django/django.git@master#egg=Django | ||
djangomaster: git+https://github.com/wagtail/django-modelcluster.git | ||
|
||
wagtail2.14: wagtail>=2.14,<2.15 | ||
wagtail2.15: wagtail>=2.15,<2.16 | ||
wagtail2.16: wagtail>=2.16,<2.17 | ||
wagtailmaster: git+https://github.com/wagtail/wagtail.git | ||
|
||
[testenv:flake8] | ||
basepython=python3.7 | ||
deps=flake8>=2.2.0 | ||
commands=flake8 wagtail_honeypot |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
default_app_config = "wagtail_honeypot.apps.WagtailHoneypotAppConfig" | ||
|
||
|
||
VERSION = (0, 1, 0) | ||
__version__ = ".".join(map(str, VERSION)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
from django.apps import AppConfig | ||
|
||
|
||
class WagtailHoneypotAppConfig(AppConfig): | ||
label = "wagtail_honeypot" | ||
name = "wagtail_honeypot" | ||
verbose_name = "Wagtail Honeypot" |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
from django.conf import settings | ||
from django.db import models | ||
from wagtail.admin.edit_handlers import FieldPanel, MultiFieldPanel | ||
from wagtail.contrib.forms.models import AbstractEmailForm | ||
|
||
|
||
class HoneypotMixin(AbstractEmailForm): | ||
honeypot = models.BooleanField(default=False, verbose_name="Honeypot Enabled") | ||
|
||
honeypot_panels = [ | ||
MultiFieldPanel( | ||
[ | ||
FieldPanel("honeypot"), | ||
], | ||
heading="Reduce Form Spam", | ||
) | ||
] | ||
|
||
class Meta: | ||
abstract = True | ||
|
||
def process_form_submission(self, form): | ||
honeypot_name = getattr(settings, "HONEYPOT_NAME", "whf_name") | ||
if honeypot_name in form.data and not form.data[honeypot_name]: | ||
return super().process_form_submission(form) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/wagtail-honeypot.js |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
{% load static wagtailcore_tags wagtailuserbar %} | ||
|
||
<!DOCTYPE html> | ||
<html class="no-js" lang="en"> | ||
<head> | ||
<meta charset="utf-8" /> | ||
<title> | ||
{% block title %} | ||
{% if page.seo_title %}{{ page.seo_title }}{% else %}{{ page.title }}{% endif %} | ||
{% endblock %} | ||
{% block title_suffix %} | ||
{% wagtail_site as current_site %} | ||
{% if current_site and current_site.site_name %}- {{ current_site.site_name }}{% endif %} | ||
{% endblock %} | ||
</title> | ||
<meta name="description" content="" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1" /> | ||
|
||
{# Global stylesheets #} | ||
|
||
{% block extra_css %} | ||
{# Override this in templates to add extra stylesheets #} | ||
{% endblock %} | ||
</head> | ||
|
||
<body class="{% block body_class %}{% endblock %}"> | ||
{% wagtailuserbar %} | ||
|
||
{% block content %}{% endblock %} | ||
|
||
{# Global javascript #} | ||
|
||
{% block extra_js %} | ||
{# Override this in templates to add extra javascript #} | ||
{% endblock %} | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<input type="text" name="{{ honeypot_name }}" id="{{ honeypot_name }}" data-{{ honeypot_name }} tabindex="-1" autocomplete="off"> |
Oops, something went wrong.