From 14f0af03190e9a979f0a2fdc155b4e455388515a Mon Sep 17 00:00:00 2001 From: Jonathan Weth <git@jonathanweth.de> Date: Thu, 11 Jun 2020 17:07:34 +0200 Subject: [PATCH] Remove legacy subject linking stuff --- aleksis/apps/untis/forms.py | 19 ----- aleksis/apps/untis/model_extensions.py | 12 ---- .../templates/untis/groups_subjects.html | 69 ------------------- aleksis/apps/untis/urls.py | 1 - aleksis/apps/untis/views.py | 35 +--------- 5 files changed, 1 insertion(+), 135 deletions(-) delete mode 100644 aleksis/apps/untis/templates/untis/groups_subjects.html diff --git a/aleksis/apps/untis/forms.py b/aleksis/apps/untis/forms.py index 28cff78..af3c2e5 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 c5214fb..0e3088b 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 7f58b1a..0000000 --- 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 db389b6..1a5119e 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 e795226..4815765 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) -- GitLab