Skip to content

Commit

Permalink
Merge pull request #86 from MaxCunningham19/niall/unique-pair
Browse files Browse the repository at this point in the history
Added unique pair constraint to model
  • Loading branch information
ni-sauvage authored Mar 3, 2023
2 parents db66b8d + 799f799 commit 176b176
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 2 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
/node_modules
/node_modules
/env
17 changes: 17 additions & 0 deletions api/migrations/0004_alter_block_unique_together.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Generated by Django 4.1.5 on 2023-03-02 14:27

from django.db import migrations


class Migration(migrations.Migration):

dependencies = [
('api', '0003_block_block_order'),
]

operations = [
migrations.AlterUniqueTogether(
name='block',
unique_together={('block_document', 'block_order')},
),
]
5 changes: 4 additions & 1 deletion api/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,17 @@ class Block(models.Model):
The text content of a block.
"""

block_order = models.IntegerField(default=0, unique=True)
block_order = models.IntegerField(default=0)
"""
The index of a block within a document.
"""

created_at = models.DateTimeField(auto_now_add=True)
updated_at = models.DateTimeField(auto_now_add=True)

class Meta:
unique_together = ['block_document', 'block_order']

def __str__(self):
return self.block_content

Expand Down
8 changes: 8 additions & 0 deletions test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
mkdir -p static/client/js
touch static/client/js/main.js
cd docker
sudo docker-compose build
sudo docker-compose up -d webserver
sudo docker-compose exec -T webserver bash -c '. scripts/install.sh; python3 manage.py test'
sudo rm -rf ../static
sudo docker-compose down

0 comments on commit 176b176

Please sign in to comment.