Wagify / wagtail-social-network

Social networking site built with Wagtail CMS
GNU Affero General Public License v3.0
19 stars 9 forks source link

Make `first_name` and `last_name` optional on Account Settings form #27

Open brylie opened 3 years ago

brylie commented 3 years ago

Split from #26

Our custom User model has optional first_name and last_name fields. However, the Account Settings form displays those fields as required.

Make the first_name and last_name fields optional on the Account Settings form.

Resources

brylie commented 3 years ago

@Upasanadhameliya would you consider helping out with this issue? We're a bit stuck and it seemed like you had an idea how to customize the Account Settings form :smiley:

Upasanadhameliya commented 3 years ago

@brylie Sorry for the delay, I have been busy. I will try my hand at it and see what I can do. Thanks :)

Upasanadhameliya commented 3 years ago

@brylie I checked out the user account settings form and it isn't showing first name or last name as required.. Can you explain a bit further as though what exactly do you need to modify?

ques13

brylie commented 3 years ago

@Upasanadhameliya it turns out there are two user-related forms:

Peek 2021-08-17 14-08

I don't know how to make the first_name and last_name fields optional on the "account settings" form. Would you be interested to take a look?

Upasanadhameliya commented 3 years ago

Oh I see.. thanks for the clarification.. I will check it out :smile:

Upasanadhameliya commented 3 years ago

@brylie I went through two links:

  1. https://docs.wagtail.io/en/stable/advanced_topics/customisation/custom_account_settings.html
  2. https://github.com/wagtail/wagtail/blob/b349ba436eeb853a8c2b2ff749f173a1f7d26d59/wagtail/admin/forms/account.py#L85

In the second link they have defined a NameEmailForm where the first_name and last_name are set as required. We would need to import this class and override these fields to be as optional.

  1. https://github.com/wagtail/wagtail/blob/b349ba436eeb853a8c2b2ff749f173a1f7d26d59/wagtail/admin/views/account.py#L205

In the link number 3. they are providing the functionality of adding extra panels to the existing panels as written in the documentation (link 1.) However they haven't provided the code to modify existing panels.

brylie commented 3 years ago

@Upasanadhameliya great research! Do you want to give your suggestion a try?

Perhaps the documentation from link three could also be updated. I'll mention the missing documentation in the upstream issue with Wagtail:

https://github.com/wagtail/wagtail/issues/7410

AbhijithGanesh commented 3 years ago

Was this suggestion resolved? I'd attempt to fix it if assigned. Thank you @brylie (If you believe there is a better way to reach out instead of GH mentions, Please let me know.)

brylie commented 3 years ago

@AbhijithGanesh thanks. I'll assign you to the task.

AbhijithGanesh commented 3 years ago

I am working on this and I will issue a patch soon.