diff --git a/backend/project/api/serializers/observations.py b/backend/project/api/serializers/observations.py index 94546be..785c63f 100644 --- a/backend/project/api/serializers/observations.py +++ b/backend/project/api/serializers/observations.py @@ -5,7 +5,13 @@ from rest_framework_gis import serializers as gis_serializers from sorl.thumbnail import get_thumbnail -from project.observations.models import Area, Media, Observation, ObservationCategory +from project.observations.models import ( + Area, + Media, + MediaType, + Observation, + ObservationCategory, +) class ObservationCategorySerializer(serializers.ModelSerializer): @@ -34,7 +40,7 @@ class ThumbnailSerializer(serializers.Serializer): def get_thumbnail_by_size( self, obj, height=100, width=100, format="JPEG", quality=70 ): - if obj.media_type == Media.MediaType.IMAGE: + if obj.media_type == MediaType.IMAGE: return self.context["request"].build_absolute_uri( get_thumbnail( obj.media_file, f"{width}x{height}", format=format, quality=quality @@ -102,4 +108,4 @@ def get_bbox(self, obj): class Meta: model = Area - fields = ("id", "name", "bbox") + fields = ("id", "name", "description", "bbox") diff --git a/backend/project/observations/migrations/0002_alter_observation_comments.py b/backend/project/observations/migrations/0002_alter_observation_comments.py new file mode 100644 index 0000000..fa06ad6 --- /dev/null +++ b/backend/project/observations/migrations/0002_alter_observation_comments.py @@ -0,0 +1,18 @@ +# Generated by Django 5.0.6 on 2024-07-08 07:34 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ("observations", "0001_initial"), + ] + + operations = [ + migrations.AlterField( + model_name="observation", + name="comments", + field=models.TextField(blank=True, default=""), + ), + ] diff --git a/backend/project/observations/models.py b/backend/project/observations/models.py index bfb7f5d..ed42048 100644 --- a/backend/project/observations/models.py +++ b/backend/project/observations/models.py @@ -61,7 +61,7 @@ class Observation(TimeStampMixin): observer = models.ForeignKey( "accounts.User", on_delete=models.SET_NULL, null=True, blank=True ) - comments = models.TextField() + comments = models.TextField(blank=True, default="") event_date = models.DateField(default=timezone_today, db_index=True) source = models.ForeignKey(Source, on_delete=models.SET_NULL, blank=True, null=True) category = models.ForeignKey(ObservationCategory, on_delete=models.PROTECT)