prune_captcha 1.8.0__tar.gz → 1.10.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {prune_captcha-1.8.0 → prune_captcha-1.10.0}/PKG-INFO +41 -29
- {prune_captcha-1.8.0 → prune_captcha-1.10.0}/README.md +40 -28
- {prune_captcha-1.8.0 → prune_captcha-1.10.0}/captcha_prune/utils.py +3 -3
- {prune_captcha-1.8.0 → prune_captcha-1.10.0}/prune_captcha.egg-info/PKG-INFO +41 -29
- {prune_captcha-1.8.0 → prune_captcha-1.10.0}/prune_captcha.egg-info/SOURCES.txt +0 -1
- {prune_captcha-1.8.0 → prune_captcha-1.10.0}/pyproject.toml +1 -1
- prune_captcha-1.8.0/captcha_prune/context_processors.py +0 -12
- {prune_captcha-1.8.0 → prune_captcha-1.10.0}/captcha_prune/__init__.py +0 -0
- {prune_captcha-1.8.0 → prune_captcha-1.10.0}/captcha_prune/apps.py +0 -0
- {prune_captcha-1.8.0 → prune_captcha-1.10.0}/captcha_prune/asgi.py +0 -0
- {prune_captcha-1.8.0 → prune_captcha-1.10.0}/captcha_prune/migrations/0001_initial.py +0 -0
- {prune_captcha-1.8.0 → prune_captcha-1.10.0}/captcha_prune/migrations/0002_remove_captcha_created_at_remove_captcha_pos_x_and_more.py +0 -0
- {prune_captcha-1.8.0 → prune_captcha-1.10.0}/captcha_prune/migrations/0003_captcha_created_at_captcha_updated_at.py +0 -0
- {prune_captcha-1.8.0 → prune_captcha-1.10.0}/captcha_prune/migrations/__init__.py +0 -0
- {prune_captcha-1.8.0 → prune_captcha-1.10.0}/captcha_prune/models.py +0 -0
- {prune_captcha-1.8.0 → prune_captcha-1.10.0}/captcha_prune/payloads.py +0 -0
- {prune_captcha-1.8.0 → prune_captcha-1.10.0}/captcha_prune/settings.py +0 -0
- {prune_captcha-1.8.0 → prune_captcha-1.10.0}/captcha_prune/urls.py +0 -0
- {prune_captcha-1.8.0 → prune_captcha-1.10.0}/captcha_prune/views.py +0 -0
- {prune_captcha-1.8.0 → prune_captcha-1.10.0}/captcha_prune/wsgi.py +0 -0
- {prune_captcha-1.8.0 → prune_captcha-1.10.0}/commons/base_model.py +0 -0
- {prune_captcha-1.8.0 → prune_captcha-1.10.0}/commons/decorators.py +0 -0
- {prune_captcha-1.8.0 → prune_captcha-1.10.0}/prune_captcha.egg-info/dependency_links.txt +0 -0
- {prune_captcha-1.8.0 → prune_captcha-1.10.0}/prune_captcha.egg-info/requires.txt +0 -0
- {prune_captcha-1.8.0 → prune_captcha-1.10.0}/prune_captcha.egg-info/top_level.txt +0 -0
- {prune_captcha-1.8.0 → prune_captcha-1.10.0}/setup.cfg +0 -0
- {prune_captcha-1.8.0 → prune_captcha-1.10.0}/tests/__init__.py +0 -0
- {prune_captcha-1.8.0 → prune_captcha-1.10.0}/tests/captcha_prune/__init__.py +0 -0
- {prune_captcha-1.8.0 → prune_captcha-1.10.0}/tests/captcha_prune/test_views.py +0 -0
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: prune_captcha
|
3
|
-
Version: 1.
|
3
|
+
Version: 1.10.0
|
4
4
|
Summary: A tool to protect formulaire from spam.
|
5
5
|
Author-email: Arnout <bastien@prune.sh>
|
6
6
|
Project-URL: Made_by, https://prune.sh/
|
@@ -61,81 +61,94 @@ Don't hesitate to regularly run `poetry update`, as the captcha evolves with tim
|
|
61
61
|
In `settings.py`, set the path to the images used for the puzzle:
|
62
62
|
|
63
63
|
```python
|
64
|
-
PUZZLE_IMAGE_STATIC_PATH = "website/images/"
|
64
|
+
PUZZLE_IMAGE_STATIC_PATH = "website/static/website/images/"
|
65
65
|
```
|
66
66
|
|
67
67
|
### Utilisation
|
68
68
|
|
69
69
|
- GET request (form display)
|
70
70
|
|
71
|
-
- Use create_and_get_puzzle to generate the captcha data
|
71
|
+
- Use create_and_get_puzzle to generate the captcha data:
|
72
72
|
|
73
|
-
|
73
|
+
```python
|
74
|
+
from captcha_prune.utils import create_and_get_puzzle
|
75
|
+
```
|
74
76
|
|
75
|
-
|
77
|
+
```python
|
78
|
+
puzzle = create_and_get_puzzle(request)
|
79
|
+
```
|
80
|
+
|
81
|
+
- Passes the data into the context under the puzzle variable:
|
76
82
|
|
77
83
|
```python
|
78
|
-
|
84
|
+
return render(
|
85
|
+
request,
|
86
|
+
"website/pages/contact/page.html",
|
87
|
+
{"form": form, "puzzle": puzzle},
|
88
|
+
)
|
79
89
|
```
|
80
90
|
|
91
|
+
- Include the component in your template:
|
92
|
+
|
81
93
|
```
|
82
94
|
{% include "captcha_prune/captcha.html" %}
|
83
95
|
```
|
84
96
|
|
85
97
|
- POST request (form submission)
|
86
98
|
|
87
|
-
- Use verify_captcha to validate the captcha
|
99
|
+
- Use verify_captcha to validate the captcha:
|
88
100
|
|
89
101
|
```python
|
90
102
|
from captcha_prune.utils import verify_captcha
|
91
103
|
```
|
92
104
|
|
93
105
|
```python
|
94
|
-
|
106
|
+
response = verify_captcha(
|
107
|
+
request, redirect("/"), redirect("website:contact-page"), form
|
108
|
+
)
|
95
109
|
```
|
96
110
|
|
97
|
-
-
|
111
|
+
- None if the captcha is correct.
|
98
112
|
|
99
|
-
- Redirects in case of expired session or incorrect captcha
|
113
|
+
- Redirects in case of expired session or incorrect captcha:
|
114
|
+
|
115
|
+
```python
|
116
|
+
if response is not None:
|
117
|
+
return response
|
118
|
+
```
|
100
119
|
|
101
120
|
### Example
|
102
121
|
|
103
122
|
```python
|
104
|
-
from django.shortcuts import render, redirect
|
105
|
-
|
106
|
-
from django.contrib import messages
|
107
|
-
from captcha_prune.utils import create_and_get_puzzle, verify_captcha
|
108
|
-
from .forms import ContactForm
|
109
|
-
|
110
123
|
def contact_view(request):
|
111
124
|
if request.method == "POST":
|
112
125
|
form = ContactForm(request.POST)
|
113
126
|
if form.is_valid():
|
114
|
-
verify_captcha(
|
115
|
-
request,
|
116
|
-
redirect("/"),
|
117
|
-
redirect("website:contact-page"),
|
118
|
-
form
|
127
|
+
response = verify_captcha(
|
128
|
+
request, redirect("/"), redirect("website:contact-page"), form
|
119
129
|
)
|
120
|
-
|
121
|
-
return
|
122
|
-
|
123
|
-
|
130
|
+
if response is not None:
|
131
|
+
return response
|
132
|
+
messages.success(request, "Formulaire soumis avec succès.")
|
133
|
+
return redirect("/")
|
124
134
|
else:
|
125
|
-
form = ContactForm()
|
126
135
|
puzzle = create_and_get_puzzle(request)
|
136
|
+
else:
|
137
|
+
form = ContactForm()
|
138
|
+
puzzle = create_and_get_puzzle(request)
|
127
139
|
return render(
|
128
140
|
request,
|
129
141
|
"website/pages/contact/page.html",
|
130
142
|
{"form": form, "puzzle": puzzle},
|
131
143
|
)
|
132
|
-
|
133
|
-
```
|
144
|
+
```
|
134
145
|
|
135
146
|
# Available Versions
|
136
147
|
|
137
148
|
| Version | Date | Notes |
|
138
149
|
| ------- | ---------- | ---------------------------------- |
|
150
|
+
| 1.10.0 | 2025-05-20 | fix documentation, removed ... |
|
151
|
+
| 1.9.0 | 2025-05-20 | puzzle images path fixed |
|
139
152
|
| 1.8.0 | 2025-05-20 | added migrations |
|
140
153
|
| 1.7.0 | 2025-05-20 | PUZZLE_IMAGE_STATIC_PATH ... |
|
141
154
|
| 1.6.0 | 2025-05-20 | added templates |
|
@@ -145,4 +158,3 @@ PUZZLE_IMAGE_STATIC_PATH = "website/images/"
|
|
145
158
|
| 1.2.0 | 2025-04-30 | fixed prune_captcha command, ... |
|
146
159
|
| 1.1.0 | 2025-04-30 | start_server was not a module, ... |
|
147
160
|
| 1.0.0 | 2025-04-29 | First version of the `captcha` ... |
|
148
|
-
```
|
@@ -43,81 +43,94 @@ Don't hesitate to regularly run `poetry update`, as the captcha evolves with tim
|
|
43
43
|
In `settings.py`, set the path to the images used for the puzzle:
|
44
44
|
|
45
45
|
```python
|
46
|
-
PUZZLE_IMAGE_STATIC_PATH = "website/images/"
|
46
|
+
PUZZLE_IMAGE_STATIC_PATH = "website/static/website/images/"
|
47
47
|
```
|
48
48
|
|
49
49
|
### Utilisation
|
50
50
|
|
51
51
|
- GET request (form display)
|
52
52
|
|
53
|
-
- Use create_and_get_puzzle to generate the captcha data
|
53
|
+
- Use create_and_get_puzzle to generate the captcha data:
|
54
54
|
|
55
|
-
|
55
|
+
```python
|
56
|
+
from captcha_prune.utils import create_and_get_puzzle
|
57
|
+
```
|
56
58
|
|
57
|
-
|
59
|
+
```python
|
60
|
+
puzzle = create_and_get_puzzle(request)
|
61
|
+
```
|
62
|
+
|
63
|
+
- Passes the data into the context under the puzzle variable:
|
58
64
|
|
59
65
|
```python
|
60
|
-
|
66
|
+
return render(
|
67
|
+
request,
|
68
|
+
"website/pages/contact/page.html",
|
69
|
+
{"form": form, "puzzle": puzzle},
|
70
|
+
)
|
61
71
|
```
|
62
72
|
|
73
|
+
- Include the component in your template:
|
74
|
+
|
63
75
|
```
|
64
76
|
{% include "captcha_prune/captcha.html" %}
|
65
77
|
```
|
66
78
|
|
67
79
|
- POST request (form submission)
|
68
80
|
|
69
|
-
- Use verify_captcha to validate the captcha
|
81
|
+
- Use verify_captcha to validate the captcha:
|
70
82
|
|
71
83
|
```python
|
72
84
|
from captcha_prune.utils import verify_captcha
|
73
85
|
```
|
74
86
|
|
75
87
|
```python
|
76
|
-
|
88
|
+
response = verify_captcha(
|
89
|
+
request, redirect("/"), redirect("website:contact-page"), form
|
90
|
+
)
|
77
91
|
```
|
78
92
|
|
79
|
-
-
|
93
|
+
- None if the captcha is correct.
|
80
94
|
|
81
|
-
- Redirects in case of expired session or incorrect captcha
|
95
|
+
- Redirects in case of expired session or incorrect captcha:
|
96
|
+
|
97
|
+
```python
|
98
|
+
if response is not None:
|
99
|
+
return response
|
100
|
+
```
|
82
101
|
|
83
102
|
### Example
|
84
103
|
|
85
104
|
```python
|
86
|
-
from django.shortcuts import render, redirect
|
87
|
-
|
88
|
-
from django.contrib import messages
|
89
|
-
from captcha_prune.utils import create_and_get_puzzle, verify_captcha
|
90
|
-
from .forms import ContactForm
|
91
|
-
|
92
105
|
def contact_view(request):
|
93
106
|
if request.method == "POST":
|
94
107
|
form = ContactForm(request.POST)
|
95
108
|
if form.is_valid():
|
96
|
-
verify_captcha(
|
97
|
-
request,
|
98
|
-
redirect("/"),
|
99
|
-
redirect("website:contact-page"),
|
100
|
-
form
|
109
|
+
response = verify_captcha(
|
110
|
+
request, redirect("/"), redirect("website:contact-page"), form
|
101
111
|
)
|
102
|
-
|
103
|
-
return
|
104
|
-
|
105
|
-
|
112
|
+
if response is not None:
|
113
|
+
return response
|
114
|
+
messages.success(request, "Formulaire soumis avec succès.")
|
115
|
+
return redirect("/")
|
106
116
|
else:
|
107
|
-
form = ContactForm()
|
108
117
|
puzzle = create_and_get_puzzle(request)
|
118
|
+
else:
|
119
|
+
form = ContactForm()
|
120
|
+
puzzle = create_and_get_puzzle(request)
|
109
121
|
return render(
|
110
122
|
request,
|
111
123
|
"website/pages/contact/page.html",
|
112
124
|
{"form": form, "puzzle": puzzle},
|
113
125
|
)
|
114
|
-
|
115
|
-
```
|
126
|
+
```
|
116
127
|
|
117
128
|
# Available Versions
|
118
129
|
|
119
130
|
| Version | Date | Notes |
|
120
131
|
| ------- | ---------- | ---------------------------------- |
|
132
|
+
| 1.10.0 | 2025-05-20 | fix documentation, removed ... |
|
133
|
+
| 1.9.0 | 2025-05-20 | puzzle images path fixed |
|
121
134
|
| 1.8.0 | 2025-05-20 | added migrations |
|
122
135
|
| 1.7.0 | 2025-05-20 | PUZZLE_IMAGE_STATIC_PATH ... |
|
123
136
|
| 1.6.0 | 2025-05-20 | added templates |
|
@@ -127,4 +140,3 @@ PUZZLE_IMAGE_STATIC_PATH = "website/images/"
|
|
127
140
|
| 1.2.0 | 2025-04-30 | fixed prune_captcha command, ... |
|
128
141
|
| 1.1.0 | 2025-04-30 | start_server was not a module, ... |
|
129
142
|
| 1.0.0 | 2025-04-29 | First version of the `captcha` ... |
|
130
|
-
```
|
@@ -10,7 +10,7 @@ from django.urls import reverse
|
|
10
10
|
|
11
11
|
|
12
12
|
def create_and_get_puzzle(request: HttpRequest) -> HttpResponse | dict:
|
13
|
-
|
13
|
+
_, _, puzzle_images_path = settings.PUZZLE_IMAGE_STATIC_PATH.rpartition("static/")
|
14
14
|
try:
|
15
15
|
response = requests.post(
|
16
16
|
request.build_absolute_uri(reverse("captcha:create-captcha"))
|
@@ -20,7 +20,7 @@ def create_and_get_puzzle(request: HttpRequest) -> HttpResponse | dict:
|
|
20
20
|
request.session["puzzle_uuid"] = response["uuid"]
|
21
21
|
puzzle_images = [
|
22
22
|
f
|
23
|
-
for f in os.listdir(
|
23
|
+
for f in os.listdir(settings.PUZZLE_IMAGE_STATIC_PATH)
|
24
24
|
if f.lower().endswith((".jpg", ".jpeg", ".png", ".gif"))
|
25
25
|
]
|
26
26
|
selected_image = random.choice(puzzle_images)
|
@@ -34,7 +34,7 @@ def create_and_get_puzzle(request: HttpRequest) -> HttpResponse | dict:
|
|
34
34
|
"pos_y_solution": response["pos_y_solution"],
|
35
35
|
"piece_pos_x": response["piece_pos_x"],
|
36
36
|
"piece_pos_y": response["piece_pos_y"],
|
37
|
-
"image": f"{
|
37
|
+
"image": f"{puzzle_images_path}{selected_image}",
|
38
38
|
}
|
39
39
|
|
40
40
|
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: prune_captcha
|
3
|
-
Version: 1.
|
3
|
+
Version: 1.10.0
|
4
4
|
Summary: A tool to protect formulaire from spam.
|
5
5
|
Author-email: Arnout <bastien@prune.sh>
|
6
6
|
Project-URL: Made_by, https://prune.sh/
|
@@ -61,81 +61,94 @@ Don't hesitate to regularly run `poetry update`, as the captcha evolves with tim
|
|
61
61
|
In `settings.py`, set the path to the images used for the puzzle:
|
62
62
|
|
63
63
|
```python
|
64
|
-
PUZZLE_IMAGE_STATIC_PATH = "website/images/"
|
64
|
+
PUZZLE_IMAGE_STATIC_PATH = "website/static/website/images/"
|
65
65
|
```
|
66
66
|
|
67
67
|
### Utilisation
|
68
68
|
|
69
69
|
- GET request (form display)
|
70
70
|
|
71
|
-
- Use create_and_get_puzzle to generate the captcha data
|
71
|
+
- Use create_and_get_puzzle to generate the captcha data:
|
72
72
|
|
73
|
-
|
73
|
+
```python
|
74
|
+
from captcha_prune.utils import create_and_get_puzzle
|
75
|
+
```
|
74
76
|
|
75
|
-
|
77
|
+
```python
|
78
|
+
puzzle = create_and_get_puzzle(request)
|
79
|
+
```
|
80
|
+
|
81
|
+
- Passes the data into the context under the puzzle variable:
|
76
82
|
|
77
83
|
```python
|
78
|
-
|
84
|
+
return render(
|
85
|
+
request,
|
86
|
+
"website/pages/contact/page.html",
|
87
|
+
{"form": form, "puzzle": puzzle},
|
88
|
+
)
|
79
89
|
```
|
80
90
|
|
91
|
+
- Include the component in your template:
|
92
|
+
|
81
93
|
```
|
82
94
|
{% include "captcha_prune/captcha.html" %}
|
83
95
|
```
|
84
96
|
|
85
97
|
- POST request (form submission)
|
86
98
|
|
87
|
-
- Use verify_captcha to validate the captcha
|
99
|
+
- Use verify_captcha to validate the captcha:
|
88
100
|
|
89
101
|
```python
|
90
102
|
from captcha_prune.utils import verify_captcha
|
91
103
|
```
|
92
104
|
|
93
105
|
```python
|
94
|
-
|
106
|
+
response = verify_captcha(
|
107
|
+
request, redirect("/"), redirect("website:contact-page"), form
|
108
|
+
)
|
95
109
|
```
|
96
110
|
|
97
|
-
-
|
111
|
+
- None if the captcha is correct.
|
98
112
|
|
99
|
-
- Redirects in case of expired session or incorrect captcha
|
113
|
+
- Redirects in case of expired session or incorrect captcha:
|
114
|
+
|
115
|
+
```python
|
116
|
+
if response is not None:
|
117
|
+
return response
|
118
|
+
```
|
100
119
|
|
101
120
|
### Example
|
102
121
|
|
103
122
|
```python
|
104
|
-
from django.shortcuts import render, redirect
|
105
|
-
|
106
|
-
from django.contrib import messages
|
107
|
-
from captcha_prune.utils import create_and_get_puzzle, verify_captcha
|
108
|
-
from .forms import ContactForm
|
109
|
-
|
110
123
|
def contact_view(request):
|
111
124
|
if request.method == "POST":
|
112
125
|
form = ContactForm(request.POST)
|
113
126
|
if form.is_valid():
|
114
|
-
verify_captcha(
|
115
|
-
request,
|
116
|
-
redirect("/"),
|
117
|
-
redirect("website:contact-page"),
|
118
|
-
form
|
127
|
+
response = verify_captcha(
|
128
|
+
request, redirect("/"), redirect("website:contact-page"), form
|
119
129
|
)
|
120
|
-
|
121
|
-
return
|
122
|
-
|
123
|
-
|
130
|
+
if response is not None:
|
131
|
+
return response
|
132
|
+
messages.success(request, "Formulaire soumis avec succès.")
|
133
|
+
return redirect("/")
|
124
134
|
else:
|
125
|
-
form = ContactForm()
|
126
135
|
puzzle = create_and_get_puzzle(request)
|
136
|
+
else:
|
137
|
+
form = ContactForm()
|
138
|
+
puzzle = create_and_get_puzzle(request)
|
127
139
|
return render(
|
128
140
|
request,
|
129
141
|
"website/pages/contact/page.html",
|
130
142
|
{"form": form, "puzzle": puzzle},
|
131
143
|
)
|
132
|
-
|
133
|
-
```
|
144
|
+
```
|
134
145
|
|
135
146
|
# Available Versions
|
136
147
|
|
137
148
|
| Version | Date | Notes |
|
138
149
|
| ------- | ---------- | ---------------------------------- |
|
150
|
+
| 1.10.0 | 2025-05-20 | fix documentation, removed ... |
|
151
|
+
| 1.9.0 | 2025-05-20 | puzzle images path fixed |
|
139
152
|
| 1.8.0 | 2025-05-20 | added migrations |
|
140
153
|
| 1.7.0 | 2025-05-20 | PUZZLE_IMAGE_STATIC_PATH ... |
|
141
154
|
| 1.6.0 | 2025-05-20 | added templates |
|
@@ -145,4 +158,3 @@ PUZZLE_IMAGE_STATIC_PATH = "website/images/"
|
|
145
158
|
| 1.2.0 | 2025-04-30 | fixed prune_captcha command, ... |
|
146
159
|
| 1.1.0 | 2025-04-30 | start_server was not a module, ... |
|
147
160
|
| 1.0.0 | 2025-04-29 | First version of the `captcha` ... |
|
148
|
-
```
|
@@ -20,7 +20,7 @@ classifiers = [
|
|
20
20
|
keywords = ["captcha", "django", "code-quality"]
|
21
21
|
urls = {Made_by = "https://prune.sh/"}
|
22
22
|
name = "prune_captcha"
|
23
|
-
version = "1.
|
23
|
+
version = "1.10.0"
|
24
24
|
description = "A tool to protect formulaire from spam."
|
25
25
|
readme = "README.md"
|
26
26
|
dependencies = [
|
@@ -1,12 +0,0 @@
|
|
1
|
-
from django.conf import settings
|
2
|
-
from django.core.exceptions import ImproperlyConfigured
|
3
|
-
|
4
|
-
|
5
|
-
def puzzle_static_path(request):
|
6
|
-
try:
|
7
|
-
path = settings.PUZZLE_IMAGE_STATIC_PATH
|
8
|
-
except AttributeError:
|
9
|
-
raise ImproperlyConfigured(
|
10
|
-
"Vous devez définir PUZZLE_IMAGE_STATIC_PATH dans votre settings.py"
|
11
|
-
)
|
12
|
-
return {"PUZZLE_IMAGE_STATIC_PATH": path}
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|