Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue 25 attribution change #48

Draft
wants to merge 24 commits into
base: refactor
Choose a base branch
from

Conversation

brandonrosenbloom
Copy link
Collaborator

SEVERAL CHANGES:

  1. Added .idea files to gitignore to help keep the repo clean
  2. Added several models to the Resources app in order to help better organize the data while also providing future adjustability.
  3. Created a basic author form so new authors could be created while also adding the necessary admin settings. STILL NOT DONE.

aeltanawy and others added 10 commits May 15, 2021 13:56
-Added extra installation instructions for Mac users
-Added database setup using migrate command
Co-authored-by: Martin Breuss [email protected]

-Added extra installation instructions for Mac users
-Added database setup using migrate command
19: Improve installation instructions
…ke resource status, devices, audiance, etc. Did this so as new values were required, we wouldn't require a code change/redeployment of the application.
brandon.rosenbloom added 10 commits May 20, 2021 14:57
Registered new models with admin. Created new migration. Added __str__ method to all new models. Updated resource list view to return all resources for now. Will need to update to only allow for approved resources in the future.
Commented out language field as it was replaced by a many to many field.
Deleted the choices file and removed references in models.py, views.py and commented references in tests.py. Need to update the tests to utilize the appropriate models instead of the choices file.
Removed the multiselectfield import as it was no longer being used.
Added a sequence field to the ResourceStatus model so we can programmatically identify the Proposed status without having to rely on the "Proposed" value itself. This will allow us to change the status name if needed.
Added logic to default the status of a resource to the first status in the sequence so we can change the name of the status in the future if needed.
Removed unnecessary comments and fields that no longer exist on the Resource model.
Updated model name to remove pluralization. Added more details admin capabilities for all models.
Created CreateResourceForm in forms.py and updated views.py to utilize the new custom form. This form will more appropriately handle multiselect fields. Still need to add the ability to add a new author.
Updated resource list form to utilize the newly created fields/models. Also appears to have fixed the filters functionality as well.


def get_initial_status():
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is raising issue while migration. I think the issue is because of the fact that ResourceStatus won't exist until this point?
I have attached the screenshot herewith.
resource

Created a data migration file that will be used to automatically populate several tables within the DB.
@brandonrosenbloom
Copy link
Collaborator Author

@sijanonly I have now added the data migration file. You should be able to pull the latest version of this request down and run migrate to see the data appear.

@sijanonly
Copy link
Collaborator

@sijanonly I have now added the data migration file. You should be able to pull the latest version of this request down and run migrate to see the data appear.

@brandonrosenbloom I am still getting this issue while running migration.

can you please have a look?

mig_issue

Updated get_initial_status to return None if there is no default status available.
Removed unneeded period.
@brandonrosenbloom
Copy link
Collaborator Author

@sijanonly Try now. I've updated the get_default_value method to return a none if there are no values available.

@sijanonly
Copy link
Collaborator

@sijanonly Try now. I've updated the get_default_value method to return a none if there are no values available.

@brandonrosenbloom , the changes didn't work. Actually, the statement ResourceStatus.objects.get(sequence=1).id will raise error since it won't find the ResourceStatus object. I changed it to following and it works.

def get_initial_status():
    try:
        initial_status = ResourceStatus.objects.get(sequence=1).id
    except ResourceStatus.DoesNotExist:
        initial_status = None
    return initial_status

Also, there is one issue I am facing while creating user. I tried to create superuser python manage.py createsuperuser
and Profile model has populations field, which is NOT NULL. And it raises
django.db.utils.IntegrityError: NOT NULL constraint failed: resources_profile.populations_id

I think it's better to set null=True for populations field in Profile model.

Added try/except logic to get_initial_status method as recommended by @sijanonly
@brandonrosenbloom
Copy link
Collaborator Author

@sijanonly I've applied the change to the get_initial_status method as suggested. @meg-ray Do we want to guarantee that all profiles have a population entered?

@sijanonly
Copy link
Collaborator

@sijanonly I've applied the change to the get_initial_status method as suggested. @meg-ray Do we want to guarantee that all profiles have a population entered?

@brandonrosenbloom I just found that there is a separate ProfileUpdateView where user can update populations,.. information. It seems like we can put None for default ?

@brandonrosenbloom
Copy link
Collaborator Author

@sijanonly The only issue I see with setting the population attribute to None on the model is really how it may impact the business process by which users are created. @meg-ray if we don't expect new users to always be created with a population value, then setting the value to no longer be required makes sense. However, if we expect all new users to have a population to be identified when they are first created, then we should probably leave the field as required. Thoughts?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Refactor modeling Resources Database Model - Change "Attribution" to "Author"
5 participants