openwisp-radius icon indicating copy to clipboard operation
openwisp-radius copied to clipboard

[change] User Model Extension (Bulk Update)

Open chanduaki opened this issue 4 years ago • 5 comments

Extending User Models in openwisp-radius I have followed the documentation(https://github.com/openwisp/openwisp-users/#extend-openwisp-users) to extended the User models. But when we extend the User models here

Are these fields will add in Bulk User creation ( through csv we are doing according to https://openwisp-radius.readthedocs.io/en/latest/user/importing_users.html)

But when i have in the code itself , only considering the below fields to create or update the user according to https://github.com/openwisp/openwisp-radius/blob/e6b931a278fbf67b155f1d6dbab14a7dacfad677/openwisp_radius/base/models.py#L942

    User = get_user_model()
    username, password, email, first_name, last_name = row

This was seen in multiple places , fixing the fields in the Bulk User creation

Do we need to make changes in the core code or is there any other way to extend them

I think code needs to be improved

chanduaki avatar Sep 30 '21 14:09 chanduaki

I think we should add an additional method there which by default is empty but can be used by third party apps to add their own logic.

Eg:

    ...
    user = self.customize_user_creation(user, row)
    user.full_clean()

def customize_user_creation(user, row):
     return user

Third parties should be able to extend customize_user_creation to do add the custom fields.

We should create a test for this use case in the SAMPLE_APP: https://github.com/openwisp/openwisp-radius/tree/master/tests/openwisp2/sample_radius

nemesifier avatar Sep 30 '21 14:09 nemesifier

Hi can i work on this? Since i am new can you please explain the issue and its solution in simple terms?

eleensmathew avatar Feb 06 '22 07:02 eleensmathew

You can start working @eleensmathew

codesankalp avatar Feb 06 '22 08:02 codesankalp

Since i am new can you please explain the issue and its solution in simple terms?

If you are new, please try to explore openwisp-radius first.

codesankalp avatar Feb 06 '22 08:02 codesankalp

Should I add this code (https://github.com/openwisp/openwisp-radius/issues/310#issuecomment-931397201) in the https://github.com/openwisp/openwisp-radius/blob/master/tests/openwisp2/sample_radius/models.py file?

eleensmathew avatar Feb 10 '22 08:02 eleensmathew