Skip to content

Commit 8f9f644

Browse files
authored
Merge pull request #163 from Xpirix/fix_feed_review_process
Fix feed review process
2 parents 1766476 + b2094f5 commit 8f9f644

File tree

13 files changed

+950
-230
lines changed

13 files changed

+950
-230
lines changed

qgisfeedproject/qgisfeed/forms.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
from .languages import LANGUAGES
77
from .models import CharacterLimitConfiguration, QgisFeedEntry
8+
from .utils import get_content_plain_text_length
89

910

1011
class HomePageFilterForm(forms.Form):
@@ -198,9 +199,11 @@ def clean_content(self):
198199
except CharacterLimitConfiguration.DoesNotExist:
199200
content_max_length = 500
200201

201-
if len(content) > content_max_length:
202+
content_length = get_content_plain_text_length(content)
203+
204+
if content_length > content_max_length:
202205
raise ValidationError(
203-
f"Ensure this value has at most {str(content_max_length)} characters (it has {str(len(content))})."
206+
f"Ensure this value has at most {str(content_max_length)} characters (it has {str(content_length)})."
204207
)
205208
return content
206209

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
from django.db import migrations, models
2+
3+
4+
class Migration(migrations.Migration):
5+
6+
dependencies = [
7+
("qgisfeed", "0016_qgisfeedentry_reviewers_and_more"),
8+
]
9+
10+
operations = [
11+
migrations.AddField(
12+
model_name="feedentryrevision",
13+
name="field_changes",
14+
field=models.JSONField(
15+
blank=True,
16+
default=list,
17+
help_text="Structured list of per-field old→new changes",
18+
verbose_name="Field Changes",
19+
),
20+
),
21+
]
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Generated by Django 4.2.24 on 2026-03-03 17:08
2+
3+
from django.db import migrations
4+
5+
6+
class Migration(migrations.Migration):
7+
8+
dependencies = [
9+
("qgisfeed", "0017_feedentryrevision_field_changes"),
10+
]
11+
12+
operations = [
13+
migrations.AlterModelOptions(
14+
name="feedentryreview",
15+
options={
16+
"ordering": ["created_at"],
17+
"verbose_name": "Feed Entry Review",
18+
"verbose_name_plural": "Feed Entry Reviews",
19+
},
20+
),
21+
]

qgisfeedproject/qgisfeed/models.py

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
from django.utils.translation import gettext as _
2121
from imagekit.models import ProcessedImageField
2222
from imagekit.processors import ResizeToFill
23-
from qgisfeed.utils import simplify
23+
from qgisfeed.utils import get_content_plain_text_length, simplify
2424
from user_visit.models import UserVisit
2525

2626
from .languages import LANGUAGES
@@ -349,9 +349,11 @@ def save(self, *args, **kwargs):
349349
except CharacterLimitConfiguration.DoesNotExist:
350350
content_max_length = 500
351351

352-
if len(self.content) > content_max_length:
352+
content_length = get_content_plain_text_length(self.content)
353+
354+
if content_length > content_max_length:
353355
raise ValidationError(
354-
f"Ensure content value has at most {str(content_max_length)} characters (it has {str(len(self.content))})."
356+
f"Ensure content value has at most {str(content_max_length)} characters (it has {str(content_length)})."
355357
)
356358

357359
super(QgisFeedEntry, self).save(*args, **kwargs)
@@ -422,7 +424,7 @@ class FeedEntryRevision(models.Model):
422424
get_user_model(), on_delete=models.CASCADE, verbose_name=_("Modified by")
423425
)
424426

425-
# Snapshot of changed fields
427+
# Snapshot of changed fields (kept for backward-compat / full-text auditing)
426428
title = models.CharField(_("Title"), max_length=255)
427429
content = models.TextField(_("Content"))
428430
url = models.URLField(_("URL"), max_length=200, blank=True, null=True)
@@ -436,6 +438,14 @@ class FeedEntryRevision(models.Model):
436438
help_text=_("Brief description of what changed"),
437439
)
438440

441+
# Per-field diff: list of {"label": ..., "old": ..., "new": ...}
442+
field_changes = models.JSONField(
443+
_("Field Changes"),
444+
default=list,
445+
blank=True,
446+
help_text=_("Structured list of per-field old→new changes"),
447+
)
448+
439449
class Meta:
440450
ordering = ["-changed_at"]
441451
verbose_name = _("Feed Entry Revision")

0 commit comments

Comments
 (0)