Skip to content

Commit 618daf2

Browse files
committed
Add character limitations for all open question fields
1 parent 592de08 commit 618daf2

File tree

3 files changed

+33
-1
lines changed

3 files changed

+33
-1
lines changed

backend/api/grants/mutations.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,11 @@ def validate(self, conference: Conference, user: User) -> GrantErrors:
6969
"departure_country": 100,
7070
"nationality": 100,
7171
"departure_city": 100,
72+
"why": 1000,
73+
"python_usage": 700,
74+
"been_to_other_events": 500,
75+
"community_contribution": 900,
76+
"notes": 350,
7277
}
7378
for field, max_length in max_length_fields.items():
7479
value = getattr(self, field, "")

backend/api/grants/tests/test_send_grant.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,11 @@ def test_cannot_send_grant_outside_allowed_values(
243243
departureCountry="Very long location" * 50,
244244
nationality="Freedonia" * 50,
245245
departureCity="Emerald City " * 50,
246+
why="Very long why" * 100,
247+
pythonUsage="Very long python usage" * 100,
248+
beenToOtherEvents="Very long been to other events" * 100,
249+
communityContribution="Very long community contribution" * 100,
250+
notes="Very long notes" * 100,
246251
)
247252

248253
assert response["data"]["sendGrant"]["__typename"] == "GrantErrors"
@@ -258,6 +263,21 @@ def test_cannot_send_grant_outside_allowed_values(
258263
assert response["data"]["sendGrant"]["errors"]["validationDepartureCity"] == [
259264
"departure_city: Cannot be more than 100 chars"
260265
]
266+
assert response["data"]["sendGrant"]["errors"]["validationWhy"] == [
267+
"why: Cannot be more than 1000 chars"
268+
]
269+
assert response["data"]["sendGrant"]["errors"]["validationPythonUsage"] == [
270+
"python_usage: Cannot be more than 700 chars"
271+
]
272+
assert response["data"]["sendGrant"]["errors"]["validationBeenToOtherEvents"] == [
273+
"been_to_other_events: Cannot be more than 500 chars"
274+
]
275+
assert response["data"]["sendGrant"]["errors"][
276+
"validationCommunityContribution"
277+
] == ["community_contribution: Cannot be more than 900 chars"]
278+
assert response["data"]["sendGrant"]["errors"]["validationNotes"] == [
279+
"notes: Cannot be more than 350 chars"
280+
]
261281

262282

263283
def test_cannot_send_grant_with_empty_values(

frontend/src/components/grant-form/index.tsx

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -544,6 +544,7 @@ export const GrantForm = ({
544544
required={true}
545545
placeholder={inputPlaceholderText}
546546
errors={getErrors("why")}
547+
maxLength={1000}
547548
/>
548549
</InputWrapper>
549550
</Grid>
@@ -658,6 +659,7 @@ export const GrantForm = ({
658659
required={true}
659660
placeholder={inputPlaceholderText}
660661
errors={getErrors("pythonUsage")}
662+
maxLength={700}
661663
/>
662664
</InputWrapper>
663665

@@ -676,6 +678,7 @@ export const GrantForm = ({
676678
required={true}
677679
errors={getErrors("beenToOtherEvents")}
678680
placeholder={inputPlaceholderText}
681+
maxLength={500}
679682
/>
680683
</InputWrapper>
681684

@@ -694,6 +697,7 @@ export const GrantForm = ({
694697
required={false}
695698
errors={getErrors("communityContribution")}
696699
placeholder={inputPlaceholderText}
700+
maxLength={900}
697701
/>
698702
</InputWrapper>
699703
</Grid>
@@ -739,6 +743,7 @@ export const GrantForm = ({
739743
{...textarea("notes")}
740744
errors={getErrors("notes")}
741745
placeholder={inputPlaceholderText}
746+
maxLength={350}
742747
/>
743748
</InputWrapper>
744749
</Grid>
@@ -753,7 +758,9 @@ export const GrantForm = ({
753758
photoRequired={false}
754759
getParticipantValidationError={(field) =>
755760
getErrors(
756-
`validationSpeaker${field[0].toUpperCase()}${field.substring(1)}` as any,
761+
`validationSpeaker${field[0].toUpperCase()}${field.substring(
762+
1,
763+
)}` as any,
757764
)
758765
}
759766
showPhotoField={false}

0 commit comments

Comments
 (0)