Skip to content

Conversation

@fsellaouti
Copy link
Contributor

@fsellaouti fsellaouti commented Mar 15, 2025

close #333

@fallen fallen self-requested a review March 16, 2025 14:53
@fallen
Copy link
Member

fallen commented Mar 16, 2025

Hello @fsellaouti
Something bothers me with this new feature.
It unconditionally adds a new field to petitions (the field can be optionally filled, ok).
Maybe some other users of Pytition don't want this field, maybe they want it (like you).

I would like to make it possible to add/remove fields, for real, from the petition forms, by-petition, configurable in the web UI in the "edit petition" UI.

This would allow you to add your zip code field but would let others keep their form "small".

I honestly don't know if it's easy to do what I'm describing ... I would bet it's not easy because usually forms in Django are described by a class and backed by an sql "table" so it would not be that easy to modify those 1/ on-the-fly and 2/ by-petition.

What do you think?

@fsellaouti
Copy link
Contributor Author

Hello @fsellaouti Something bothers me with this new feature. It unconditionally adds a new field to petitions (the field can be optionally filled, ok). Maybe some other users of Pytition don't want this field, maybe they want it (like you).

I would like to make it possible to add/remove fields, for real, from the petition forms, by-petition, configurable in the web UI in the "edit petition" UI.

This would allow you to add your zip code field but would let others keep their form "small".

I honestly don't know if it's easy to do what I'm describing ... I would bet it's not easy because usually forms in Django are described by a class and backed by an sql "table" so it would not be that easy to modify those 1/ on-the-fly and 2/ by-petition.

What do you think?

Hello @fallen ,
I agree with your response.
What we can do is adding a "Fields" tab in the petition editing interface where users can choose fields to show and whether they are required or not. For now it would be only the phone number field and maybe later the zip code and even a comment for example.
But those fields would be still associated each to a column.
Otherwise, to make it dynamic you might want to add a JSON typed column but this solution might create other technical and functional problems.

@fallen
Copy link
Member

fallen commented Oct 25, 2025

For the sake of documenting this discussion, indeed I've read somewhere that a JSONField https://docs.djangoproject.com/fr/5.2/ref/models/fields/#jsonfield could be used to simulate a "dynamic" class.
Why not... it's a bit of work but it deserves a test in a branch to see how it would work :)

We would need to add a JSONField to both the Petition and the Signature Models.

  • The JSONField of the Petition would at least contain the list of field name + field type (+ default value ?) + optionally a Form widget type when using the default one related to the Field Type is necessary.
    • Then the petition display view should be modified to display the correct signature Form with the mandatory fields + the optional ones from the JSONField
  • The JSONField of the Signature model would contain the field names and values

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add zip code field to signature

2 participants