Skip to content

Commit

Permalink
files API
Browse files Browse the repository at this point in the history
  • Loading branch information
dtkav committed Mar 20, 2019
1 parent 5c2999c commit 9f4b22d
Show file tree
Hide file tree
Showing 21 changed files with 1,122 additions and 45 deletions.
1 change: 1 addition & 0 deletions .envs/.local/.django
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@
USE_DOCKER=yes
IPYTHONDIR=/app/.ipython
DJANGO_JWT_SECRET=ILIKEASCREThowlongdoesitNeedtTOBeHey
DJANGO_FILE_STORAGE_PATH=/tmp/django-file-storage
2 changes: 2 additions & 0 deletions Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ scipy = "*"
python-jose = "*"
tabulate = "*"
django-environ = "*"
boto3 = "*"
datalake-common-dtkav = "*"

[dev-packages]
pylint = "*"
Expand Down
92 changes: 85 additions & 7 deletions Pipfile.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion cli/psql
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
COMPOSE_ENV=${COMPOSE_ENV:-local.yml}
CMD='PGPASSWORD=$POSTGRES_PASSWORD psql -h $POSTGRES_HOST -U $POSTGRES_USER -p $POSTGRES_PORT $POSTGRES_DB'

docker-compose -f $COMPOSE_ENV run --rm postgres \
docker-compose -f $COMPOSE_ENV exec postgres \
bash -c "$CMD"
3 changes: 3 additions & 0 deletions config/settings/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@
LOCAL_APPS = [
# Your stuff: custom apps go here
'home',
'datalake',
]
# https://docs.djangoproject.com/en/dev/ref/settings/#installed-apps
INSTALLED_APPS = DJANGO_APPS + THIRD_PARTY_APPS + LOCAL_APPS
Expand Down Expand Up @@ -279,3 +280,5 @@ def immutable_file_test(path, url):


WHITENOISE_IMMUTABLE_FILE_TEST = immutable_file_test

FILE_STORAGE_PATH = env.str('DJANGO_FILE_STORAGE_PATH')
1 change: 1 addition & 0 deletions config/settings/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,3 +53,4 @@

# Your stuff...
# ------------------------------------------------------------------------------
FILE_STORAGE_PATH = 's3://bucketname/django-file-storage/'
1 change: 1 addition & 0 deletions local.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ services:
ports:
- "8000:8000"
command: /start
restart: always

frontend:
build:
Expand Down
2 changes: 1 addition & 1 deletion missioncontrol/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def object_does_not_exist(exception):


def validation_error(exception):
problem = connexion.problem(400, "Validation Error", str(exception))
problem = connexion.problem(400, "Validation Error", exception.messages)
return connexion.FlaskApi.get_response(problem)


Expand Down
Empty file.
6 changes: 6 additions & 0 deletions missioncontrol/datalake/admin.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
from django.contrib import admin
from django import forms
from . import models

admin.site.register(models.What)
admin.site.register(models.RelatedFile)
5 changes: 5 additions & 0 deletions missioncontrol/datalake/apps.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
from django.apps import AppConfig


class DatalakeConfig(AppConfig):
name = 'datalake'
61 changes: 61 additions & 0 deletions missioncontrol/datalake/migrations/0001_initial.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
# Generated by Django 2.1.7 on 2019-03-20 06:35

import datalake.models
from django.db import migrations, models
import django.db.models.deletion
import django.utils.timezone
import uuid


class Migration(migrations.Migration):

initial = True

dependencies = [
('contenttypes', '0002_remove_content_type_name'),
]

operations = [
migrations.CreateModel(
name='DatalakeFile',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('uuid', models.UUIDField(default=uuid.uuid4, unique=True)),
('cid', models.CharField(max_length=33)),
('what', models.TextField()),
('where', models.TextField()),
('path', models.TextField(blank=True, null=True)),
('start', datalake.models.ISODateTimeField(default=django.utils.timezone.now, help_text='The time of the first event in the file. If instantaneous, set this and leave end as null')),
('end', datalake.models.ISODateTimeField(blank=True, help_text='The time of the last event in the file. Can be blank if instantaneous file.', null=True)),
('created', datalake.models.ISODateTimeField(auto_now_add=True)),
('work_id', models.TextField(blank=True, null=True)),
('version', models.IntegerField(choices=[(1, 1)])),
],
options={
'ordering': ('-start',),
},
bases=(models.Model, datalake.models.Serializable),
),
migrations.CreateModel(
name='RelatedFile',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('work_id', models.CharField(max_length=256)),
('object_id', models.PositiveIntegerField()),
('content_type', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='contenttypes.ContentType')),
],
),
migrations.CreateModel(
name='What',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('what', models.CharField(max_length=128, unique=True)),
],
bases=(models.Model, datalake.models.Serializable),
),
migrations.AddField(
model_name='datalakefile',
name='_related_to',
field=models.ForeignKey(blank=True, editable=False, null=True, on_delete=django.db.models.deletion.SET_NULL, to='datalake.RelatedFile'),
),
]
Empty file.
Loading

0 comments on commit 9f4b22d

Please sign in to comment.