Skip to content

Commit

Permalink
Merge branch 'master' into frontend-release
Browse files Browse the repository at this point in the history
  • Loading branch information
ndepaola committed Feb 27, 2024
2 parents a66e8e2 + 87e9697 commit 510b633
Show file tree
Hide file tree
Showing 4 changed files with 222 additions and 184 deletions.
6 changes: 3 additions & 3 deletions MPCAutofill/cardpicker/sources/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,19 +89,19 @@ def unpack_name(self, tags: Tags) -> tuple[pycountry.Languages, str, set[str], s
language = pycountry.languages.get(alpha_2=language_code) if language_code else None
name_with_no_tags, extracted_tags = tags.extract_name_and_tags(name)
return (
language,
language or self.folder.get_language(tags=tags),
sanitisation.fix_whitespace(name_with_no_tags),
extracted_tags | self.folder.get_tags(tags=tags),
extension,
)

def get_language(self, tags: Tags) -> pycountry.Languages:
language, _, _, _ = self.unpack_name(tags=tags)
return language if language is not None else self.folder.get_language(tags=tags)
return language

def get_tags(self, tags: Tags) -> set[str]:
_, _, image_tags, _ = self.unpack_name(tags=tags)
return image_tags | self.folder.get_tags(tags=tags)
return image_tags


# region google drive API
Expand Down
18 changes: 18 additions & 0 deletions MPCAutofill/cardpicker/tests/test_sources.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,22 @@ class TestAPI:
IMAGE_DOUBLE_NSFW = Image(
id="double nsfw", name="NSFW (NSFW) [NSFW].png", size=1, created_time=DEFAULT_DATE, height=1, folder=FOLDER_A
)
IMAGE_IMPLICITLY_FRENCH = Image(
id="implicitly_french",
name="Implicitly French.png",
size=1,
created_time=DEFAULT_DATE,
height=1,
folder=FOLDER_FRENCH,
)
IMAGE_EXPLICITLY_ENGLISH = Image(
id="explicitly_english",
name="{EN} Explicitly English.png",
size=1,
created_time=DEFAULT_DATE,
height=1,
folder=FOLDER_FRENCH,
)

# endregion

Expand Down Expand Up @@ -142,6 +158,8 @@ def test_folder_name(
(IMAGE_A, None),
(IMAGE_FRENCH, "FR"),
(IMAGE_ENGLISH, "EN"),
(IMAGE_IMPLICITLY_FRENCH, "FR"),
(IMAGE_EXPLICITLY_ENGLISH, "EN"), # despite being in a French folder
],
)
def test_image_language(self, django_settings, image, expected_language):
Expand Down
232 changes: 124 additions & 108 deletions frontend/src/features/card/__snapshots__/cardSlot.test.tsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -484,7 +484,7 @@ exports[`the html structure of a CardSlot's grid selector, cards faceted by sour
}
<div
class="modal-dialog modal-lg modal-dialog-scrollable"
class="modal-dialog modal-xl modal-dialog-scrollable"
data-testid="front-slot0-grid-selector"
>
<div
Expand Down Expand Up @@ -515,15 +515,19 @@ exports[`the html structure of a CardSlot's grid selector, cards faceted by sour
class="mt-0"
/>
<div
class="d-flex ps-4 pe-4 hstack gap-2"
class="d-flex ps-3 pe-3 hstack gap-2"
>
<h4>
Jump to Version
</h4>
<h4
class="ms-auto bi bi-chevron-left rotate-neg90"
style="transition: all 0.25s 0s;"
/>
<button
class="ms-auto bg-transparent border-0"
>
<h4
class="bi bi-chevron-left rotate-neg90"
style="transition: all 0.25s 0s;"
/>
</button>
</div>
<hr
class="mb-0"
Expand All @@ -532,63 +536,67 @@ exports[`the html structure of a CardSlot's grid selector, cards faceted by sour
<div
class="py-2"
/>
<form
class="px-3 collapse"
id="jumpToVersionForm"
<div
class="collapse"
>
<div
class="g-0 row"
<form
class="px-3"
id="jumpToVersionForm"
>
<div
class="col-lg-3 col-md-5"
class="g-0 row"
>
<label
class="form-label"
<div
class="col-lg-3 col-md-5"
>
Specify Option Number,
<b>
or...
</b>
</label>
<input
class="form-control"
pattern="[0-9]*"
placeholder="1"
type="number"
value=""
/>
<label
class="form-label"
>
Specify Option Number,
<b>
or...
</b>
</label>
<input
class="form-control"
pattern="[0-9]*"
placeholder="1"
type="number"
value=""
/>
</div>
<div
class="col-lg-9 col-md-7"
>
<label
class="form-label"
>
Specify ID
</label>
<input
class="form-control"
placeholder="abc123"
type="text"
value=""
/>
</div>
</div>
<div
class="col-lg-9 col-md-7"
class="d-grid gap-0 pt-3"
>
<label
class="form-label"
<button
aria-label="jump-to-version-submit"
class="btn btn-primary"
disabled=""
form="jumpToVersionForm"
type="submit"
>
Specify ID
</label>
<input
class="form-control"
placeholder="abc123"
type="text"
value=""
/>
Select This Version
</button>
</div>
</div>
<div
class="d-grid gap-0 pt-3"
>
<button
aria-label="jump-to-version-submit"
class="btn btn-primary"
disabled=""
form="jumpToVersionForm"
type="submit"
>
Select This Version
</button>
</div>
</form>
<hr />
</form>
<hr />
</div>
<div
class="px-3 pb-3"
>
Expand Down Expand Up @@ -637,7 +645,7 @@ exports[`the html structure of a CardSlot's grid selector, cards faceted by sour
</div>
</div>
<div
class="g-0 px-3 row row-cols-xxl-4 row-cols-xl-4 row-cols-lg-3 row-cols-md-2 row-cols-sm-2 row-cols-2"
class="g-0 px-3 row row-cols-xxl-6 row-cols-xl-6 row-cols-lg-4 row-cols-md-3 row-cols-sm-2 row-cols-2"
>
<div
class="renderIfVisible "
Expand Down Expand Up @@ -872,7 +880,7 @@ exports[`the html structure of a CardSlot's grid selector, cards grouped togethe
}
<div
class="modal-dialog modal-lg modal-dialog-scrollable"
class="modal-dialog modal-xl modal-dialog-scrollable"
data-testid="front-slot0-grid-selector"
>
<div
Expand Down Expand Up @@ -903,15 +911,19 @@ exports[`the html structure of a CardSlot's grid selector, cards grouped togethe
class="mt-0"
/>
<div
class="d-flex ps-4 pe-4 hstack gap-2"
class="d-flex ps-3 pe-3 hstack gap-2"
>
<h4>
Jump to Version
</h4>
<h4
class="ms-auto bi bi-chevron-left rotate-neg90"
style="transition: all 0.25s 0s;"
/>
<button
class="ms-auto bg-transparent border-0"
>
<h4
class="bi bi-chevron-left rotate-neg90"
style="transition: all 0.25s 0s;"
/>
</button>
</div>
<hr
class="mb-0"
Expand All @@ -920,63 +932,67 @@ exports[`the html structure of a CardSlot's grid selector, cards grouped togethe
<div
class="py-2"
/>
<form
class="px-3 collapse"
id="jumpToVersionForm"
<div
class="collapse"
>
<div
class="g-0 row"
<form
class="px-3"
id="jumpToVersionForm"
>
<div
class="col-lg-3 col-md-5"
class="g-0 row"
>
<label
class="form-label"
<div
class="col-lg-3 col-md-5"
>
Specify Option Number,
<b>
or...
</b>
</label>
<input
class="form-control"
pattern="[0-9]*"
placeholder="1"
type="number"
value=""
/>
<label
class="form-label"
>
Specify Option Number,
<b>
or...
</b>
</label>
<input
class="form-control"
pattern="[0-9]*"
placeholder="1"
type="number"
value=""
/>
</div>
<div
class="col-lg-9 col-md-7"
>
<label
class="form-label"
>
Specify ID
</label>
<input
class="form-control"
placeholder="abc123"
type="text"
value=""
/>
</div>
</div>
<div
class="col-lg-9 col-md-7"
class="d-grid gap-0 pt-3"
>
<label
class="form-label"
<button
aria-label="jump-to-version-submit"
class="btn btn-primary"
disabled=""
form="jumpToVersionForm"
type="submit"
>
Specify ID
</label>
<input
class="form-control"
placeholder="abc123"
type="text"
value=""
/>
Select This Version
</button>
</div>
</div>
<div
class="d-grid gap-0 pt-3"
>
<button
aria-label="jump-to-version-submit"
class="btn btn-primary"
disabled=""
form="jumpToVersionForm"
type="submit"
>
Select This Version
</button>
</div>
</form>
<hr />
</form>
<hr />
</div>
<div
class="px-3 pb-3"
>
Expand Down Expand Up @@ -1025,7 +1041,7 @@ exports[`the html structure of a CardSlot's grid selector, cards grouped togethe
</div>
</div>
<div
class="g-0 px-3 row row-cols-xxl-4 row-cols-xl-4 row-cols-lg-3 row-cols-md-2 row-cols-sm-2 row-cols-2"
class="g-0 px-3 row row-cols-xxl-6 row-cols-xl-6 row-cols-lg-4 row-cols-md-3 row-cols-sm-2 row-cols-2"
>
<div
class="renderIfVisible "
Expand Down
Loading

0 comments on commit 510b633

Please sign in to comment.