nearbeach / NearBeach

NearBeach is an open sourced project management tool, helping you keep track of your project. You can track requirements, projects and tasks

Home Page:https://nearbeach.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Use get_user_model or settings.AUTH_USER_MODEL

sbonelo-nje opened this issue Β· comments

Is your feature request related to a problem? Please describe.
A clear and concise description of what the problem is.

  • I'd like to use the package for a new project, but in the project I have a custom user model with extra fields and have it setup in settings.
    The 2 don't play along very well as expected since NearBeach uses the auth.models.User to reference to the User model and is not loading the set project AUTH_USER_MODEL.

Describe the solution you'd like
A clear and concise description of what you want to happen.

  • Would like to see NearBeach using either -get_user_model or settings.AUTH_USER_MODEL to easily allow integration on projects that have customized their user model.

Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.

  • NearBeach currently has the import in the models.py and the views (dashboard_views.py and authentication_views.py)

In either one of the two approaches we can add User variable after the imports that instantiates or fetch the project user model which I think would be picked up by underlying code since they already reference "User".

For now this is just at the top of my head, possibly there is a better solution πŸ‘€πŸ˜…, but can we please change the auth.models.User reference? πŸ˜ŠπŸ™ƒ

Additional context
Add any other context or screenshots about the feature request here.

  • I haven't tried this yet so unfortunately I don't.
commented

I'll have to do some research today

I would like to assist if possible, it would be the first time ever contributing in a project so I'm inexperienced.

I can though, if provided with the guidance on how I can contribute.

commented

We have documentation on how to setup NearBeach for local development here - https://nearbeach.readthedocs.io/en/latest/002-local-development-environment-setup/index.html

The main instructions would be;

  1. Clone repository
  2. Create python virtual environment (or use existing one)
  3. Install packages (both pip and npm)

When submitting a pull request, you'll need to fork the code first. With the forked code you'll be able to submit a pull request :)

As for the request, I can easily place the following code into the local settings py and the docker settings py. This will apply the override for the AUTH USER MODEL.
image

However I don't know if I need to get this applied to the Models.py and any views that currently use the auth.models.User. I'v gone ahead and created the following branch - https://github.com/robotichead/NearBeach/tree/issue-533-auth-user-model Feel free to download it and see if this works for your current project.

If it does not, we'll have to look at what else requires changing. :)

I also have a discord - https://discord.gg/64uhRztS6n

Thanks for the reply.

I kind of understand the above move on the settings, but I also think it won't change anything since the already underlying code is directly importing from auth.models.User.

In my case, I already have a project setup/configuration with other apps on it.
NearBeach is to be added as a package using pip, and then configured on the project.

In this case, the models and views will need a visit, nothing major but just a change of import for the User Model.

As mentioned in my initial message, I think we only have to swap out where the User model being used by models and views is coming from, and I think only have to touch 1 import line and declare a new User variable under the imports.

I will fork and make the changes so that you can further check and we can take it from there.

commented

I am going to create a new local project with a custom user model. From here I can determine what needs to change and if it is possible :)

Feel free to fork and see what you can change to make it work :)

Keep me updated :D

commented

@sbonelo-nje - out of curiosity, are you using AbstractUser or AbstractBaseUser?

Sorry for just vanishing, I'm still recovering from an accident I had last week where I hurt very badly.

I am using the AbstractBaseUser, Django recommends using it if looking at adding more fields.

I am still looking at doing the changes I mentioned, but I will need a bit of time to get better first.

commented

@sbonelo-nje - I am sorry to hear about your accident. Take time recovering and I hope you get better soon.

commented

I've been able to play around with this :)
66c9704

Good news - looks like it is possible with the ability to get most functionality ported over. There are some functionality that does not work exactly. i.e. the ADMINISTRATION -> USERS.

I will have to do some more testing etc. Sadly this will have to go through a release candidate and won't get released till 0.31.0

Hi Luke, I have to say πŸ˜….

It seems you went and done it! This looks great, I will check it out soon and tell you if I face any problems.

All good things come to those who wait πŸ™‚, so I don't see no problem with waiting till 0.31.0.

πŸ™Œ

commented

That is great news.

It does look like I'll have limitations, for example first_name, last_name. But this is something that I can think about.

commented

We have merged in this ability into develop branch. This will be released soon as 0.31.0-RC1

We understand that not all functionality will work, as NearBeach requires first_name, last_name, email, username fields for certain parts of the application. This will be fixed over time. :)