#59 Improve README (and fix typos)

Ouvert
MathieuMD veut fusionner 11 commits à partir de Intarnet/pr1 vers FFDN/master

+ 4 - 3
.gitignore

@@ -1,9 +1,10 @@
 *.pyc
 *.pyc
 __pycache__/
 __pycache__/
 *~
 *~
-*.sqlite3
 wifiwithme/settings/local.py
 wifiwithme/settings/local.py
 var/media/*
 var/media/*
 var/static/*
 var/static/*
-venv
-.idea
+.idea
+# Virtual environment folder and database file shouldn't be inside git repo.
+#venv
+#*.sqlite3

+ 110 - 49
README.md

@@ -6,80 +6,118 @@ a virtual environment (like virtualenv).
 
 
 Install packages:
 Install packages:
 
 
-     # apt-get install python3-pip python3-virtualenv libyaml-dev
+```bash
+sudo apt-get install python3-pip python3-virtualenv virtualenv libyaml-dev
+```
+
+Retrieve the repository:
+
+```bash
+# Create the base directory:
+mkdir wwm
+cd wwm
+
+# Clone the repo:
+git clone https://code.ffdn.org/FFDN/wifi-with-me.git
+
+# If you need to change to a specific branch:
+cd wifi-with-me
+git checkout myBranch
+cd ..
+```
 
 
 Create and activate the virtualenv with:
 Create and activate the virtualenv with:
 
 
-     $ virtualenv -p $(which python3) venv
-     $ source venv/bin/activate
+```bash
+virtualenv -p $(which python3) venv
+source venv/bin/activate
+```
 
 
 We use django framework.  Install it from requirements with pip:
 We use django framework.  Install it from requirements with pip:
 
 
-     $ pip install -r requirements/base.txt
+```bash
+pip install -r wifi-with-me/requirements/base.txt
+```
 
 
 For development, install `dev.txt` instead:
 For development, install `dev.txt` instead:
 
 
-     $ pip install -r requirements/dev.txt
+```bash
+pip install -r wifi-with-me/requirements/dev.txt
+```
 
 
 Set up configuration
 Set up configuration
 ====================
 ====================
 
 
-Then create and edit a `wifiwithme/settings/local.py` configuration file
-`wifiwithme/settings/local.py`.
+Then create and edit the configuration file
+`wifi-with-me/wifiwithme/settings/local.py` according to following
+instructions:
 
 
 Mandatory settings
 Mandatory settings
 ------------------
 ------------------
 
 
 You **must** Define some details about your ISP in the ISP variable, eg:
 You **must** Define some details about your ISP in the ISP variable, eg:
 
 
-    ISP={
-        'NAME':'FAIMAISON',
-        'TITLE':'Réseau wifi expérimental',
-        'SITE':'//www.faimaison.net',
-        'EMAIL':'bureau (at) faimaison.net',
-        'ZONE':'Nantes et environs',
-        'ADDRESS_EXAMPLE': 'rue du calvaire, nantes',
-        'URL_CONTACT':'//www.faimaison.net/pages/contact.html',
-        'LATITUDE':47.218371,
-        'LONGITUDE':-1.553621,
-        'ZOOM':13,
-        'CNIL':{
-            'LINK':'//www.faimaison.net/files/cnil-faimaison-1819684-withwithme.pdf',
-            'NUMBER':1819684
-        }
+```python
+ISP={
+    'NAME':'FAIMAISON',
+    'TITLE':'Réseau wifi expérimental',
+    'SITE':'//www.faimaison.net',
+    'EMAIL':'bureau (at) faimaison.net',
+    'ZONE':'Nantes et environs',
+    'ADDRESS_EXAMPLE': 'rue du calvaire, nantes',
+    'URL_CONTACT':'//www.faimaison.net/pages/contact.html',
+    'LATITUDE':47.218371,
+    'LONGITUDE':-1.553621,
+    'ZOOM':13,
+    'CNIL':{
+        'LINK':'//www.faimaison.net/files/cnil-faimaison-1819684-withwithme.pdf',
+        'NUMBER':1819684
     }
     }
+}
+```
 
 
-    SITE_URL='https://wifi.faimaison.net
+The wifi-with-me website URL (for links included in emails) defaults to
+`http://localhost:8000`, so it must be customized:
 
 
-Optional settings
------------------
-
-### Website URL
+```python
+SITE_URL='https://wifi.faimaison.net'
+```
 
 
-The wifi-with-me website URL (for links included in emails :)
+List of domain name(s) under wich the website is accessible:
 
 
-    SITE_URL="http://example.tld"
+```python
+ALLOWED_HOSTS=['wifi.faimaison.net']
+# Or, for several domains:
+ALLOWED_HOSTS=['wifi.faimaison.net', 'faimaison.net']
+```
 
 
+Optional settings
+-----------------
 
 
-## URL Prefix
+### Website URL
 
 
 Optionaly, you can define an url prefix (ex: `/foo/`) so that wifi-with-me is
 Optionaly, you can define an url prefix (ex: `/foo/`) so that wifi-with-me is
-accessible under *http://example.com/foo/* :
+accessible under *http://example.com/foo/*:
 
 
-    URL_PREFIX='foo/'
+```python
+URL_PREFIX='foo/'
+```
 
 
 ### Notifications
 ### Notifications
 
 
-If you to receive notifications on each new contrib, customize those :
+If you want to receive notifications on each new contrib, customize those:
 
 
 List of notification recipients:
 List of notification recipients:
 
 
-    NOTIFICATION_EMAILS=['admin@example.tld']
+```python
+NOTIFICATION_EMAILS=['admin@example.com', 'admin2@example.com']
+```
 
 
 Notification sender address:
 Notification sender address:
 
 
-    DEFAULT_FROM_EMAIL='notifier@example.tld'
-
+```python
+DEFAULT_FROM_EMAIL='notifier@example.tld'
+```
 
 
 ### Data expiration
 ### Data expiration
 
 
@@ -89,10 +127,12 @@ its explicit consent to keep it one more year.
 Reminders are sent to the contribution author when expiration date gets
 Reminders are sent to the contribution author when expiration date gets
 close. By default we send two notifications :
 close. By default we send two notifications :
 
 
-    DATA_EXPIRATION_REMINDERS = [
-        30,  # 1 month before
-        7,   # 1 week before
-    ]
+```python
+DATA_EXPIRATION_REMINDERS = [
+    30,  # 1 month before
+    7,   # 1 week before
+]
+```
 
 
 You can tweak it to your will or decide to send no reminder (with value `[]`).
 You can tweak it to your will or decide to send no reminder (with value `[]`).
 
 
@@ -103,23 +143,34 @@ Migrate from bottle version (optional)
 If you used the (old) bottle version of wifi-with-me and want to migrate your
 If you used the (old) bottle version of wifi-with-me and want to migrate your
 data follow this extra step :
 data follow this extra step :
 
 
-    $ ./manage.py migrate auth
-    $ ./manage.py migrate contribmap 0001 --fake
+```bash
+./wifi-with-me/manage.py migrate auth
+./wifi-with-me/manage.py migrate contribmap 0001 --fake
+```
 
 
 Run development server
 Run development server
 ======================
 ======================
 
 
+NOTE: For prod environment, replace `./wifi-with-me/manage.py` with
+`DJANGO_SETTINGS_MODULE=wifiwithme.settings.prod ./wifi-with-me/manage.py`.
+
 It is required to initialize database first:
 It is required to initialize database first:
 
 
-    $ ./manage.py migrate
+```bash
+./wifi-with-me/manage.py migrate
+```
 
 
 Create an admin:
 Create an admin:
 
 
-    $ ./manage.py createsuperuser
+```bash
+./wifi-with-me/manage.py createsuperuser
+```
 
 
 Then launch service with:
 Then launch service with:
 
 
-    $ ./manage.py runserver
+```bash
+./wifi-with-me/manage.py runserver
+```
 
 
 You can visit with your browser at <http://127.0.0.1:8000/map/contribute>
 You can visit with your browser at <http://127.0.0.1:8000/map/contribute>
 
 
@@ -128,7 +179,9 @@ Drop the database
 
 
 If you want to **reset all your data**.
 If you want to **reset all your data**.
 
 
-    $ rm db.sqlite3
+```bash
+rm db.sqlite3
+```
 
 
 
 
 Run production server
 Run production server
@@ -138,8 +191,16 @@ Run production server
 
 
 1. Deploy it [like any django site](https://docs.djangoproject.com/en/1.11/howto/deployment/)
 1. Deploy it [like any django site](https://docs.djangoproject.com/en/1.11/howto/deployment/)
 2. Customize [mandatory and optional settings](#set-up-configuration)
 2. Customize [mandatory and optional settings](#set-up-configuration)
-3. Customize `SECRET_KEY` to something really random. Hint: `python -c "import string,random; uni=string.ascii_letters+string.digits+string.punctuation; print(repr(''.join([random.SystemRandom().choice(uni) for i in range(random.randint(45,50))])))"`
+3. Customize `SECRET_KEY` to something really random. Hint:
+
+```bash
+python -c "import string,random; uni=string.ascii_letters+string.digits+string.punctuation; print(repr(''.join([random.SystemRandom().choice(uni) for i in range(random.randint(45,50))])))"
+```
+
 4. Set *daily* crons for the two commands that take care of data expiration
 4. Set *daily* crons for the two commands that take care of data expiration
    handling (run them with `--help` for more information):
    handling (run them with `--help` for more information):
-    - `./manage.py delete_expired_contribs`
-    - `./manage.py send_expiration_reminders`
+
+```bash
+./wifi-with-me/manage.py delete_expired_contribs
+./wifi-with-me/manage.py send_expiration_reminders
+```

+ 1 - 1
wifiwithme/apps/contribmap/templates/contribmap/wifi-form.html

@@ -57,7 +57,7 @@
       {% endfor %}
       {% endfor %}
     </div>
     </div>
 
 
-    <div id="contrib-type-share"
+    <div id="contrib-type-share">
     <h2>Partager une connexion</h2>
     <h2>Partager une connexion</h2>
 
 
     <h3>Type de connexion</h3>
     <h3>Type de connexion</h3>

+ 1 - 4
wifiwithme/settings/base.py

@@ -80,7 +80,7 @@ WSGI_APPLICATION = 'wifiwithme.wsgi.application'
 DATABASES = {
 DATABASES = {
     'default': {
     'default': {
         'ENGINE': 'django.db.backends.sqlite3',
         'ENGINE': 'django.db.backends.sqlite3',
-        'NAME': os.path.join(os.path.dirname(BASE_DIR), 'db.sqlite3'),
+        'NAME': os.path.join(os.path.dirname(BASE_DIR), '../db.sqlite3'),
     }
     }
 }
 }
 
 
@@ -136,9 +136,6 @@ STATICFILES_DIRS = [
 
 
 NOTIFICATION_EMAILS = []
 NOTIFICATION_EMAILS = []
 
 
-SITE_URL = 'http://example.com/wifi'
-
-
 # Data expiration warning
 # Data expiration warning
 
 
 DATA_EXPIRATION_REMINDERS = [
 DATA_EXPIRATION_REMINDERS = [