Skip to content

Commit a4ffcd5

Browse files
authored
Merge pull request #944 from uw-it-aca/develop
Develop
2 parents 8d36616 + 83ec2a4 commit a4ffcd5

File tree

2 files changed

+49
-1
lines changed

2 files changed

+49
-1
lines changed

docker/test.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ elif [ -d ${DJANGO_APP}/static/js ]; then
2121
run_test "jshint ${DJANGO_APP}/static/js --verbose"
2222
fi
2323

24-
run_test "coverage run --source=${DJANGO_APP} '--omit=*/migrations/*' manage.py test ${DJANGO_APP}"
24+
run_test "python -Wd -m coverage run --source=${DJANGO_APP} '--omit=*/migrations/*' manage.py test ${DJANGO_APP}"
2525

2626
# put generated coverage result where it will get processed
2727
cp .coverage.* /coverage
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
# Copyright 2024 UW-IT, University of Washington
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
5+
from django.core.management.base import BaseCommand
6+
from django.conf import settings
7+
from sis_provisioner.dao.canvas import (
8+
get_course_report_data, DataFailureException)
9+
from uw_canvas.collaborations import Collaborations
10+
from logging import getLogger
11+
import csv
12+
13+
logger = getLogger(__name__)
14+
15+
16+
class Command(BaseCommand):
17+
help = ('Create a report of all course collaborations')
18+
19+
def handle(self, *args, **options):
20+
client = Collaborations()
21+
22+
outpath = 'course-collaborations.csv'
23+
outfile = open(outpath, 'w')
24+
csv.register_dialect('unix_newline', lineterminator='\n')
25+
writer = csv.writer(outfile, dialect='unix_newline')
26+
writer.writerow([
27+
'course_id', 'course_sis_id', 'collaboration_id',
28+
'collaboration_type', 'document_id', 'url', 'title'])
29+
30+
report_data = get_course_report_data()
31+
header = report_data.pop(0)
32+
for row in csv.reader(report_data):
33+
if not len(row):
34+
continue
35+
36+
canvas_id = row[0]
37+
course_sis_id = row[1]
38+
try:
39+
for col in client.get_collaborations_for_course(canvas_id):
40+
writer.writerow([
41+
canvas_id, course_sis_id, col.collaboration_id,
42+
col.collaboration_type, col.document_id, col.url,
43+
col.title])
44+
except DataFailureException as ex:
45+
logger.info(f'ERROR fetching collaborations, {ex}')
46+
continue
47+
48+
outfile.close()

0 commit comments

Comments
 (0)