Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,16 @@
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Python: Django",
"type": "python",
"request": "launch",
"program": "${workspaceFolder}/manage.py",
"args": [
"runserver"
],
"django": true
},
{
"name": "Python: Remote Attach",
"type": "python",
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,9 @@ Then clone the [RMG-models](https://github.com/comocheng/RMG-models) repository

```export RMGMODELSPATH=/path/to/RMG-models/```

Also set `DBHOST`:
Also set `DB_HOST`:

```export DBHOST=0.0.0.0```
```export DB_HOST=0.0.0.0```

Put these lines in your shell config file (ie. `.bashrc`) so you don't have to type it every time.

Expand Down
5 changes: 5 additions & 0 deletions api/admin.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
from django.contrib import admin
from rest_framework.authtoken.admin import TokenAdmin

from api.models import Revision

TokenAdmin.raw_id_fields = ["user"]

admin.site.register(Revision)
33 changes: 33 additions & 0 deletions api/migrations/0001_initial.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Generated by Django 3.0 on 2021-01-11 04:46

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


class Migration(migrations.Migration):

initial = True

dependencies = [
('contenttypes', '0002_remove_content_type_name'),
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
]

operations = [
migrations.CreateModel(
name='Revision',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('created_on', models.DateTimeField(auto_now_add=True)),
('status', models.CharField(choices=[('P', 'Pending'), ('A', 'Approved'), ('D', 'Denied')], default='P', max_length=1)),
('proposal_comment', models.TextField(blank=True)),
('reviewer_comment', models.TextField(blank=True)),
('diff', django.contrib.postgres.fields.jsonb.JSONField(unique=True)),
('content_type', models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, to='contenttypes.ContentType')),
('created_by', models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='proposals', to=settings.AUTH_USER_MODEL)),
('reviewed_by', models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='reviews', to=settings.AUTH_USER_MODEL)),
],
),
]
29 changes: 29 additions & 0 deletions api/models.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
from django.db import models
from django.contrib.contenttypes.models import ContentType
from django.contrib.auth.models import User
from django.contrib.postgres.fields import JSONField


class Revision(models.Model):
PENDING = "P"
APPROVED = "A"
DENIED = "D"
STATUS_CHOICES = [(PENDING, "Pending"), (APPROVED, "Approved"), (DENIED, "Denied")]
content_type = models.ForeignKey(ContentType, null=True, on_delete=models.SET_NULL)
created_by = models.ForeignKey(
User, null=True, on_delete=models.SET_NULL, related_name="proposals"
)
reviewed_by = models.ForeignKey(
User, null=True, on_delete=models.SET_NULL, related_name="reviews"
)
created_on = models.DateTimeField(auto_now_add=True)
status = models.CharField(max_length=1, choices=STATUS_CHOICES, default=PENDING)
proposal_comment = models.TextField(blank=True)
reviewer_comment = models.TextField(blank=True)
diff = JSONField(unique=True)

def __str__(self):
return f"{self.content_type.model.title()} | Status: {self.status} | Data: {self.diff}"

def is_approved(self):
return self.status == self.APPROVED
Loading