Skip to content

Commit 27b85d9

Browse files
committed
Add documentation content
1 parent 020025e commit 27b85d9

11 files changed

+216
-125
lines changed

README.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,18 @@ Froide
44
[![Build Status](https://travis-ci.org/stefanw/froide.png?branch=master)](https://travis-ci.org/stefanw/froide)
55

66

7-
Froide is a Freedom Of Information Portal written in Python using Django 1.4.3.
8-
The name comes from Freedom of Information (de). Also Froide
9-
sounds like Freude which is German for joy.
7+
Froide is a Freedom Of Information Portal written in Python using Django 1.5.
108

11-
It is used by the German FoI site fragdenstaat.de, but it is fully
9+
It is used by the German and the Austrian FOI site, but it is fully
1210
internationalized and written in English.
1311

1412
Docs
1513
----
1614

1715
[Read the documentation](http://readthedocs.org/docs/froide/en/latest/) including a [Getting Started Guide](http://readthedocs.org/docs/froide/en/latest/gettingstarted/).
1816

17+
Froide is supported by the [Open Knowledge Foundation](http://okfn.org/).
18+
1919

2020
License
2121
-------

docs/about.rst

+15-10
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,8 @@
22
About
33
=====
44

5-
Froide was designed to mimic the functionality of `What do they know <http://whatdotheyknow.com>`_ – a Freedom of Information portal in the UK written in Ruby on Rails 2.3. At the time when a German FoI portal was needed, the general FoI solution forked from WDTK called `Alaveteli <http://alaveteli.org>`_ was hard to install and not ready for reuse.
6-
That's why Froide was developed as a fresh start, fully
7-
internationalized and configurable written in Django 1.3 to power `Frag den Staat <https://fragdenstaat.de>`_.
5+
Froide is a Freedom of Information portal software written in Python with Django 1.5.
6+
87

98
Development Goals
109
-----------------
@@ -36,20 +35,26 @@ Features
3635
request-unique email address (using SMTP) and the platform will receive answers on
3736
that mail address (by accessing an IMAP account).
3837
- Search functionality for Requests and Public Bodies.
39-
- Error Reporting interface via Sentry.
38+
- A read/write REST-API
39+
- Redaction of PDFs
4040

4141
Dependencies
4242
------------
4343

4444
A detailed list of Python package dependencies can be found in `requirements.txt`, but here is a general overview:
4545

46-
- Django 1.3 - the Web framework
47-
- South 0.7.3 - the database migration framework (development dependency)
48-
- Sphinx 1.0.7 - the documentation tool (development dependency)
49-
- Celery 2.2.5 - task queue for background processing
50-
- Haystack 1.2.0 - abstraction layer for search
46+
- Django 1.5 - the Web framework
47+
- Celery 3.X - task queue for background processing
48+
- Haystack 2.X-beta - abstraction layer for search
49+
50+
A development goal is that, even though a task queue (like Celery) and a search server (like Solr) are highly recommended, they are not necessary for either development or production setup and can be replaced with Cronjobs and database queries respectively (results/performance will probably degrade, but it will work nonetheless).
5151

52-
A development goal is that, even though a task queue (like Celery) and a search server (like Solr) are highly recommended, they are not necessary for either development or production setup and can be replaced with Cronjobs and database queries respectively (results/performance will probably degrade, but it should work).
52+
History
53+
-------
54+
55+
Froide was designed to mimic the functionality of `What do they know <http://whatdotheyknow.com>`_ – a Freedom of Information portal in the UK written in Ruby on Rails 2.3. At the time when a German FoI portal was needed, the general FoI solution forked from WDTK called `Alaveteli <http://alaveteli.org>`_ was hard to install and not ready for reuse.
56+
That's why Froide was developed in spring 2011 as a fresh start, fully
57+
internationalized and configurable written in Django 1.3 to power `Frag den Staat <https://fragdenstaat.de>`_ which launched in August 2011.
5358

5459
Name
5560
----

docs/admin.rst

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
============
2+
Froide Admin
3+
============
4+
5+
The Django admin exposes database objects to staff users and superusers.
6+
Superusers have access to all objects while staff users can be given specific read/write/delete access to kinds of objects (e.g. only public bodies). Users can also given a group that has certain rights associated with it.

docs/conf.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141

4242
# General information about the project.
4343
project = u'froide'
44-
copyright = u'2011, Stefan Wehrmeyer'
44+
copyright = u'2013, Stefan Wehrmeyer, Open Knowledge Foundation'
4545

4646
# The version info for the project you're documenting, acts as replacement for
4747
# |version| and |release|, also used in various other places throughout the

docs/configuration.rst

+12-43
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Configuration
44

55
Froide can be configured in many ways to reflect the needs of your local FoI portal.
66

7-
All configuration is kept in the Django `settings.py` file. Individual settings can be overwritten by placing a `local_settings.py` file on the Python path (e.g. in the same directory) and redefining the configuration key in there.
7+
The `custom_settings.py.example` file that comes with froide has all the settings from the `settings.py` file but they are commented out. You can copy this file to `custom_settings.py`
88

99
Froide Configuration
1010
--------------------
@@ -37,6 +37,9 @@ The following keys in that dictionary must be present:
3737
*integer* The id of the Freedom of Information law in the database
3838
that is used by default (e.g. 1)
3939

40+
**search_engine_query**
41+
*string* You can give a URL with string formatting placeholders `query` and `domain` in them that will be presented to the user as the URL for web searches. The default is a Google search.
42+
4043

4144
Greeting Regexes
4245
----------------
@@ -77,7 +80,7 @@ You must adapt the standard Django parameters for sending email.
7780
Configure the backend depending on your environment (development vs.
7881
production)::
7982

80-
# development environment:
83+
# development/testing environment:
8184
EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend'
8285
# production environment:
8386
EMAIL_BACKEND = 'djcelery_email.backends.CeleryEmailBackend'
@@ -136,52 +139,17 @@ right before the mail is
136139
sent out (the changed address is not stored). This allows for some
137140
testing of sending and receiving mails to and from public bodies wihtout spamming them.
138141

139-
Setting Up Search with Solr
140-
---------------------------
141-
142-
Froide uses `django-haystack` to interface with a search. Solr is
143-
recommended, but thanks to `django-haystack` you can use something
144-
else as well.
145-
146-
Haystack configuration for solr works like so::
147-
148-
HAYSTACK_SITECONF = 'froide.search_sites'
149-
HAYSTACK_SEARCH_ENGINE = 'solr'
150-
HAYSTACK_SOLR_URL = 'http://127.0.0.1:8983/solr'
151-
152-
If you have a solr multicore setup, your solr URL would probably look more like this::
153-
154-
HAYSTACK_SOLR_URL = 'http://127.0.0.1:8983/solr/froide'
155-
156-
For details, please refer to the `Haystack Documentation <http://haystacksearch.org>`_.
157-
158-
Setting Up Background Processing with Celery
159-
--------------------------------------------
160-
161-
The following part in `settings.py` does the configuration of Celery.
162-
Overwrite the `CELERY*` values with your own in `local_settings.py`::
163-
164-
import djcelery
165-
djcelery.setup_loader()
166-
167-
CELERY_IMPORTS = ("foirequest.tasks", )
168-
169-
CELERY_RESULT_BACKEND = "database"
170-
CELERY_RESULT_DBURI = "sqlite:///dev.db"
171-
172-
CELERYBEAT_SCHEDULER = "djcelery.schedulers.DatabaseScheduler"
173-
174-
For details please refer to the `django-celery documentation <http://django-celery.readthedocs.org/en/latest/index.html>`_.
175142

176143
Some more settings
177144
------------------
178145

179-
Configure the name and default domain URL (without trailing slash) of your site with the following settings::
146+
Configure the name, default domain URL and default email (without trailing slash) of your site with the following settings::
180147

181148
SITE_NAME = 'FroIde'
182149
SITE_URL = 'http://localhost:8000'
150+
SITE_EMAIL = '[email protected]'
183151

184-
You can give a URL with string formatting placeholders `query` and `domain` in them that will be presented to the user as the URL for web searches via the setting `SEARCH_ENGINE_QUERY`. The default is a Google search.
152+
More suggestions of settings you can change can be found in the `custom_settings.py.example` file that comes with froide.
185153

186154

187155
Securing your site
@@ -193,11 +161,10 @@ parts configurable by `local_settings` you can use the following
193161
setting::
194162

195163
SECRET_URLS = {
196-
"admin": "my-secret-admin",
197-
"sentry": "my-secret-sentry"
164+
"admin": "my-secret-admin"
198165
}
199166

200-
It's also recommended to protect the admin and sentry further via HTTP
167+
It's also recommended to protect the admin further via HTTP
201168
auth in your production reverse proxy (e.g. nginx).
202169

203170
The app `djangosecure <https://github.com/carljm/django-secure/>`_ is part of Froide
@@ -212,3 +179,5 @@ Some Django settings related to security and SSL::
212179
SESSION_COOKIE_AGE = 3628800 # six weeks for usability
213180
SESSION_COOKIE_HTTPONLY = True
214181
SESSION_COOKIE_SECURE = True
182+
183+
Make sure that your frontend server transports the information that HTTPS is used to the web server.

docs/development.rst

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
Development
2+
===========
3+
4+
Run tests
5+
---------
6+
7+
Froide has a test suite. You have to install the test dependencies first::
8+
9+
pip install -r requirements-test.txt
10+
11+
The default test configuration requires a running elasticsearch instance.
12+
You either have to install elasticsearch or change the configuration to
13+
another search engine.
14+
15+
Then you can run the tests::
16+
17+
make test
18+
19+
This also does test coverage analysis that you can then
20+
find at `htmlcov/index.html`.
21+
22+
23+
Build docs
24+
----------
25+
26+
The docs can be build with Sphinx but first you must install the theme.
27+
Excecute these commands from the top level of the froide directory::
28+
29+
git submodule init
30+
git submodule update
31+
32+
Then change into the `docs` directory and type::
33+
34+
make html
35+
36+
The documentation will be build and you can find the resulting html in `docs/_build/html`.

docs/gettingstarted.rst

+91-33
Original file line numberDiff line numberDiff line change
@@ -9,71 +9,129 @@ more advanced features are discussed at the end.
99
Set up the development environment
1010
----------------------------------
1111

12-
You should be using `virtualenv` and it is suggested you
13-
also use `virtualenvwrapper`. Setup a virtual environment for development like so::
12+
You should be using a Python virtual environment.
13+
Setup a virtual environment for development with `virtualenv`like so::
1414

15-
mkvirtualenv --no-site-packages froide
15+
virtualenv --no-site-packages ~/pyenv
16+
. ~/pyenv/bin/activate
1617

17-
Get the source code with Git from the official GitHub repository or from
18-
your fork::
18+
Get the source code with Git from the GitHub repository::
1919

2020
git clone git://github.com/stefanw/froide.git
2121
cd froide
2222

2323
Install the requirements inside the virtual env with `pip`::
2424

25-
which pip
26-
<should display your virtual env pip>
2725
pip install -r requirements.txt
2826

29-
If only your global `pip` is available, run `easy_install pip`. The dependency installation takes a couple of seconds, but after that everything is in place.
27+
The dependency installation may take a couple of minutes, but after that everything is in place.
3028

31-
Copy `custom_settings.py.example` to `custom_settings.py`::
29+
Sync and migrate and *do NOT* create a superuser just yet::
30+
31+
python manage.py syncdb --noinput --migrate
32+
33+
Now you can already start the web server::
34+
35+
python manage.py runserver
36+
37+
Visit `http://localhost:8000 <http://localhost:8000>`_ and there is your running Froide instance!
38+
39+
You can quit the server (Ctrl+C) and create a superuser account::
40+
41+
python manage.py createsuperuser
42+
43+
44+
Add basic database objects
45+
--------------------------
46+
47+
Run the web server again and login to the admin interface at `http://localhost:8000/admin/ <http://localhost:8000/admin/>`_ with the credentials of your superuser.
48+
49+
The first thing you should do is create a jurisdiction. Click on "Jurisdiction" in the "Publicbody" section and then on "Add Jurisdiction".
50+
Name your jurisdiction however you want (e.g. Federal). If you only ever intend to have one, the name will not even show up. Click "Save" to continue.
51+
52+
Go back into the public body section and add an FOI law. Give it a name (e.g. Freedom of Information Act) and choose a jurisdiction. There are many more things that can be configured, but you can leave them for now.
53+
54+
Now you can add your first public body by going back to the public body section and clicking on "Add" next to "Public Bodies". Give it a name (e.g. Ministry of the Interior).
55+
Click on the little plus-sign next to topic to add a topic for this public body. The classification is to distinguish different areas of government (e.g. "Ministry", "Council").
56+
If you want to make a request to this public body, it needs to have an email address.
57+
Select your previously created jurisdiction and FOI law and save.
58+
59+
You should also fill out your user details like your name in the user section of the admin.
60+
61+
Now you are ready to make your first request. Go back to the front page and give it a go. You can also find out more about the :doc:`admin`.
62+
63+
64+
Custom configuration
65+
--------------------
66+
67+
By default the Django Web server uses the `settings.py` file in the froide directory (the `froide.settings` Python module). This will be fine for your first experiments but if you want to customize your froide instance you will want your own settings file.
68+
69+
Go into the froide directory and copy the `custom_settings.py.example` to `custom_settings.py`::
3270

3371
cd froide
3472
cp custom_settings.py.example custom_settings.py
3573

36-
The development environment uses SQLite. You can override the default Django settings values for froide in your `custom_settings.py`, if you want, but you don't have to.
74+
Now you can customize that settings file to your liking. Note that it imports the original `settings.py` at the top, so you only have to change the values you need to change.
3775

38-
Your `custom_settings.py` file (you can name it differently) is your Django settings file that you must give on each Django manage.py command. You can also set the `DJANGO_SETTINGS_MODULE` environment variable.
76+
In order for Django to start your web server with these new settings you either have to set the environment variable `DJANGO_SETTINGS_MODULE` or give the settings module as a command line argument.
3977

40-
Sync and migrate and *do NOT* create a superuser just yet::
78+
Either type::
79+
80+
export DJANGO_SETTINGS_MODULE=froide.custom_settings
81+
python manage.py runserver
4182

42-
python manage.py syncdb --noinput --migrate --settings=froide.custom_settings
83+
The environment variable will be set for this shell session. If you open a new shell, you have to export the settings again.
84+
Or::
4385

44-
Now you can create a superuser account::
86+
python manage.py runserver --settings=froide.custom_settings
4587

46-
python manage.py createsuperuser --settings=froide.custom_settings
88+
Since it can be annoying to type this (or to remember to export the environment variable), you can create a shortcut shell script, create an alias, put an export in your virtualenv's `activate` file or use `virtualenvwrapper <http://virtualenvwrapper.readthedocs.org/en/latest/>`_ and put the export in your `postactivate` hook.
4789

48-
That's it for a setup that basically works. Run this::
4990

50-
python manage.py runserver --settings=froide.custom_settings
5191

52-
and go to `http://localhost:8000 <http://localhost:8000>`_. You should
53-
be greeted by a working Froide installation. It doesn't have any data
54-
inside, but you can change that by going to `http://localhost:8000/admin/ <http://localhost:8000/admin/>`_ and logging in with your superuser account.
92+
Search with Haystack
93+
--------------------
94+
95+
In order to get a real search engine running you need to override the `HAYSTACK_CONNECTIONS` setting with the details of your search engine. Find out `how to configure your search engine at the Haystack Docs <http://django-haystack.readthedocs.org/en/latest/tutorial.html#modify-your-settings-py>`_.
96+
97+
An example configuration for solr would look like this::
98+
99+
HAYSTACK_CONNECTIONS = {
100+
'default': {
101+
'ENGINE': 'haystack.backends.solr_backend.SolrEngine',
102+
'URL': 'http://127.0.0.1:8983/solr/froide'
103+
}
104+
}
105+
106+
107+
Background Tasks with Celery
108+
----------------------------
55109

56-
For more information on the different models you find in the admin visit :doc:`models`.
110+
From the standard settings file everything is already setup for background tasks except that they are not running in the background.
57111

58-
Run tests
59-
---------
112+
You need to change the `CELERY_ALWAYS_EAGER` setting to `False` in your custom settings::
60113

61-
Froide has a test suite. Copy `test_settings.py.example` to `test_settings.py`. `test_settings.py` does not use your `custom_settings.py` changes.
114+
CELERY_ALWAYS_EAGER = False
62115

63-
You can then run for tests::
116+
You need a broker for Celery. Find out more at the `Celery Docs <http://docs.celeryproject.org/en/latest/getting-started/first-steps-with-celery.html#choosing-a-broker>`_.
64117

65-
make test
118+
We recommend `RabbitMQ <http://www.rabbitmq.com/>`_ as broker. Install it and then start it in a different terminal like this::
66119

67-
This also does test coverage analysis that you can then
68-
find at `htmlcov/index.html`.
69-
Note some tests will not work without a search engine like solr running.
120+
rabbitmq-server
70121

122+
After you started the broker open yet another terminal, activate your virtual environment and run the celery worker like this::
71123

72-
Search with Haystack and Solr
73-
-----------------------------
124+
python manage.py celeryd -l INFO -B
74125

126+
Now your server will send background tasks to Celery. Lots of common tasks are designed as background tasks so that an ongoing HTTP request can send a response more quickly. The following things are designed as background tasks:
75127

76-
Background Processing with Celery
77-
---------------------------------
128+
- Search Indexing: Updates to database objects are indexed in the background
129+
- Email Sending: When an action triggers an email, it's sent in the background
130+
- Denormalized Counts on database objects
78131

132+
Celery also takes the role of `cron` and handles periodic tasks. You should set up periodic tasks in the admin under "Djcelery - Periodic tasks". Here is a recommended configuration:
79133

134+
- Fetch Mail: every minute
135+
- Detect Overdue at Midnight: 0 0 * * * (m/h/d/dM/MY)
136+
- Batch Update Followers every 24 hours: 0 0 * * * (m/h/d/dM/MY)
137+
- Remind users to classify there requests: 0 7 6 * * (m/h/d/dM/MY)

0 commit comments

Comments
 (0)