We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Adjust the Server to the Changes in Gender Options
The server needs to be changed slightly in order to work with the new client after implementing [feature no 8842](https://github.com/fossasia/open-event-frontend/issues/8842) in the frontend.

--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `app/models/custom_form.py`
Content:
```
1 import json
2 
3 from sqlalchemy.event import listens_for
4 from sqlalchemy.schema import UniqueConstraint
5 
6 from app.api.helpers.utilities import to_snake_case
7 from app.models import db
8 
9 SESSION_FORM = {
10     "title": {"include": 1, "require": 1},
11     "subtitle": {"include": 0, "require": 0},
12     "short_abstract": {"include": 1, "require": 0},
13     "long_abstract": {"include": 0, "require": 0},
14     "comments": {"include": 1, "require": 0},
15     "track": {"include": 0, "require": 0},
16     "session_type": {"include": 0, "require": 0},
17     "language": {"include": 0, "require": 0},
18     "slides": {"include": 1, "require": 0},
19     "video": {"include": 0, "require": 0},
20     "audio": {"include": 0, "require": 0},
21 }
22 
23 SESSION_CUSTOM_FORM = {
24     "title": "Title",
25     "subtitle": "Subtitle",
26     "shortAbstract": "Short Abstract",
27     "longAbstract": "Long Abstract",
28     "comments": "Comment",
29     "track": "Track",
30     "sessionType": "Session Type",
31     "level": "Level",
32     "language": "Language",
33     "slidesUrl": "Slide",
34     "slides": "Slides",
35     "videoUrl": "Video",
36     "audioUrl": "Audio",
37     "website": "Website",
38     "facebook": "Facebook",
39     "twitter": "Twitter",
40     "github": "GitHub",
41     "linkedin": "Linkedin",
42     "instagram": "Instagram",
43     "gitlab": "Gitlab",
44     "mastodon": "Mastodon",
45 }
46 
47 SPEAKER_FORM = {
48     "name": {"include": 1, "require": 1},
49     "email": {"include": 1, "require": 1},
50     "photo": {"include": 1, "require": 0},
51     "organisation": {"include": 1, "require": 0},
52     "position": {"include": 1, "require": 0},
53     "country": {"include": 1, "require": 0},
54     "short_biography": {"include": 1, "require": 0},
55     "long_biography": {"include": 0, "require": 0},
56     "mobile": {"include": 0, "require": 0},
57     "website": {"include": 1, "require": 0},
58     "facebook": {"include": 0, "require": 0},
59     "twitter": {"include": 1, "require": 0},
60     "github": {"include": 0, "require": 0},
61     "linkedin": {"include": 0, "require": 0},
62 }
63 
64 SPEAKER_CUSTOM_FORM = {
65     "name": "Name",
66     "email": "Email",
67     "photoUrl": "Photo",
68     "organisation": "Organisation",
69     "position": "Position",
70     "address": "Address",
71     "country": "Country",
72     "city": "City",
73     "longBiography": "Long Biography",
74     "shortBiography": "Short Biography",
75     "speakingExperience": "Speaking Experience",
76     "sponsorshipRequired": "Sponsorship Required",
77     "gender": "Gender",
78     "heardFrom": "Heard From",
79     "mobile": "Mobile",
80     "website": "Website",
81     "facebook": "Facebook",
82     "twitter": "Twitter",
83     "github": "GitHub",
84     "linkedin": "Linkedin",
85     "instagram": "Instagram",
86     "mastodon": "Mastodon",
87 }
88 
89 ATTENDEE_FORM = {
90     "firstname": {"include": 1, "require": 1},
91     "lastname": {"include": 1, "require": 1},
92     "email": {"include": 1, "require": 1},
93     "address": {"include": 1, "require": 0},
94     "city": {"include": 1, "require": 0},
95     "state": {"include": 1, "require": 0},
96     "country": {"include": 1, "require": 0},
97     "job_title": {"include": 1, "require": 0},
98     "phone": {"include": 1, "require": 0},
99     "tax_business_info": {"include": 1, "require": 0},
100     "billing_address": {"include": 0, "require": 0},
101     "home_address": {"include": 0, "require": 0},
102     "shipping_address": {"include": 0, "require": 0},
103     "company": {"include": 1, "require": 0},
104     "work_address": {"include": 0, "require": 0},
105     "work_phone": {"include": 0, "require": 0},
106     "website": {"include": 1, "require": 0},
107     "blog": {"include": 0, "require": 0},
108     "twitter": {"include": 1, "require": 0},
109     "facebook": {"include": 0, "require": 0},
110     "github": {"include": 1, "require": 0},
111     "gender": {"include": 0, "require": 0},
112     "age_group": {"include": 0, "require": 0},
113     "home_wiki": {"include": 0, "require": 0},
114     "wiki_scholarship": {"include": 0, "require": 0},
115     "accept_video_recording": {"include": 0, "require": 0},
116     "is_consent_of_refund_policy": {"include": 0, "require": 0},
117     "language_form_1": {"include": 0, "require": 0},
118     "language_form_2": {"include": 0, "require": 0},
119     "is_consent_form_field": {"include": 0, "require": 0},
120     "is_consent_form_field_photo": {"include": 0, "require": 0},
121     "is_consent_form_field_email": {"include": 0, "require": 0},
122 }
123 
124 ATTENDEE_CUSTOM_FORM = {
125     "firstname": "First Name",
126     "lastname": "Last Name",
127     "email": "Email",
128     "address": "Address",
129     "city": "City",
130     "state": "State",
131     "country": "Country",
132     "jobTitle": "Job Title",
133     "phone": "Phone",
134     "taxBusinessInfo": "Tax Business Info",
135     "billingAddress": "Billing Address",
136     "homeAddress": "Home Address",
137     "shippingAddress": "Shipping Address",
138     "company": "Organisation",
139     "workAddress": "Work Address",
140     "workPhone": "Work Phone",
141     "website": "Website",
142     "blog": "Blog",
143     "twitter": "Twitter",
144     "facebook": "Facebook",
145     "github": "GitHub",
146     "linkedin": "LinkedIn",
147     "instagram": "Instagram",
148     "gender": "Gender",
149     "ageGroup": "Age Group",
150     "acceptVideoRecording": "Photo & video & text consent",
151     "acceptShareDetails": "Partner contact consent",
152     "acceptReceiveEmails": "Email consent",
153     "is_consent_form_field": "Consent form field",
154     "is_consent_form_field_photo": "Wikimania photo consent",
155     "is_consent_form_field_email": "Wikimania email updates",
156     "is_consent_of_refund_policy": "Consent of refund policy",
157     "language_form_1": "What is your native language, or what language are you most fluent in?",
158     "language_form_2": "Are you fluent in any other of the following languages?",
159     "home_wiki": "What is your home wiki",
160     "wiki_scholarship": "Have you received a Wikimania scholarship?",
161 }
162 
163 
164 session_form_str = json.dumps(SESSION_FORM, separators=(',', ':'))
165 speaker_form_str = json.dumps(SPEAKER_FORM, separators=(',', ':'))
166 attendee_form_str = json.dumps(ATTENDEE_FORM, separators=(',', ':'))
167 
168 
169 CUSTOM_FORM_IDENTIFIER_NAME_MAP = {
170     "session": SESSION_CUSTOM_FORM,
171     "speaker": SPEAKER_CUSTOM_FORM,
172     "attendee": ATTENDEE_CUSTOM_FORM,
173 }
174 
175 
176 class CustomForms(db.Model):
177     """custom form model class"""
178 
179     class TYPE:
180         ATTENDEE = 'attendee'
181         SESSION = 'session'
182         SPEAKER = 'speaker'
183 
184     __tablename__ = 'custom_forms'
185     __table_args__ = (
186         UniqueConstraint(
187             'event_id',
188             'field_identifier',
189             'form',
190             'form_id',
191             name='custom_form_identifier',
192         ),
193     )
194     id = db.Column(db.Integer, primary_key=True)
195     field_identifier = db.Column(db.String, nullable=False)
196     form = db.Column(db.String, nullable=False)
197     type = db.Column(db.String, nullable=False)
198     name = db.Column(db.String, nullable=False)
199     description = db.Column(db.String, nullable=True)
200     is_required = db.Column(db.Boolean, default=False)
201     is_included = db.Column(db.Boolean, default=False)
202     is_fixed = db.Column(db.Boolean, default=False)
203     position = db.Column(db.Integer, default=0, nullable=False)
204     is_public = db.Column(db.Boolean, nullable=False, default=False)
205     is_complex = db.Column(db.Boolean, nullable=False, default=False)
206     event_id = db.Column(db.Integer, db.ForeignKey('events.id', ondelete='CASCADE'))
207     custom_form_options = db.relationship('CustomFormOptions', backref="custom_form")
208     form_id = db.Column(db.String)
209     min = db.Column(db.Integer, default=0, nullable=True)
210     max = db.Column(db.Integer, default=10, nullable=True)
211     main_language = db.Column(db.String)
212 
213     @property
214     def identifier(self):
215         return to_snake_case(self.field_identifier)
216 
217     def __repr__(self):
218         return f'<CustomForm {self.id!r} {self.identifier!r}>'
219 
220 
221 def get_set_field_name(target: CustomForms) -> str:
222     form_map = CUSTOM_FORM_IDENTIFIER_NAME_MAP[target.form]
223     target_name = form_map.get(target.field_identifier)
224     if target_name:
225         target.name = target_name
226 
227     return target.name
228 
229 
230 @listens_for(CustomForms, 'before_insert')
231 @listens_for(CustomForms, 'before_update')
232 def generate_name(mapper, connect, target: CustomForms) -> None:
233     get_set_field_name(target)
234 
235 
236 def assign_field_names(session) -> None:
237     "Used to migrate existing form fields in DB. Don't modify"
238     statements = []
239 
240     for form, dict_map in CUSTOM_FORM_IDENTIFIER_NAME_MAP.items():
241         for identifier, name in dict_map.items():
242             statements.append(
243                 f"UPDATE custom_forms SET name = '{name}' WHERE form = '{form}' and field_identifier = '{identifier}';"
244             )
245 
246     for statement in statements:
247         session.execute(statement)
248
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/app/models/custom_form.py b/app/models/custom_form.py
--- a/app/models/custom_form.py
+++ b/app/models/custom_form.py
@@ -145,7 +145,7 @@
     "github": "GitHub",
     "linkedin": "LinkedIn",
     "instagram": "Instagram",
-    "gender": "Gender",
+    "gender": "Which of these categories describe your gender identity? (check all that apply)",
     "ageGroup": "Age Group",
     "acceptVideoRecording": "Photo & video & text consent",
     "acceptShareDetails": "Partner contact consent",

{"golden_diff": "diff --git a/app/models/custom_form.py b/app/models/custom_form.py\n--- a/app/models/custom_form.py\n+++ b/app/models/custom_form.py\n@@ -145,7 +145,7 @@\n     \"github\": \"GitHub\",\n     \"linkedin\": \"LinkedIn\",\n     \"instagram\": \"Instagram\",\n-    \"gender\": \"Gender\",\n+    \"gender\": \"Which of these categories describe your gender identity? (check all that apply)\",\n     \"ageGroup\": \"Age Group\",\n     \"acceptVideoRecording\": \"Photo & video & text consent\",\n     \"acceptShareDetails\": \"Partner contact consent\",\n", "issue": "Adjust the Server to the Changes in Gender Options\nThe server needs to be changed slightly in order to work with the new client after implementing [feature no 8842](https://github.com/fossasia/open-event-frontend/issues/8842) in the frontend.\n", "before_files": [{"content": "import json\n\nfrom sqlalchemy.event import listens_for\nfrom sqlalchemy.schema import UniqueConstraint\n\nfrom app.api.helpers.utilities import to_snake_case\nfrom app.models import db\n\nSESSION_FORM = {\n    \"title\": {\"include\": 1, \"require\": 1},\n    \"subtitle\": {\"include\": 0, \"require\": 0},\n    \"short_abstract\": {\"include\": 1, \"require\": 0},\n    \"long_abstract\": {\"include\": 0, \"require\": 0},\n    \"comments\": {\"include\": 1, \"require\": 0},\n    \"track\": {\"include\": 0, \"require\": 0},\n    \"session_type\": {\"include\": 0, \"require\": 0},\n    \"language\": {\"include\": 0, \"require\": 0},\n    \"slides\": {\"include\": 1, \"require\": 0},\n    \"video\": {\"include\": 0, \"require\": 0},\n    \"audio\": {\"include\": 0, \"require\": 0},\n}\n\nSESSION_CUSTOM_FORM = {\n    \"title\": \"Title\",\n    \"subtitle\": \"Subtitle\",\n    \"shortAbstract\": \"Short Abstract\",\n    \"longAbstract\": \"Long Abstract\",\n    \"comments\": \"Comment\",\n    \"track\": \"Track\",\n    \"sessionType\": \"Session Type\",\n    \"level\": \"Level\",\n    \"language\": \"Language\",\n    \"slidesUrl\": \"Slide\",\n    \"slides\": \"Slides\",\n    \"videoUrl\": \"Video\",\n    \"audioUrl\": \"Audio\",\n    \"website\": \"Website\",\n    \"facebook\": \"Facebook\",\n    \"twitter\": \"Twitter\",\n    \"github\": \"GitHub\",\n    \"linkedin\": \"Linkedin\",\n    \"instagram\": \"Instagram\",\n    \"gitlab\": \"Gitlab\",\n    \"mastodon\": \"Mastodon\",\n}\n\nSPEAKER_FORM = {\n    \"name\": {\"include\": 1, \"require\": 1},\n    \"email\": {\"include\": 1, \"require\": 1},\n    \"photo\": {\"include\": 1, \"require\": 0},\n    \"organisation\": {\"include\": 1, \"require\": 0},\n    \"position\": {\"include\": 1, \"require\": 0},\n    \"country\": {\"include\": 1, \"require\": 0},\n    \"short_biography\": {\"include\": 1, \"require\": 0},\n    \"long_biography\": {\"include\": 0, \"require\": 0},\n    \"mobile\": {\"include\": 0, \"require\": 0},\n    \"website\": {\"include\": 1, \"require\": 0},\n    \"facebook\": {\"include\": 0, \"require\": 0},\n    \"twitter\": {\"include\": 1, \"require\": 0},\n    \"github\": {\"include\": 0, \"require\": 0},\n    \"linkedin\": {\"include\": 0, \"require\": 0},\n}\n\nSPEAKER_CUSTOM_FORM = {\n    \"name\": \"Name\",\n    \"email\": \"Email\",\n    \"photoUrl\": \"Photo\",\n    \"organisation\": \"Organisation\",\n    \"position\": \"Position\",\n    \"address\": \"Address\",\n    \"country\": \"Country\",\n    \"city\": \"City\",\n    \"longBiography\": \"Long Biography\",\n    \"shortBiography\": \"Short Biography\",\n    \"speakingExperience\": \"Speaking Experience\",\n    \"sponsorshipRequired\": \"Sponsorship Required\",\n    \"gender\": \"Gender\",\n    \"heardFrom\": \"Heard From\",\n    \"mobile\": \"Mobile\",\n    \"website\": \"Website\",\n    \"facebook\": \"Facebook\",\n    \"twitter\": \"Twitter\",\n    \"github\": \"GitHub\",\n    \"linkedin\": \"Linkedin\",\n    \"instagram\": \"Instagram\",\n    \"mastodon\": \"Mastodon\",\n}\n\nATTENDEE_FORM = {\n    \"firstname\": {\"include\": 1, \"require\": 1},\n    \"lastname\": {\"include\": 1, \"require\": 1},\n    \"email\": {\"include\": 1, \"require\": 1},\n    \"address\": {\"include\": 1, \"require\": 0},\n    \"city\": {\"include\": 1, \"require\": 0},\n    \"state\": {\"include\": 1, \"require\": 0},\n    \"country\": {\"include\": 1, \"require\": 0},\n    \"job_title\": {\"include\": 1, \"require\": 0},\n    \"phone\": {\"include\": 1, \"require\": 0},\n    \"tax_business_info\": {\"include\": 1, \"require\": 0},\n    \"billing_address\": {\"include\": 0, \"require\": 0},\n    \"home_address\": {\"include\": 0, \"require\": 0},\n    \"shipping_address\": {\"include\": 0, \"require\": 0},\n    \"company\": {\"include\": 1, \"require\": 0},\n    \"work_address\": {\"include\": 0, \"require\": 0},\n    \"work_phone\": {\"include\": 0, \"require\": 0},\n    \"website\": {\"include\": 1, \"require\": 0},\n    \"blog\": {\"include\": 0, \"require\": 0},\n    \"twitter\": {\"include\": 1, \"require\": 0},\n    \"facebook\": {\"include\": 0, \"require\": 0},\n    \"github\": {\"include\": 1, \"require\": 0},\n    \"gender\": {\"include\": 0, \"require\": 0},\n    \"age_group\": {\"include\": 0, \"require\": 0},\n    \"home_wiki\": {\"include\": 0, \"require\": 0},\n    \"wiki_scholarship\": {\"include\": 0, \"require\": 0},\n    \"accept_video_recording\": {\"include\": 0, \"require\": 0},\n    \"is_consent_of_refund_policy\": {\"include\": 0, \"require\": 0},\n    \"language_form_1\": {\"include\": 0, \"require\": 0},\n    \"language_form_2\": {\"include\": 0, \"require\": 0},\n    \"is_consent_form_field\": {\"include\": 0, \"require\": 0},\n    \"is_consent_form_field_photo\": {\"include\": 0, \"require\": 0},\n    \"is_consent_form_field_email\": {\"include\": 0, \"require\": 0},\n}\n\nATTENDEE_CUSTOM_FORM = {\n    \"firstname\": \"First Name\",\n    \"lastname\": \"Last Name\",\n    \"email\": \"Email\",\n    \"address\": \"Address\",\n    \"city\": \"City\",\n    \"state\": \"State\",\n    \"country\": \"Country\",\n    \"jobTitle\": \"Job Title\",\n    \"phone\": \"Phone\",\n    \"taxBusinessInfo\": \"Tax Business Info\",\n    \"billingAddress\": \"Billing Address\",\n    \"homeAddress\": \"Home Address\",\n    \"shippingAddress\": \"Shipping Address\",\n    \"company\": \"Organisation\",\n    \"workAddress\": \"Work Address\",\n    \"workPhone\": \"Work Phone\",\n    \"website\": \"Website\",\n    \"blog\": \"Blog\",\n    \"twitter\": \"Twitter\",\n    \"facebook\": \"Facebook\",\n    \"github\": \"GitHub\",\n    \"linkedin\": \"LinkedIn\",\n    \"instagram\": \"Instagram\",\n    \"gender\": \"Gender\",\n    \"ageGroup\": \"Age Group\",\n    \"acceptVideoRecording\": \"Photo & video & text consent\",\n    \"acceptShareDetails\": \"Partner contact consent\",\n    \"acceptReceiveEmails\": \"Email consent\",\n    \"is_consent_form_field\": \"Consent form field\",\n    \"is_consent_form_field_photo\": \"Wikimania photo consent\",\n    \"is_consent_form_field_email\": \"Wikimania email updates\",\n    \"is_consent_of_refund_policy\": \"Consent of refund policy\",\n    \"language_form_1\": \"What is your native language, or what language are you most fluent in?\",\n    \"language_form_2\": \"Are you fluent in any other of the following languages?\",\n    \"home_wiki\": \"What is your home wiki\",\n    \"wiki_scholarship\": \"Have you received a Wikimania scholarship?\",\n}\n\n\nsession_form_str = json.dumps(SESSION_FORM, separators=(',', ':'))\nspeaker_form_str = json.dumps(SPEAKER_FORM, separators=(',', ':'))\nattendee_form_str = json.dumps(ATTENDEE_FORM, separators=(',', ':'))\n\n\nCUSTOM_FORM_IDENTIFIER_NAME_MAP = {\n    \"session\": SESSION_CUSTOM_FORM,\n    \"speaker\": SPEAKER_CUSTOM_FORM,\n    \"attendee\": ATTENDEE_CUSTOM_FORM,\n}\n\n\nclass CustomForms(db.Model):\n    \"\"\"custom form model class\"\"\"\n\n    class TYPE:\n        ATTENDEE = 'attendee'\n        SESSION = 'session'\n        SPEAKER = 'speaker'\n\n    __tablename__ = 'custom_forms'\n    __table_args__ = (\n        UniqueConstraint(\n            'event_id',\n            'field_identifier',\n            'form',\n            'form_id',\n            name='custom_form_identifier',\n        ),\n    )\n    id = db.Column(db.Integer, primary_key=True)\n    field_identifier = db.Column(db.String, nullable=False)\n    form = db.Column(db.String, nullable=False)\n    type = db.Column(db.String, nullable=False)\n    name = db.Column(db.String, nullable=False)\n    description = db.Column(db.String, nullable=True)\n    is_required = db.Column(db.Boolean, default=False)\n    is_included = db.Column(db.Boolean, default=False)\n    is_fixed = db.Column(db.Boolean, default=False)\n    position = db.Column(db.Integer, default=0, nullable=False)\n    is_public = db.Column(db.Boolean, nullable=False, default=False)\n    is_complex = db.Column(db.Boolean, nullable=False, default=False)\n    event_id = db.Column(db.Integer, db.ForeignKey('events.id', ondelete='CASCADE'))\n    custom_form_options = db.relationship('CustomFormOptions', backref=\"custom_form\")\n    form_id = db.Column(db.String)\n    min = db.Column(db.Integer, default=0, nullable=True)\n    max = db.Column(db.Integer, default=10, nullable=True)\n    main_language = db.Column(db.String)\n\n    @property\n    def identifier(self):\n        return to_snake_case(self.field_identifier)\n\n    def __repr__(self):\n        return f'<CustomForm {self.id!r} {self.identifier!r}>'\n\n\ndef get_set_field_name(target: CustomForms) -> str:\n    form_map = CUSTOM_FORM_IDENTIFIER_NAME_MAP[target.form]\n    target_name = form_map.get(target.field_identifier)\n    if target_name:\n        target.name = target_name\n\n    return target.name\n\n\n@listens_for(CustomForms, 'before_insert')\n@listens_for(CustomForms, 'before_update')\ndef generate_name(mapper, connect, target: CustomForms) -> None:\n    get_set_field_name(target)\n\n\ndef assign_field_names(session) -> None:\n    \"Used to migrate existing form fields in DB. Don't modify\"\n    statements = []\n\n    for form, dict_map in CUSTOM_FORM_IDENTIFIER_NAME_MAP.items():\n        for identifier, name in dict_map.items():\n            statements.append(\n                f\"UPDATE custom_forms SET name = '{name}' WHERE form = '{form}' and field_identifier = '{identifier}';\"\n            )\n\n    for statement in statements:\n        session.execute(statement)\n", "path": "app/models/custom_form.py"}], "after_files": [{"content": "import json\n\nfrom sqlalchemy.event import listens_for\nfrom sqlalchemy.schema import UniqueConstraint\n\nfrom app.api.helpers.utilities import to_snake_case\nfrom app.models import db\n\nSESSION_FORM = {\n    \"title\": {\"include\": 1, \"require\": 1},\n    \"subtitle\": {\"include\": 0, \"require\": 0},\n    \"short_abstract\": {\"include\": 1, \"require\": 0},\n    \"long_abstract\": {\"include\": 0, \"require\": 0},\n    \"comments\": {\"include\": 1, \"require\": 0},\n    \"track\": {\"include\": 0, \"require\": 0},\n    \"session_type\": {\"include\": 0, \"require\": 0},\n    \"language\": {\"include\": 0, \"require\": 0},\n    \"slides\": {\"include\": 1, \"require\": 0},\n    \"video\": {\"include\": 0, \"require\": 0},\n    \"audio\": {\"include\": 0, \"require\": 0},\n}\n\nSESSION_CUSTOM_FORM = {\n    \"title\": \"Title\",\n    \"subtitle\": \"Subtitle\",\n    \"shortAbstract\": \"Short Abstract\",\n    \"longAbstract\": \"Long Abstract\",\n    \"comments\": \"Comment\",\n    \"track\": \"Track\",\n    \"sessionType\": \"Session Type\",\n    \"level\": \"Level\",\n    \"language\": \"Language\",\n    \"slidesUrl\": \"Slide\",\n    \"slides\": \"Slides\",\n    \"videoUrl\": \"Video\",\n    \"audioUrl\": \"Audio\",\n    \"website\": \"Website\",\n    \"facebook\": \"Facebook\",\n    \"twitter\": \"Twitter\",\n    \"github\": \"GitHub\",\n    \"linkedin\": \"Linkedin\",\n    \"instagram\": \"Instagram\",\n    \"gitlab\": \"Gitlab\",\n    \"mastodon\": \"Mastodon\",\n}\n\nSPEAKER_FORM = {\n    \"name\": {\"include\": 1, \"require\": 1},\n    \"email\": {\"include\": 1, \"require\": 1},\n    \"photo\": {\"include\": 1, \"require\": 0},\n    \"organisation\": {\"include\": 1, \"require\": 0},\n    \"position\": {\"include\": 1, \"require\": 0},\n    \"country\": {\"include\": 1, \"require\": 0},\n    \"short_biography\": {\"include\": 1, \"require\": 0},\n    \"long_biography\": {\"include\": 0, \"require\": 0},\n    \"mobile\": {\"include\": 0, \"require\": 0},\n    \"website\": {\"include\": 1, \"require\": 0},\n    \"facebook\": {\"include\": 0, \"require\": 0},\n    \"twitter\": {\"include\": 1, \"require\": 0},\n    \"github\": {\"include\": 0, \"require\": 0},\n    \"linkedin\": {\"include\": 0, \"require\": 0},\n}\n\nSPEAKER_CUSTOM_FORM = {\n    \"name\": \"Name\",\n    \"email\": \"Email\",\n    \"photoUrl\": \"Photo\",\n    \"organisation\": \"Organisation\",\n    \"position\": \"Position\",\n    \"address\": \"Address\",\n    \"country\": \"Country\",\n    \"city\": \"City\",\n    \"longBiography\": \"Long Biography\",\n    \"shortBiography\": \"Short Biography\",\n    \"speakingExperience\": \"Speaking Experience\",\n    \"sponsorshipRequired\": \"Sponsorship Required\",\n    \"gender\": \"Gender\",\n    \"heardFrom\": \"Heard From\",\n    \"mobile\": \"Mobile\",\n    \"website\": \"Website\",\n    \"facebook\": \"Facebook\",\n    \"twitter\": \"Twitter\",\n    \"github\": \"GitHub\",\n    \"linkedin\": \"Linkedin\",\n    \"instagram\": \"Instagram\",\n    \"mastodon\": \"Mastodon\",\n}\n\nATTENDEE_FORM = {\n    \"firstname\": {\"include\": 1, \"require\": 1},\n    \"lastname\": {\"include\": 1, \"require\": 1},\n    \"email\": {\"include\": 1, \"require\": 1},\n    \"address\": {\"include\": 1, \"require\": 0},\n    \"city\": {\"include\": 1, \"require\": 0},\n    \"state\": {\"include\": 1, \"require\": 0},\n    \"country\": {\"include\": 1, \"require\": 0},\n    \"job_title\": {\"include\": 1, \"require\": 0},\n    \"phone\": {\"include\": 1, \"require\": 0},\n    \"tax_business_info\": {\"include\": 1, \"require\": 0},\n    \"billing_address\": {\"include\": 0, \"require\": 0},\n    \"home_address\": {\"include\": 0, \"require\": 0},\n    \"shipping_address\": {\"include\": 0, \"require\": 0},\n    \"company\": {\"include\": 1, \"require\": 0},\n    \"work_address\": {\"include\": 0, \"require\": 0},\n    \"work_phone\": {\"include\": 0, \"require\": 0},\n    \"website\": {\"include\": 1, \"require\": 0},\n    \"blog\": {\"include\": 0, \"require\": 0},\n    \"twitter\": {\"include\": 1, \"require\": 0},\n    \"facebook\": {\"include\": 0, \"require\": 0},\n    \"github\": {\"include\": 1, \"require\": 0},\n    \"gender\": {\"include\": 0, \"require\": 0},\n    \"age_group\": {\"include\": 0, \"require\": 0},\n    \"home_wiki\": {\"include\": 0, \"require\": 0},\n    \"wiki_scholarship\": {\"include\": 0, \"require\": 0},\n    \"accept_video_recording\": {\"include\": 0, \"require\": 0},\n    \"is_consent_of_refund_policy\": {\"include\": 0, \"require\": 0},\n    \"language_form_1\": {\"include\": 0, \"require\": 0},\n    \"language_form_2\": {\"include\": 0, \"require\": 0},\n    \"is_consent_form_field\": {\"include\": 0, \"require\": 0},\n    \"is_consent_form_field_photo\": {\"include\": 0, \"require\": 0},\n    \"is_consent_form_field_email\": {\"include\": 0, \"require\": 0},\n}\n\nATTENDEE_CUSTOM_FORM = {\n    \"firstname\": \"First Name\",\n    \"lastname\": \"Last Name\",\n    \"email\": \"Email\",\n    \"address\": \"Address\",\n    \"city\": \"City\",\n    \"state\": \"State\",\n    \"country\": \"Country\",\n    \"jobTitle\": \"Job Title\",\n    \"phone\": \"Phone\",\n    \"taxBusinessInfo\": \"Tax Business Info\",\n    \"billingAddress\": \"Billing Address\",\n    \"homeAddress\": \"Home Address\",\n    \"shippingAddress\": \"Shipping Address\",\n    \"company\": \"Organisation\",\n    \"workAddress\": \"Work Address\",\n    \"workPhone\": \"Work Phone\",\n    \"website\": \"Website\",\n    \"blog\": \"Blog\",\n    \"twitter\": \"Twitter\",\n    \"facebook\": \"Facebook\",\n    \"github\": \"GitHub\",\n    \"linkedin\": \"LinkedIn\",\n    \"instagram\": \"Instagram\",\n    \"gender\": \"Which of these categories describe your gender identity? (check all that apply)\",\n    \"ageGroup\": \"Age Group\",\n    \"acceptVideoRecording\": \"Photo & video & text consent\",\n    \"acceptShareDetails\": \"Partner contact consent\",\n    \"acceptReceiveEmails\": \"Email consent\",\n    \"is_consent_form_field\": \"Consent form field\",\n    \"is_consent_form_field_photo\": \"Wikimania photo consent\",\n    \"is_consent_form_field_email\": \"Wikimania email updates\",\n    \"is_consent_of_refund_policy\": \"Consent of refund policy\",\n    \"language_form_1\": \"What is your native language, or what language are you most fluent in?\",\n    \"language_form_2\": \"Are you fluent in any other of the following languages?\",\n    \"home_wiki\": \"What is your home wiki\",\n    \"wiki_scholarship\": \"Have you received a Wikimania scholarship?\",\n}\n\n\nsession_form_str = json.dumps(SESSION_FORM, separators=(',', ':'))\nspeaker_form_str = json.dumps(SPEAKER_FORM, separators=(',', ':'))\nattendee_form_str = json.dumps(ATTENDEE_FORM, separators=(',', ':'))\n\n\nCUSTOM_FORM_IDENTIFIER_NAME_MAP = {\n    \"session\": SESSION_CUSTOM_FORM,\n    \"speaker\": SPEAKER_CUSTOM_FORM,\n    \"attendee\": ATTENDEE_CUSTOM_FORM,\n}\n\n\nclass CustomForms(db.Model):\n    \"\"\"custom form model class\"\"\"\n\n    class TYPE:\n        ATTENDEE = 'attendee'\n        SESSION = 'session'\n        SPEAKER = 'speaker'\n\n    __tablename__ = 'custom_forms'\n    __table_args__ = (\n        UniqueConstraint(\n            'event_id',\n            'field_identifier',\n            'form',\n            'form_id',\n            name='custom_form_identifier',\n        ),\n    )\n    id = db.Column(db.Integer, primary_key=True)\n    field_identifier = db.Column(db.String, nullable=False)\n    form = db.Column(db.String, nullable=False)\n    type = db.Column(db.String, nullable=False)\n    name = db.Column(db.String, nullable=False)\n    description = db.Column(db.String, nullable=True)\n    is_required = db.Column(db.Boolean, default=False)\n    is_included = db.Column(db.Boolean, default=False)\n    is_fixed = db.Column(db.Boolean, default=False)\n    position = db.Column(db.Integer, default=0, nullable=False)\n    is_public = db.Column(db.Boolean, nullable=False, default=False)\n    is_complex = db.Column(db.Boolean, nullable=False, default=False)\n    event_id = db.Column(db.Integer, db.ForeignKey('events.id', ondelete='CASCADE'))\n    custom_form_options = db.relationship('CustomFormOptions', backref=\"custom_form\")\n    form_id = db.Column(db.String)\n    min = db.Column(db.Integer, default=0, nullable=True)\n    max = db.Column(db.Integer, default=10, nullable=True)\n    main_language = db.Column(db.String)\n\n    @property\n    def identifier(self):\n        return to_snake_case(self.field_identifier)\n\n    def __repr__(self):\n        return f'<CustomForm {self.id!r} {self.identifier!r}>'\n\n\ndef get_set_field_name(target: CustomForms) -> str:\n    form_map = CUSTOM_FORM_IDENTIFIER_NAME_MAP[target.form]\n    target_name = form_map.get(target.field_identifier)\n    if target_name:\n        target.name = target_name\n\n    return target.name\n\n\n@listens_for(CustomForms, 'before_insert')\n@listens_for(CustomForms, 'before_update')\ndef generate_name(mapper, connect, target: CustomForms) -> None:\n    get_set_field_name(target)\n\n\ndef assign_field_names(session) -> None:\n    \"Used to migrate existing form fields in DB. Don't modify\"\n    statements = []\n\n    for form, dict_map in CUSTOM_FORM_IDENTIFIER_NAME_MAP.items():\n        for identifier, name in dict_map.items():\n            statements.append(\n                f\"UPDATE custom_forms SET name = '{name}' WHERE form = '{form}' and field_identifier = '{identifier}';\"\n            )\n\n    for statement in statements:\n        session.execute(statement)\n", "path": "app/models/custom_form.py"}]}