Skip to content

Commit

Permalink
adding get_choices under the __init__ function of the serializer
Browse files Browse the repository at this point in the history
  • Loading branch information
Gpetrak committed Dec 6, 2024
1 parent 564877f commit 1971c99
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 4 deletions.
16 changes: 12 additions & 4 deletions geonode/layers/api/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -217,18 +217,26 @@ class Meta:

class DatasetTimeSeriesSerializer(serializers.Serializer):

def __init__(self, *args, **kwargs):

super().__init__(*args, **kwargs)

choices = self._get_choices()
self.fields["attribute"].choices = choices
self.fields["end_attribute"].choices = choices

@staticmethod
def _get_choices():

attributes = Attribute.objects.all()
choices = [(None, "-----")] + [

return [(None, "-----")] + [
(_a.pk, _a.attribute) for _a in attributes if _a.attribute_type in ["xsd:dateTime", "xsd:date"]
]
return choices

has_time = serializers.BooleanField(default=False)
attribute = serializers.ChoiceField(choices=_get_choices(), required=False)
end_attribute = serializers.ChoiceField(choices=_get_choices(), required=False)
attribute = serializers.ChoiceField(choices=[], required=False)
end_attribute = serializers.ChoiceField(choices=[], required=False)
presentation = serializers.ChoiceField(
required=False,
choices=[
Expand Down
20 changes: 20 additions & 0 deletions geonode/upload/migrations/0050_alter_uploadsizelimit_max_size.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Generated by Django 4.2.16 on 2024-12-06 08:35

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
("upload", "0049_move_data_from_importer_to_upload"),
]

operations = [
migrations.AlterField(
model_name="uploadsizelimit",
name="max_size",
field=models.PositiveBigIntegerField(
default=104857600, help_text="The maximum file size allowed for upload (bytes)."
),
),
]

0 comments on commit 1971c99

Please sign in to comment.