Skip to main content

Python libraries for Prune.

Project description

prune_libs

prune_libs is a Python library containing reusable utility functions. The goal is to facilitate project development by centralizing common tools.

The project also includes prune_captcha, a module dedicated to adding a custom CAPTCHA to contact forms.

UV project

Installation

Run the following command in the console:

uv add prune_libs

Updating the library

Don't hesitate to regularly run uv sync --upgrade, as the library evolves with time and our practices!

Poetry project

Installation

Run the following command:

poetry add prune_libs

Updating the library

Don't hesitate to regularly run poetry update, as the library evolves with time and our practices!

Objectives

  • Easily reuse common functions.
  • Provide a simple alternative to reCAPTCHA.
  • Do not depend on any external services.

Captcha Integration

Configuration

In settings.py, set the path to the images used for the puzzle:

PUZZLE_IMAGE_STATIC_PATH = "website/static/website/images/puzzles/"

Important: You must import the static files (css, js) present in "prune_captcha/static/".

<header>
    <link
        rel="stylesheet"
        href="{% static 'prune_captcha/css/captcha.css' %}"
    />
    <script defer src="{% static 'prune_captcha/js/captcha.js' %}"></script>
</header>

Utilisation

  • GET request (form display)

    • Use create_and_get_captcha to generate the captcha data:

      from prune_captcha.utils import create_and_get_captcha
      
      puzzle = create_and_get_captcha(request)
      
    • Passes the data into the context under the puzzle variable:

      return render(
          request,
          "website/pages/contact/page.html",
          {"form": form, "puzzle": puzzle},
      )
      
    • Include the component in your template:

      {% include "prune_captcha/captcha.html" %}
      
  • POST request (form submission)

    • Use verify_captcha to validate the captcha:

      from prune_captcha.utils import verify_captcha
      
      response = verify_captcha(request)
      
    • True if the captcha is correct, else False.

    • Redirects in case of incorrect captcha.

Available Versions

Version Date Notes
1.21.3 2025-06-11 Add static finder
1.21.2 2025-06-11 added value error
1.21.1 2025-06-05 deleted EmailTemplates
1.21.0 2025-06-05 added tests, libraries, ...
1.20.2 2025-06-03 fix prune_libs directory
1.20.1 2025-06-03 fix prune_libs directory
1.20.0 2025-06-03 added prune's logic
1.19.1 2025-06-02 fix
1.19.0 2025-06-02 from prune-captcha to prune-libs
1.18.7 2025-05-28 PUZZLE_HINT_TEXT fix
1.18.6 2025-05-28 added PUZZLE_HINT_TEXT
1.18.5 2025-05-23 ValueError fixed
1.18.4 2025-05-23 deleted var
1.18.3 2025-05-22 add puzzle info
1.18.2 2025-05-22 fix
1.18.1 2025-05-22 some improvements
1.18.0 2025-05-22 create "addHiddenInputs" func
1.17.0 2025-05-21 fix pos_answer
1.16.1 2025-05-21 fix static
1.16.0 2025-05-21 fix static
1.15.2 2025-05-21 fix manifest
1.15.1 2025-05-21 fix manifest
1.15.0 2025-05-21 fix manifest
1.14.0 2025-05-21 fix static and templates dirs
1.13.0 2025-05-21 use session, add static
1.12.2 2025-05-21 doc fixed
1.12.1 2025-05-21 doc fixed
1.12.0 2025-05-21 removed views, added utils, ...
1.11.0 2025-05-21 removed utils
1.10.0 2025-05-20 fix documentation, removed ...
1.9.0 2025-05-20 puzzle images path fixed
1.8.0 2025-05-20 added migrations
1.7.0 2025-05-20 PUZZLE_IMAGE_STATIC_PATH ...
1.6.0 2025-05-20 added templates
1.5.0 2025-05-20 app config fixed, components ...
1.4.0 2025-05-20 added BaseModel in Captcha, ...
1.3.0 2025-04-30 deleted start_server, deleted ...
1.2.0 2025-04-30 fixed prune_captcha command, ...
1.1.0 2025-04-30 start_server was not a module, ...
1.0.0 2025-04-29 First version of the captcha ...

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

prune_libs-1.21.3.tar.gz (13.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

prune_libs-1.21.3-py3-none-any.whl (17.4 kB view details)

Uploaded Python 3

File details

Details for the file prune_libs-1.21.3.tar.gz.

File metadata

  • Download URL: prune_libs-1.21.3.tar.gz
  • Upload date:
  • Size: 13.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.5.31

File hashes

Hashes for prune_libs-1.21.3.tar.gz
Algorithm Hash digest
SHA256 dc8b87e2f97c97d51109724b13018d1844a6309f9877118197370778555b0331
MD5 a8a877ca51a51ef8456fb93dc97e2313
BLAKE2b-256 e3c4934a51fda94ec00c272d1e043077e2935449d945edd839b9b5bad3158953

See more details on using hashes here.

File details

Details for the file prune_libs-1.21.3-py3-none-any.whl.

File metadata

File hashes

Hashes for prune_libs-1.21.3-py3-none-any.whl
Algorithm Hash digest
SHA256 975c7375f0028c889dbffd20c31b1ee03d59b9c4e87caf8ec7656cef1eeec941
MD5 68638af0649703e17d1f7e39f55ec74d
BLAKE2b-256 d2595e10dc790f843d0e751f98a8ceae4c2c5e450fbf1795bd871174356f6586

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page