Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Anthony
memopol
Commits
8c2dde9f
Commit
8c2dde9f
authored
Jun 29, 2016
by
njoyard
Committed by
GitHub
Jun 29, 2016
Browse files
Merge pull request #95 from political-memory/pgsql
Switch to pgsql-only
parents
f6a4020a
64ad6580
Changes
17
Hide whitespace changes
Inline
Side-by-side
.travis.yml
View file @
8c2dde9f
sudo
:
false
env
:
-
DJANGO_DEBUG=True DJANGO_SETTINGS_MODULE=memopol.settings
global
:
-
DJANGO_DEBUG=True
-
DJANGO_SETTINGS_MODULE=memopol.settings
-
MEMOPOL_DB_NAME=memopol
-
MEMOPOL_DB_USER=memopol
-
MEMOPOL_DB_PASSWORD=memopol
-
MEMOPOL_DB_HOST=localhost
-
MEMOPOL_DB_PORT=5432
-
MEMOPOL_DB_ENGINE=django.db.backends.postgresql_psycopg2
language
:
python
python
:
-
'
2.7'
services
:
-
postgresql
install
:
-
pip install -e .[testing]
before_script
:
-
bin/install_client_deps.sh
-
psql -c "CREATE USER memopol WITH CREATEDB PASSWORD 'memopol';" -U postgres
-
psql -c "CREATE DATABASE memopol WITH OWNER memopol;" -U postgres
script
:
-
flake8 . --exclude '*/migrations,docs,static' --ignore E128
-
py.test memopol representatives_positions representatives_recommendations
...
...
bin/quickstart.sh
View file @
8c2dde9f
...
...
@@ -22,6 +22,15 @@ pip install -e .[testing]
# Install client dependencies
bin/install_client_deps.sh
# Create pg user and database
if
[
$(
psql
-c
"select 'CNT=' || count(1) from pg_catalog.pg_user where usename='memopol';"
-U
postgres |
grep
CNT
=
1 |
wc
-l
)
-lt
1
]
;
then
psql
-c
"create user memopol with password 'memopol';"
-U
postgres
fi
psql
-c
"alter role memopol with createdb;"
-U
postgres
if
[
$(
psql
-l
-U
postgres | egrep
"^ memopol
\W
"
|
wc
-l
)
-lt
1
]
;
then
psql
-c
"create database memopol with owner memopol;"
-U
postgres
fi
# Setup environment
export
DJANGO_DEBUG
=
True
export
DJANGO_SETTINGS_MODULE
=
memopol.settings
...
...
docs/development.rst
View file @
8c2dde9f
...
...
@@ -101,38 +101,33 @@ the ``DJANGO_DEBUG`` variable in the current shell::
$ export DJANGO_DEBUG=True
Run
the d
evelopment server
==================
========
Setup
the d
atabase
==================
Run the development server::
Memopol requires PostgreSQL 9.1 or higher. It used to run with SQLite, too, but
that is no longer the case. Memopol uses the following environment variables
for database access:
$ ./manage.py runserver
* ``MEMOPOL_DB_NAME`` (defaults to 'memopol')
* ``MEMOPOL_DB_USER`` (defaults to 'memopol')
* ``MEMOPOL_DB_PASSWORD`` (defaults to 'memopol')
* ``MEMOPOL_DB_HOST`` (defaults to 'localhost')
* ``MEMOPOL_DB_PORT`` (defaults to '5432')
Performing system checks...
Make sure the corresponding user and database exist on your system; the user
will need the 'createdb' permission in order to be able to run tests. To create
them, you may use the following commands:
System check identified no issues (0 silenced).
December 09, 2015 - 21:26:47
Django version 1.8.7, using settings 'memopol.settings'
Starting development server at http://127.0.0.1:8000/
Quit the server with CONTROL-C.
[09/Dec/2015 21:26:48] "GET / HTTP/1.1" 200 13294
The website is running on ``http://127.0.0.1:8000/``.
$ psql -c "create user memopol with password 'memopol';" -U postgres
$ psql -c "alter role memopol with createdb;" -U postgres
$ psql -c "create database memopol with owner memopol;" -U postgres
Database migrations
===================
The repo comes with a pre-configured SQLite db with sample data so that you can
start hacking right away. However, if you were to use a local postgresql
database ie. with this sort of environment::
export DJANGO_DATABASE_DEFAULT_NAME=memopol
export DJANGO_DATABASE_DEFAULT_USER=postgres
export DJANGO_DATABASE_DEFAULT_ENGINE=django.db.backends.postgresql_psycopg2
export DJANGO_DEBUG=1
export DJANGO_SETTINGS_MODULE=memopol.settings
Then you could run database migrations::
Database migrations ensure the database schema is up to date with the project.
If you're not sure, you can run them anyway, they won't do any harm. Use the
following command::
$ ./manage.py migrate
Operations to perform:
...
...
@@ -153,8 +148,7 @@ Then you could run database migrations::
Provision with data
===================
Again, the repo comes with a pre-configured SQLite db with sample data so that
you can start hacking right away. However, you could still reload sample data::
You can load a small data sample for quick setup:
$ ./manage.py loaddata memopol/fixtures/small_sample.json
...
...
@@ -162,4 +156,22 @@ Or actual data (takes a while)::
$ bin/update_all
Run the development server
==========================
Run the development server::
$ ./manage.py runserver
Performing system checks...
System check identified no issues (0 silenced).
December 09, 2015 - 21:26:47
Django version 1.8.7, using settings 'memopol.settings'
Starting development server at http://127.0.0.1:8000/
Quit the server with CONTROL-C.
[09/Dec/2015 21:26:48] "GET / HTTP/1.1" 200 13294
The website is running on ``http://127.0.0.1:8000/``.
Continue to :doc:`administration`.
memopol/settings.py
View file @
8c2dde9f
...
...
@@ -125,20 +125,16 @@ WSGI_APPLICATION = 'memopol.wsgi.application'
DATABASES
=
{
'default'
:
{
'NAME'
:
os
.
environ
.
get
(
'DJANGO_DATABASE_DEFAULT_NAME'
,
'db.sqlite'
),
'USER'
:
os
.
environ
.
get
(
'DJANGO_DATABASE_DEFAULT_USER'
,
''
),
'PASSWORD'
:
os
.
environ
.
get
(
'DJANGO_DATABASE_DEFAULT_PASSWORD'
,
''
),
'HOST'
:
os
.
environ
.
get
(
'DJANGO_DATABASE_DEFAULT_HOST'
,
''
),
'PORT'
:
os
.
environ
.
get
(
'DJANGO_DATABASE_DEFAULT_PORT'
,
''
),
'ENGINE'
:
os
.
environ
.
get
(
'DJANGO_DATABASE_DEFAULT_ENGINE'
,
'django.db.backends.sqlite3'
),
'NAME'
:
os
.
environ
.
get
(
'MEMOPOL_DB_NAME'
,
'memopol'
),
'USER'
:
os
.
environ
.
get
(
'MEMOPOL_DB_USER'
,
'memopol'
),
'PASSWORD'
:
os
.
environ
.
get
(
'MEMOPOL_DB_PASSWORD'
,
'memopol'
),
'HOST'
:
os
.
environ
.
get
(
'MEMOPOL_DB_HOST'
,
'localhost'
),
'PORT'
:
os
.
environ
.
get
(
'MEMOPOL_DB_PORT'
,
'5432'
),
'ENGINE'
:
os
.
environ
.
get
(
'MEMOPOL_DB_ENGINE'
,
'django.db.backends.postgresql_psycopg2'
),
}
}
if
'OPENSHIFT_DATA_DIR'
in
os
.
environ
:
DATABASES
[
'default'
][
'NAME'
]
=
os
.
path
.
join
(
DATA_DIR
,
'db.sqlite'
)
if
'OPENSHIFT_POSTGRESQL_DB_HOST'
in
os
.
environ
:
DATABASES
[
'default'
][
'NAME'
]
=
os
.
environ
[
'OPENSHIFT_APP_NAME'
]
DATABASES
[
'default'
][
'USER'
]
=
os
.
environ
[
...
...
@@ -147,7 +143,6 @@ if 'OPENSHIFT_POSTGRESQL_DB_HOST' in os.environ:
'OPENSHIFT_POSTGRESQL_DB_PASSWORD'
]
DATABASES
[
'default'
][
'HOST'
]
=
os
.
environ
[
'OPENSHIFT_POSTGRESQL_DB_HOST'
]
DATABASES
[
'default'
][
'PORT'
]
=
os
.
environ
[
'OPENSHIFT_POSTGRESQL_DB_PORT'
]
DATABASES
[
'default'
][
'ENGINE'
]
=
'django.db.backends.postgresql_psycopg2'
# Internationalization
# https://docs.djangoproject.com/en/1.7/topics/i18n/
...
...
memopol/tests/RepresentativeDetailTest/test_mandates_display.html
View file @
8c2dde9f
...
...
@@ -3,17 +3,23 @@
<table
class=
'table table-condensed mandates'
>
<tr
class=
'mandate'
>
<td>
Member
</td>
<td>
Substitute
</td>
<td>
<a
href=
'/legislature/representative/committee/European%20Parliament/Committee%20on%20Women's%20Rights%20and%20Gender%20Equality/'
>
Committee on Women
'
s Rights and Gender Equality
FEMM
<a
href=
'/legislature/representative/delegation/European%20Parliament/Delegation%20for%20relations%20with%20Palestine/'
>
Delegation for relations with Palestine
</a>
</td>
<td>
01/07/2014
</td>
<td>
present
</td>
<td>
14/07/2014
</td>
<td>
present
</td>
<td>
European Parliament
</td>
</tr>
...
...
@@ -21,15 +27,43 @@
<tr
class=
'mandate'
>
<td>
Member
</td>
<td>
<a
href=
'/legislature/representative/
committee
/European%20Parliament/
Committee%20on%20Legal%20Affairs
/'
>
Committee on Legal Affairs
<a
href=
'/legislature/representative/
delegation
/European%20Parliament/
Delegation%20for%20relations%20with%20South%20Africa
/'
>
Delegation for relations with South Africa
JURI
</a>
</td>
<td>
14/07/2014
</td>
<td>
present
</td>
<td>
European Parliament
</td>
</tr>
<tr
class=
'mandate'
>
<td>
Member
</td>
<td>
<a
href=
'/legislature/representative/delegation/European%20Parliament/Delegation%20to%20the%20Parliamentary%20Assembly%20of%20the%20Union%20for%20the%20Mediterranean/'
>
Delegation to the Parliamentary Assembly of the Union for the Mediterranean
</a>
</td>
<td>
01/07/2014
</td>
<td>
present
</td>
<td>
14/07/2014
</td>
<td>
present
</td>
<td>
European Parliament
</td>
</tr>
...
...
@@ -44,22 +78,16 @@
</a>
</td>
<td>
08/07/2014
</td>
<td>
present
</td>
<td>
European Parliament
</td>
<td>
</tr>
08/07/2014
<tr
class=
'mandate'
>
<td>
Member
</td>
</td>
<td>
<a
href=
'/legislature/representative/delegation/European%20Parliament/Delegation%20for%20relations%20with%20South%20Africa/'
>
Delegation for relations with South Africa
</a>
present
</td>
<td>
14/07/2014
</td>
<td>
present
</td>
<td>
European Parliament
</td>
</tr>
...
...
@@ -67,27 +95,23 @@
<tr
class=
'mandate'
>
<td>
Member
</td>
<td>
<a
href=
'/legislature/representative/delegation/European%20Parliament/Delegation%20to%20the%20Parliamentary%20Assembly%20of%20the%20Union%20for%20the%20Mediterranean/'
>
Delegation to the Parliamentary Assembly of the Union for the Mediterranean
<a
href=
'/legislature/representative/committee/European%20Parliament/Committee%20on%20Legal%20Affairs/'
>
Committee on Legal Affairs
JURI
</a>
</td>
<td>
14/07/2014
</td>
<td>
present
</td>
<td>
European Parliament
</td>
<td>
</tr>
01/07/2014
<tr
class=
'mandate'
>
<td>
Substitute
</td>
</td>
<td>
<a
href=
'/legislature/representative/delegation/European%20Parliament/Delegation%20for%20relations%20with%20Palestine/'
>
Delegation for relations with Palestine
</a>
present
</td>
<td>
14/07/2014
</td>
<td>
present
</td>
<td>
European Parliament
</td>
</tr>
...
...
@@ -95,15 +119,23 @@
<tr
class=
'mandate'
>
<td>
Member
</td>
<td>
<a
href=
'/legislature/representative/
group
/European%20Parliament/
Group%20of%20the%20Progressive%20Alliance%20of%20Socialists%20and%20Democrats%20in%20the%20European%20Parliament
/'
>
Group of the Progressive Alliance of Socialists and Democrats in the European Parliament
<a
href=
'/legislature/representative/
committee
/European%20Parliament/
Committee%20on%20Women's%20Rights%20and%20Gender%20Equality
/'
>
Committee on Women
'
s Rights and Gender Equality
SD
FEMM
</a>
</td>
<td>
01/07/2014
</td>
<td>
present
</td>
<td>
01/07/2014
</td>
<td>
present
</td>
<td>
European Parliament
</td>
</tr>
...
...
@@ -118,8 +150,16 @@
</a>
</td>
<td>
01/07/2014
</td>
<td>
present
</td>
<td>
01/07/2014
</td>
<td>
present
</td>
<td>
Labour Party
</td>
</tr>
...
...
@@ -127,15 +167,23 @@
<tr
class=
'mandate'
>
<td>
Member
</td>
<td>
<a
href=
'/legislature/representative/
committee
/European%20Parliament/
Committee%20on%20Women's%20Rights%20and%20Gender%20Equality
/'
>
Committee on Women
'
s Rights and Gender Equality
<a
href=
'/legislature/representative/
group
/European%20Parliament/
Group%20of%20the%20Progressive%20Alliance%20of%20Socialists%20and%20Democrats%20in%20the%20European%20Parliament
/'
>
Group of the Progressive Alliance of Socialists and Democrats in the European Parliament
FEMM
SD
</a>
</td>
<td>
19/01/2012
</td>
<td>
30/06/2014
</td>
<td>
01/07/2014
</td>
<td>
present
</td>
<td>
European Parliament
</td>
</tr>
...
...
@@ -150,8 +198,16 @@
</a>
</td>
<td>
19/01/2012
</td>
<td>
30/06/2014
</td>
<td>
19/01/2012
</td>
<td>
30/06/2014
</td>
<td>
European Parliament
</td>
</tr>
...
...
@@ -166,8 +222,40 @@
</a>
</td>
<td>
19/01/2012
</td>
<td>
30/06/2014
</td>
<td>
19/01/2012
</td>
<td>
30/06/2014
</td>
<td>
European Parliament
</td>
</tr>
<tr
class=
'mandate'
>
<td>
Member
</td>
<td>
<a
href=
'/legislature/representative/committee/European%20Parliament/Committee%20on%20Women's%20Rights%20and%20Gender%20Equality/'
>
Committee on Women
'
s Rights and Gender Equality
FEMM
</a>
</td>
<td>
19/01/2012
</td>
<td>
30/06/2014
</td>
<td>
European Parliament
</td>
</tr>
...
...
@@ -180,24 +268,16 @@
</a>
</td>
<td>
16/09/2009
</td>
<td>
30/06/2014
</td>
<td>
European Parliament
</td>
<td>
</tr>
16/09/2009
<tr
class=
'mandate'
>
<td>
Member
</td>
</td>
<td>
<a
href=
'/legislature/representative/group/European%20Parliament/Group%20of%20the%20Progressive%20Alliance%20of%20Socialists%20and%20Democrats%20in%20the%20European%20Parliament/'
>
Group of the Progressive Alliance of Socialists and Democrats in the European Parliament
SD
30/06/2014
</a>
</td>
<td>
14/07/2009
</td>
<td>
30/06/2014
</td>
<td>
European Parliament
</td>
</tr>
...
...
@@ -212,8 +292,16 @@
</a>
</td>
<td>
14/07/2009
</td>
<td>
30/06/2014
</td>
<td>
14/07/2009
</td>
<td>
30/06/2014
</td>
<td>
Labour Party
</td>
</tr>
...
...
@@ -221,15 +309,47 @@
<tr
class=
'mandate'
>
<td>
Member
</td>
<td>
<a
href=
'/legislature/representative/
committee
/European%20Parliament/
Committee%20on%20Women's%20Rights%20and%20Gender%20Equality
/'
>
Committee on Women
'
s Rights and Gender Equality
<a
href=
'/legislature/representative/
group
/European%20Parliament/
Group%20of%20the%20Progressive%20Alliance%20of%20Socialists%20and%20Democrats%20in%20the%20European%20Parliament
/'
>
Group of the Progressive Alliance of Socialists and Democrats in the European Parliament
FEMM
SD
</a>
</td>
<td>
16/07/2009
</td>
<td>
18/01/2012
</td>
<td>
14/07/2009
</td>
<td>
30/06/2014
</td>
<td>
European Parliament
</td>
</tr>
<tr
class=
'mandate'
>
<td>
Substitute
</td>
<td>
<a
href=
'/legislature/representative/committee/European%20Parliament/Committee%20on%20Legal%20Affairs/'
>
Committee on Legal Affairs
JURI
</a>
</td>
<td>
20/09/2010
</td>
<td>
18/01/2012
</td>
<td>
European Parliament
</td>
</tr>
...
...
@@ -244,24 +364,40 @@
</a>
</td>
<td>
16/07/2009
</td>
<td>
18/01/2012
</td>
<td>
16/07/2009
</td>
<td>
18/01/2012
</td>
<td>
European Parliament
</td>
</tr>
<tr
class=
'mandate'
>
<td>
Substitute
</td>
<td>
Member
</td>
<td>
<a
href=
'/legislature/representative/committee/European%20Parliament/Committee%20on%20
Legal%20Affairs
/'
>
Committee on
Legal Affairs
<a
href=
'/legislature/representative/committee/European%20Parliament/Committee%20on%20
Women's%20Rights%20and%20Gender%20Equality
/'
>
Committee on
Women
'
s Rights and Gender Equality
JURI
FEMM
</a>
</td>
<td>
20/09/2010
</td>
<td>
18/01/2012
</td>
<td>
16/07/2009
</td>
<td>
18/01/2012
</td>
<td>
European Parliament
</td>
</tr>
...
...
@@ -276,24 +412,16 @@
</a>
</td>
<td>
16/07/2009
</td>
<td>
19/09/2010
</td>
<td>
European Parliament
</td>
<td>
</tr>
16/07/2009
<tr
class=
'mandate'
>
<td>
Member
</td>
</td>
<td>
<a
href=
'/legislature/representative/committee/European%20Parliament/Committee%20on%20Industry,%20Research%20and%20Energy/'
>
Committee on Industry, Research and Energy
ITRE
19/09/2010
</a>
</td>
<td>
31/01/2007
</td>