diff --git a/metadata_catalogue/maps/migrations/0003_alter_layer_slug_alter_map_slug_alter_source_slug.py b/metadata_catalogue/maps/migrations/0003_alter_layer_slug_alter_map_slug_alter_source_slug.py new file mode 100644 index 0000000..8fa932f --- /dev/null +++ b/metadata_catalogue/maps/migrations/0003_alter_layer_slug_alter_map_slug_alter_source_slug.py @@ -0,0 +1,27 @@ +# Generated by Django 4.2.8 on 2023-12-19 10:46 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + dependencies = [ + ("maps", "0002_alter_layer_group"), + ] + + operations = [ + migrations.AlterField( + model_name="layer", + name="slug", + field=models.SlugField(blank=True, max_length=250, null=True), + ), + migrations.AlterField( + model_name="map", + name="slug", + field=models.SlugField(max_length=150), + ), + migrations.AlterField( + model_name="source", + name="slug", + field=models.SlugField(blank=True, max_length=250, null=True), + ), + ] diff --git a/metadata_catalogue/maps/models.py b/metadata_catalogue/maps/models.py index 522fc7a..c8b9b83 100644 --- a/metadata_catalogue/maps/models.py +++ b/metadata_catalogue/maps/models.py @@ -17,7 +17,7 @@ def empty_json(): class Source(PolymorphicModel): name = models.CharField(max_length=250) - slug = models.SlugField(null=True, blank=True) + slug = models.SlugField(null=True, blank=True, max_length=250) extra = models.JSONField(default=empty_json, blank=True) owner = models.ForeignKey("users.User", on_delete=models.SET_NULL, null=True, blank=True) style = models.JSONField(default=empty_json, blank=True) @@ -89,7 +89,7 @@ def type(self): class Layer(models.Model): name = models.CharField(max_length=250, null=True, blank=True) - slug = models.SlugField(null=True, blank=True) + slug = models.SlugField(null=True, blank=True, max_length=250) map = models.ForeignKey("maps.Map", on_delete=models.CASCADE, related_name="layers") source = models.ForeignKey("maps.Source", on_delete=models.CASCADE, null=True, blank=True) source_layer = models.CharField(blank=True, null=True) @@ -131,7 +131,7 @@ class Meta: class Map(models.Model): title = models.CharField(max_length=150) - slug = models.SlugField() + slug = models.SlugField(max_length=150) subtitle = models.CharField(max_length=250, null=True, blank=True) description = models.TextField(blank=True) # center = @@ -152,7 +152,7 @@ class Meta: def get_metadata(self, request): layers = [] - for root in self.groups.order_by("-order").all(): + for root in self.groups.order_by("order").all(): layers.append(root.as_layer_tree()) style_url = request.build_absolute_uri(