* Python code cleanup by the cleanup-python-code Jenkins job. This pull request was generated by the cleanup-python-code Jenkins job, which ran ``` cd lms/djangoapps/dashboard; find . -type f -name '*.py' | while read fname; do sed -i 's/ # lint-amnesty, pylint: disable=super-with-arguments//; s/ # lint-amnesty, pylint: disable=import-error, wrong-import-order//; s/ # lint-amnesty, pylint: disable=wrong-import-order//' "$fname"; done; find . -type f -name '*.py' | while read fname; do pyupgrade --exit-zero-even-if-changed --py3-plus --py36-plus --py38-plus "$fname"; done; isort --recursive . ``` The following packages were installed: `pyupgrade,isort` * feedback done Co-authored-by: Zulqarnain <muhammad.zulqarnain@arbisoft.com>
26 lines
903 B
Python
26 lines
903 B
Python
# lint-amnesty, pylint: disable=missing-module-docstring
|
|
from django.core.management.base import BaseCommand, CommandError
|
|
from opaque_keys.edx.keys import CourseKey
|
|
|
|
from lms.djangoapps.courseware.courses import get_course
|
|
|
|
|
|
class Command(BaseCommand): # lint-amnesty, pylint: disable=missing-class-docstring
|
|
help = 'Write a discussion link for a given course on standard output.'
|
|
|
|
def add_arguments(self, parser):
|
|
parser.add_argument('course_id',
|
|
help='course for which to write a discussion link')
|
|
|
|
def handle(self, *args, **options):
|
|
course_id = options['course_id']
|
|
|
|
course_key = CourseKey.from_string(course_id)
|
|
|
|
course = get_course(course_key)
|
|
if not course:
|
|
raise CommandError(f'Invalid course id: {course_id}')
|
|
|
|
if course.discussion_link:
|
|
self.stdout.write(course.discussion_link)
|