Skip to content
Snippets Groups Projects
Verified Commit 8666add0 authored by Jonathan Weth's avatar Jonathan Weth :keyboard:
Browse files

Add option to mark instructions as done in lesson documentation

parent b0dd660b
No related branches found
No related tags found
1 merge request!215Draft: Resolve "Instructions can be linked to a document as remarks by the group"
...@@ -38,9 +38,11 @@ from .models import ( ...@@ -38,9 +38,11 @@ from .models import (
class LessonDocumentationForm(forms.ModelForm): class LessonDocumentationForm(forms.ModelForm):
layout = Layout("topic", "homework", "group_note")
class Meta: class Meta:
model = LessonDocumentation model = LessonDocumentation
fields = ["topic", "homework", "group_note"] fields = ["topic", "homework", "group_note", "done_instructions"]
def __init__(self, *args, **kwargs): def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs) super().__init__(*args, **kwargs)
......
# Generated by Django 3.2.13 on 2022-06-14 13:51
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('core', '0019_fix_uniqueness_per_site'),
('alsijil', '0017_instruction'),
]
operations = [
migrations.AddField(
model_name='lessondocumentation',
name='done_instructions',
field=models.ManyToManyField(blank=True, null=True, related_name='documentations', to='alsijil.Instruction', verbose_name='Done instructions'),
),
]
...@@ -350,6 +350,14 @@ class LessonDocumentation(RegisterObjectRelatedMixin, ExtensibleModel): ...@@ -350,6 +350,14 @@ class LessonDocumentation(RegisterObjectRelatedMixin, ExtensibleModel):
homework = models.CharField(verbose_name=_("Homework"), max_length=200, blank=True) homework = models.CharField(verbose_name=_("Homework"), max_length=200, blank=True)
group_note = models.CharField(verbose_name=_("Group note"), max_length=200, blank=True) group_note = models.CharField(verbose_name=_("Group note"), max_length=200, blank=True)
done_instructions = models.ManyToManyField(
"Instruction",
blank=True,
null=True,
related_name="documentations",
verbose_name=_("Done instructions"),
)
def carry_over_data(self, all_periods_of_lesson: LessonPeriod): def carry_over_data(self, all_periods_of_lesson: LessonPeriod):
"""Carry over data to given periods in this lesson if data is not already set. """Carry over data to given periods in this lesson if data is not already set.
......
{% load i18n material_form_internal material_form %} {% load i18n material_form_internal material_form data_helpers %}
{% include "alsijil/partials/lesson/heading.html" %} {% include "alsijil/partials/lesson/heading.html" %}
{% include "alsijil/partials/lesson/prev_next.html" with with_save=0 %} {% include "alsijil/partials/lesson/prev_next.html" with with_save=0 %}
...@@ -19,6 +19,29 @@ ...@@ -19,6 +19,29 @@
{% if can_edit_lesson_documentation %} {% if can_edit_lesson_documentation %}
{% form form=lesson_documentation_form %}{% endform %} {% form form=lesson_documentation_form %}{% endform %}
{% if instructions %}
<h6>{% trans "Instructions" %}</h6>
<div class="collection">
{% for instruction in instructions %}
<div class="collection-item">
<i class="material-icons primary-color-text left">{{ instruction.icon|default:"rule" }}</i>
{{ instruction.name }}
<div class="right grey-text darken-4">
{% trans "Instruction done" %}&nbsp;&nbsp;
<label class="secondary-content right">
<input type="checkbox"
class="filled-in"
name="lesson_documentation-done_instructions"
value="{{ instruction.pk }}"
{% if instruction.pk|slugify in lesson_documentation_form.done_instructions.value %}checked{% endif %}>
<span></span>
</label>
</div>
</div>
{% endfor %}
</div>
{% endif %}
{% elif can_view_lesson_documentation %} {% elif can_view_lesson_documentation %}
<table> <table>
<tr> <tr>
......
...@@ -220,11 +220,17 @@ def register_object( ...@@ -220,11 +220,17 @@ def register_object(
lesson_documentation = register_object.get_or_create_lesson_documentation(wanted_week) lesson_documentation = register_object.get_or_create_lesson_documentation(wanted_week)
context["has_documentation"] = bool(lesson_documentation.topic) context["has_documentation"] = bool(lesson_documentation.topic)
instructions = Instruction.objects.on_day(date_of_lesson).filter(
Q(groups__in=groups) | Q(groups__isnull=True)
)
context["instructions"] = instructions
lesson_documentation_form = LessonDocumentationForm( lesson_documentation_form = LessonDocumentationForm(
request.POST or None, request.POST or None,
instance=lesson_documentation, instance=lesson_documentation,
prefix="lesson_documentation", prefix="lesson_documentation",
) )
lesson_documentation_form.fields["done_instructions"].queryset = instructions
# Prefetch object permissions for all related groups of the register object # Prefetch object permissions for all related groups of the register object
# because the object permissions are checked for all groups of the register object # because the object permissions are checked for all groups of the register object
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment