Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add group_work_allowed boolean to CourseInstance to avoid expensive l… #1368

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft
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
1 change: 1 addition & 0 deletions course/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ class CourseInstanceAdmin(admin.ModelAdmin):
'course',
'instance_name',
'visible_to_students',
'group_work_allowed',
'starting_time',
'ending_time',
instance_url,
Expand Down
3 changes: 3 additions & 0 deletions course/api/full_serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ class Meta(CourseBriefSerializer.Meta):
'starting_time',
'ending_time',
'visible_to_students',
'group_work_allowed',
# links
'exercises',
'tree',
Expand Down Expand Up @@ -148,6 +149,7 @@ class Meta(AplusModelSerializer.Meta):
'starting_time',
'ending_time',
'visible_to_students',
'group_work_allowed',
'configure_url',
'teachers',
)
Expand Down Expand Up @@ -205,6 +207,7 @@ def update(self, instance: CourseInstance, validated_data: OrderedDict) -> Cours
instance.starting_time = validated_data.get('starting_time', instance.starting_time)
instance.ending_time = validated_data.get('ending_time', instance.ending_time)
instance.visible_to_students = validated_data.get('visible_to_students', instance.visible_to_students)
instance.group_work_allowed = validated_data.get('group_work_allowed', instance.group_work_allowed)
instance.configure_url = validated_data.get('configure_url', instance.configure_url)
instance.save()
self.set_teachers(instance, self.teachers)
Expand Down
20 changes: 20 additions & 0 deletions course/migrations/0059_courseinstance_group_work_allowed.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Generated by Django 4.2.13 on 2024-05-22 08:06

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
("course", "0058_coursemodule_model_answer_and_more"),
]

operations = [
migrations.AddField(
model_name="courseinstance",
name="group_work_allowed",
field=models.BooleanField(
default=True, verbose_name="LABEL_GROUP_WORK_ALLOWED"
),
),
]
4 changes: 4 additions & 0 deletions course/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -614,6 +614,10 @@ class CourseInstance(CourseInstanceProto, models.Model):
verbose_name=_('LABEL_VISIBLE_TO_STUDENTS'),
default=True,
)
group_work_allowed = models.BooleanField(
verbose_name=_('LABEL_GROUP_WORK_ALLOWED'),
default=True,
)
enrollment_audience = models.IntegerField(
verbose_name=_('LABEL_ENROLLMENT_AUDIENCE'),
choices=ENROLLMENT_AUDIENCE.choices,
Expand Down
2 changes: 1 addition & 1 deletion course/templates/course/_course_menu.html
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ <h4 id="course-menu-heading">{% translate "COURSE" %}</h4>
</a>
</li>

{% if instance_max_group_size > 1 %}
{% if instance.group_work_allowed %}
<li class="menu-groups">
<a href="{{ instance|url:'groups' }}">
<span class="glyphicon glyphicon-heart" aria-hidden="true"></span>
Expand Down
2 changes: 1 addition & 1 deletion course/templates/course/groups.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

{% block columns %}
<div class="col-md-7">
{% if instance_max_group_size > 1 %}
{% if instance.group_work_allowed %}

<div class="alert alert-info">
{% translate "[STAFF_HAS_NONE]" as staff_code %}
Expand Down
1 change: 1 addition & 0 deletions edit_course/course_forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ class Meta:
model = CourseInstance
fields = [
'visible_to_students',
'group_work_allowed',
'instance_name',
'url',
'image',
Expand Down
4 changes: 4 additions & 0 deletions locale/en/LC_MESSAGES/django.po
Original file line number Diff line number Diff line change
Expand Up @@ -401,6 +401,10 @@ msgstr "enrolments"
msgid "LABEL_VISIBLE_TO_STUDENTS"
msgstr "visible to students"

#: course/models.py
msgid "LABEL_GROUP_WORK_ALLOWED"
msgstr "students can form groups"

#: course/models.py
msgid "MODEL_NAME_USER_TAG"
msgstr "user tag"
Expand Down
4 changes: 4 additions & 0 deletions locale/fi/LC_MESSAGES/django.po
Original file line number Diff line number Diff line change
Expand Up @@ -402,6 +402,10 @@ msgstr "ilmoittautumiset"
msgid "LABEL_VISIBLE_TO_STUDENTS"
msgstr "näkyy opiskelijoille"

#: course/models.py
msgid "LABEL_GROUP_WORK_ALLOWED"
msgstr "opiskelijat saavat luoda ryhmiä"

#: course/models.py
msgid "MODEL_NAME_USER_TAG"
msgstr "käyttäjämerkintä"
Expand Down
Loading