Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ These are notable changes in edx-platform. This is a rolling list of changes,
in roughly chronological order, most recent first. Add your entries at or near
the top. Include a label indicating the component affected.

Common: Add a manage.py that knows about edx-platform specific settings and projects

Common: Added *experimental* support for jsinput type.

Expand Down
25 changes: 9 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ those files to run edX, mirroring the folder in `/opt/edx/edx-platform`).
You may also want to create a super-user with:

```
$ rake django-admin["createsuperuser"]
$ ./manage.py lms createsuperuser
```

Also note that if you register a new user through the web interface,
Expand Down Expand Up @@ -229,30 +229,23 @@ or any other process management tool.

Configuring Your Project
------------------------
We use [`rake`](http://rake.rubyforge.org/) to execute common tasks in our
project. The `rake` tasks are defined in the `rakefile`, or you can run `rake -T`
to view a summary.

Before you run your project, you need to create a sqlite database, create
tables in that database, run database migrations, and populate templates for
CMS templates. Fortunately, `rake` will do all of this for you! Just run:

$ rake django-admin[syncdb]
$ rake django-admin[migrate]
tables in that database, and run database migrations. Fortunately, `django`
will do all of this for you

If you are running these commands using the [`zsh`](http://www.zsh.org/) shell,
zsh will assume that you are doing
[shell globbing](https://en.wikipedia.org/wiki/Glob_%28programming%29), search for
a file in your directory named `django-adminsyncdb` or `django-adminmigrate`,
and fail. To fix this, just surround the argument with quotation marks, so that
you're running `rake "django-admin[syncdb]"`.
$ ./manage.py lms syncdb --migrate
$ ./manage.py cms syncdb --migrate

Run Your Project
----------------
edX has two components: Studio, the course authoring system; and the LMS
(learning management system) used by students. These two systems communicate
through the MongoDB database, which stores course information.

We use [`rake`](http://rake.rubyforge.org/) to execute common tasks in our
project. The `rake` tasks are defined in the `rakefile`, or you can run `rake -T`
to view a summary.

To run Studio, run:

$ rake cms
Expand Down
16 changes: 0 additions & 16 deletions cms/manage.py

This file was deleted.

6 changes: 3 additions & 3 deletions common/djangoapps/external_auth/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
If you make changes to this model, be sure to create an appropriate migration
file and check it in at the same time as your model changes. To do that,

1. Go to the mitx dir
2. django-admin.py schemamigration student --auto --settings=lms.envs.dev --pythonpath=. description_of_your_change
3. Add the migration file created in mitx/common/djangoapps/external_auth/migrations/
1. Go to the edx-platform dir
2. ./manage.py lms schemamigration student --auto description_of_your_change
3. Add the migration file created in edx-platform/common/djangoapps/external_auth/migrations/
"""

from django.db import models
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class Command(BaseCommand):
files and then uploads over SFTP to Pearson and stuffs the entry in an
S3 bucket for archive purposes.

Usage: django-admin.py pearson-transfer --mode [import|export|both]
Usage: ./manage.py pearson-transfer --mode [import|export|both]
"""

option_list = BaseCommand.option_list + (
Expand Down
6 changes: 3 additions & 3 deletions common/djangoapps/student/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
If you make changes to this model, be sure to create an appropriate migration
file and check it in at the same time as your model changes. To do that,

1. Go to the mitx dir
2. django-admin.py schemamigration student --auto --settings=lms.envs.dev --pythonpath=. description_of_your_change
3. Add the migration file created in mitx/common/djangoapps/student/migrations/
1. Go to the edx-platform dir
2. ./manage.py lms schemamigration student --auto description_of_your_change
3. Add the migration file created in edx-platform/common/djangoapps/student/migrations/
"""
from datetime import datetime
import hashlib
Expand Down
4 changes: 2 additions & 2 deletions doc/development.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,14 @@ Both the LMS and Studio can be started using the following shortcut tasks
rake lms[cms.dev] # Start LMS to run alongside Studio
rake lms[cms.dev_preview] # Start LMS to run alongside Studio in preview mode

Under the hood, this executes `django-admin.py runserver --pythonpath=$WORKING_DIRECTORY --settings=lms.envs.dev`,
Under the hood, this executes `./manage.py {lms|cms} --settings $ENV runserver`,
which starts a local development server.

Both of these commands take arguments to start the servers in different environments
or with additional options:

# Start the LMS using the test configuration, on port 5000
rake lms[test,5000] # Executes django-admin.py runserver --pythonpath=$WORKING_DIRECTORY --setings=lms.envs.test 5000
rake lms[test,5000] # Executes ./manage.py lms --settings test runserver 5000

*N.B.* You may have to escape the `[` characters, depending on your shell: `rake "lms[test,5000]"`

Expand Down
17 changes: 6 additions & 11 deletions doc/discussion.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,24 +68,19 @@ First make sure that the database is up-to-date:

If you have created users in the edx-platform django apps when the comment service was not running, you will need to one-way sync the users into the comment service back end database:

rake django-admin[sync_user_info]

For convenience, add the following environment variables to the terminal (assuming that you're using configuration set lms.envs.dev):

export DJANGO_SETTINGS_MODULE=lms.envs.dev
export PYTHONPATH=.
./manage.py lms sync_user_info

Now initialize roles and permissions, providing a course id. See the example below. Note that you do not need to do this for Studio-created courses, as the Studio application does this for you.

django-admin.py seed_permissions_roles "MITx/6.002x/2012_Fall"
./manage.py lms seed_permissions_roles "MITx/6.002x/2012_Fall"

To assign yourself as a moderator, use the following command (assuming your username is "test", and the course id is "MITx/6.002x/2012_Fall"):

django-admin.py assign_role test Moderator "MITx/6.002x/2012_Fall"
./manage.py lms assign_role test Moderator "MITx/6.002x/2012_Fall"

To assign yourself as an administrator, use the following command

django-admin.py assign_role test Administrator "MITx/6.002x/2012_Fall"
./manage.py lms assign_role test Administrator "MITx/6.002x/2012_Fall"

## Some other useful commands

Expand Down Expand Up @@ -155,8 +150,8 @@ You can use the following command to launch a console within the service environ

Use the following command to see the roles and permissions of a user in a given course (assuming, again, that the username is "test"):

django-admin.py show_permissions moderator
./manage.py lms show_permissions moderator

You need to make sure that the environment variables are exported. Otherwise you would need to do

django-admin.py show_permissions moderator --settings=lms.envs.dev --pythonpath=.
./manage.py lms show_permissions moderator
2 changes: 1 addition & 1 deletion doc/testing.md
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ generates HTML and XML (Cobertura format) reports.

When testing problems that use a queue server on AWS (e.g. sandbox-xqueue.edx.org), you'll need to run your server on your public IP, like so.

`django-admin.py runserver --settings=lms.envs.dev --pythonpath=. 0.0.0.0:8000`
`./manage.py lms runserver 0.0.0.0:8000`

When you connect to the LMS, you need to use the public ip. Use `ifconfig` to figure out the number, and connect e.g. to `http://18.3.4.5:8000/`

Expand Down
2 changes: 1 addition & 1 deletion lms/djangoapps/courseware/tests/test_masquerade.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

Notes for running by hand:

django-admin.py test --settings=lms.envs.test --pythonpath=. lms/djangoapps/courseware
./manage.py lms --settings test test lms/djangoapps/courseware
"""

from django.test.utils import override_settings
Expand Down
2 changes: 1 addition & 1 deletion lms/djangoapps/instructor/tests/test_download_csv.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

Notes for running by hand:

django-admin.py test --settings=lms.envs.test --pythonpath=. lms/djangoapps/instructor
./manage.py lms --settings test test lms/djangoapps/instructor
"""

from django.test.utils import override_settings
Expand Down
3 changes: 1 addition & 2 deletions lms/djangoapps/notes/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,7 @@ Developer Overview
### Quickstart

```
$ rake django-admin[syncdb]
$ rake django-admin[migrate]
$ ./manage.py lms syncdb --migrate
```

Then follow the steps above to enable the *My Notes* tab or manually add a tab to the policy tab configuration with ```{"type": "notes", "name": "My Notes"}```.
Expand Down
2 changes: 1 addition & 1 deletion lms/djangoapps/open_ended_grading/tests.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""
Tests for open ended grading interfaces

django-admin.py test --settings=lms.envs.test --pythonpath=. lms/djangoapps/open_ended_grading
./manage.py lms --settings test test lms/djangoapps/open_ended_grading
"""

import json
Expand Down
16 changes: 0 additions & 16 deletions lms/envs/README.txt

This file was deleted.

97 changes: 97 additions & 0 deletions manage.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
#!/usr/bin/env python
"""
Usage: manage.py {lms|cms} [--settings env] ...

Run django management commands. Because edx-platform contains multiple django projects,
the first argument specifies which project to run (cms [Studio] or lms [Learning Management System]).

By default, those systems run in with a settings file appropriate for development. However,
by passing the --settings flag, you can specify what environment specific settings file to use.

Any arguments not understood by this manage.py will be passed to django-admin.py
"""

import os
import sys
import glob2
import imp
from argparse import ArgumentParser

def parse_args():
"""Parse edx specific arguments to manage.py"""
parser = ArgumentParser()
subparsers = parser.add_subparsers(title='system', description='edx service to run')

lms = subparsers.add_parser(
'lms',
help='Learning Management System',
add_help=False,
usage='%(prog)s [options] ...'
)
lms.add_argument('-h', '--help', action='store_true', help='show this help message and exit')
lms.add_argument(
'--settings',
help="Which django settings module to use. Will search for a submodule of lms.envs first, and "
"if that module doesn't exist, will search in sys.path. If not provided, the DJANGO_SETTINGS_MODULE "
"environment variable will be used if it is set, otherwise will default to lms.envs.dev")
lms.add_argument(
'-s', '--service-variant',
choices=['lms', 'lms-xml', 'lms-preview'],
default='lms',
help='Which service variant to run, when using the aws environment')
lms.set_defaults(
help_string=lms.format_help(),
settings_base='lms/envs',
default_settings='lms.envs.dev'
)

cms = subparsers.add_parser(
'cms',
help='Studio',
add_help=False,
usage='%(prog)s [options] ...'
)
cms.add_argument(
'--settings',
help="Which django settings module to use. Will search for a submodule of cms.envs first, and "
"if that module doesn't exist, will search in sys.path. If not provided, the DJANGO_SETTINGS_MODULE "
"environment variable will be used if it is set, otherwise will default to cms.envs.dev")
cms.add_argument('-h', '--help', action='store_true', help='show this help message and exit')
cms.set_defaults(
help_string=cms.format_help(),
settings_base='cms/envs',
default_settings='cms.envs.dev',
service_variant='cms'
)


edx_args, django_args = parser.parse_known_args()

if edx_args.help:
print "edX:"
print edx_args.help_string

return edx_args, django_args


if __name__ == "__main__":
edx_args, django_args = parse_args()

if edx_args.settings:
try:
imp.find_module(edx_args.settings, [edx_args.settings_base])
os.environ["DJANGO_SETTINGS_MODULE"] = edx_args.settings_base.replace('/', '.') + "." + edx_args.settings
except ImportError:
imp.find_module(edx_args.settings)
os.environ["DJANGO_SETTINGS_MODULE"] = edx_args.settings
else:
os.environ.setdefault("DJANGO_SETTINGS_MODULE", edx_args.default_settings)
os.environ.setdefault("SERVICE_VARIANT", edx_args.service_variant)
if edx_args.help:
print "Django:"
# This will trigger django-admin.py to print out its help
django_args.insert(0, '--help')

from django.core.management import execute_from_command_line

execute_from_command_line([sys.argv[0]] + django_args)
6 changes: 2 additions & 4 deletions rakelib/django.rake
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@ end

task :fastlms do
# this is >2 times faster that rake [lms], and does not need web, good for local dev
django_admin = ENV['DJANGO_ADMIN_PATH'] || select_executable('django-admin.py', 'django-admin')
sh("#{django_admin} runserver --traceback --settings=lms.envs.dev --pythonpath=.")
sh("./manage.py lms runserver --traceback")
end

# Start :system locally with the specified :env and :options.
Expand All @@ -36,9 +35,8 @@ end
desc "Start #{system} Celery worker"
task "#{system}_worker", [:options] => [:predjango] do |t, args|
args.with_defaults(:options => default_options[system])
django_admin = ENV['DJANGO_ADMIN_PATH'] || select_executable('django-admin.py', 'django-admin')
command = 'celery worker'
sh("#{django_admin} #{command} --loglevel=INFO --settings=#{system}.envs.dev_with_worker --pythonpath=. #{args.join(' ')}")
sh("./manage.py #{system} --settings dev_with_worker #{command} --loglevel=INFO #{args.join(' ')}")
end

# Per environment tasks
Expand Down
3 changes: 1 addition & 2 deletions rakelib/helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@ def select_executable(*cmds)
end

def django_admin(system, env, command, *args)
django_admin = ENV['DJANGO_ADMIN_PATH'] || select_executable('django-admin.py', 'django-admin')
return "#{django_admin} #{command} --traceback --settings=#{system}.envs.#{env} --pythonpath=. #{args.join(' ')}"
return "./manage.py #{system} --settings #{env} #{command} --traceback #{args.join(' ')}"
end

def report_dir_path(dir)
Expand Down
11 changes: 3 additions & 8 deletions scripts/create-dev-env.sh
Original file line number Diff line number Diff line change
Expand Up @@ -495,8 +495,8 @@ mkdir -p "$BASE/log"
mkdir -p "$BASE/db"
mkdir -p "$BASE/data"

rake django-admin[syncdb,lms,dev,--noinput]
rake django-admin[migrate]
./manage.py lms syncdb --noinput --migrate
./manage.py cms syncdb --noinput --migrate

# Configure Git

Expand All @@ -520,18 +520,13 @@ if [[ ! $quiet ]]; then

$ workon mitx

To initialize Django

$ rake django-admin[syncdb]
$ rake django-admin[migrate]

To start the Django on port 8000

$ rake lms

Or to start Django on a different <port#>

$ rake django-admin[runserver,lms,dev,<port#>]
$ ./manage.py lms runserver <port#>

If the Django development server starts properly you
should see:
Expand Down
Loading