Commit 1d8364e1 authored by Florent Chehab's avatar Florent Chehab

migrate to postgres

parent 31201003
Pipeline #21946 failed with stages
in 3 minutes and 36 seconds
......@@ -8,3 +8,4 @@ db.sqlite3
node_modules
.coverage
htmlcov
.vscode
\ No newline at end of file
image: python:3.6.5-jessie
services:
- postgres:9.6.8
testing:
stage: test
script:
- export DATABASE_URL=postgres://postgres:@postgres:5432/python-test-app
- pip install -r requirements.txt
- ./manage.py check
- coverage3 run manage.py test
......
{
"python.pythonPath": "/home/florent/miniconda3/bin/python3",
"python.pythonPath": "/home/florent/Env/outgoing/bin/python",
"files.exclude": {
"**/.git": true,
"**/.svn": true,
"**/.hg": true,
"**/CVS": true,
"**/.DS_Store": true,
"**/__pycache__":true
"**/__pycache__":true,
"**/.pyc":true
},
"cSpell.language": "en",
"python.linting.flake8Enabled": true
......
......@@ -24,3 +24,5 @@ To populate universities, also run in `./manage.py shell`:
```
%run ./rex/utils/insert_universities.py
```
Follow this tutorial : https://devcenter.heroku.com/articles/heroku-postgresql#local-setup
\ No newline at end of file
......@@ -11,23 +11,12 @@ https://docs.djangoproject.com/en/2.0/ref/settings/
"""
import os
import django_heroku
import dj_database_url
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/2.0/howto/deployment/checklist/
# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = '0a1kbtt%as4624u*9+r+c%j1tlq&dc08==c3w604(4igc+t6tw'
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True
ALLOWED_HOSTS = []
# Application definition
INSTALLED_APPS = [
......@@ -97,11 +86,9 @@ WSGI_APPLICATION = 'general.wsgi.application'
# Database
# https://docs.djangoproject.com/en/2.0/ref/settings/#databases
# DB are set at the end of the file
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
}
'default': None
}
......@@ -142,11 +129,34 @@ USE_L10N = True
USE_TZ = True
# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/2.0/howto/static-files/
# override DATABASE_URL set by django_heroku because it forces SSL mode locally
dev_env = os.environ['ENV'] == 'development'
if dev_env:
DEBUG = True
ALLOWED_HOSTS = []
SECRET_KEY = '0a1kbtt%as4624u*9+r+c%j1tlq&dc08==c3w604(4igc+t6tw'
# If bellow fails, your need to add DATABASE_URL and ENV to your virutalenv
locals()['DATABASES']['default'] = dj_database_url.config(
conn_max_age=django_heroku.MAX_CONN_AGE, ssl_require=not dev_env)
# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/2.0/howto/static-files/
STATIC_URL = '/static/'
STATIC_ROOT = os.path.join(BASE_DIR, 'static')
MEDIA_ROOT = os.path.join(BASE_DIR, 'media')
MEDIA_URL = '/media/'
STATIC_URL = '/static/'
STATIC_ROOT = os.path.join(BASE_DIR, 'static')
STATIC_URL = '/static/'
STATIC_ROOT = os.path.join(BASE_DIR, 'static')
MEDIA_ROOT = os.path.join(BASE_DIR, 'media')
MEDIA_URL = '/media/'
MEDIA_ROOT = os.path.join(BASE_DIR, 'media')
MEDIA_URL = '/media/'
else:
# We should be on heroku server
print("You are running in production mode")
django_heroku.settings(locals())
DEBUG = False
#OutGoing_REX
Django==2.0.3
psycopg2-binary==2.7.4
git+https://github.com/mingchen/django-cas-ng.git@23e755c61d58c957a056c7a321272ab5888797a9#egg=django-cas-ng
Pillow==5.0.0
django-imagekit==4.0.2
......
# Generated by Django 2.0.3 on 2018-03-20 11:47
# Generated by Django 2.0.3 on 2018-04-23 09:44
from django.conf import settings
import django.core.validators
from django.db import migrations, models
import django.db.models.deletion
import django.utils.timezone
import rex.utils.friendly_path
class Migration(migrations.Migration):
......@@ -11,19 +10,26 @@ class Migration(migrations.Migration):
initial = True
dependencies = [
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
]
operations = [
migrations.CreateModel(
name='Post',
name='Country',
fields=[
('name', models.CharField(max_length=200)),
('iso_code', models.CharField(max_length=2, primary_key=True, serialize=False)),
],
),
migrations.CreateModel(
name='University',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('title', models.CharField(max_length=200)),
('text', models.TextField()),
('created_date', models.DateTimeField(default=django.utils.timezone.now)),
('published_date', models.DateTimeField(blank=True, null=True)),
('author', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)),
('name', models.CharField(max_length=200)),
('acronym', models.CharField(max_length=20)),
('localization_lat', models.DecimalField(decimal_places=6, max_digits=10, validators=[django.core.validators.MinValueValidator(-85.05112878), django.core.validators.MaxValueValidator(85.05112878)])),
('localization_lon', models.DecimalField(decimal_places=6, max_digits=10, validators=[django.core.validators.MinValueValidator(-180), django.core.validators.MaxValueValidator(180)])),
('logo', models.ImageField(default='path/to/my/default/image.jpg', max_length=250, upload_to=rex.utils.friendly_path.friendly_path('uploads/universities/logos/', 'name'))),
('country', models.ForeignKey(on_delete='CASCADE', to='rex.Country')),
],
),
]
# Generated by Django 2.0.3 on 2018-04-01 09:54
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('rex', '0001_initial'),
]
operations = [
migrations.CreateModel(
name='University',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('name', models.CharField(max_length=200)),
('localization_lat', models.DecimalField(decimal_places=6, max_digits=10)),
('localization_lon', models.DecimalField(decimal_places=6, max_digits=10)),
],
),
migrations.RemoveField(
model_name='post',
name='author',
),
migrations.DeleteModel(
name='Post',
),
]
# Generated by Django 2.0.3 on 2018-04-01 13:43
from django.db import migrations, models
import django.utils.timezone
import rex.utils.friendly_path
class Migration(migrations.Migration):
dependencies = [
('rex', '0002_auto_20180401_1154'),
]
operations = [
migrations.AddField(
model_name='university',
name='acronym',
field=models.CharField(default=django.utils.timezone.now, max_length=20),
preserve_default=False,
),
migrations.AddField(
model_name='university',
name='logo',
field=models.ImageField(default=django.utils.timezone.now, upload_to=rex.utils.friendly_path.friendly_path('uploads/universities/logos/', 'name')),
preserve_default=False,
),
]
# Generated by Django 2.0.3 on 2018-04-01 13:50
from django.db import migrations, models
import rex.utils.friendly_path
class Migration(migrations.Migration):
dependencies = [
('rex', '0003_auto_20180401_1543'),
]
operations = [
migrations.AlterField(
model_name='university',
name='logo',
field=models.ImageField(max_length=250, upload_to=rex.utils.friendly_path.friendly_path('uploads/universities/logos/', 'name')),
),
]
# Generated by Django 2.0.3 on 2018-04-01 14:57
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('rex', '0004_auto_20180401_1550'),
]
operations = [
migrations.CreateModel(
name='Country',
fields=[
('name', models.CharField(max_length=200)),
('iso_code', models.CharField(max_length=2, primary_key=True, serialize=False)),
],
),
]
# Generated by Django 2.0.3 on 2018-04-01 15:50
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('rex', '0005_country'),
]
operations = [
migrations.AddField(
model_name='university',
name='country',
field=models.ForeignKey(default='FR', on_delete='CASCADE', to='rex.Country'),
preserve_default=False,
),
]
# Generated by Django 2.0.3 on 2018-04-01 16:06
import django.core.validators
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('rex', '0006_university_country'),
]
operations = [
migrations.AlterField(
model_name='university',
name='localization_lat',
field=models.DecimalField(decimal_places=6, max_digits=10, validators=[django.core.validators.MinValueValidator(-85.05112878), django.core.validators.MaxValueValidator(85.05112878)]),
),
migrations.AlterField(
model_name='university',
name='localization_lon',
field=models.DecimalField(decimal_places=6, max_digits=10, validators=[django.core.validators.MinValueValidator(-180), django.core.validators.MaxValueValidator(180)]),
),
]
# Generated by Django 2.0.3 on 2018-04-01 20:53
from django.db import migrations, models
import rex.utils.friendly_path
class Migration(migrations.Migration):
dependencies = [
('rex', '0007_auto_20180401_1806'),
]
operations = [
migrations.AlterField(
model_name='university',
name='logo',
field=models.ImageField(default='path/to/my/default/image.jpg', max_length=250, upload_to=rex.utils.friendly_path.friendly_path('uploads/universities/logos/', 'name')),
),
]
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment