Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
Backend
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Container Registry
Analyze
Contributor analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Arkindex
Backend
Commits
78cf0947
Commit
78cf0947
authored
3 years ago
by
Valentin Rigal
Committed by
Erwan Rouchet
3 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Preserve image path first character using CreateIIIFURL with a new server
parent
be64ad14
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!1531
Preserve image path first character using CreateIIIFURL with a new server
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
arkindex/images/managers.py
+4
-2
4 additions, 2 deletions
arkindex/images/managers.py
arkindex/images/tests/test_image_api.py
+2
-0
2 additions, 0 deletions
arkindex/images/tests/test_image_api.py
arkindex/images/tests/test_imageserver.py
+6
-6
6 additions, 6 deletions
arkindex/images/tests/test_imageserver.py
with
12 additions
and
8 deletions
arkindex/images/managers.py
+
4
−
2
View file @
78cf0947
...
...
@@ -4,7 +4,7 @@ from django.utils.functional import cached_property
# Lower-case markers that *may* indicate a IIIF server handles
# images after that path
IIIF_MARKERS
=
(
'
/iiif/
'
,
'
/i3f/
'
)
IIIF_MARKERS
=
(
'
/iiif/2/
'
,
'
/iiif/
'
,
'
/i3f/
'
)
class
ImageServerManager
(
models
.
Manager
):
...
...
@@ -30,7 +30,9 @@ class ImageServerManager(models.Manager):
for
marker
in
IIIF_MARKERS
:
if
marker
not
in
url
.
lower
():
continue
server_url
=
url
[:
url
.
lower
().
index
(
marker
)
+
len
(
marker
)]
# Remove the marker trailing slash as it caused IIIFImageSerializer to strip the first
# character of the image path when creating a new server
server_url
=
url
[:
url
.
lower
().
index
(
marker
)
+
len
(
marker
)].
rstrip
(
'
/
'
)
return
self
.
create
(
url
=
server_url
,
display_name
=
server_url
,
...
...
This diff is collapsed.
Click to expand it.
arkindex/images/tests/test_image_api.py
+
2
−
0
View file @
78cf0947
...
...
@@ -340,6 +340,7 @@ class TestImageApi(FixtureAPITestCase):
{
'
url
'
:
'
https://test-server.eu/images/image_path
'
}
)
self
.
assertEqual
(
response
.
status_code
,
status
.
HTTP_201_CREATED
)
self
.
assertTrue
(
Image
.
objects
.
filter
(
path
=
'
image_path
'
).
exists
())
def
test_create_iiif_image_admin_noscope
(
self
):
self
.
client
.
force_login
(
self
.
superuser
)
...
...
@@ -359,6 +360,7 @@ class TestImageApi(FixtureAPITestCase):
)
self
.
assertEqual
(
response
.
status_code
,
status
.
HTTP_201_CREATED
)
self
.
assertTrue
(
ImageServer
.
objects
.
filter
(
url
=
'
https://randomserver.com/iiif
'
).
exists
())
self
.
assertTrue
(
Image
.
objects
.
filter
(
path
=
'
path/to/image.jpg
'
).
exists
())
def
test_create_iiif_image_wrong_urls
(
self
):
self
.
client
.
force_login
(
self
.
superuser
)
...
...
This diff is collapsed.
Click to expand it.
arkindex/images/tests/test_imageserver.py
+
6
−
6
View file @
78cf0947
...
...
@@ -161,8 +161,8 @@ class TestImageServer(TestCase):
# A new server will be created
new_server
=
ImageServer
.
objects
.
from_url
(
'
http://new.server.dev/iiif/test.jpg
'
)
self
.
assertEqual
(
ImageServer
.
objects
.
count
(),
6
)
self
.
assertEqual
(
new_server
.
url
,
'
http://new.server.dev/iiif
/
'
)
self
.
assertEqual
(
new_server
.
display_name
,
'
http://new.server.dev/iiif
/
'
)
self
.
assertEqual
(
new_server
.
url
,
'
http://new.server.dev/iiif
'
)
self
.
assertEqual
(
new_server
.
display_name
,
'
http://new.server.dev/iiif
'
)
self
.
assertTrue
(
new_server
.
validated
)
# And then reused for later calls
...
...
@@ -172,12 +172,12 @@ class TestImageServer(TestCase):
# We also support i3f and weird formats
new_server
=
ImageServer
.
objects
.
from_url
(
'
https://whatever.online/prefix/I3f/xxx/test.jpg
'
)
self
.
assertEqual
(
ImageServer
.
objects
.
count
(),
7
)
self
.
assertEqual
(
new_server
.
url
,
'
https://whatever.online/prefix/I3f
/
'
)
self
.
assertEqual
(
new_server
.
display_name
,
'
https://whatever.online/prefix/I3f
/
'
)
self
.
assertEqual
(
new_server
.
url
,
'
https://whatever.online/prefix/I3f
'
)
self
.
assertEqual
(
new_server
.
display_name
,
'
https://whatever.online/prefix/I3f
'
)
self
.
assertTrue
(
new_server
.
validated
)
new_server
=
ImageServer
.
objects
.
from_url
(
'
http://whatever.online/prefixYz/IIIf/path/to/image.jpg
'
)
self
.
assertEqual
(
ImageServer
.
objects
.
count
(),
8
)
self
.
assertEqual
(
new_server
.
url
,
'
http://whatever.online/prefixYz/IIIf
/
'
)
self
.
assertEqual
(
new_server
.
display_name
,
'
http://whatever.online/prefixYz/IIIf
/
'
)
self
.
assertEqual
(
new_server
.
url
,
'
http://whatever.online/prefixYz/IIIf
'
)
self
.
assertEqual
(
new_server
.
display_name
,
'
http://whatever.online/prefixYz/IIIf
'
)
self
.
assertTrue
(
new_server
.
validated
)
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment