Skip to content
Merged
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
25 changes: 25 additions & 0 deletions .github/workflows/format.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: Check Python Code Formatting

on:
pull_request:
branches:
- main

jobs:
format-check:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.12.x"

- name: Install Black
run: pip install black

- name: Run Black
run: black . --check
4 changes: 3 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,7 @@
"[python]": {
"editor.defaultFormatter": "ms-python.black-formatter",
"editor.formatOnSave": true
}
},
"editor.formatOnPaste": true,
"editor.formatOnSave": true
}
1 change: 1 addition & 0 deletions config/settings/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@
"teleband.instruments",
"teleband.musics",
"teleband.submissions",
"teleband.dashboards",
]
# https://docs.djangoproject.com/en/dev/ref/settings/#installed-apps
INSTALLED_APPS = DJANGO_APPS + THIRD_PARTY_APPS + LOCAL_APPS
Expand Down
1 change: 1 addition & 0 deletions config/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
SpectacularSwaggerView.as_view(url_name="schema"),
name="swagger-ui",
),
path("dashboards/", include("teleband.dashboards.urls", namespace="dashboards")),
] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
if settings.DEBUG:
# Static file serving when using Gunicorn + Uvicorn for local web socket development
Expand Down
479 changes: 479 additions & 0 deletions docs/downloaded.txt

Large diffs are not rendered by default.

474 changes: 474 additions & 0 deletions docs/get_recordings-from-s3.sh

Large diffs are not rendered by default.

Empty file added teleband/dashboards/__init__.py
Empty file.
3 changes: 3 additions & 0 deletions teleband/dashboards/admin.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from django.contrib import admin

# Register your models here.
6 changes: 6 additions & 0 deletions teleband/dashboards/apps.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
from django.apps import AppConfig


class DashboardConfig(AppConfig):
default_auto_field = "django.db.models.BigAutoField"
name = "teleband.dashboards"
Empty file.
3 changes: 3 additions & 0 deletions teleband/dashboards/models.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from django.db import models

# Create your models here.
3 changes: 3 additions & 0 deletions teleband/dashboards/tests.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from django.test import TestCase

# Create your tests here.
9 changes: 9 additions & 0 deletions teleband/dashboards/urls.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
from django.urls import path

from teleband.dashboards.views import AssignmentListView, CourseListView, csv_view
app_name = "dashboards"
urlpatterns = [
path("", AssignmentListView.as_view(), name="assignment_list"),
path("courses/", CourseListView.as_view(), name="course_list"),
path("export/csv/", csv_view, name="export_csv"),
]
101 changes: 101 additions & 0 deletions teleband/dashboards/views.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
from typing import Any
from django.db.models.query import QuerySet
from django.shortcuts import render

from django.views import generic

from teleband.assignments.models import Assignment
from teleband.courses.models import Course
from django.contrib.auth.mixins import UserPassesTestMixin

import csv
from django.http import HttpResponse


class AssignmentListView(UserPassesTestMixin, generic.ListView):
model = Assignment

def get_queryset(self) -> QuerySet[Any]:
results = Assignment.objects.prefetch_related(
"piece",
"piece_plan",
"enrollment",
"enrollment__user",
"enrollment__course",
"enrollment__instrument",
"enrollment__course__owner",
"instrument",
"submissions__attachments",
"submissions__grade",
"submissions__self_grade",
"activity",
).all()
return results

# queryset = Course.objects.prefetch_related(
# "enrollment_set__assignment_set__submissions__attachments"
# ).all()

def test_func(self):
return self.request.user.is_superuser


class CourseListView(UserPassesTestMixin, generic.ListView):
model = Course

def test_func(self):
return self.request.user.is_superuser


def csv_view(request):
"""Function which generates a CSV file for download"""
# select related returns a queryset that will follow foreign-key relationships. This
# is a performance booster which results in a single more complex query but won't require
# database queries
assignments = Assignment.objects.select_related(
"piece",
"piece_plan",
"enrollment",
"enrollment__user",
"enrollment__course",
"enrollment__instrument",
"enrollment__course__owner",
"instrument",
"activity",
).all()

# Create the HttpResponse object with the appropriate CSV header
response = HttpResponse(
content_type="text/csv",
headers={"Content-Disposition": 'attachment; filename="assignment.csv"'}
)

writer = csv.writer(response)
writer.writerow(["ID", "Course ID", "Course Name", "Piece ID", "Piece Name", "Piece Plan ID", "Piece Plan Name",
"Student ID", "Student Instrument ID", "Student Instrument Name", "Assignment Activity ID",
"Assignment Activity", "Assignment Instrument ID", "Assignment Instrument Name", "Submissions ID",
"Submissions Content", "Submissions submitted", "Submissions grade", "Submissions Self Grade",
"Submission Attatchnment ID", "Submission Attachment File", "Submission Attachment Submitted"])
for assn in assignments:
if len(assn.submissions.all()) == 0:

writer.writerow([assn.id, assn.enrollment.course.id, assn.enrollment.course.name, assn.piece.id,
assn.piece.name, assn.piece_plan.id, assn.piece_plan, assn.enrollment.user.id,
assn.enrollment.instrument.id, assn.enrollment.instrument.name, assn.activity.id,
assn.activity, assn.instrument.id, assn.instrument.name, "N/A", "N/A", "N/A",
"N/A", "N/A", "N/A", "N/A", "N/A"])
else:
for sub in assn.submissions.all():
for att in sub.attachments.all():
csv_val = [assn.id, assn.enrollment.course.id, assn.enrollment.course.name, assn.piece.id,
assn.piece.name, assn.piece_plan.id, assn.piece_plan, assn.enrollment.user.id,
assn.enrollment.instrument.id, assn.enrollment.instrument.name, assn.activity.id,
assn.activity, assn.instrument.id, assn.instrument.name, sub.id]
if assn.activity.category == "Create":
csv_val.append("Create, see below")
else:
csv_val.append(sub.content)
csv_val.extend([sub.submitted, sub.grade, sub.self_grade, att.id, att.file, att.submitted])

writer.writerow(csv_val)
return response
19 changes: 19 additions & 0 deletions teleband/static/css/project.css
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,22 @@
background-color: #f2dede;
border-color: #eed3d7;
}

/* https://developer.mozilla.org/en-US/docs/Web/HTML/Element/col#usage_notes */
.dashboard colgroup {
border-inline-start: 2px solid black;
}

.dashboard td,
.dashboard th {
border-inline-end: 1px dashed black;
}

.dashboard thead,
.dashboard tbody {
border-block-end: 2px solid black;
}

.dashboard tr {
border-block-end: 1px dashed black;
}
6 changes: 6 additions & 0 deletions teleband/static/sass/project.scss
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@

// project specific CSS goes here


.dashboard col td {
background-color: red;
/* border-inline-start: ; */
}

////////////////////////////////
//Variables//
////////////////////////////////
Expand Down
Loading