Skip to content

Stars custom fields on the enquiry form - #563

Open
tejas7777 wants to merge 12 commits into
masterfrom
feat/link-custom-field-type
Open

tejas7777 wants to merge 12 commits into
masterfrom
feat/link-custom-field-type

Conversation

@tejas7777

@tejas7777 tejas7777 commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor

What changed

Stars custom fields on the enquiry form

  • OPTIONS type decimal goes to the widget as integer, and the POST is checked with condecimal from the field's min_value/max_value/max_digits/decimal_places. It is sent on as a float.

Optional fields

  • "" for an optional field (a box typed in, then cleared) counts as not filled in. Text, and a dropdown with an empty option, still send "".

The Link field work is removed: TutorCruncher no longer has a Link type or Show as Link (tutorcruncher/TutorCruncher2#18222 now shows every web address in a Short Textbox as a link on TC2 pages and sends Socket the plain value). Enquiries are still queued for the worker (submit_enquiry) exactly as on master.

Why

A Stars field with "Enquiry Form" ticked raised KeyError: 'decimal' and broke that branch's whole enquiry form.

How it was tested

  • test_enquiries.py: Stars valid, refused and empty values; empty optional and required fields.
  • Full suite: 181 passed, 6 skipped. test_real_s3_test needs real AWS keys and fails locally the same way without this change. flake8 passes.

Deploy order

None: independent of tutorcruncher/TutorCruncher2#18222.

Demo

Local run of socket-frontend (tutorcruncher/socket-frontend#361) and socket-server (#563) with TutorCruncher: on the Socket enquiry form the Stars field refuses 7 and takes 4, a Date and Time field typed then cleared is sent as not filled in, the enquiry is accepted, and the new Client in TutorCruncher shows 4 stars. reCAPTCHA is stubbed locally. The clip is on TutorCruncher2's private pr-screenshots branch, so it shows only to people with access to that repo.

Full-quality video: https://github.com/tutorcruncher/TutorCruncher2/raw/pr-screenshots/feat_link_custom_field_type_socket/feat_link_custom_field_type_socket.webm

🤖 Generated with Claude Code

TutorCruncher2 is adding a "url" custom field type (shown as "Link").
Without this, socket rejects a tutor or lesson that has a Link value,
and loading an enquiry form with a Link field raises KeyError.

- ExtraAttributeModel.EATypeEnum accepts 'url'.
- Enquiry form: a 'url' attribute renders as an <input type="url"> and
  is validated as an http/https URL with a TLD (pydantic.HttpUrl).

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@tejas7777 tejas7777 self-assigned this Oct 15, 2026
@codecov

codecov Bot commented Oct 15, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

tejas7777 and others added 2 commits October 15, 2026 15:47
TutorCruncher2 reports a Link field as {type: url, required: False,
read_only: False, label, sort_index} with no max_length or help_text.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
TutorCruncher reports a Stars custom field as type "decimal", which the
enquiry form's type lookups didn't have, so a Stars field on the enquiry
form raised KeyError on GET and POST. Show it as a whole-number input and
check the value against the field's min, max and decimal places before
queueing, then send it to TutorCruncher as a float.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
tejas7777 and others added 2 commits October 16, 2026 04:43
…ional box

- Tutor profiles and lessons keep the link_text TutorCruncher sends for a
  Link field, so the widget can show it instead of the web address. It is
  stored only when sent, so other fields are stored as before.
- An enquiry link longer than the max_length TutorCruncher reports (2048)
  is refused with a 400. Before, it was accepted, TutorCruncher refused it
  and the enquiry was lost.
- A "" for an optional field (a box typed in then cleared) counts as not
  filled in, instead of failing the whole enquiry. Text and a dropdown
  with an empty option still send "".

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
The enquiry form sends "" for a box typed in then cleared. For an
optional field this now counts as not filled in, instead of failing the
whole enquiry with "value is not a valid decimal". Text and a dropdown
with an empty option still send "".

The same validator is in the Link PR (#563), byte for byte, so the two
merge cleanly in either order.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@tejas7777 tejas7777 changed the title Accept the Link (url) custom field type Accept the Link (url) and Stars custom field types Oct 16, 2026
pydantic's HttpUrl accepts links TutorCruncher refuses (an underscore in the host, an empty user,
999.1.1.1), and rewrites a non-ASCII host as punycode after the length check. socket answered 201,
TutorCruncher refused the enquiry and it was lost. LinkUrl uses the patterns of Django's URLValidator,
which TutorCruncher's LINK_URL_VALIDATOR is, and passes the value on unchanged.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
The enquiry form now waits for TutorCruncher's answer: a refusal comes back as a
400 with TutorCruncher's errors, a bad reCAPTCHA as a 400, and an outage as a 502,
instead of a 201 for an enquiry that was never saved.

TutorCruncher now sends a link as a Short Textbox with link_text rather than a url
type, so drop url from the profile and lesson types and keep a link out of the
tutor's tag line. The enquiry form's url field type stays.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@tejas7777 tejas7777 changed the title Accept the Link (url) and Stars custom field types Tell the client when TutorCruncher refuses an enquiry; Show as Link and Stars fields Oct 19, 2026
tejas7777 and others added 2 commits October 19, 2026 14:56
…g the deploy still reach TutorCruncher

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@tejas7777 tejas7777 changed the title Tell the client when TutorCruncher refuses an enquiry; Show as Link and Stars fields Show as Link and Stars custom fields Oct 19, 2026
tejas7777 and others added 2 commits October 19, 2026 15:49
…er does

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… in a text field as a link

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@tejas7777 tejas7777 changed the title Show as Link and Stars custom fields Stars custom fields on the enquiry form Oct 20, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants