Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ coverage.xml
.static_storage/
.media/
local_settings.py
pytition/pytition/settings/config.py
/scripts

# Flask stuff:
instance/
Expand Down Expand Up @@ -89,6 +91,7 @@ venv/
ENV/
env.bak/
venv.bak/
my-venv/

# Spyder project settings
.spyderproject
Expand Down
1 change: 1 addition & 0 deletions .pdm-python
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/venv/.venv/bin/python3.8
62 changes: 62 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
# Changelog

All notable changes to this project should be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).


## [Unreleased]

### Added

- Docstrings in python pytition/petition files (see https://peps.python.org/pep-0257/)
- Project tree


## [2025-03-10]
https://framagit.org/framasoft/framapetitions/pytitions/-/commit/ae55f0988c0cb5d0c42b620c23fd16c79615abaf

### Added

- Several features in petition admin page :
- new admin actions : publish, moderate and unpublish
- petition admin page now displays more petition attributes
- possibility of filtering petitions by their attributes


## [2025-01-23]
https://framagit.org/framasoft/framapetitions/pytitions/-/commit/b7bf6a2e1b5e206929b6f09e1e27737c89f7b1b2

### Changed

- Modified `petition/edit` to improve both clarity of page and UX :
- moved the signatures target panel on top of "Content" section
- added some space between input panels for friendlier UI
- resized some input panels


## [2024-11-28]
https://framagit.org/framasoft/framapetitions/pytitions/-/commit/7201a72bc23a056669240e63149df49b8f87bb14

### Added

- Warning message in the edition page when the petition is not published yet


## [2024-11-13]
https://framagit.org/framasoft/framapetitions/pytitions/-/commit/7708c922bf779678d224f7547c73728eada477f1
https://framagit.org/framasoft/framapetitions/pytitions/-/commit/30310d474268dcde3b6f31913ff1159eea726729

### Changed

- Modified `petition/edit` to improve both clarity of page and UX :
- moved the petition image selector to the top of the `Social Networks` panel
- rephrased indicator texts in the `Content` panel


## [2024-10-15]
https://framagit.org/framasoft/framapetitions/pytitions/-/commit/385abcc571e6c2ecfb8fec245df33231452f6ba5

### Fixed

- Set docker-compose command to use correct venv path, fixing an install problem
- Completed French translation
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ Those are external projects that are needed and used by Pytition, but included i
* django-tinymce 3.5.0
* django-colorfield 0.8.0
* requests 2.20.x
* mysqlclient 2.0.1
* beautifulsoup4 4.6.3
* django-formtools 2.2
* bcrypt
Expand Down
4 changes: 4 additions & 0 deletions dev/initialize.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ echo "Creating superuser account"

cd pytition && python3 ./manage.py createsuperuser && cd -

echo "Generating moderation and monitoring reasons"

cd pytition && python3 ./manage.py gen_reasons && cd -

echo "Done"

echo "Do you want to pre-populate the database with some users, organizations and petitions? (y/N)"
Expand Down
78 changes: 78 additions & 0 deletions doc/configuration.rst
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ Pytition specific settings
.. autodata:: pytition.settings.base.USE_MAIL_QUEUE
.. autodata:: pytition.settings.base.ALLOW_REGISTER
.. autodata:: pytition.settings.base.DEFAULT_NOREPLY_MAIL
.. autodata:: pytition.settings.base.MODERATION_EMAIL

Django settings
---------------
Expand All @@ -43,6 +44,82 @@ You should configure a real SMTP email account and not just rely on "fake" email
* :setting:`EMAIL_USE_SSL`
* others when necessary

Spam-fighting related settings
==============================

.. autodata:: pytition.settings.base.SPAM_DETECTORS
.. autodata:: pytition.settings.base.FORBIDDEN_WORDS
.. autodata:: pytition.settings.base.AKISMET_KEY
.. autodata:: pytition.settings.base.AKISMET_URL
.. autodata:: pytition.settings.base.AKISMET_MODERATION_AUTO
.. autodata:: pytition.settings.base.SEND_MONITORING_MAIL_TO_USER

Monitoring and moderation thresholds
------------------------------------

Pytition checks if petitions and or users behave weirldy in order to detect abuses.

Set variable to 0 if you want to disable a test.

Signature variation from one day to the next
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

.. autodata:: pytition.settings.base.SIGNATURE_VARIATION_CRITICAL
.. autodata:: pytition.settings.base.SIGNATURE_VARIATION_STRONG
.. autodata:: pytition.settings.base.SIGNATURE_VARIATION_AVERAGE
.. autodata:: pytition.settings.base.SIGNATURE_VARIATION_LOW

Total signature numbers according to monitoring priorities
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

.. autodata:: pytition.settings.base.SIGNATURE_NUMBER_CRITICAL
.. autodata:: pytition.settings.base.SIGNATURE_NUMBER_STRONG
.. autodata:: pytition.settings.base.SIGNATURE_NUMBER_AVERAGE
.. autodata:: pytition.settings.base.SIGNATURE_NUMBER_LOW

Number of unconfirmed signatures in the last 6h according to monitoring priorities
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

.. autodata:: pytition.settings.base.UNCONFIRMED_NUMBER_CRITICAL
.. autodata:: pytition.settings.base.UNCONFIRMED_NUMBER_STRONG
.. autodata:: pytition.settings.base.UNCONFIRMED_NUMBER_AVERAGE
.. autodata:: pytition.settings.base.UNCONFIRMED_NUMBER_LOW

Number of signatures in 24h after the creation of the petition according to monitoring priorities
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

.. autodata:: pytition.settings.base.CREATION_NUMBER_CRITICAL
.. autodata:: pytition.settings.base.CREATION_NUMBER_STRONG
.. autodata:: pytition.settings.base.CREATION_NUMBER_AVERAGE
.. autodata:: pytition.settings.base.CREATION_NUMBER_LOW

Maximum numbers of petitions created in one day by a user or an organization
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

.. autodata:: pytition.settings.base.DAY_PETITION_CRITICAL
.. autodata:: pytition.settings.base.DAY_PETITION_STRONG
.. autodata:: pytition.settings.base.DAY_PETITION_AVERAGE
.. autodata:: pytition.settings.base.DAY_PETITION_LOW

Maximum numbers of monitored or moderated petitions for a user or an organization
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Checked at the creation of a petition

.. autodata:: pytition.settings.base.MONITORED_PETITIONS_CRITICAL
.. autodata:: pytition.settings.base.MONITORED_PETITIONS_STRONG
.. autodata:: pytition.settings.base.MONITORED_PETITIONS_AVERAGE
.. autodata:: pytition.settings.base.MONITORED_PETITIONS_LOW

Maximum total numbers of signatures for a user’s or an organization’s petitions
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

.. autodata:: pytition.settings.base.SIGNATURES_TOTAL_CRITICAL
.. autodata:: pytition.settings.base.SIGNATURES_TOTAL_STRONG
.. autodata:: pytition.settings.base.SIGNATURES_TOTAL_AVERAGE
.. autodata:: pytition.settings.base.SIGNATURES_TOTAL_LOW


Other optional settings
=======================

Expand All @@ -52,3 +129,4 @@ Those are things you can configure to customize your Pytition instance:
.. autodata:: pytition.settings.base.FOOTER_TEMPLATE
.. autodata:: pytition.settings.base.DISABLE_USER_PETITION
.. autodata:: pytition.settings.base.RESTRICT_ORG_CREATION
.. autodata:: pytition.settings.base.NUMBER_OF_DAYS_FOR_EXPIRATION
29 changes: 29 additions & 0 deletions doc/installation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ Initialize Pytition project database. Pay attention to be in your virtualenv to
$ python3 manage.py collectstatic
$ python3 manage.py compilemessages
$ python3 manage.py createsuperuser
$ python3 manage.py gen_reasons

.. note:: You will be asked to enter a `username`, `email` and `password` for the administrator's account.

Expand Down Expand Up @@ -253,6 +254,8 @@ Start uwsgi and nginx servers:

Your Pytition home page should be available over there: http://mydomain.tld

You also need to launch :ref:`cron-commands`.

Now it's time to :ref:`Configure<Configuration>` your Pytition instance the way you want!

Installation via Docker (recommended for development)
Expand Down Expand Up @@ -307,9 +310,35 @@ Last command before being able to click on the "http://0.0.0.0:8000/" link that

$ docker-compose exec web pdm run ./dev/initialize.sh

Now, you need to launch :ref:`cron-commands`.

Aaaand that's it! You can now just click on the links:

- http://0.0.0.0:8000/ for the Pytition interface
- http://0.0.0.0:8080/ for the mail server web interface

Next time, just run ``$ docker-compose up --build``

Cron commands
=====================================================

In both installation methods, you need to call three commands with cron: two for spam management and one for the expiration of bins.

The first one filters the petitions that need to have their signature numbers checked periodically and calls anti-spam functions on them.

.. code-block:: bash

$ python3 pytition/manage.py cron

The second one removes permissions from moderated users in their organizations.

.. code-block:: bash

$ python3 pytition/manage.py cron_permissions

The last one deletes petitions permanently after 3 months in the bin.

.. code-block:: bash

$ python3 pytition/manage.py cron_delete_bin

2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ services:
- DJANGO_SETTINGS_MODULE=config.docker_config
- PYTHONPATH=/
build: .
command: pdm run python pytition/manage.py runserver 0.0.0.0:8000
command: bash -c "pdm use -f /venv/.venv && pdm run python pytition/manage.py runserver 0.0.0.0:8000"
volumes:
- .:/code
ports:
Expand Down
Loading