Skip to content

Commit

Permalink
add location data
Browse files Browse the repository at this point in the history
  • Loading branch information
nicokant committed Oct 8, 2024
1 parent 08c8126 commit f6dc6f4
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 4 deletions.
1 change: 1 addition & 0 deletions src/apps/core/management/commands/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,5 @@ def handle(self: Self, **options) -> None:
call_command("loaddata", "users.json")

call_command("loaddata", "bestilling.json")
call_command("loaddata", "location.json")
call_command("loaddata", "groups.json")
1 change: 1 addition & 0 deletions src/fixtures/locations.json

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions src/genlab_bestilling/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,8 @@ class OrganizationAdmin(ModelAdmin):

@admin.register(Location)
class LocationAdmin(ModelAdmin):
list_display = ["name", "type", "river_id", "station_id"]
search_fields = ["name", "river_id", "station_id"]
list_display = ["name", "type", "river_id", "code"]
search_fields = ["name", "river_id", "code"]
list_filter = [("type", RelatedDropdownFilter)]
list_filter_submit = True

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Generated by Django 5.1.1 on 2024-10-08 08:38

from django.db import migrations, models


class Migration(migrations.Migration):
dependencies = [
("genlab_bestilling", "0004_remove_sample_date_sample_year"),
]

operations = [
migrations.RenameField(
model_name="location",
old_name="station_id",
new_name="code",
),
migrations.AddField(
model_name="location",
name="fylke",
field=models.CharField(blank=True, null=True),
),
]
5 changes: 3 additions & 2 deletions src/genlab_bestilling/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,11 +81,12 @@ class Location(models.Model):
"LocationType", null=True, blank=True, on_delete=models.CASCADE
)
river_id = models.CharField(max_length=250, null=True, blank=True)
station_id = models.CharField(max_length=20, null=True, blank=True)
code = models.CharField(max_length=20, null=True, blank=True)
fylke = models.CharField(null=True, blank=True)

def __str__(self):
if self.river_id:
return f"{self.river_id} {self.station_id} {self.name}"
return f"{self.river_id} {self.name}"

return self.name

Expand Down

0 comments on commit f6dc6f4

Please sign in to comment.