Skip to content

Commit 7a5639b

Browse files
authored
Better handling for users entering long names (#4590)
<!-- Thanks for contributing to Hypha! Please ensure your contributions pass all necessary linting/testing and that the appropriate documentation has been updated. --> <!-- Describe briefly what your pull request changes. If this is resolving an issue, please specify below via "Fixes #<Github Issue ID>" --> Fixes #4589. This adds a global max character limit to the `full_name` field, working both in the application form and the account settings. There's a few other fixes also bundled in this: - Better handling for displaying long names in application details, submission all (table & list views), etc - In account view, the slack max input field not showing character count - Added translation to a few strings ## Test Steps <!-- If step does not require manual testing, skip/remove this section. Give a brief overview of the steps required for a user/dev to test this contribution. Important things to include: - Required user roles for where necessary (ie. "As a Staff Admin...") - Clear & validatable expected results (ie. "Confirm the submit button is now not clickable") - Language that can be understood by non-technical testers if being tested by users --> - [ ] Set `FORCE_LOGIN_FOR_APPLICATION = False` - [ ] Ensure when submitting an application and not logged in, you cannot submit a name longer than 255 chars - [ ] Ensure character count updates on typing for both name & slack fields in the account view
1 parent a7c0a18 commit 7a5639b

5 files changed

Lines changed: 18 additions & 13 deletions

File tree

hypha/apply/funds/blocks.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
from hypha.addressfield.fields import ADDRESS_FIELDS_ORDER, AddressField
88
from hypha.apply.categories.blocks import CategoryQuestionBlock
99
from hypha.apply.stream_forms.blocks import FormFieldsBlock
10+
from hypha.apply.users.models import User
1011
from hypha.apply.utils.blocks import (
1112
CustomFormFieldsBlock,
1213
MustIncludeFieldBlock,
@@ -27,7 +28,6 @@ class ApplicationMustIncludeFieldBlock(MustIncludeFieldBlock):
2728
class TitleBlock(ApplicationMustIncludeFieldBlock):
2829
name = "title"
2930
description = "The title of the project"
30-
widget = forms.TextInput()
3131
field_label = blocks.CharBlock(
3232
label=_("Label"), default=_("What is the title of your application?")
3333
)
@@ -132,6 +132,12 @@ class FullNameBlock(ApplicationMustIncludeFieldBlock):
132132
),
133133
)
134134

135+
def get_field_kwargs(self, struct_value):
136+
kwargs = super().get_field_kwargs(struct_value)
137+
# Pull the max length from the full_name db field
138+
kwargs["max_length"] = User._meta.get_field("full_name").max_length
139+
return kwargs
140+
135141
class Meta:
136142
label = _("Full name")
137143
icon = "user"

hypha/apply/funds/templates/funds/applicationsubmission_detail.html

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ <h5>{% blocktrans with stage=object.previous.stage %}Your {{ stage }} applicatio
9494
<relative-time datetime={{ object.submit_time|date:"c" }} class="font-semibold">
9595
{{ object.submit_time|date:"SHORT_DATETIME_FORMAT" }}
9696
</relative-time>
97-
{% trans "by" %} <strong class="font-semibold">{% display_submission_author %}</strong>
97+
{% trans "by" %} <strong class="max-w-md font-semibold line-clamp-2">{% display_submission_author %}</strong>
9898
</span>
9999

100100
<span class="self-center">
@@ -103,7 +103,7 @@ <h5>{% blocktrans with stage=object.previous.stage %}Your {{ stage }} applicatio
103103
{{ object.live_revision.timestamp|date:"SHORT_DATETIME_FORMAT" }}
104104
</relative-time>
105105
{% trans "by" %}
106-
<strong class="font-semibold">
106+
<strong class="max-w-md font-semibold line-clamp-2">
107107
{% display_submission_author True %}
108108
</strong>)
109109
</span>
@@ -121,7 +121,6 @@ <h5>{% blocktrans with stage=object.previous.stage %}Your {{ stage }} applicatio
121121
{% trans "Edit" %}
122122
</a>
123123
{% endif %}
124-
125124
{% can "delete_submission" object as can_delete_submission %}
126125
{% if can_delete_submission %}
127126
<a

