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

Separate app by feature #687

Merged
merged 11 commits into from
Feb 20, 2024
Merged

Conversation

dpgraham4401
Copy link
Member

Description

This PR is part of series of TLC PRs i intend to submit for the backend. Namely this PR does 1 major thing and that is separates the organization of our backend by feature, instead of just clumping all the source into just a few modules.

Now, when we navigate to the server/apps/ directory there are a list of django apps that each coorrespond to a feature of the haztrak application. This makes the layout and organization of the overall django project easier to understand, as well as the scope of each django app. These apps have limited scope in terms of the models/entities/DB tables they implement, as well as the services, views, tests, and configs that accompany them. I'm really happy with the way this is going, and there is a lot more work to do on this subject.

In addition, I also started but havne't finished, abstracting our model queries into django's model managers. This way we'll keep our views and controllers ignorent of the structure of our database tables.

It's a little embarressing we are doing this now and not at the beggining of the project but Haztrak has always been a learn by doing project. Now we know better.

Issue ticket number and link

Checklist

  • I have added tests that prove my fix is effective or that my feature works
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings

    initial migrate manifest model (along with PortsOfEntry, CorrectionInfo, AdditionalInfo, etc.) to the manifest app.
    remove wasteline information from the 'trak' app, including the data migrations
    that populates the database with initial DOT codes

    move test fixtures, and tests related to the waste line to our new 'wasteline' django app

    add urls to wasteline app

    add wasteline app models and views
…steline' or 'manifest' apps

    move remaining services, views and tests related to the manifest entity to the 'manifest' django app

    The one corollary to this is we moved many of the test fixtures to the django app
    root. Would like to move these back into the corresponding apps to keep things
    relatively isolated

    move manifest URLs and views to manifest app

    move the manifest model and related classes to the new django 'manifest' app
    The handler app contains information about a waste handler, which is an instance of a RCRAinfo site on a manifest (e.g., signature info)
    To clarify this feature is related to the RCRAInfo site, as opposed to the site app which will contain the haztrak site
    move HaztrakOrg model to new 'org' django app

    move HaztrakOrg related views, services, and test to the new django 'org' app
    scaffold new 'profile' django app which will house user profile information not related to authentication
…eign keys generally resolve back to the user model instead of pointing towards each other where applicable. This commit also takes the time to apply a more consistent naming convention to our Trak service (our monolithic backend Restful API)

    rename RcrainfoSitePermissions to RcrainfoSiteAccess for consistency

    update development fixtures

    consistent naming in Test... classes

    use consistent naming in services, serializers and views, and models

    rename SitePermission to TrakSiteAccess

    rename HaztrakSite to TrakSite

    rename HaztrakProfile to TrakProfile

    rename HaztrakOrg to TrakOrg

    rename HaztrakUser to TrakUser

    remove foreign key between RcraSite and RcrainfoSitePermissions
        this is a hold over from when a user could only interact with a resource in RCRAInfo if they had the site manager permissions for a site (and therefore an API ID and Key). This has changed since the Remote Signer Policy

    implement access through the TrakOrgPermissions model
…s, remove dead code (ImportInfo and CorrectionInfo)

    use settings.AUTH_USER_MODEL instead of explicitly using the core user model

    Add new settings including TRAK_RCRAINFO_SITE_MODEL, TRAK_SITE_MODEL, TRAK_HANDLER_MODEL, TRAK_ORG_MODEL, TRAK_MANIFEST_MODEL
…ay from our controllers and views and consolidating those queries in the model portion of our application. It's incomplete, and there is still more work to be done on this subject. This commit is squashed and contains a number of other things that it shouldn't such as adding an Organization details view, and a shell script function for running coverage reports.

    Apply consistent style/structure to the new wasteline app so each view calls a service module function that calls a query method on the appropriate model manager

        get_state_waste_codes service method

        New DotLookupBaseManager base class for all DotLookup manager with an additional 'filter_by_value' method applicable to all classes

        filter_by_state_id query method for state waste codes

    Add manager methods to TrakSite model manager and implement
    add coverage dependency and document process in the runhaz.sh shell script

    use manager method and chain with & operator to filter by user and EPA id number

    site filter by EPA id

    add filter_by_user method

    move test fixtures into smaller scope python modules (django apps) where applicable rename abstract factory methods

    use new TrakSite filter_by_username query method in manifest service

    get_by_user query method for the TrakSite model
@github-actions github-actions bot added database changes that require modification to the database schema dependencies project dependency problems or modifications documentation Improvements or additions to documentation server Related to backend workings (Django/Rest API) test Unit tests are, or need to be, included labels Feb 20, 2024
@dpgraham4401 dpgraham4401 merged commit 607d9d1 into USEPA:main Feb 20, 2024
4 checks passed
@dpgraham4401 dpgraham4401 deleted the separate_app_by_feature branch February 20, 2024 15:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
database changes that require modification to the database schema dependencies project dependency problems or modifications documentation Improvements or additions to documentation server Related to backend workings (Django/Rest API) test Unit tests are, or need to be, included
Projects
No open projects
Status: Done
Development

Successfully merging this pull request may close these issues.

1 participant