Use a materialized Extension.latest_version field instead of a dynamic property #152

Merged
Oleg-Komarov merged 15 commits from latest-version-field into main 2024-05-27 17:58:56 +02:00
4 changed files with 65 additions and 21 deletions
Showing only changes of commit 94ae7d98f0 - Show all commits

View File

@ -102,6 +102,12 @@
/* Lightbox component. */ /* Lightbox component. */
.galleria .galleria
--galleria-btn-width: 100px
--galleria-media-max-width: 100%
+media-lg
--galleria-media-max-width: calc(100% - calc(var(--galleria-btn-width) * 1.5))
align-items: center align-items: center
display: flex display: flex
inset: 0 0 0 0 inset: 0 0 0 0
@ -110,19 +116,21 @@
position: fixed position: fixed
z-index: var(--z-index-galleria) z-index: var(--z-index-galleria)
img img, video
max-height: 100% max-height: 100%
max-width: 100% max-width: var(--galleria-media-max-width)
object-fit: contain object-fit: contain
/* Previous/Next buttons.*/ /* Previous/Next buttons.*/
.btn .btn
background: transparent background: transparent
border: none border: none
color: white
cursor: pointer cursor: pointer
font-size: 5.6rem font-size: 5.6rem
height: 100vh height: 100vh
max-width: 200px max-height: 300px
max-width: var(--galleria-btn-width)
opacity: .6 opacity: .6
outline: 0 outline: 0
position: absolute position: absolute
@ -137,12 +145,7 @@
color: white color: white
opacity: 1 opacity: 1
svg
opacity: 0
transition: all var(--transition-speed) var(--transition-ease-bezier)
&.btn-close &.btn-close
fill: white
font-size: 3.2rem font-size: 3.2rem
height: 20vh height: 20vh
max-height: 80px max-height: 80px

View File

@ -1,3 +1,7 @@
.dropdown-menu-filter
.dropdown-item
align-items: center
.dropdown-filter-sort .dropdown-filter-sort
@extend .box @extend .box
@ -18,7 +22,7 @@
&.is-visible &.is-visible
display: grid display: grid
grid-template-columns: repeat(3, 1fr); grid-template-columns: repeat(3, 1fr)
.dropdown-menu-filter-sort .dropdown-menu-filter-sort
max-height: calc(var(--spacer) * 24.25) max-height: calc(var(--spacer) * 24.25)

View File

@ -29,17 +29,17 @@
{{ tag.name }} {{ tag.name }}
{# TODO: @back-end add tags count dynamic #} {# TODO: @back-end add tags count dynamic #}
{% comment %} {% comment %}
<div class="align-items-center bg-secondary d-flex h-4 fs-xs justify-content-center ms-2 rounded-circle w-4"> <div class="align-items-center bg-tertiary d-flex h-4 fs-xs justify-content-center ms-2 rounded-circle w-4">
1 1
</div> </div>
{% endcomment %} {% endcomment %}
{% else %} {% else %}
All All
{# TODO: @back-end add tags count dynamic #} {# TODO: @back-end add tags count dynamic #}
{% comment %} {% comment %}
<div class="align-items-center bg-secondary d-flex h-4 fs-xs justify-content-center ms-2 rounded-circle w-4"> <div class="align-items-center bg-tertiary d-flex h-4 fs-xs justify-content-center ms-2 rounded-circle w-4">
1 1
</div> </div>
{% endcomment %} {% endcomment %}
{% endif %} {% endif %}
@ -52,7 +52,7 @@
<a class="dropdown-item {% if not tag.name %}is-active{% endif %}" href="/{{ tag.get_type_display|slugify }}s/"> <a class="dropdown-item {% if not tag.name %}is-active{% endif %}" href="/{{ tag.get_type_display|slugify }}s/">
All All
{% comment %} {% comment %}
<div class="align-items-center bg-secondary d-flex h-4 fs-xs justify-content-center ms-2 rounded-circle w-4"> <div class="align-items-center bg-tertiary d-flex h-4 fs-xs justify-content-center ms-2 rounded-circle w-4">
1 1
</div> </div>
{% endcomment %} {% endcomment %}
@ -65,9 +65,9 @@
{{ list_tag.name }} {{ list_tag.name }}
{% comment %} {% comment %}
<div class="align-items-center bg-secondary d-flex h-4 fs-xs justify-content-center ms-2 rounded-circle w-4"> <div class="align-items-center bg-tertiary d-flex h-4 fs-xs justify-content-center ms-2 rounded-circle w-4">
1 1
</div> </div>
{% endcomment %} {% endcomment %}
</a> </a>
</li> </li>

View File

@ -1,10 +1,47 @@
from django.test import TestCase from django.test import TestCase
from common.tests.factories.extensions import create_version from common.tests.factories.extensions import create_version
from files.models import File
class ApproveExtensionTest(TestCase): class ApproveExtensionTest(TestCase):
fixtures = ['licenses'] fixtures = ['licenses']
def test_approve_extension(self): # TODO def test_approve_extension(self):
create_version().extension first_version = create_version()
extension = first_version.extension
self.assertFalse(extension.is_listed)
extension.approve()
self.assertTrue(extension.is_listed)
# auto approve of new versions
new_version = create_version(extension=extension)
extension.refresh_from_db()
self.assertEqual(new_version, extension.latest_version)
self.assertTrue(new_version.is_listed)
self.assertTrue(extension.is_listed)
# TODO stop supporting direct file status updates, introduce methods for Version object
# that would replace the signals logic
# latest_version of approved extension must be listed
# check that we rollback latest_version when file is not approved
new_version.file.status = File.STATUSES.AWAITING_REVIEW
new_version.file.save()
self.assertFalse(new_version.is_listed)
extension.refresh_from_db()
self.assertEqual(first_version, extension.latest_version)
self.assertTrue(extension.is_listed)
# break the first_version, check that nothing is listed anymore
first_version.file.status = File.STATUSES.AWAITING_REVIEW
first_version.file.save()
self.assertFalse(first_version.is_listed)
extension.refresh_from_db()
self.assertFalse(extension.is_listed)
# this looks weird, but that's the current definition of latest_version, it's different
# for listed and unlisted extensions:
# now the extension is not listed, its latest_version doesn't have to be the latest
# listed version
self.assertEqual(new_version, extension.latest_version)