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
12 changes: 7 additions & 5 deletions src/conversations/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
following the testable-first architecture with typed data contracts.
"""

from dataclasses import dataclass
from dataclasses import dataclass, field
from typing import Dict, Optional, List
from uuid import UUID
from datetime import datetime
Expand Down Expand Up @@ -108,9 +108,11 @@ class ConversationDetailData:
messages: List[MessageViewData]
can_submit: bool
is_teacher_test: bool
paste_events: List[PasteEventViewData] = None
rapid_text_growth_events: List[RapidTextGrowthEventViewData] = None
user_id: UUID = None
paste_events: Optional[List[PasteEventViewData]] = field(default=None)
rapid_text_growth_events: Optional[List[RapidTextGrowthEventViewData]] = field(
default=None
)
user_id: Optional[UUID] = field(default=None)


@dataclass
Expand Down Expand Up @@ -156,7 +158,7 @@ def validate_and_authorize_request(
# Create processing request
processing_request = MessageProcessingRequest(
conversation_id=conversation_id,
user=request.user,
user=request.user, # type: ignore[arg-type]
content=content,
message_type=message_type,
)
Expand Down
4 changes: 2 additions & 2 deletions src/courses/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ class Course(models.Model):
code = models.CharField(max_length=256, unique=True)

# Many-to-many relationships
teachers = models.ManyToManyField(
teachers: models.ManyToManyField = models.ManyToManyField(
"accounts.Teacher", through="CourseTeacher", related_name="courses"
)
students = models.ManyToManyField(
students: models.ManyToManyField = models.ManyToManyField(
"accounts.Student", through="CourseEnrollment", related_name="enrolled_courses"
)

Expand Down
34 changes: 29 additions & 5 deletions src/courses/templates/courses/detail.html
Original file line number Diff line number Diff line change
Expand Up @@ -60,13 +60,37 @@ <h2 class="mb-0"><i class="bi bi-file-text"></i> Homeworks</h2>
<div class="list-group">
{% for homework in data.homeworks %}
<a href="{% url 'homeworks:detail' homework.id %}" class="list-group-item list-group-item-action">
<div class="d-flex w-100 justify-content-between">
<h5 class="mb-1">{{ homework.title }}</h5>
<small class="text-muted">
<i class="bi bi-calendar-event"></i> Due: {{ homework.due_date }}
<div class="d-flex w-100 justify-content-between align-items-start">
<div>
<h5 class="mb-1">{{ homework.title }}</h5>
{% if data.user_type == 'teacher' %}
{% if homework.is_draft %}
<span class="badge bg-warning text-dark me-1"><i class="bi bi-pencil-square"></i> Draft</span>
{% if homework.publish_at %}
<span class="badge bg-info text-dark me-1"><i class="bi bi-clock"></i> Publishes {{ homework.publish_at|date:"M d, H:i" }}</span>
{% endif %}
{% elif homework.is_hidden %}
<span class="badge bg-secondary me-1">Hidden</span>
{% elif not homework.is_accessible_to_students %}
<span class="badge bg-danger me-1">Expired</span>
{% elif homework.expires_at %}
<span class="badge bg-primary me-1" title="Expires {{ homework.expires_at|date:'M d, Y' }}">Expires {{ homework.expires_at|date:"M d" }}</span>
{% endif %}
{% endif %}
{% if homework.is_overdue and not homework.is_draft %}
<span class="badge bg-danger me-1">Overdue</span>
{% endif %}
</div>
<small class="text-muted text-nowrap ms-2">
<i class="bi bi-calendar-event"></i> {{ homework.due_date }}
{% if homework.section_count %}
&nbsp;· {{ homework.section_count }} section{{ homework.section_count|pluralize }}
{% endif %}
</small>
</div>
<p class="mb-1 text-muted">{{ homework.description|truncatewords:20 }}</p>
{% if homework.description %}
<p class="mb-1 text-muted small">{{ homework.description|truncatewords:20 }}</p>
{% endif %}
</a>
{% endfor %}
</div>
Expand Down
251 changes: 0 additions & 251 deletions src/courses/templates/courses/homework_form.html

This file was deleted.

2 changes: 1 addition & 1 deletion src/courses/tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -727,7 +727,7 @@ def test_get_homework_create_form_renders(self):
)

self.assertEqual(response.status_code, 200)
self.assertTemplateUsed(response, "courses/homework_form.html")
self.assertTemplateUsed(response, "homeworks/form.html")

def test_create_homework_for_course_success(self):
"""Test that teachers can create homeworks for their courses."""
Expand Down
Loading
Loading