udata 10.8.1.dev36652__py2.py3-none-any.whl → 10.8.1.dev36703__py2.py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of udata might be problematic. Click here for more details.

@@ -172,21 +172,38 @@ def populate_slug(instance, field):
172
172
  # Ensure uniqueness
173
173
  if field.unique:
174
174
  base_slug = slug
175
- index = 1
176
175
  qs = instance.__class__.objects
177
176
  if previous:
178
177
  qs = qs(id__ne=previous.id)
179
178
 
180
- def exists(s):
181
- return qs(**{field.db_field: s}).clear_cls_query().limit(1).count(True) > 0
179
+ def exists(slug):
180
+ return qs(**{field.db_field: slug}).clear_cls_query().limit(1).count(True) > 0
182
181
 
183
- while exists(slug):
184
- # keep space for index suffix, trim slug if needed
182
+ def get_existing_slug_suffixes(slug):
183
+ qs_suffix = qs(slug__regex=f"^{slug}-\d*$").clear_cls_query().only(field.db_field)
184
+ return [getattr(obj, field.db_field) for obj in qs_suffix]
185
+
186
+ def trim_base_slug(base_slug, index):
185
187
  slug_overflow = len("{0}-{1}".format(base_slug, index)) - field.max_length
186
188
  if slug_overflow >= 1:
187
189
  base_slug = base_slug[:-slug_overflow]
188
- slug = "{0}-{1}".format(base_slug, index)
189
- index += 1
190
+ return base_slug
191
+
192
+ if exists(base_slug):
193
+ # We'll iterate to get the first free slug suffix
194
+ index = 1
195
+ existing_slugs = None
196
+ while True:
197
+ # Keep space for index suffix, trim slug if needed
198
+ trimmed_slug = trim_base_slug(base_slug, index)
199
+ # Find all existing slugs with suffixes
200
+ if existing_slugs is None or trimmed_slug != base_slug:
201
+ base_slug = trimmed_slug
202
+ existing_slugs = set(sorted(get_existing_slug_suffixes(base_slug)))
203
+ slug = "{0}-{1}".format(base_slug, index)
204
+ if slug not in existing_slugs:
205
+ break
206
+ index += 1
190
207
 
191
208
  if is_uuid(slug):
192
209
  slug = "{0}-uuid".format(slug)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: udata
3
- Version: 10.8.1.dev36652
3
+ Version: 10.8.1.dev36703
4
4
  Summary: Open data portal
5
5
  Home-page: https://github.com/opendatateam/udata
6
6
  Author: Opendata Team
@@ -142,6 +142,7 @@ It is collectively taken care of by members of the
142
142
 
143
143
  ## Current (in progress)
144
144
 
145
+ - Fix user deletion performances issues [#3388](https://github.com/opendatateam/udata/pull/3388)
145
146
  - Add search to discussions [#3384](https://github.com/opendatateam/udata/pull/3384)
146
147
  - Separate metrics for opened discussions [#3370](https://github.com/opendatateam/udata/pull/3370)
147
148
 
@@ -385,7 +385,7 @@ udata/mongo/engine.py,sha256=KdvaQnpw6un47CHpu3q9PYWwTtovVmsKZK_k1DmN48M,2552
385
385
  udata/mongo/errors.py,sha256=SpTMAc_aNIfGkqyXGCbTlIAmYxU86rGM_NtIYaB642c,472
386
386
  udata/mongo/extras_fields.py,sha256=FfyVvRkpLn4pUeCqwI33NBJblHOywGlnA05RCEZ-ugs,4139
387
387
  udata/mongo/queryset.py,sha256=yIECtsmdDAk_KqbLm0pFzWdon_1ybODfjRdThBdbjac,3939
388
- udata/mongo/slug_fields.py,sha256=zif1aRHajBfP0BitYq8KivcSJKa14KViz97mNrH3iVE,6665
388
+ udata/mongo/slug_fields.py,sha256=XdfjLyjnsVse3p64k10Zcp_iMUH5AwYlCNzbDQaa-FA,7496
389
389
  udata/mongo/taglist_field.py,sha256=RPi8DlgMEMK1wk8hbQDLAyH2GnzZCfNpWXQsllxPB6g,1371
390
390
  udata/mongo/url_field.py,sha256=UmUr9c5SxDFDpS5QsRTq2pKcCTOr1SoB4UITwNjtuaI,1345
391
391
  udata/mongo/uuid_fields.py,sha256=tuQ3zs_BnQHjaiKSIYv43jxvYtOvRLw9nP5CQ3fcMks,482
@@ -740,9 +740,9 @@ udata/translations/pt/LC_MESSAGES/udata.mo,sha256=9sCd1MUKvtVP_sOXvK-G5v4PfWkkdA
740
740
  udata/translations/pt/LC_MESSAGES/udata.po,sha256=-eJptz9s63rjkdm-3HJi_2t70pyv3-8EuXBn-B2qI_4,48419
741
741
  udata/translations/sr/LC_MESSAGES/udata.mo,sha256=qduXntHWe__KaUxJ4JwwyGG3eSgYb1auGdNax0lS49c,29169
742
742
  udata/translations/sr/LC_MESSAGES/udata.po,sha256=6QCuLMCRjgyAvu9U7i0P19ae8fm_uStfmxHLqUO9EoY,55394
743
- udata-10.8.1.dev36652.dist-info/LICENSE,sha256=V8j_M8nAz8PvAOZQocyRDX7keai8UJ9skgmnwqETmdY,34520
744
- udata-10.8.1.dev36652.dist-info/METADATA,sha256=P3IbXyLUIdt0AdS0kOAfPNTF4-FkICc9VjzclbGeHqs,151981
745
- udata-10.8.1.dev36652.dist-info/WHEEL,sha256=Kh9pAotZVRFj97E15yTA4iADqXdQfIVTHcNaZTjxeGM,110
746
- udata-10.8.1.dev36652.dist-info/entry_points.txt,sha256=ETvkR4r6G1duBsh_V_fGWENQy17GTFuobi95MYBAl1A,498
747
- udata-10.8.1.dev36652.dist-info/top_level.txt,sha256=39OCg-VWFWOq4gCKnjKNu-s3OwFlZIu_dVH8Gl6ndHw,12
748
- udata-10.8.1.dev36652.dist-info/RECORD,,
743
+ udata-10.8.1.dev36703.dist-info/LICENSE,sha256=V8j_M8nAz8PvAOZQocyRDX7keai8UJ9skgmnwqETmdY,34520
744
+ udata-10.8.1.dev36703.dist-info/METADATA,sha256=xqzLUlzajkcp361rwUbD_SDIJaLheSWjc1fFU61vvm4,152078
745
+ udata-10.8.1.dev36703.dist-info/WHEEL,sha256=Kh9pAotZVRFj97E15yTA4iADqXdQfIVTHcNaZTjxeGM,110
746
+ udata-10.8.1.dev36703.dist-info/entry_points.txt,sha256=ETvkR4r6G1duBsh_V_fGWENQy17GTFuobi95MYBAl1A,498
747
+ udata-10.8.1.dev36703.dist-info/top_level.txt,sha256=39OCg-VWFWOq4gCKnjKNu-s3OwFlZIu_dVH8Gl6ndHw,12
748
+ udata-10.8.1.dev36703.dist-info/RECORD,,