Giter VIP home page Giter VIP logo

pytition's Introduction

Pytition

Why using Pytition?

  • Because it allows you to host petitions without compromising the privacy of your signatories.
  • No tracking, ever: CSS, JS and all resources are self-hosted. Pytition does not use CDN.
  • Nice UI: Bootstrap 4 + JQuery 3.
  • Based on solid backend technology: Django.
  • Responsive UI: works well on phones/tablets/laptops/desktops.
  • If you host an instance of Pytition, you can guarantee your signatories that their informations won't leak to third parties.
  • It is Open Source and Free Software.

Features

  • Multi-lingual UI with i18n. For now only English and French translations available but you can send a Pull Request :)
  • You can pre-visualize petitions before publishing them.
  • Easy to use: petition content is typed-in via TinyMCE editors (like WordPress).
  • You can setup real SMTP account for the confirmation e-mail so that it is less likely considered as SPAM.
  • Supports Open Graph tags to provide description and image to allow nice cards to be shown when people post the petition link on social networks.
  • You can propose your signatories to subscribe to a newsletter/mailinglist (via HTTP GET/POST or EMAIL methods).
  • You can export signatures in CSV format.

Future features

  • Support for several organizations on the same Pytition instance v2.0
  • Support for multi-lingual petition content: v3.0
  • Support for adding several petition templates: v4.0
  • Add optional Mastodon/Diaspora share-icons

Install development environment

See dev/CONTRIBUTE.md

Installing in production

Setup virtualenv and clone the code

$ mkdir -p www/static
$ virtualenv -p python3 pytition_venv
$ source pytition_venv/bin/activate
(pytition_venv) $ cd www
(pytition_venv) $ git clone https://github.com/fallen/pytition
(pytition_venv) $ cd pytition
(pytition_venv) $ pip3 install -r requirements.txt

Configure pytition/pytition/pytition/settings.py:

In a production environment you should modify the following settings:

  • SECRET_KEY => put YOUR value, it's important for security.
  • DEBUG => False
  • ALLOWED_HOSTS => your DNS
  • DATABASES => use mysql backend instead of sqlite3
  • STATIC_ROOT => /home/your_user/www/static

Setup your customization

You can customize the TinyMCE variables:

  • TINYMCE_JS_URL
  • TINYMCE_DEFAULT_CONFIG

Setup mysql credentials

~/www/pytition$ cat ~/www/my.cnf
[client]
database = DATABASENAME
user = USERNAME
password = A_PASSWORD
default-character-set = utf8

Then tell Django to use those credentials on settings.py:

~/www/pytition$ grep -A 8 DATABASE ./pytition/pytition/settings.py
DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.mysql',
        'OPTIONS': {
            'read_default_file': '/home/YOUR_USER/www/my.cnf',
            'init_command': "SET sql_mode='STRICT_TRANS_TABLES'",
        },
    }
}

Initialize the Django project

Beware to still be in the virtual environment, if not please re-do the source pytition_venv/bin/activate command.

(pytition_venv) $ cd www/pytition/pytition
(pytition_venv) $ python3 manage.py migrate
(pytition_venv) $ python3 manage.py createsuperuser

Configure Apache

~/www/pytition$ cat /etc/apache2/sites-enabled/petition.conf
WSGIPythonHome /home/YOUR_USER/pytition_venv
WSGIPythonPath /home/YOUR_USER/www/pytition/pytition

<VirtualHost *:80>
ServerName petition.yourdomain.tld
WSGIScriptAlias / /home/YOUR_USER/www/pytition/pytition/pytition/wsgi.py

Alias /static /home/YOUR_USER/www/static

<Directory /home/YOUR_USER/www/static>
Require all granted
</Directory>

<Directory /home/YOUR_USER/www/pytition/pytition/pytition>
<Files wsgi.py>
Require all granted
</Files>
</Directory>
</VirtualHost>

I won't explain how to setup HTTPS and let's encrypt TLS certificate, but you should use and force use of HTTPS for security reasons.

For more information about how to deploy a Django app, please see: https://docs.djangoproject.com/en/1.11/howto/deployment/ and https://developer.mozilla.org/en-US/docs/Learn/Server-side/Django/Deployment

Test connecting to the application

When Apache is setup and running and your database is created and populated with Django models (migrations commands) and the superuser is created, you can try accessing your petition application: http://petition.yourdomain.tld/admin

You should be able to log-in and create your first petition.

Then when the petition is created, you can access it via http://petition.yourdomain.tld/ which will always redirect to the last created petition.

If you try this URL before creating a petition you will get an error.

Included dependencies

Those are external projects that are needed and used by Pytition, but included in Pytition source tree:

  • Bootstrap 4.2.1
  • JQuery 3.3.1
  • Popper 1.14.6
  • Open Iconic 1.1.1
  • TinyMCE 4.9.2
  • jQuery Smart Wizard 4

Dependencies

  • Python 3
  • Django 2.1.x
  • django-tinymce 2.8.0
  • django-colorfield 0.1.15
  • requests 2.20.x
  • mysqlclient 1.3.12
  • beautifulsoup4 4.6.3
  • django-formtools 2.1

pytition's People

Contributors

angristan avatar dostoi avatar fallen avatar goofy-mdn avatar numahell avatar spiderweak avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.