Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix typography for submission diff #3673

Merged
merged 2 commits into from
Dec 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 11 additions & 15 deletions hypha/apply/funds/differ.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,25 +6,21 @@
from django.utils.safestring import mark_safe


def wrap_with_span(text, class_name):
def wrap_deleted(text):
return format_html(
'<span class="diff diff__{}">{}</span>', class_name, mark_safe(text)
'<span class="bg-red-200 line-through">{}</span>', mark_safe(text)
)


def wrap_deleted(text):
return wrap_with_span(text, "deleted")


def wrap_added(text):
return wrap_with_span(text, "added")
return format_html('<span class="bg-green-200">{}</span>', mark_safe(text))


def compare(answer_a, answer_b, should_bleach=True):
if should_bleach:
cleaner = Cleaner(tags=["h4"], attributes={}, strip=True)
answer_a = re.sub("(<li[^>]*>)", r"\1 ", answer_a)
answer_b = re.sub("(<li[^>]*>)", r"\1 ", answer_b)
answer_a = re.sub("(<li[^>]*>)", r"\1 ", answer_a)
answer_b = re.sub("(<li[^>]*>)", r"\1 ", answer_b)
answer_a = cleaner.clean(answer_a)
answer_b = cleaner.clean(answer_b)

Expand All @@ -37,20 +33,20 @@ def compare(answer_a, answer_b, should_bleach=True):
to_diff.append(mark_safe(diff.b[b0:b1]))
elif opcode == "insert":
from_diff.append(mark_safe(diff.a[a0:a1]))
to_diff.append(wrap_with_span(diff.b[b0:b1], "added"))
to_diff.append(wrap_added(diff.b[b0:b1]))
elif opcode == "delete":
from_diff.append(wrap_with_span(diff.a[a0:a1], "deleted"))
from_diff.append(wrap_deleted(diff.a[a0:a1]))
to_diff.append(mark_safe(diff.b[b0:b1]))
elif opcode == "replace":
from_diff.append(wrap_with_span(diff.a[a0:a1], "deleted"))
to_diff.append(wrap_with_span(diff.b[b0:b1], "added"))
from_diff.append(wrap_deleted(diff.a[a0:a1]))
to_diff.append(wrap_added(diff.b[b0:b1]))

from_display = "".join(from_diff)
to_display = "".join(to_diff)
from_display = re.sub(r"([●○]|[0-9]{1,2}[\)\.])", r"<br>\1", from_display)
to_display = re.sub(r"([●○]|[0-9]{1,2}[\)\.])", r"<br>\1", to_display)
from_display = re.sub("(\\.\n)", r"\1<br><br>", from_display)
to_display = re.sub("(\\.\n)", r"\1<br><br>", to_display)
from_display = re.sub(r"([◦])", r"<br>\1", from_display)
to_display = re.sub(r"([◦])", r"<br>\1", to_display)
from_display = mark_safe(from_display)
to_display = mark_safe(to_display)

Expand Down

This file was deleted.

38 changes: 35 additions & 3 deletions hypha/apply/funds/templates/funds/revisions_compare.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,39 @@

{% endadminbar %}

<div class="wrapper wrapper--large wrapper--tabs">
{% include "funds/includes/revision_diff_table.html" %}
</div>
<table class="revision-diff-table prose prose-h4:mt-0 max-w-none mb-8">
<tr>
<td>
<h3>{% trans "Proposal Information (Old)" %}</h3>
<p>{% trans "Submitted" %}: <strong>{{ timestamps.0|date:"DATETIME_FORMAT"}}</strong></p>
</td>
<td>
<h3>{% trans "Proposal Information (New)" %}</h3>
<p>{% trans "Submitted" %}: <strong>{{ timestamps.1|date:"DATETIME_FORMAT"}}</strong></p>
</td>
</tr>

{% for from_field, to_field in required_fields %}
{% if forloop.first %}
<tr><td><h4>{% trans "Title" %}</h4>{{ from_field }}</td><td><h4>{% trans "Title" %}</h4>{{ to_field }}</td></tr>
{% elif forloop.counter == 2 %}
<tr><td><h4>{% trans "Legal Name" %}</h4>{{ from_field }}</td><td><h4>{% trans "Legal Name" %}</h4>{{ to_field }}</td></tr>
{% elif forloop.counter == 3 %}
<tr><td><h4>{% trans "E-mail" %}</h4>{{ from_field }}</td><td><h4>{% trans "E-mail" %}</h4>{{ to_field }}</td></tr>
{% elif forloop.counter == 4 %}
<tr><td><h4>{% trans "Address" %}</h4>{{ from_field }}</td><td><h4>{% trans "Address" %}</h4>{{ to_field }}</td></tr>
{% elif forloop.counter == 5 %}
<tr><td><h4>{% trans "Project Duration" %}</h4>{{ from_field }}</td><td><h4>{% trans "Project Duration" %}</h4>{{ to_field }}</td></tr>
{% elif forloop.counter == 6 %}
<tr><td><h4>{% trans "Requested Funding" %}</h4>{{ from_field }}</td><td><h4>{% trans "Requested Funding" %}</h4>{{ to_field }}</td></tr>

{% else %}
<tr><td>{{ from_field }}</td><td>{{ to_field }}</td></tr>
{% endif %}
{% endfor %}
{% for from_field, to_field in stream_fields %}
<tr><td>{{ from_field }}</td><td>{{ to_field }}</td></tr>
{% endfor %}
</table>

{% endblock %}