Skip to content
GitLab
Menu
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
sudo
:
false
env
:
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
language
:
python
python
:
python
:
-
'
2.7'
-
'
2.7'
services
:
-
postgresql
install
:
install
:
-
pip install -e .[testing]
-
pip install -e .[testing]
before_script
:
before_script
:
-
bin/install_client_deps.sh
-
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
:
script
:
-
flake8 . --exclude '*/migrations,docs,static' --ignore E128
-
flake8 . --exclude '*/migrations,docs,static' --ignore E128
-
py.test memopol representatives_positions representatives_recommendations
-
py.test memopol representatives_positions representatives_recommendations
...
...
bin/quickstart.sh
View file @
8c2dde9f
...
@@ -22,6 +22,15 @@ pip install -e .[testing]
...
@@ -22,6 +22,15 @@ pip install -e .[testing]
# Install client dependencies
# Install client dependencies
bin/install_client_deps.sh
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
# Setup environment
export
DJANGO_DEBUG
=
True
export
DJANGO_DEBUG
=
True
export
DJANGO_SETTINGS_MODULE
=
memopol.settings
export
DJANGO_SETTINGS_MODULE
=
memopol.settings
...
...
docs/development.rst
View file @
8c2dde9f
...
@@ -101,38 +101,33 @@ the ``DJANGO_DEBUG`` variable in the current shell::
...
@@ -101,38 +101,33 @@ the ``DJANGO_DEBUG`` variable in the current shell::
$ export DJANGO_DEBUG=True
$ 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).
$ psql -c "create user memopol with password 'memopol';" -U postgres
December 09, 2015 - 21:26:47
$ psql -c "alter role memopol with createdb;" -U postgres
Django version 1.8.7, using settings 'memopol.settings'
$ psql -c "create database memopol with owner memopol;" -U postgres
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/``.
Database migrations
Database migrations
===================
===================
The repo comes with a pre-configured SQLite db with sample data so that you can
Database migrations ensure the database schema is up to date with the project.
start hacking right away. However, if you were to use a local postgresql
If you're not sure, you can run them anyway, they won't do any harm. Use the
database ie. with this sort of environment::
following command::
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::
$ ./manage.py migrate
$ ./manage.py migrate
Operations to perform:
Operations to perform:
...
@@ -153,8 +148,7 @@ Then you could run database migrations::
...
@@ -153,8 +148,7 @@ Then you could run database migrations::
Provision with data
Provision with data
===================
===================
Again, the repo comes with a pre-configured SQLite db with sample data so that
You can load a small data sample for quick setup:
you can start hacking right away. However, you could still reload sample data::
$ ./manage.py loaddata memopol/fixtures/small_sample.json
$ ./manage.py loaddata memopol/fixtures/small_sample.json
...
@@ -162,4 +156,22 @@ Or actual data (takes a while)::
...
@@ -162,4 +156,22 @@ Or actual data (takes a while)::
$ bin/update_all
$ 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`.
Continue to :doc:`administration`.
memopol/settings.py
View file @
8c2dde9f
...
@@ -125,20 +125,16 @@ WSGI_APPLICATION = 'memopol.wsgi.application'
...
@@ -125,20 +125,16 @@ WSGI_APPLICATION = 'memopol.wsgi.application'
DATABASES
=
{
DATABASES
=
{
'default'
:
{
'default'
:
{
'NAME'
:
os
.
environ
.
get
(
'DJANGO_DATABASE_DEFAULT_NAME'
,
'db.sqlite'
),
'NAME'
:
os
.
environ
.
get
(
'MEMOPOL_DB_NAME'
,
'memopol'
),
'USER'
:
os
.
environ
.
get
(
'DJANGO_DATABASE_DEFAULT_USER'
,
''
),
'USER'
:
os
.
environ
.
get
(
'MEMOPOL_DB_USER'
,
'memopol'
),
'PASSWORD'
:
os
.
environ
.
get
(
'DJANGO_DATABASE_DEFAULT_PASSWORD'
,
''
),
'PASSWORD'
:
os
.
environ
.
get
(
'MEMOPOL_DB_PASSWORD'
,
'memopol'
),
'HOST'
:
os
.
environ
.
get
(
'DJANGO_DATABASE_DEFAULT_HOST'
,
''
),
'HOST'
:
os
.
environ
.
get
(
'MEMOPOL_DB_HOST'
,
'localhost'
),
'PORT'
:
os
.
environ
.
get
(
'DJANGO_DATABASE_DEFAULT_PORT'
,
''
),
'PORT'
:
os
.
environ
.
get
(
'MEMOPOL_DB_PORT'
,
'5432'
),
'ENGINE'
:
os
.
environ
.
get
(
'DJANGO_DATABASE_DEFAULT_ENGINE'
,
'ENGINE'
:
os
.
environ
.
get
(
'MEMOPOL_DB_ENGINE'
,
'django.db.backends.sqlite3'
),
'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
:
if
'OPENSHIFT_POSTGRESQL_DB_HOST'
in
os
.
environ
:
DATABASES
[
'default'
][
'NAME'
]
=
os
.
environ
[
'OPENSHIFT_APP_NAME'
]
DATABASES
[
'default'
][
'NAME'
]
=
os
.
environ
[
'OPENSHIFT_APP_NAME'
]
DATABASES
[
'default'
][
'USER'
]
=
os
.
environ
[
DATABASES
[
'default'
][
'USER'
]
=
os
.
environ
[
...
@@ -147,7 +143,6 @@ if 'OPENSHIFT_POSTGRESQL_DB_HOST' in os.environ:
...
@@ -147,7 +143,6 @@ if 'OPENSHIFT_POSTGRESQL_DB_HOST' in os.environ:
'OPENSHIFT_POSTGRESQL_DB_PASSWORD'
]
'OPENSHIFT_POSTGRESQL_DB_PASSWORD'
]
DATABASES
[
'default'
][
'HOST'
]
=
os
.
environ
[
'OPENSHIFT_POSTGRESQL_DB_HOST'
]
DATABASES
[
'default'
][
'HOST'
]
=
os
.
environ
[
'OPENSHIFT_POSTGRESQL_DB_HOST'
]
DATABASES
[
'default'
][
'PORT'
]
=
os
.
environ
[
'OPENSHIFT_POSTGRESQL_DB_PORT'
]
DATABASES
[
'default'
][
'PORT'
]
=
os
.
environ
[
'OPENSHIFT_POSTGRESQL_DB_PORT'
]
DATABASES
[
'default'
][
'ENGINE'
]
=
'django.db.backends.postgresql_psycopg2'
# Internationalization
# Internationalization
# https://docs.djangoproject.com/en/1.7/topics/i18n/
# https://docs.djangoproject.com/en/1.7/topics/i18n/
...
...
memopol/tests/RepresentativeDetailTest/test_mandates_display.html
View file @
8c2dde9f
...
@@ -3,17 +3,23 @@
...
@@ -3,17 +3,23 @@
<table
class=
'table table-condensed mandates'
>
<table
class=
'table table-condensed mandates'
>
<tr
class=
'mandate'
>
<tr
class=
'mandate'
>
<td>
Member
</td>
<td>
Substitute
</td>
<td>
<td>
<a
href=
'/legislature/representative/committee/European%20Parliament/Committee%20on%20Women's%20Rights%20and%20Gender%20Equality/'
>
<a
href=
'/legislature/representative/delegation/European%20Parliament/Delegation%20for%20relations%20with%20Palestine/'
>
Committee on Women
'
s Rights and Gender Equality
Delegation for relations with Palestine
FEMM
</a>
</a>
</td>
</td>
<td>
01/07/2014
</td>
<td>
<td>
present
</td>
14/07/2014
</td>
<td>
present
</td>
<td>
European Parliament
</td>
<td>
European Parliament
</td>
</tr>
</tr>
...
@@ -21,15 +27,43 @@
...
@@ -21,15 +27,43 @@
<tr
class=
'mandate'
>
<tr
class=
'mandate'
>
<td>
Member
</td>
<td>
Member
</td>
<td>
<td>
<a
href=
'/legislature/representative/
committee
/European%20Parliament/
Committee%20on%20Legal%20Affairs
/'
>
<a
href=
'/legislature/representative/
delegation
/European%20Parliament/
Delegation%20for%20relations%20with%20South%20Africa
/'
>
Committee on Legal Affairs
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>
</a>
</td>
</td>
<td>
01/07/2014
</td>
<td>
<td>
present
</td>
14/07/2014
</td>
<td>
present
</td>
<td>
European Parliament
</td>
<td>
European Parliament
</td>
</tr>
</tr>
...
@@ -44,22 +78,16 @@
...
@@ -44,22 +78,16 @@
</a>
</a>
</td>
</td>
<td>
08/07/2014
</td>
<td>
<td>
present
</td>
<td>
European Parliament
</td>
</tr>
08/07/2014
<tr
class=
'mandate'
>
</td>
<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>
<td>
14/07/2014
</td>
<td>
present
</td>
<td>
European Parliament
</td>
<td>
European Parliament
</td>
</tr>
</tr>
...
@@ -67,27 +95,23 @@
...
@@ -67,27 +95,23 @@
<tr
class=
'mandate'
>
<tr
class=
'mandate'
>
<td>
Member
</td>
<td>
Member
</td>
<td>
<td>
<a
href=
'/legislature/representative/delegation/European%20Parliament/Delegation%20to%20the%20Parliamentary%20Assembly%20of%20the%20Union%20for%20the%20Mediterranean/'
>
<a
href=
'/legislature/representative/committee/European%20Parliament/Committee%20on%20Legal%20Affairs/'
>
Delegation to the Parliamentary Assembly of the Union for the Mediterranean
Committee on Legal Affairs
JURI
</a>
</a>
</td>
</td>
<td>
14/07/2014
</td>
<td>
<td>
present
</td>
<td>
European Parliament
</td>
</tr>
01/07/2014
<tr
class=
'mandate'
>
</td>
<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>
<td>
14/07/2014
</td>
<td>
present
</td>
<td>
European Parliament
</td>
<td>
European Parliament
</td>
</tr>
</tr>
...
@@ -95,15 +119,23 @@
...
@@ -95,15 +119,23 @@
<tr
class=
'mandate'
>
<tr
class=
'mandate'
>
<td>
Member
</td>
<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
/'
>
<a
href=
'/legislature/representative/
committee
/European%20Parliament/
Committee%20on%20Women's%20Rights%20and%20Gender%20Equality
/'
>
Group of the Progressive Alliance of Socialists and Democrats in the European Parliament
Committee on Women
'
s Rights and Gender Equality
SD
FEMM
</a>
</a>
</td>
</td>
<td>
01/07/2014
</td>
<td>
<td>
present
</td>
01/07/2014
</td>
<td>
present
</td>
<td>
European Parliament
</td>
<td>
European Parliament
</td>
</tr>
</tr>
...
@@ -118,8 +150,16 @@
...
@@ -118,8 +150,16 @@
</a>
</a>
</td>
</td>
<td>
01/07/2014
</td>
<td>
<td>
present
</td>
01/07/2014
</td>
<td>
present
</td>
<td>
Labour Party
</td>
<td>
Labour Party
</td>
</tr>
</tr>
...
@@ -127,15 +167,23 @@
...
@@ -127,15 +167,23 @@
<tr
class=
'mandate'
>
<tr
class=
'mandate'
>
<td>
Member
</td>
<td>
Member
</td>
<td>
<td>
<a
href=
'/legislature/representative/
committee
/European%20Parliament/
Committee%20on%20Women's%20Rights%20and%20Gender%20Equality
/'
>
<a
href=
'/legislature/representative/
group
/European%20Parliament/
Group%20of%20the%20Progressive%20Alliance%20of%20Socialists%20and%20Democrats%20in%20the%20European%20Parliament
/'
>
Committee on Women
'
s Rights and Gender Equality
Group of the Progressive Alliance of Socialists and Democrats in the European Parliament
FEMM
SD
</a>
</a>
</td>
</td>
<td>
19/01/2012
</td>
<td>
<td>
30/06/2014
</td>
01/07/2014
</td>
<td>
present
</td>
<td>
European Parliament
</td>
<td>
European Parliament
</td>
</tr>
</tr>
...
@@ -150,8 +198,16 @@
...
@@ -150,8 +198,16 @@
</a>
</a>
</td>
</td>
<td>
19/01/2012
</td>
<td>
<td>
30/06/2014
</td>
19/01/2012
</td>
<td>
30/06/2014
</td>
<td>
European Parliament
</td>
<td>
European Parliament
</td>
</tr>
</tr>
...
@@ -166,8 +222,40 @@
...
@@ -166,8 +222,40 @@
</a>
</a>
</td>
</td>
<td>
19/01/2012
</td>
<td>
<td>
30/06/2014
</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>
<td>
European Parliament
</td>
</tr>
</tr>
...
@@ -180,24 +268,16 @@
...
@@ -180,24 +268,16 @@
</a>
</a>
</td>
</td>
<td>
16/09/2009
</td>
<td>
<td>
30/06/2014
</td>
<td>
European Parliament
</td>
</tr>
16/09/2009
<tr
class=
'mandate'
>
</td>
<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>
<td>
14/07/2009
</td>
<td>
30/06/2014
</td>
<td>
European Parliament
</td>
<td>
European Parliament
</td>
</tr>
</tr>
...
@@ -212,8 +292,16 @@
...
@@ -212,8 +292,16 @@
</a>
</a>
</td>
</td>
<td>
14/07/2009
</td>
<td>
<td>
30/06/2014
</td>
14/07/2009
</td>
<td>
30/06/2014
</td>
<td>
Labour Party
</td>
<td>
Labour Party
</td>
</tr>
</tr>
...
@@ -221,15 +309,47 @@
...
@@ -221,15 +309,47 @@
<tr
class=
'mandate'
>
<tr
class=
'mandate'
>
<td>
Member
</td>
<td>
Member
</td>
<td>
<td>
<a
href=
'/legislature/representative/
committee
/European%20Parliament/
Committee%20on%20Women's%20Rights%20and%20Gender%20Equality
/'
>
<a
href=
'/legislature/representative/
group
/European%20Parliament/
Group%20of%20the%20Progressive%20Alliance%20of%20Socialists%20and%20Democrats%20in%20the%20European%20Parliament
/'
>
Committee on Women
'
s Rights and Gender Equality
Group of the Progressive Alliance of Socialists and Democrats in the European Parliament