IFRCGo / go-web-app

GO Web application! GO is a Red Cross Red Crescent platform to connect information on emergency needs with the right response.
https://go.ifrc.org
MIT License
8 stars 1 forks source link

Featured Document sections shows HTML code #1279

Open toffehoff opened 3 months ago

toffehoff commented 3 months ago

Issue

An operation can have "Featured Documents". In the short explanation section under the document title, the Paragraph HTML codes are shown (which are not shown in the edit section in the backend).

Steps to reproduce

Go to the Ukraine Operation Reports page (https://go.ifrc.org/emergencies/5854/reports). There you see this:

image

Expected behaviour

The <p> and </p> html codes should not be shown

Related feature

Maybe linked to issues related to a rich-text editor in the back-end.

Impact

This is visible for everyone.

Severity

Minor, since it is a cosmetic issue.

Is there a workaround?

Not tested.

samshara commented 3 months ago

@toffehoff, it looks like the description field still contains<p> tags because they were not stripped out during backend ingestion. We can address this.

szabozoltan69 commented 3 months ago

Deployed to Staging and (as a hotfix) to Prod.

szabozoltan69 commented 3 months ago

Let's search for a nicer solution, prohibiting TextField usage for TinyMCE.

szabozoltan69 commented 3 months ago

A suggested one: Let's update the tinyMCE default config to use "selector": "textarea.rich-textarea", And do

        widgets = {
            "description": forms.Textarea(attrs={"class": "rich-textarea"}),
        }

(Or model-wise if possible, let's link it to HTMLFields by default.)

szabozoltan69 commented 3 months ago

There are 11 places to insert this:

grep HTMLF $(find . -name "models.py" 2>/dev/null)|grep -v import

./deployments/models.py:    description = HTMLField(verbose_name=_("description"), blank=True, default="")
./per/models.py:    description = HTMLField(verbose_name=_("description"), null=True, blank=True)
./flash_update/models.py:    situational_overview = HTMLField(verbose_name=_("Situational Overview"), blank=True, default="")
./api/models.py:    snippet = HTMLField(verbose_name=_("snippet"), null=True, blank=True)
./api/models.py:    snippet = HTMLField(verbose_name=_("snippet"), null=True, blank=True)
./api/models.py:    snippet = HTMLField(verbose_name=_("snippet"), null=True, blank=True)
./api/models.py:    snippet = HTMLField(verbose_name=_("snippet"), null=True, blank=True)
./api/models.py:    snippet = HTMLField(verbose_name=_("snippet"), null=True, blank=True)
./api/models.py:    summary = HTMLField(verbose_name=_("summary"), blank=True, default="")
./api/models.py:    snippet = HTMLField(verbose_name=_("snippet"), null=True, blank=True)
./api/models.py:    description = HTMLField(verbose_name=_("description"), blank=True, default="")
nanometrenat commented 2 months ago

Deployed to Staging and (as a hotfix) to Prod.

Is the hotfix only for "featured documents"? is it possible to roll it out to "links" as well? I can see that "links" section of the Mpox GO page has the html markings: image https://go.ifrc.org/emergencies/7118/details

szabozoltan69 commented 2 months ago

Oh, true. Let me check that "links" section.

szabozoltan69 commented 2 months ago

@nanometrenat fixed the field on admin (Staging and Prod), also the erroneous texts in database. :-)