-
Notifications
You must be signed in to change notification settings - Fork 48
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
feat: customizable management command to generate local enterprise data #1826
feat: customizable management command to generate local enterprise data #1826
Conversation
6ac4cfc
to
2bda6f1
Compare
bd5b43c
to
3812217
Compare
@alex-sheehan-edx [curious] Just seeking clarification on the approach here: how does this new command relate to the existing |
23dfe4a
to
bfad7f3
Compare
@adamstankiewicz The hope is to deprecate the old one! But there are also some use cases for this that I think apply outside of that script that I will try and highlight 😄 |
8f34217
to
f2c7060
Compare
f2c7060
to
da9dcfc
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks great so far. would like to see some example scripts which utilize it.
dafb7fc
to
f4d02bf
Compare
69a2f9b
to
76b9123
Compare
016db49
to
d5b83b9
Compare
from django.core.management.base import CommandError | ||
|
||
|
||
def call_command(command_name, *args, **options): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I had to redefine call_command to allow us to use unrecognized args
16400d1
to
00700c0
Compare
bea89b6
to
c508a5d
Compare
c508a5d
to
da5e1e1
Compare
How to use this work:
Upon invoking the command, supply a model param (
--model
) that is a complete path to a model that has a corresponding test factory ie./manage.py lms manufacture_data --model enterprise.models.EnterpriseCustomer
This will generate an enterprise customer record with place holder values according to the test factory
We can also provide customizations to the record being generated, ie
./manage.py lms manufacture_data --model enterprise.models.EnterpriseCustomer --name "FRED"
which will produce the customized record:
we can also supply parent model/subfactory customizations as well:
./manage.py lms manufacture_data --model enterprise.models.EnterpriseCustomerCatalog --enterprise_customer__site__name "Fred" --enterprise_catalog_query__title "JOE SHMO" --title "who?"
will result inNote the non subclass customization
--title "who?"
is applied to the specified modelEnterpriseCustomerCatalog
But say we want to supply an existing record as a FK to our object:
./manage.py lms manufacture_data --model enterprise.models.EnterpriseCustomerUser --enterprise_customer 994599e6-3787-48ba-a2d1-42d1bdf6c46e
we get:
or we can do something like:
./manage.py lms manufacture_data --model enterprise.models.EnterpriseCustomerUser --enterprise_customer__site 9 --enterprise_customer__name "joe"
which would yield:
but if you try and get something that doesn't exist...
./manage.py lms manufacture_data --model enterprise.models.EnterpriseCustomerUser --enterprise_customer <SOMETHING BAD>
we'd get:
another limitation of this script is that it can only fetch or customize, you cannot customize a specified, existing FK...
./manage.py lms manufacture_data --model enterprise.models.EnterpriseCustomerUser --enterprise_customer__site__name "fred" --enterprise_customer 994599e6-3787-48ba-a2d1-42d1bdf6c46e
would yield a
CommandError: This script does not support customizing provided existing objects
https://2u-internal.atlassian.net/browse/ENT-7403
Merge checklist:
requirements/*.txt
files)base.in
if needed in production but edx-platform doesn't install ittest-master.in
if edx-platform pins it, with a matching versionmake upgrade && make requirements
have been run to regenerate requirementsmake static
has been run to update webpack bundling if any static content was updated./manage.py makemigrations
has been run./manage.py lms makemigrations
in the shell.Post merge:
(so basically once your build finishes, after maybe a minute you should see the new version in PyPi automatically (on refresh))
make upgrade
in edx-platform will look for the latest version in PyPi.