hypha/apply/funds/templates/funds/includes/submission-list-row.html

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -72,14 +72,14 @@
7272
<div class="pt-1">
7373
<p class="m-0 text-xs">
7474
#{{ s.application_id }}
75-
submitted <relative-time datetime="{{ s.submit_time|date:"c" }}">{{ s.submit_time|date:"SHORT_DATE_FORMAT" }}</relative-time>
76-
{% if s|show_applicant_identity:request.user %}by <a
75+
{% trans "submitted" %} <relative-time datetime="{{ s.submit_time|date:"c" }}">{{ s.submit_time|date:"SHORT_DATE_FORMAT" }}</relative-time>
76+
{% if s|show_applicant_identity:request.user %}{% trans "by" %} <a
7777
href="{% url "apply:submissions:list" %}{% modify_query "only_query_string" "page" applicants=s.user.id %}"
7878
hx-get="{% url "apply:submissions:list" %}{% modify_query "only_query_string" "page" applicants=s.user.id %}"
7979
hx-target="#main"
8080
hx-push-url="true"
8181
hx-swap="outerHTML transition:true"
82-
class="link link-muted text-inherit"
82+
class="inline-flex max-w-sm link link-muted text-inherit text-inherit truncate"
8383
>{{ s.user }}</a>{% endif %} • {{ s.stage }} •
8484

8585

@@ -135,17 +135,17 @@
135135
<div
136136
data-tippy-content="Assigned to {{ s.lead }}"
137137
data-tippy-placement="left"
138-
class="flex gap-1 truncate"
138+
class="flex gap-1"
139139
>
140140
{% comment %} <span class="block mb-1 text-xs text-fg-muted">Lead: </span> {% endcomment %}
141-
{% heroicon_micro "user-circle" aria_hidden="true" size=16 class="fill-fg-muted" %}
141+
{% heroicon_micro "user-circle" aria_hidden="true" size=16 class="fill-fg-muted min-w-[16px]" %}
142142
<a
143143
hx-get="{% url "apply:submissions:list" %}{% modify_query "only_query_string" "page" leads=s.lead.id %}"
144144
href="{% url "apply:submissions:list" %}{% modify_query "only_query_string" "page" leads=s.lead.id %}"
145145
hx-target="#main"
146146
hx-push-url="true"
147147
hx-swap="outerHTML transition:true"
148-
class="link link-muted text-inherit"
148+
class="max-w-sm link link-muted text-inherit truncate"
149149
>
150150
{{ s.lead }}
151151
</a>

hypha/apply/funds/templates/funds/includes/submission-table-row.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@
7474
hx-target="#main"
7575
hx-push-url="true"
7676
hx-swap="outerHTML transition:true"
77-
class="link link-muted text-inherit"
77+
class="max-w-lg text-center link link-muted text-inherit line-clamp-2"
7878
>
7979
{{ s.user }}
8080
</a>
@@ -122,7 +122,7 @@
122122
hx-target="#main"
123123
hx-push-url="true"
124124
hx-swap="outerHTML transition:true"
125-
class="link link-muted text-inherit"
125+
class="max-w-lg text-center link link-muted text-inherit line-clamp-2"
126126
>{{ s.lead }}</a>
127127
</td>
128128
{% endif %}

hypha/apply/funds/templates/submissions/partials/submission-lead.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
hx-get="{% url 'funds:submissions:lead_update' pk=submission.pk %}"
88
hx-target="#htmx-modal"
99
>
10-
{% trans "Lead" %}: {{ submission.lead }}
10+
<div class="inline-flex max-w-lg"><span class="truncate">{% trans "Lead" %}: {{ submission.lead }}</span></div>
1111
{% heroicon_micro "pencil-square" class="inline ms-1" aria_hidden=true %}
1212
</a>
1313
{% elif request.user.is_org_faculty or not HIDE_STAFF_IDENTITY %}

0 commit comments

Comments
 (0)