Skip to content

Commit

Permalink
#175: Add native name field
Browse files Browse the repository at this point in the history
  • Loading branch information
normade committed Jan 14, 2024
1 parent 41ba5a6 commit 03cb1dd
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 3 deletions.
10 changes: 9 additions & 1 deletion mia_buildings/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,9 +173,16 @@ class BuildingImageInline(SortableTabularInline):

@admin.register(Building)
class BuildingAdmin(SortableAdminBase, admin.ModelAdmin):
search_fields = ["name", "description", "city__name", "city__country__name"]
search_fields = [
"name",
"name_addition",
"description",
"city__name",
"city__country__name",
]
list_display = [
"name",
"name_addition",
"pk",
"is_published",
"history_is_clean",
Expand Down Expand Up @@ -223,6 +230,7 @@ class BuildingAdmin(SortableAdminBase, admin.ModelAdmin):
"is_published",
"published_on_twitter",
"name",
"name_addition",
"slug",
"seo_title",
"address",
Expand Down
22 changes: 22 additions & 0 deletions mia_buildings/migrations/0022_building_name_addition.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Generated by Django 4.2.7 on 2024-01-14 00:48

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
("mia_buildings", "0021_alter_buildingimage_image_order"),
]

operations = [
migrations.AddField(
model_name="building",
name="name_addition",
field=models.CharField(
blank=True,
help_text="Add here the original name or info displayed in brackets behind the title. Do not add the brackets.",
max_length=254,
),
),
]
5 changes: 5 additions & 0 deletions mia_buildings/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,11 @@ class Building(models.Model):
updated = models.DateTimeField(auto_now=True)

name = models.CharField(max_length=254, unique=True)
name_addition = models.CharField(
max_length=254,
blank=True,
help_text="Add here the original name or info displayed in brackets behind the title. Do not add the brackets.",
)
subtitle = models.CharField(max_length=254, blank=True)
todays_use = models.CharField(max_length=254, blank=True)
year_of_construction = models.CharField(max_length=4, blank=True)
Expand Down
11 changes: 10 additions & 1 deletion mia_buildings/templates/mia_buildings/building_details.html
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,16 @@
<section class="section last-section">
<div class="container">
<h1 class="is-size-3 mb-5">
{{building.name}}{% if building.year_of_construction %} ({{building.year_of_construction}}){% endif %} {% if building.protected_monument %}<span class="has-tooltip-arrow" data-tooltip="Protected monument"><ion-icon name="shield-half-outline"></ion-icon></span>{% endif %}
{{building.name}}
{% if building.name_addition %}
({{building.name_addition}})
{% endif %}
{% if building.year_of_construction %}
({{building.year_of_construction}})
{% endif %}
{% if building.protected_monument %}
<span class="has-tooltip-arrow" data-tooltip="Protected monument"><ion-icon name="shield-half-outline"></ion-icon></span>
{% endif %}
</h1>
<div class="columns reverse-column-order">
<div class="column is-4-desktop">
Expand Down
2 changes: 1 addition & 1 deletion modernism/static/lib/miaBuilding.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ const setUpMap = () => {
}).addTo(map);

L.marker([buildingLat, buildingLong], { icon: customSingleIcon }).addTo(map)
map.setView([buildingLat, buildingLong], 12)
map.setView([buildingLat, buildingLong], 15)
}

const addClickEventListenerToBuildingImages = () => {
Expand Down

0 comments on commit 03cb1dd

Please sign in to comment.