Skip to content

Commit

Permalink
Fix links to published-details
Browse files Browse the repository at this point in the history
  • Loading branch information
alukach committed Oct 14, 2023
1 parent 292c4ea commit a2c7f54
Show file tree
Hide file tree
Showing 4 changed files with 76 additions and 34 deletions.
104 changes: 73 additions & 31 deletions app/admin_ui/tables/published.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,10 @@ class Meta:

class IOPPublishedTable(tables.Table):
short_name = ConditionalValueColumn(
linkify=("published-detail", dict(pk=tables.A("uuid"), model=camel_to_snake('IOP'))),
linkify=(
"published-detail",
dict(canonical_uuid=tables.A("uuid"), model=camel_to_snake('IOP')),
),
verbose_name="Short Name",
accessor="short_name",
)
Expand All @@ -70,7 +73,7 @@ class SignificantEventPublishedTable(tables.Table):
short_name = ConditionalValueColumn(
linkify=(
"published-detail",
dict(pk=tables.A("uuid"), model=camel_to_snake('SignificantEvent')),
dict(canonical_uuid=tables.A("uuid"), model=camel_to_snake('SignificantEvent')),
),
verbose_name="Short Name",
accessor="short_name",
Expand All @@ -94,7 +97,7 @@ class CollectionPeriodPublishedTable(tables.Table):
deployment = ShortNamefromUUIDColumn(
linkify=(
"published-detail",
dict(pk=tables.A('uuid'), model=camel_to_snake('CollectionPeriod')),
dict(canonical_uuid=tables.A('uuid'), model=camel_to_snake('CollectionPeriod')),
),
model=Deployment,
verbose_name="Deployment",
Expand All @@ -121,7 +124,10 @@ class Meta(LimitedTableBase.Meta):

class DOIPublishedTable(tables.Table):
concept_id = ConditionalValueColumn(
linkify=("published-detail", dict(pk=tables.A("uuid"), model=camel_to_snake('DOI'))),
linkify=(
"published-detail",
dict(canonical_uuid=tables.A("uuid"), model=camel_to_snake('DOI')),
),
verbose_name="Concept ID",
accessor="concept_id",
)
Expand Down Expand Up @@ -149,7 +155,10 @@ class Meta(LimitedTableBase.Meta):

class DeploymentPublishedTable(LimitedTableBase):
short_name = ConditionalValueColumn(
linkify=("published-detail", dict(pk=tables.A("uuid"), model=camel_to_snake('Deployment'))),
linkify=(
"published-detail",
dict(canonical_uuid=tables.A("uuid"), model=camel_to_snake('Deployment')),
),
verbose_name="Short Name",
accessor="short_name",
)
Expand All @@ -170,7 +179,7 @@ class PlatformTypePublishedTable(LimitedTableBase):
short_name = ConditionalValueColumn(
linkify=(
"published-detail",
dict(pk=tables.A("uuid"), model=camel_to_snake('PlatformType')),
dict(canonical_uuid=tables.A("uuid"), model=camel_to_snake('PlatformType')),
),
verbose_name="Short Name",
accessor="short_name",
Expand All @@ -187,7 +196,7 @@ class MeasurementTypePublishedTable(LimitedTableBase):
short_name = ConditionalValueColumn(
linkify=(
"published-detail",
dict(pk=tables.A("uuid"), model=camel_to_snake('MeasurementType')),
dict(canonical_uuid=tables.A("uuid"), model=camel_to_snake('MeasurementType')),
),
verbose_name="Short Name",
accessor="short_name",
Expand All @@ -204,7 +213,7 @@ class MeasurementStylePublishedTable(LimitedTableBase):
short_name = ConditionalValueColumn(
linkify=(
"published-detail",
dict(pk=tables.A("uuid"), model=camel_to_snake('MeasurementStyle')),
dict(canonical_uuid=tables.A("uuid"), model=camel_to_snake('MeasurementStyle')),
),
verbose_name="Short Name",
accessor="short_name",
Expand All @@ -219,7 +228,10 @@ class Meta(LimitedTableBase.Meta):

class HomeBasePublishedTable(LimitedTableBase):
short_name = ConditionalValueColumn(
linkify=("published-detail", dict(pk=tables.A("uuid"), model=camel_to_snake('HomeBase'))),
linkify=(
"published-detail",
dict(canonical_uuid=tables.A("uuid"), model=camel_to_snake('HomeBase')),
),
verbose_name="Short Name",
accessor="short_name",
)
Expand All @@ -233,7 +245,10 @@ class Meta(LimitedTableBase.Meta):

class FocusAreaPublishedTable(LimitedTableBase):
short_name = ConditionalValueColumn(
linkify=("published-detail", dict(pk=tables.A("uuid"), model=camel_to_snake('FocusArea'))),
linkify=(
"published-detail",
dict(canonical_uuid=tables.A("uuid"), model=camel_to_snake('FocusArea')),
),
verbose_name="Short Name",
accessor="short_name",
)
Expand All @@ -247,7 +262,10 @@ class Meta(LimitedTableBase.Meta):

class SeasonPublishedTable(LimitedTableBase):
short_name = ConditionalValueColumn(
linkify=("published-detail", dict(pk=tables.A("uuid"), model=camel_to_snake('Season'))),
linkify=(
"published-detail",
dict(canonical_uuid=tables.A("uuid"), model=camel_to_snake('Season')),
),
verbose_name="Short Name",
accessor="short_name",
)
Expand All @@ -261,7 +279,10 @@ class Meta(LimitedTableBase.Meta):

class RepositoryPublishedTable(LimitedTableBase):
short_name = ConditionalValueColumn(
linkify=("published-detail", dict(pk=tables.A("uuid"), model=camel_to_snake('Repository'))),
linkify=(
"published-detail",
dict(canonical_uuid=tables.A("uuid"), model=camel_to_snake('Repository')),
),
verbose_name="Short Name",
accessor="short_name",
)
Expand All @@ -277,16 +298,18 @@ class MeasurementRegionPublishedTable(LimitedTableBase):
short_name = ConditionalValueColumn(
linkify=(
"published-detail",
dict(pk=tables.A("uuid"), model=camel_to_snake('MeasurementRegion')),
dict(canonical_uuid=tables.A("uuid"), model=camel_to_snake('MeasurementRegion')),
),
verbose_name="Short Name",
accessor="short_name",
)
example = tables.Column(verbose_name="Example", accessor="example")
example = tables.Column(verbose_name="Example", accessor="example")

class Meta(LimitedTableBase.Meta):
fields = LimitedTableBase.initial_fields + ("example",)
fields = (
*LimitedTableBase.initial_fields,
"example",
)
sequence = fields
model = MeasurementRegion

Expand All @@ -295,13 +318,12 @@ class GeographicalRegionPublishedTable(LimitedTableBase):
short_name = ConditionalValueColumn(
linkify=(
"published-detail",
dict(pk=tables.A("uuid"), model=camel_to_snake('GeographicalRegion')),
dict(canonical_uuid=tables.A("uuid"), model=camel_to_snake('GeographicalRegion')),
),
verbose_name="Short Name",
accessor="short_name",
)
example = tables.Column(verbose_name="Example", accessor="example")
example = tables.Column(verbose_name="Example", accessor="example")

class Meta(LimitedTableBase.Meta):
fields = LimitedTableBase.initial_fields + ("example",)
Expand All @@ -313,13 +335,12 @@ class GeophysicalConceptPublishedTable(LimitedTableBase):
short_name = ConditionalValueColumn(
linkify=(
"published-detail",
dict(pk=tables.A("uuid"), model=camel_to_snake('GeophysicalConcept')),
dict(canonical_uuid=tables.A("uuid"), model=camel_to_snake('GeophysicalConcept')),
),
verbose_name="Short Name",
accessor="short_name",
)
example = tables.Column(verbose_name="Example", accessor="example")
example = tables.Column(verbose_name="Example", accessor="example")

class Meta(LimitedTableBase.Meta):
fields = LimitedTableBase.initial_fields + ("example",)
Expand All @@ -329,7 +350,10 @@ class Meta(LimitedTableBase.Meta):

class PartnerOrgPublishedTable(LimitedTableBase):
short_name = ConditionalValueColumn(
linkify=("published-detail", dict(pk=tables.A("uuid"), model=camel_to_snake('PartnerOrg'))),
linkify=(
"published-detail",
dict(canonical_uuid=tables.A("uuid"), model=camel_to_snake('PartnerOrg')),
),
verbose_name="Short Name",
accessor="short_name",
)
Expand All @@ -345,7 +369,7 @@ class WebsiteTypePublishedTable(LimitedTableBase):
short_name = ConditionalValueColumn(
linkify=(
"published-detail",
dict(pk=tables.A("uuid"), model=camel_to_snake('WebsiteType')),
dict(canonical_uuid=tables.A("uuid"), model=camel_to_snake('WebsiteType')),
),
verbose_name="Short Name",
accessor="short_name",
Expand All @@ -360,7 +384,10 @@ class Meta(LimitedTableBase.Meta):

class CampaignPublishedTable(LimitedTableBase):
short_name = ConditionalValueColumn(
linkify=("published-detail", dict(pk=tables.A("uuid"), model=camel_to_snake('Campaign'))),
linkify=(
"published-detail",
dict(canonical_uuid=tables.A("uuid"), model=camel_to_snake('Campaign')),
),
verbose_name="Short Name",
accessor="short_name",
)
Expand All @@ -374,7 +401,10 @@ class Meta(LimitedTableBase.Meta):

class PlatformPublishedTable(LimitedTableBase):
short_name = ConditionalValueColumn(
linkify=("published-detail", dict(pk=tables.A("uuid"), model=camel_to_snake('Platform'))),
linkify=(
"published-detail",
dict(canonical_uuid=tables.A("uuid"), model=camel_to_snake('Platform')),
),
verbose_name="Short Name",
accessor="short_name",
)
Expand All @@ -388,7 +418,10 @@ class Meta(LimitedTableBase.Meta):

class InstrumentPublishedTable(LimitedTableBase):
short_name = ConditionalValueColumn(
linkify=("published-detail", dict(pk=tables.A("uuid"), model=camel_to_snake('Instrument'))),
linkify=(
"published-detail",
dict(canonical_uuid=tables.A("uuid"), model=camel_to_snake('Instrument')),
),
verbose_name="Short Name",
accessor="short_name",
)
Expand All @@ -402,7 +435,10 @@ class Meta(LimitedTableBase.Meta):

class WebsitePublishedTable(tables.Table):
title = ConditionalValueColumn(
linkify=("published-detail", dict(pk=tables.A("uuid"), model=camel_to_snake('Website'))),
linkify=(
"published-detail",
dict(canonical_uuid=tables.A("uuid"), model=camel_to_snake('Website')),
),
verbose_name="Title",
accessor="title",
)
Expand All @@ -417,7 +453,10 @@ class Meta(LimitedTableBase.Meta):

class AliasPublishedTable(LimitedTableBase):
short_name = ConditionalValueColumn(
linkify=("published-detail", dict(pk=tables.A("uuid"), model=camel_to_snake('Alias'))),
linkify=(
"published-detail",
dict(canonical_uuid=tables.A("uuid"), model=camel_to_snake('Alias')),
),
verbose_name="Short Name",
accessor="short_name",
)
Expand All @@ -434,7 +473,7 @@ class GcmdProjectPublishedTable(LimitedTableBase):
short_name = ConditionalValueColumn(
linkify=(
"published-detail",
dict(pk=tables.A("uuid"), model=camel_to_snake('GcmdProject')),
dict(canonical_uuid=tables.A("uuid"), model=camel_to_snake('GcmdProject')),
),
verbose_name="Short Name",
accessor="short_name",
Expand All @@ -451,7 +490,7 @@ class GcmdInstrumentPublishedTable(LimitedTableBase):
short_name = ConditionalValueColumn(
linkify=(
"published-detail",
dict(pk=tables.A("uuid"), model=camel_to_snake('GcmdInstrument')),
dict(canonical_uuid=tables.A("uuid"), model=camel_to_snake('GcmdInstrument')),
),
verbose_name="Short Name",
accessor="short_name",
Expand Down Expand Up @@ -482,7 +521,7 @@ class GcmdPlatformPublishedTable(LimitedTableBase):
short_name = ConditionalValueColumn(
linkify=(
"published-detail",
dict(pk=tables.A("uuid"), model=camel_to_snake('GcmdPlatform')),
dict(canonical_uuid=tables.A("uuid"), model=camel_to_snake('GcmdPlatform')),
),
verbose_name="Short Name",
accessor="short_name",
Expand All @@ -499,7 +538,7 @@ class GcmdPhenomenonPublishedTable(tables.Table):
variable_3 = ConditionalValueColumn(
linkify=(
"published-detail",
dict(pk=tables.A("uuid"), model=camel_to_snake('GcmdPhenomenon')),
dict(canonical_uuid=tables.A("uuid"), model=camel_to_snake('GcmdPhenomenon')),
),
verbose_name="Variable 3",
accessor="variable_3",
Expand All @@ -518,7 +557,10 @@ class Meta(LimitedTableBase.Meta):

class ImagePublishedTable(tables.Table):
title = ConditionalValueColumn(
linkify=("published-detail", dict(pk=tables.A("uuid"), model=camel_to_snake('Image'))),
linkify=(
"published-detail",
dict(canonical_uuid=tables.A("uuid"), model=camel_to_snake('Image')),
),
verbose_name="Title",
accessor="title",
)
Expand Down
2 changes: 1 addition & 1 deletion app/admin_ui/templates/api_app/change_gcmd.html
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ <h3>Activity</h3>
</tr>
{% for record in affected_records %}
<tr>
<td><a href="{% url 'published-detail' pk=record.link.casei_uuid model=record.link.model %}?back={{ request.path }}">{{record.row.short_name}}</a></td>
<td><a href="{% url 'published-detail' canonical_uuid=record.link.casei_uuid model=record.link.model %}?back={{ request.path }}">{{record.row.short_name}}</a></td>
</a>
<td>{{record.category}}</td>
<td>{{record.status}}</td>
Expand Down
2 changes: 1 addition & 1 deletion app/admin_ui/templates/api_app/change_update.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<div class="px-1">
<a
class="btn btn-primary"
href="{% url 'published-detail' pk=object.model_instance_uuid model=view_model %}"
href="{% url 'published-detail' canonical_uuid=object.model_instance_uuid model=view_model %}"
>
View published version
</a>
Expand Down
2 changes: 1 addition & 1 deletion app/admin_ui/widgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ def render(self, name, value, *args, **kwargs):
published_url = reverse(
"published-detail",
kwargs={
"pk": published.pk,
"canonical_uuid": published.pk,
"model": camel_to_snake(self.model._meta.object_name),
},
)
Expand Down

0 comments on commit a2c7f54

Please sign in to comment.