diff --git a/aleksis/apps/untis/forms.py b/aleksis/apps/untis/forms.py index 28cff78cacb677cce0106671a62d1ac9e6a97df0..af3c2e53155b7c94a16d5ec01f4a136e03a63ec4 100644 --- a/aleksis/apps/untis/forms.py +++ b/aleksis/apps/untis/forms.py @@ -11,23 +11,4 @@ class UntisUploadForm(forms.Form): untis_xml = forms.FileField(label=_("Untis XML export")) -class GroupSubjectForm(forms.ModelForm): - child_groups = forms.ModelMultipleChoiceField(queryset=Group.objects.all()) - - class Meta: - model = Group - fields = [ - "name", - "short_name", - "untis_subject", - ] - - def __init__(self, *args, **kwargs): - super().__init__(*args, **kwargs) - self.fields["name"].widget = forms.HiddenInput() - self.fields["short_name"].widget = forms.HiddenInput() - - -GroupSubjectFormset = forms.modelformset_factory(Group, form=GroupSubjectForm, max_num=0, extra=0) - EditGroupForm.add_node_to_layout(Fieldset(_("UNTIS import"), "untis_subject")) diff --git a/aleksis/apps/untis/model_extensions.py b/aleksis/apps/untis/model_extensions.py index c5214fb692ce62321c0771531fb9e2fd1d6d7441..0e3088ba5c3beea13299ffd2edc0a47c25595a78 100644 --- a/aleksis/apps/untis/model_extensions.py +++ b/aleksis/apps/untis/model_extensions.py @@ -12,18 +12,6 @@ core_models.Group.field( import_ref_untis=IntegerField(verbose_name=_("UNTIS import reference"), null=True, blank=True) ) -core_models.Group.field( - untis_subject=CharField( - verbose_name=_("UNTIS subject"), - help_text=_( - "The UNTIS import will use this for matching course groups" - "(along with parent groups)." - ), - blank=True, - max_length=255, - ) -) - # Chronos models chronos_models.Subject.field( import_ref_untis=IntegerField(verbose_name=_("UNTIS import reference"), null=True, blank=True) diff --git a/aleksis/apps/untis/templates/untis/groups_subjects.html b/aleksis/apps/untis/templates/untis/groups_subjects.html deleted file mode 100644 index 7f58b1ac4ae69050e8bf9c89283404aff0946293..0000000000000000000000000000000000000000 --- a/aleksis/apps/untis/templates/untis/groups_subjects.html +++ /dev/null @@ -1,69 +0,0 @@ -{# -*- engine:django -*- #} - -{% extends "core/base.html" %} - -{% load i18n %} - -{% block browser_title %}{% blocktrans %}Assign subjects to groups{% endblocktrans %}{% endblock %} -{% block page_title %} - {% blocktrans %}Assign subjects to groups{% endblocktrans %} -{% endblock %} - - -{% block content %} - <div class="alert info"> - <p> - <i class="material-icons left">info</i> - {% blocktrans %} - You can use this form to assign subjects to groups. Please enter the exact names of the subjects as they are - saved in UNTIS (case-insensitive). These values are only used to match course groups while importing from MySQL. - {% endblocktrans %} - </p> - </div> - - <div class="alert warning"> - <p> - <i class="material-icons left">warning</i> - {% blocktrans %} - If there are more than 100 groups, this table will have multiple pages. That means that you must save your - changes on every page. <strong>Please don't change the page before you saved your changes!</strong> - {% endblocktrans %} - </p> - </div> - - <form method="post"> - {% csrf_token %} - {{ formset.management_form }} - - {% include "core/save_button.html" %} - - {% include "components/pagination.html" %} - - <table> - <tr> - <th>{% blocktrans %}Group{% endblocktrans %}</th> - <th>{% blocktrans %}Subject{% endblocktrans %}</th> - </tr> - {% for form in formset %} - {{ form.id }} - <tr> - <td> - {{ form.name }} {{ form.short_name }} - {{ form.name.value }} {% if form.short_name.value %}({{ form.short_name.value }}){% endif %} - </td> - <td>{{ form.untis_subject }}</td> - </tr> - {% endfor %} - </table> - - {% include "components/pagination.html" %} - - {% include "core/save_button.html" %} - - <div class="fixed-action-btn"> - <button class="btn-floating btn-large green" type="submit"> - <i class="large material-icons">save</i> - </button> - </div> - </form> -{% endblock %} diff --git a/aleksis/apps/untis/urls.py b/aleksis/apps/untis/urls.py index db389b6ac1056d854064d4d517c5668b8dd8417f..1a5119ea3c6195ab915588b2e3fd684891294b0b 100644 --- a/aleksis/apps/untis/urls.py +++ b/aleksis/apps/untis/urls.py @@ -4,5 +4,4 @@ from . import views urlpatterns = [ path("import/xml/", views.xml_import, name="untis_xml_import"), - path("groups_subjects", views.groups_subjects, name="untis_groups_subjects"), ] diff --git a/aleksis/apps/untis/views.py b/aleksis/apps/untis/views.py index e7952266ff4bb885df60cbf9b8d8c7ee982d3bc8..48157659a8ef0c2af2ae24a2ae5515956148ee9b 100644 --- a/aleksis/apps/untis/views.py +++ b/aleksis/apps/untis/views.py @@ -1,14 +1,10 @@ -from django.contrib import messages -from django.core.paginator import Paginator from django.http import HttpRequest, HttpResponse from django.shortcuts import render -from django.utils.translation import gettext as _ from rules.contrib.views import permission_required -from aleksis.core.models import Group -from .forms import GroupSubjectFormset, UntisUploadForm +from .forms import UntisUploadForm from .util.xml.xml import untis_import_xml @@ -27,32 +23,3 @@ def xml_import(request: HttpRequest) -> HttpResponse: context["upload_form"] = upload_form return render(request, "untis/xml_import.html", context) - - -@permission_required("untis.assign_subjects_to_groups") -def groups_subjects(request: HttpRequest) -> HttpResponse: - """Assign subjects to groups (for matching by MySQL importer).""" - context = {} - - groups_qs = Group.objects.all() - - # Paginate - paginator = Paginator(groups_qs, 100) - page_number = request.GET.get("page") - page = paginator.get_page(page_number) - groups_paged = groups_qs.filter(id__in=[g.id for g in page]) - - # Create filtered queryset - group_subject_formset = GroupSubjectFormset(request.POST or None, queryset=groups_paged) - - # Check if form is submitted and valid, then save - if request.method == "POST": - if group_subject_formset.is_valid(): - group_subject_formset.save() - messages.success(request, _("Your changes were successfully saved.")) - - context["formset"] = group_subject_formset - context["page"] = page - context["paginator"] = paginator - - return render(request, "untis/groups_subjects.html", context)