Skip to content

Commit

Permalink
Merge 1b187a9 into 5b9ae23
Browse files Browse the repository at this point in the history
  • Loading branch information
rstorey committed Mar 4, 2019
2 parents 5b9ae23 + 1b187a9 commit 27a7f8c
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 7 deletions.
7 changes: 6 additions & 1 deletion concordia/converters.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
from django.urls.converters import SlugConverter
from django.urls.converters import SlugConverter, StringConverter


class UnicodeSlugConverter(SlugConverter):
# This is similar to the slug_unicode_re pattern but is not anchored to the
# start of the string:
regex = r"[-\w+]+"


class ItemIdConverter(StringConverter):
# Allows . in the item ID
regex = r"[-a-zA-Z0-9_\.]+"
4 changes: 2 additions & 2 deletions concordia/tests/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@ def create_item(
*,
project=None,
title="Test Item",
item_id="testitem0123456789",
item_url="http://example.com/item/testitem0123456789/",
item_id="testitem.0123456789",
item_url="http://example.com/item/testitem.0123456789/",
published=True,
**kwargs,
):
Expand Down
13 changes: 10 additions & 3 deletions concordia/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
from . import converters, views

register_converter(converters.UnicodeSlugConverter, "uslug")
register_converter(converters.ItemIdConverter, "item_id")

tx_urlpatterns = (
[
Expand All @@ -35,7 +36,10 @@
name="project-export-bagit",
),
path(
"<uslug:campaign_slug>/<uslug:project_slug>/<slug:item_id>/export/bagit/",
(
"<uslug:campaign_slug>/<uslug:project_slug>/"
"<item_id:item_id>/export/bagit/"
),
exporter_views.ExportItemToBagIt.as_view(),
name="item-export-bagit",
),
Expand All @@ -45,7 +49,10 @@
name="campaign-report",
),
path(
"<uslug:campaign_slug>/<uslug:project_slug>/<slug:item_id>/<uslug:slug>/",
(
"<uslug:campaign_slug>/<uslug:project_slug>/"
"<item_id:item_id>/<uslug:slug>/"
),
views.AssetDetailView.as_view(),
name="asset-detail",
),
Expand All @@ -66,7 +73,7 @@
name="project-detail",
),
path(
"<uslug:campaign_slug>/<uslug:project_slug>/<slug:item_id>/",
"<uslug:campaign_slug>/<uslug:project_slug>/<item_id:item_id>/",
views.ItemDetailView.as_view(),
name="item-detail",
),
Expand Down
2 changes: 1 addition & 1 deletion exporter/tests/test_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ def test_csv_export(self):
"b'Campaign,Project,Item,ItemId,Asset,"
"AssetStatus,DownloadUrl,Transcription\\r\\n'"
"b'Test Campaign,Test Project,Test Item,"
"testitem0123456789,TestAsset,completed,"
"testitem.0123456789,TestAsset,completed,"
"http://tile.loc.gov/image-services/"
"iiif/service:mss:mal:003:0036300:002/full"
"/pct:25/0/default.jpg,Sample\\r\\n'"
Expand Down

0 comments on commit 27a7f8c

Please sign in to comment.