Skip to content

Commit

Permalink
sandboxes: Start Sandboxes
Browse files Browse the repository at this point in the history
#66

This is only available to transactions table in projects so far.

But it is a general purpose framework that could apply to any status field.
  • Loading branch information
odscjames committed Feb 10, 2021
1 parent 8ec149e commit 05fdb25
Show file tree
Hide file tree
Showing 15 changed files with 3,256 additions and 8 deletions.
7 changes: 5 additions & 2 deletions djangoproject/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,13 +148,14 @@ def load_json_schema_filter_keys(filename):
"project": {
"json_schema": load_json_schema("project.json"),
"spreadsheet_form_guide": os.path.join(
BASE_DIR, "indigo", "spreadsheetform_guides", "project_v009.xlsx",
BASE_DIR, "indigo", "spreadsheetform_guides", "project_v010.xlsx",
),
"spreadsheet_form_guide_spec": load_guide_form_spec("project_v009.xlsx"),
"spreadsheet_form_guide_spec": load_guide_form_spec("project_v010.xlsx"),
"spreadsheet_form_guide_spec_versions": {
7: load_guide_form_spec("project_v007.xlsx"),
8: load_guide_form_spec("project_v008.xlsx"),
9: load_guide_form_spec("project_v009.xlsx"),
10: load_guide_form_spec("project_v010.xlsx"),
},
"fields": load_json_schema_fields("project.json"),
"filter_keys": load_json_schema_filter_keys("project.json"),
Expand Down Expand Up @@ -185,6 +186,8 @@ def load_json_schema_filter_keys(filename):

APP_TITLE = os.getenv("APP_TITLE", "INDIGO")

API_SANDBOX_DATA_PASSWORD = os.getenv("API_SANDBOX_DATA_PASSWORD", "")

SENTRY_DSN = os.getenv("SENTRY_DSN")
if SENTRY_DSN:
import sentry_sdk
Expand Down
6 changes: 4 additions & 2 deletions indigo/admin.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from django.contrib import admin # noqa
from django.contrib import admin

# Register your models here.
from indigo.models import Sandbox

admin.site.register(Sandbox)
Original file line number Diff line number Diff line change
Expand Up @@ -998,7 +998,11 @@
},
{
"key": "/status",
"title": "Status"
"title": "(Status)"
},
{
"key": "/sandboxes",
"title": "(In Sandboxes)"
}
],
"key": "/transactions",
Expand Down
11 changes: 9 additions & 2 deletions indigo/jsonschema/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -1120,8 +1120,10 @@
"type": "string"
},
"status": {
"title": "Status",
"type": "string"
"$ref": "#/definitions/status"
},
"sandboxes": {
"$ref": "#/definitions/sandboxes"
}
}
},
Expand Down Expand Up @@ -1702,9 +1704,14 @@
"type": "string",
"enum": [
"PUBLIC",
"SANDBOX",
"PRIVATE",
"DISPUTED"
]
},
"sandboxes": {
"title": "(In Sandboxes)",
"type": "string"
}
}
}
45 changes: 45 additions & 0 deletions indigo/migrations/0012_auto_20210210_1152.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# Generated by Django 3.1.5 on 2021-02-10 11:52

import django.contrib.postgres.fields.jsonb
from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
("indigo", "0011_project_data_quality_report_counts_by_priority"),
]

operations = [
migrations.CreateModel(
name="Sandbox",
fields=[
(
"id",
models.AutoField(
auto_created=True,
primary_key=True,
serialize=False,
verbose_name="ID",
),
),
("public_id", models.CharField(max_length=200, unique=True)),
("title", models.TextField(default="")),
],
),
migrations.AddField(
model_name="fund",
name="data_sandboxes",
field=django.contrib.postgres.fields.jsonb.JSONField(default=dict),
),
migrations.AddField(
model_name="organisation",
name="data_sandboxes",
field=django.contrib.postgres.fields.jsonb.JSONField(default=dict),
),
migrations.AddField(
model_name="project",
name="data_sandboxes",
field=django.contrib.postgres.fields.jsonb.JSONField(default=dict),
),
]
6 changes: 6 additions & 0 deletions indigo/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ class BaseModel(models.Model):
status_public = models.BooleanField(default=False)
data_public = JSONField(default=dict)
data_private = JSONField(default=dict)
data_sandboxes = JSONField(default=dict)
# record is nullable for historical data - it should be NOT NULL really
record = models.ForeignKey(Record, on_delete=models.PROTECT, null=True, blank=True)
full_text_search_private = models.TextField(default="")
Expand Down Expand Up @@ -107,3 +108,8 @@ class Meta:
"project",
"fund",
)


class Sandbox(models.Model):
public_id = models.CharField(max_length=200, unique=True)
title = models.TextField(default="")
Loading

0 comments on commit 05fdb25

Please sign in to comment.