Skip to content

Commit

Permalink
Add area choices to day-care model.
Browse files Browse the repository at this point in the history
Adding area choices for make the data model compatible,
which will improve search for day care by area results.

Signed-off-by: tamirmatok <[email protected]>
  • Loading branch information
tamirmatok committed May 18, 2022
1 parent 467add9 commit de1deb7
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 2 deletions.
2 changes: 1 addition & 1 deletion conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ def daycare_data():
pytest.DESCRIPTION = "This is the first daycare test"
pytest.PRICE_PER_DAY = 10
pytest.CAPACITY = 50
pytest.AREA = "Merkaz"
pytest.AREA = "C"
pytest.CITY = "Tel-Aviv"
pytest.ADDRESS = "The best street 5"

Expand Down
20 changes: 20 additions & 0 deletions daycare/migrations/0006_alter_daycare_area.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Generated by Django 4.0.3 on 2022-04-27 13:37

import django.core.validators
from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('daycare', '0005_image_data_migration'),
]

operations = [
migrations.AlterField(
model_name='daycare',
name='area',
field=models.CharField(blank=True, choices=[('N', 'NORTH'), ('S', 'SOUTH'), ('C', 'CENTER')],
max_length=20, validators=[django.core.validators.MaxLengthValidator]),
),
]
8 changes: 7 additions & 1 deletion daycare/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,19 @@
from django.core.exceptions import ObjectDoesNotExist


class Area(models.TextChoices):
North = 'N', 'NORTH'
South = 'S', 'SOUTH'
Center = 'C', 'CENTER'


class DayCare(models.Model):
user = models.OneToOneField(User, on_delete=models.CASCADE, default=None, blank=True, null=False, editable=True)
name = models.CharField(max_length=20, blank=True, unique=True, validators=[MaxLengthValidator])
description = models.TextField(blank=True, null=True)
price_per_day = models.IntegerField(blank=False, null=False, default=0)
capacity = models.IntegerField(null=False, blank=True)
area = models.CharField(max_length=20, blank=True, validators=[MaxLengthValidator])
area = models.CharField(max_length=20, blank=True, validators=[MaxLengthValidator], choices=Area.choices)
city = models.CharField(max_length=20, blank=True, validators=[MaxLengthValidator])
address = models.CharField(max_length=50, blank=True, validators=[MaxLengthValidator])

Expand Down

0 comments on commit de1deb7

Please sign in to comment.