Skip to content
Open
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
7 changes: 6 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -216,14 +216,19 @@ demo-site: ## create a demo site if app container is running
@${MAKE} superuser
.PHONY: demo-site

ifeq (dev-data,$(firstword $(MAKECMDGOALS)))
DEV_DATA_ARGS := $(wordlist 2,$(words $(MAKECMDGOALS)),$(MAKECMDGOALS))
$(eval $(DEV_DATA_ARGS):;@:)
endif

dev-data: ## create dev data if app container is running
@echo "Check app container is running..."
@if [ $(shell docker container inspect -f '{{.State.Running}}' "$(shell $(COMPOSE) ps -q app)") = "false" ] ; then\
echo "❌ App must be up and running to create dev data.";\
exit 1;\
fi
@$(MANAGE) flush --no-input
@$(COMPOSE_EXEC_APP) python sandbox/manage.py create_dev_data ${ARGS}
@$(COMPOSE_EXEC_APP) python sandbox/manage.py create_dev_data $(DEV_DATA_ARGS)
@${MAKE} search-index
Comment on lines +219 to 232
Copy link

Copilot AI Apr 13, 2026

Choose a reason for hiding this comment

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

make dev-data -- --run-state-courses will result in DEV_DATA_ARGS containing the literal --, so the invoked command becomes create_dev_data -- --run-state-courses. In argparse, -- ends option parsing, which means --run-state-courses will be treated as a positional and the command will fail with an unrecognized argument error. Filter -- out of the forwarded arguments (while still creating a dummy rule for it so make doesn’t try to build it) before passing args to create_dev_data.

Copilot uses AI. Check for mistakes.
@${MAKE} superuser
.PHONY: dev-data
Expand Down
38 changes: 23 additions & 15 deletions src/richie/apps/demo/management/commands/create_dev_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -1204,6 +1204,7 @@ def create_dev_data(
create_certificate_discount=False,
create_credential=False,
create_credential_discount=False,
create_run_state_courses=False,
):
"""
Create a simple site tree structure for developpers to work in realistic environment.
Expand Down Expand Up @@ -1345,21 +1346,21 @@ def create_dev_data(
)
courses.append(course)

# Create courses with explicit course run states to test ordering
log("Creating courses with varied course run states...")
state_courses = create_courses_with_run_states(
languages,
levels,
licences,
lms_endpoint,
organizations,
pages_created,
persons_for_organization,
subjects,
icons,
log=log,
)
courses.extend(state_courses)
if create_run_state_courses:
log("Creating courses with varied course run states...")
state_courses = create_courses_with_run_states(
languages,
levels,
licences,
lms_endpoint,
organizations,
pages_created,
persons_for_organization,
subjects,
icons,
log=log,
)
courses.extend(state_courses)

# Create blog posts under the `News` page
log(f"Creating {NB_OBJECTS['blogposts']} blog posts...")
Expand Down Expand Up @@ -1428,6 +1429,12 @@ def add_arguments(self, parser):
default=False,
help="Create a credential product with a discount.",
)
parser.add_argument(
"--run-state-courses",
action="store_true",
default=False,
help="Create courses with explicit run states to test ordering.",
)

def handle(self, *args, **options):
def log(message):
Expand All @@ -1448,6 +1455,7 @@ def log(message):
create_certificate_discount=options.get("certificate_discount"),
create_credential=options.get("credential"),
create_credential_discount=options.get("credential_discount"),
create_run_state_courses=options.get("run_state_courses"),
)

logger.info("done")