-
Notifications
You must be signed in to change notification settings - Fork 70
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Revert "Checklist models (#449)" This reverts commit a9de904. * [WIP] Create a 2-pane interface that allows you to skip a todo * [WIP] refactored code * [WIP] refactored code * [WIP] refactored code * [WIP] refactored code * Revert "Revert "Checklist models (#449)"" This reverts commit 4352de6. * Renamed checklistTemplate to TodoListTemplates and other changes * Updated the migration script and fixed lint errors * Changed the name from checklist to todolist * Removed unused code * added the json schema for todolist * added the json schema for todolist * Fixed the tests for skipped_datetime field * Fixed the tests for skipped_datetime field * added the json schema reference in todo serializer * Adding jsl and jsonschema to requirement.tx * Removed the skipped field * Add the skipped_datetime field doc * Fixed the todo models on_delete cascade * Fixed the todo models on_delete cascade
- Loading branch information
1 parent
ae5cab3
commit cd20f48
Showing
18 changed files
with
360 additions
and
69 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import jsl | ||
|
||
|
||
class TodoSchema(jsl.Document): | ||
id = jsl.IntField(required=True) | ||
description = jsl.StringField(required=True) | ||
items = jsl.ArrayField(jsl.DocumentField('TodoSchema')) | ||
|
||
|
||
class TodoListSchema(jsl.Document): | ||
items = jsl.ArrayField(jsl.DocumentField('TodoSchema')) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
from orchestra.utils.json_schema import DefaultValidatingDraft4Validator | ||
|
||
|
||
def validate_json(blob_key, json_schema, data): | ||
""" | ||
Validate json blobs against their json schema. | ||
:param blob_key: key name for data in model | ||
:param json_schema: JSON schema object | ||
:param data: JSON data, defaults are added to it. | ||
""" | ||
if not data: | ||
# Don't validate when data is empty. Otherwise, won't be able to | ||
# create empty database objects. | ||
return data | ||
schema = json_schema.get_schema() | ||
DefaultValidatingDraft4Validator(schema).validate(data) | ||
return data |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
# -*- coding: utf-8 -*- | ||
# Generated by Django 1.11.10 on 2018-06-15 16:06 | ||
from __future__ import unicode_literals | ||
|
||
from django.db import migrations, models | ||
import django.db.models.deletion | ||
import django.utils.timezone | ||
import jsonfield.fields | ||
import orchestra.models.core.mixins | ||
import orchestra.utils.models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('orchestra', '0075_add_sanity_checks'), | ||
] | ||
|
||
operations = [ | ||
migrations.CreateModel( | ||
name='TodoListTemplate', | ||
fields=[ | ||
('id', models.AutoField(auto_created=True, | ||
primary_key=True, serialize=False, verbose_name='ID')), | ||
('created_at', models.DateTimeField( | ||
default=django.utils.timezone.now)), | ||
('is_deleted', models.BooleanField(default=False)), | ||
('slug', models.CharField(max_length=200, unique=True)), | ||
('name', models.CharField(max_length=200)), | ||
('description', models.TextField()), | ||
('todos', jsonfield.fields.JSONField(default={'items': []})), | ||
('creator', models.ForeignKey(blank=True, null=True, | ||
on_delete=django.db.models.deletion.SET_NULL, related_name='creator', to='orchestra.Worker')), | ||
], | ||
bases=(orchestra.models.core.mixins.TodoListTemplateMixin, | ||
orchestra.utils.models.DeleteMixin, models.Model), | ||
), | ||
migrations.AddField( | ||
model_name='todo', | ||
name='activity_log', | ||
field=jsonfield.fields.JSONField(default={'actions': []}), | ||
), | ||
migrations.AddField( | ||
model_name='todo', | ||
name='parent_todo', | ||
field=models.ForeignKey( | ||
null=True, on_delete=django.db.models.deletion.CASCADE, related_name='parent', to='orchestra.Todo'), | ||
), | ||
migrations.AddField( | ||
model_name='todo', | ||
name='skipped_datetime', | ||
field=models.DateTimeField(blank=True, null=True), | ||
), | ||
migrations.AddField( | ||
model_name='todo', | ||
name='template', | ||
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, | ||
related_name='template', to='orchestra.TodoListTemplate'), | ||
), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.