Skip to content

Conversation

@brianhw
Copy link
Contributor

@brianhw brianhw commented Jan 6, 2014

Use in create_user command instead of inheriting from BaseCommand.

@rocha @mulby This seems like the least intrusive way to get command information into context.

Copy link
Contributor

Choose a reason for hiding this comment

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

Can you add some documentation about the edx.mgmt.command context? And example of the generated context would also be useful.

Copy link
Contributor

Choose a reason for hiding this comment

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

Following django conventions, I would spec command.py to be located in common/djangoapps/track/management/

Copy link
Contributor Author

Choose a reason for hiding this comment

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

In looking at the doc (e.g. https://docs.djangoproject.com/en/dev/howto/custom-management-commands/), I find nothing about where to define code to be used when defining management commands elsewhere. I believe that only management commands should be put in management/commands (and this is not a management command). I haven't seen any example about adding code to management. This might be a reasonable place, but it's not based on any precedence.

Copy link
Contributor

Choose a reason for hiding this comment

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

Note that I am not saying it to put it in managent/commands, just in management. I have seen that pattern in other django projects. In addition, BaseCommand lives in django.core.management.base.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Okay, I'll do that, and I'll move the test to a tests subdirectory of management.

Copy link
Contributor

Choose a reason for hiding this comment

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

I would leave these two entries (course_id, org_id) out until they are actually being added by the create_user command

Copy link
Contributor Author

Choose a reason for hiding this comment

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

They are added by the enrollment call itself. Only "command" is now being added by the TrackedCommand class.

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah yes, I suppose they would be. Awesome.

@rocha rocha closed this Jan 9, 2014
@rocha rocha reopened this Jan 9, 2014
@rocha
Copy link
Contributor

rocha commented Jan 9, 2014

Close the PR accidentally, sorry.

@rocha rocha closed this Jan 9, 2014
@rocha rocha reopened this Jan 9, 2014
@rocha
Copy link
Contributor

rocha commented Jan 9, 2014

:LGTM: One thing we have to watch out is events that assume the context contains the course_id. If that is the case then we can provide a mechanism for users of TrackedCommand to set the course_id and related fields in the context.

However, maybe events that semantically require a course_id should put it in the event data and not the context.

@brianhw
Copy link
Contributor Author

brianhw commented Jan 9, 2014

Those events that require a course_id can put it in their context themselves as well as in their event data. At least that's what the enrollment code does. (See CourseEnrollment.emit_event() for particulars.)

@rocha
Copy link
Contributor

rocha commented Jan 9, 2014

My concern is that the enrollment event is currently the only one (from what I remember) that emitted while setting the context at the same time. The other events assume the context is set up for them. I think we should only deal with this problem if we find an example. Right now it is just hypothetical.

@rocha
Copy link
Contributor

rocha commented Jan 9, 2014

🚀

brianhw added a commit that referenced this pull request Jan 10, 2014
Define TrackedCommand for use as base class for tracking management commands
@brianhw brianhw merged commit 20489f2 into master Jan 10, 2014
@brianhw brianhw deleted the brian/track-commands branch January 10, 2014 15:39
shimulch pushed a commit to open-craft/openedx-platform that referenced this pull request Jan 26, 2021
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.

4 participants