Skip to content

Commit

Permalink
Merge pull request #22 from chnm/refactor/api-data
Browse files Browse the repository at this point in the history
Refactor/api data
  • Loading branch information
hepplerj authored Oct 8, 2024
2 parents 55b8a5c + dd4cfc4 commit 66bb094
Show file tree
Hide file tree
Showing 7 changed files with 99 additions and 35 deletions.
68 changes: 34 additions & 34 deletions exhibits/templates/exhibits/exhibit_page.html
Original file line number Diff line number Diff line change
Expand Up @@ -923,40 +923,6 @@ <h1>{{ page.title }}</h1>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/img-comparison-slider@8/dist/styles.css" />
{% elif page.image %}
{% image page.image original class="w-full max-h-[80vh] object-contain" %}
<div class="absolute bottom-0 left-0 w-full p-4">
<footer class="p-4 mt-auto">
<div class="container mx-auto">
<div class="flex flex-col items-center mb-2 space-y-2">
<div class="flex space-x-2">
{% if page.link_to_previous_page %}
<a href="{% pageurl page.link_to_previous_page %}"
class="bg-slate-500 hover:bg-slate-700 text-white font-bold py-1 px-3 rounded-full text-sm">
Previous
</a>
{% endif %}
{% if page.link_to_next_page %}
<a href="{% pageurl page.link_to_next_page %}"
class="bg-slate-500 hover:bg-slate-700 text-white font-bold py-1 px-3 rounded-full text-sm">
Next
</a>
{% endif %}
</div>
<div class="flex flex-col items-center space-y-2">
<a href="/#exhibits"
class="bg-slate-500 hover:bg-slate-700 text-white font-bold py-1 px-3 rounded-full text-sm">
Take me to the beginning
</a>
{% if page.link_to_subsection %}
<a href="{% pageurl page.link_to_subsection %}"
class="bg-slate-500 hover:bg-slate-700 text-white font-bold py-1 px-3 rounded-full text-sm">
Skip to next section
</a>
{% endif %}
</div>
</div>
</div>
</footer>
</div>
{% if page.image_caption %}
<div x-data="{ openCaption: false, openImage: false }" class="absolute top-0 right-0 m-4 hidden md:block">
<div class="flex justify-end space-x-2" :class="{ 'hidden': openCaption || openImage }" x-transition x-cloak>
Expand Down Expand Up @@ -991,6 +957,40 @@ <h1>{{ page.title }}</h1>
</p>
</div>
</div>
<div class="navigation-elements mt-4">
<footer class="p-4 mt-auto">
<div class="container mx-auto">
<div class="flex flex-col items-center mb-2 space-y-2">
<div class="flex space-x-2">
{% if page.link_to_previous_page %}
<a href="{% pageurl page.link_to_previous_page %}"
class="bg-slate-500 hover:bg-slate-700 text-white font-bold py-1 px-3 rounded-full text-sm">
Previous
</a>
{% endif %}
{% if page.link_to_next_page %}
<a href="{% pageurl page.link_to_next_page %}"
class="bg-slate-500 hover:bg-slate-700 text-white font-bold py-1 px-3 rounded-full text-sm">
Next
</a>
{% endif %}
</div>
<div class="flex flex-col items-center space-y-2">
<a href="/#exhibits"
class="bg-slate-500 hover:bg-slate-700 text-white font-bold py-1 px-3 rounded-full text-sm">
Take me to the beginning
</a>
{% if page.link_to_subsection %}
<a href="{% pageurl page.link_to_subsection %}"
class="bg-slate-500 hover:bg-slate-700 text-white font-bold py-1 px-3 rounded-full text-sm">
Skip to next section
</a>
{% endif %}
</div>
</div>
</div>
</footer>
</div>
</div>
{% endif %}
{% endif %}
Expand Down
17 changes: 17 additions & 0 deletions material/migrations/0006_alter_textilerecord_year.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Generated by Django 5.0.6 on 2024-10-08 17:21

from django.db import migrations, models


class Migration(migrations.Migration):
dependencies = [
("material", "0005_delete_archive_textilerecord_archive"),
]

operations = [
migrations.AlterField(
model_name="textilerecord",
name="year",
field=models.CharField(blank=True, null=True),
),
]
24 changes: 24 additions & 0 deletions material/migrations/0007_alter_textilerecord_archive.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Generated by Django 5.0.6 on 2024-10-08 17:28

import django.db.models.deletion
from django.db import migrations, models


class Migration(migrations.Migration):
dependencies = [
("material", "0006_alter_textilerecord_year"),
]

operations = [
migrations.AlterField(
model_name="textilerecord",
name="archive",
field=models.ForeignKey(
blank=True,
null=True,
on_delete=django.db.models.deletion.CASCADE,
related_name="textile_records",
to="material.archivalrecord",
),
),
]
17 changes: 17 additions & 0 deletions material/migrations/0008_alter_textilerecord_archive.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Generated by Django 5.0.6 on 2024-10-08 17:33

from django.db import migrations, models


class Migration(migrations.Migration):
dependencies = [
("material", "0007_alter_textilerecord_archive"),
]

operations = [
migrations.AlterField(
model_name="textilerecord",
name="archive",
field=models.CharField(blank=True, max_length=765, null=True),
),
]
2 changes: 1 addition & 1 deletion material/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ class TextileRecord(models.Model):
default=False,
help_text="Check this box if the record is publicly viewable. Unchecked will keep the record hidden.",
)
year = models.IntegerField(blank=True, null=True)
year = models.CharField(blank=True, null=True)
archive = models.CharField(max_length=765, blank=True, null=True)
primary_textile_types = models.ManyToManyField(
"PrimaryTextileType", related_name="textile_records", blank=True, default=[]
Expand Down
3 changes: 3 additions & 0 deletions material/resources.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ class TextileRecordResource(resources.ModelResource):
raise_errors = False
# Define fields to map spreadsheet columns
year = fields.Field(attribute="year", column_name="year")
archive = fields.Field(attribute="archive", column_name="archive")
textile_specifications = fields.Field(
attribute="textile_specifications", column_name="textile_specifications"
)
Expand Down Expand Up @@ -155,6 +156,7 @@ class Meta:
fields = (
"id",
"year",
"archive",
"textile_specifications",
"circulation",
"summary_of_record",
Expand Down Expand Up @@ -200,6 +202,7 @@ def before_import_row(self, row, **kwargs):
def get_or_create_textile_record(self, row):
defaults = {
"year": row.get("year"),
"archive": row.get("archive"),
"textile_specifications": row.get("textile_specifications"),
"circulation": row.get("circulation"),
"summary_of_record": row.get("summary_of_record"),
Expand Down
3 changes: 3 additions & 0 deletions templates/database/textile_records_single.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ <h1 class="text-3xl mb-4">Record {{ item.id }} from {{ item.year }}</h1>
<div class="grid grid-cols-1 md:grid-cols-2 gap-4">
<!-- Left Column -->
<div class="prose">
{% if item.archive %}
<p><em>The following data is derived from the {{item.archive}}</em>.</p>
{% endif %}
<h2 class="text-xl mb-4">Summary</h2>
<div class="font-serif text-lg mb-4">
{% if item.summary_of_record %}
Expand Down

0 comments on commit 66bb094

Please sign in to comment.