diff --git a/ubiquity/tutoring/tables.py b/ubiquity/tutoring/tables.py index f3a247592c70b87a738152cd75fda2950905e65f..5917460dd7d0bc89825b98c410b080b86d373d9c 100644 --- a/ubiquity/tutoring/tables.py +++ b/ubiquity/tutoring/tables.py @@ -80,7 +80,7 @@ class PracticalWorkTable(tables.Table): """ queryset = queryset.annotate( groups=Group.objects.filter(practical_work=OuterRef('id')).values('practical_work_id') - .annotate(Count("practical_work_id")).values("practical_work_id__count") + .annotate(Count("practical_work_id")).values("practical_work_id__count") ).order_by(("-" if is_descending else "") + "groups") return queryset, True @@ -102,19 +102,16 @@ class GroupTable(tables.Table): id = tables.Column(verbose_name=_("Group")) teacher_key = tables.Column(orderable=False, verbose_name=_('Teacher key')) student_key = tables.Column(verbose_name=_('Group key'), orderable=False) + action = tables.Column(orderable=False, empty_values=[], verbose_name=_('Access')) class Meta: """The meta class for GroupTable class""" model = Group order_by = "id" - fields = ['id', 'teacher_key', 'student_key'] + fields = ['id', 'teacher_key', 'student_key', 'action'] attrs = ATTRIBUTES row_attrs = { - "class": "text-center clickable", - "data-href": lambda record: reverse_lazy('group', kwargs={'pk': record.practical_work.id, - 'group_number': record.group_number(), - 'teacher_key': record.teacher_key}), - "onclick": "window.document.location = this.dataset.href;" + "class": "text-center", } @staticmethod @@ -144,6 +141,19 @@ class GroupTable(tables.Table): """ return record.group_number() + @staticmethod + def render_action(record): + """ + Method rendering the button to access group + :param record: The group record + :return: The button to access group + """ + access = reverse_lazy('group', kwargs={'pk': record.practical_work.id, + 'group_number': record.group_number(), + 'teacher_key': record.teacher_key}) + return mark_safe(f'<a data-toggle=\"tooltip\" title=\"{_("Access")}\"' + f' class="btn btn-primary mx-1" href="{access}">👁</a>') + class IndicatorColumn(tables.Column): """Class managing the indicator columns"""