diff --git a/aleksis/apps/alsijil/forms.py b/aleksis/apps/alsijil/forms.py index f27596eef71d1c934296e6643b7af280558320c1..975dd5d2af3f65f1a503b87b5bfdffe4d30b011b 100644 --- a/aleksis/apps/alsijil/forms.py +++ b/aleksis/apps/alsijil/forms.py @@ -11,13 +11,7 @@ from material import Layout, Row from aleksis.apps.chronos.managers import TimetableType from aleksis.core.models import Group, Person -from .models import ( - ExcuseType, - ExtraMark, - LessonDocumentation, - PersonalNote, - PersonalNoteFilter, -) +from .models import ExcuseType, ExtraMark, LessonDocumentation, PersonalNote class LessonDocumentationForm(forms.ModelForm): @@ -115,14 +109,6 @@ class RegisterAbsenceForm(forms.Form): remarks = forms.CharField(label=_("Remarks"), max_length=30, required=False) -class PersonalNoteFilterForm(forms.ModelForm): - layout = Layout(Row("identifier", "description"), Row("regex")) - - class Meta: - model = PersonalNoteFilter - fields = ["identifier", "description", "regex"] - - class ExtraMarkForm(forms.ModelForm): layout = Layout("short_name", "name") diff --git a/aleksis/apps/alsijil/menus.py b/aleksis/apps/alsijil/menus.py index 081c1ec2abca720d1f8e4eda519ceae4a931d80b..a3ec5e9cc443a951ca5ddf4803361bd29e0637f9 100644 --- a/aleksis/apps/alsijil/menus.py +++ b/aleksis/apps/alsijil/menus.py @@ -30,12 +30,6 @@ MENUS = { "icon": "rate_review", "validators": ["menu_generator.validators.is_superuser"], }, - { - "name": _("Personal note filters"), - "url": "list_personal_note_filters", - "icon": "filter_list", - "validators": ["menu_generator.validators.is_superuser"], - }, { "name": _("Excuse types"), "url": "excuse_types", diff --git a/aleksis/apps/alsijil/migrations/0004_delete_personal_notes_filter.py b/aleksis/apps/alsijil/migrations/0004_delete_personal_notes_filter.py new file mode 100644 index 0000000000000000000000000000000000000000..d04764b80ebf1318630b71830ea8f3bb030c0468 --- /dev/null +++ b/aleksis/apps/alsijil/migrations/0004_delete_personal_notes_filter.py @@ -0,0 +1,14 @@ +# Generated by Django 3.0.8 on 2020-07-18 15:23 + +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ("alsijil", "0003_extra_mark"), + ] + + operations = [ + migrations.DeleteModel(name="PersonalNoteFilter",), + ] diff --git a/aleksis/apps/alsijil/models.py b/aleksis/apps/alsijil/models.py index 76b3b8a98c4ed20a97d89acf906d66568afc6aeb..8a82caddb631fbc77c074f7b5984b7b56206bf3d 100644 --- a/aleksis/apps/alsijil/models.py +++ b/aleksis/apps/alsijil/models.py @@ -110,29 +110,6 @@ class LessonDocumentation(ExtensibleModel): ] -class PersonalNoteFilter(ExtensibleModel): - """A filter definition that can generate statistics on personal note texts.""" - - identifier = models.CharField( - verbose_name=_("Identifier"), - max_length=30, - validators=[isidentifier], - unique=True, - ) - description = models.CharField( - verbose_name=_("Description"), max_length=60, blank=True, unique=True - ) - - regex = models.CharField( - verbose_name=_("Match expression"), max_length=100, unique=True - ) - - class Meta: - verbose_name = _("Personal note filter") - verbose_name_plural = _("Personal note filters") - ordering = ["identifier"] - - class ExtraMark(ExtensibleModel): """A model for extra marks. diff --git a/aleksis/apps/alsijil/tables.py b/aleksis/apps/alsijil/tables.py index 866da69e08affc731f76d56577aff7e91dee6bfe..bd6b47a73f34c5e4343138993ee70162cd19b847 100644 --- a/aleksis/apps/alsijil/tables.py +++ b/aleksis/apps/alsijil/tables.py @@ -4,21 +4,6 @@ import django_tables2 as tables from django_tables2.utils import A -class PersonalNoteFilterTable(tables.Table): - class Meta: - attrs = {"class": "highlight"} - - identifier = tables.Column() - description = tables.Column() - regex = tables.Column() - edit_filter = tables.LinkColumn( - "edit_personal_note_filter", - args=[A("id")], - text=_("Edit"), - attrs={"a": {"class": "btn-flat waves-effect waves-orange"}}, - ) - - class ExtraMarkTable(tables.Table): class Meta: attrs = {"class": "highlight"} diff --git a/aleksis/apps/alsijil/templates/alsijil/personal_note_filter/list.html b/aleksis/apps/alsijil/templates/alsijil/personal_note_filter/list.html deleted file mode 100644 index 3673e60abb2395a368d6721320dbf654d139d953..0000000000000000000000000000000000000000 --- a/aleksis/apps/alsijil/templates/alsijil/personal_note_filter/list.html +++ /dev/null @@ -1,16 +0,0 @@ -{# -*- engine:django -*- #} - -{% extends "core/base.html" %} -{% load i18n %} -{% load render_table from django_tables2 %} - -{% block browser_title %}{% blocktrans %}All personal note filters{% endblocktrans %}{% endblock %} -{% block page_title %}{% blocktrans %}Personal note filters{% endblocktrans %}{% endblock %} - -{% block content %} - <a href="{% url 'create_personal_note_filter' %}" class="waves-effect waves-light green btn"> - <i class="material-icons left">add</i>{% blocktrans %}Add filter{% endblocktrans %} - </a> - - {% render_table personal_note_filters_table %} -{% endblock %} diff --git a/aleksis/apps/alsijil/templates/alsijil/personal_note_filter/manage.html b/aleksis/apps/alsijil/templates/alsijil/personal_note_filter/manage.html deleted file mode 100644 index 427777439d73975a0cf3434bd507d27077cb9a2a..0000000000000000000000000000000000000000 --- a/aleksis/apps/alsijil/templates/alsijil/personal_note_filter/manage.html +++ /dev/null @@ -1,34 +0,0 @@ -{# -*- engine:django -*- #} -{% extends "core/base.html" %} -{% load material_form i18n static %} - -{% block browser_title %} - {% if personal_note_filter %} - {% trans "Update personal note filter" %} - {% else %} - {% trans "Create personal note filter" %} - {% endif %} -{% endblock %} -{% block page_title %} - {% if personal_note_filter %} - {% trans "Update personal note filter" %} - {% else %} - {% trans "Create personal note filter" %} - {% endif %} -{% endblock %} - - -{% block content %} - <form method="post"> - {% csrf_token %} - {% form form=personal_note_filter_form %}{% endform %} - {% include "core/partials/save_button.html" %} - {% if personal_note_filter %} - <a href="{% url 'delete_personal_note_filter' personal_note_filter.id %}" - class="waves-effect waves-light btn red"> - <i class="material-icons left">delete</i>{% blocktrans %}Delete filter{% endblocktrans %} - </a> - {% endif %} - </form> - -{% endblock %} diff --git a/aleksis/apps/alsijil/templates/alsijil/print/full_register.html b/aleksis/apps/alsijil/templates/alsijil/print/full_register.html index daedc55094382d9dd40269641c1b6349ce7fcc82..6d0ddbacc9fcefb73bd9e36b48ca5562b620d0df 100644 --- a/aleksis/apps/alsijil/templates/alsijil/print/full_register.html +++ b/aleksis/apps/alsijil/templates/alsijil/print/full_register.html @@ -263,29 +263,6 @@ </tr> </table> - {% if personal_note_filters %} - <h5>{% trans 'Statistics on remarks' %}</h5> - <table> - <thead> - <tr> - <th>{% trans 'Description' %}</th> - <th>{% trans 'Count' %}</th> - </tr> - </thead> - - <tbody> - {% for note_filter in personal_note_filters %} - <tr> - <td>{{ note_filter.description }}</td> - {% with "_personal_notes_with_"|add:note_filter.identifier as identifier %} - <td>{{ person|get_dict:identifier }}</td> - {% endwith %} - </tr> - {% endfor %} - </tbody> - </table> - {% endif %} - <h5>{% trans 'Absences and tardiness' %}</h5> <table> <tr> diff --git a/aleksis/apps/alsijil/urls.py b/aleksis/apps/alsijil/urls.py index 12c12bc444f9e91a5c05611133ba567eea2f5b1d..3f68362598ec4c8e624f0d5df42e3d028de7ceb9 100644 --- a/aleksis/apps/alsijil/urls.py +++ b/aleksis/apps/alsijil/urls.py @@ -21,26 +21,6 @@ urlpatterns = [ "print/group/<int:id_>", views.full_register_group, name="full_register_group" ), path("absence/new", views.register_absence, name="register_absence"), - path( - "filters/list", - views.list_personal_note_filters, - name="list_personal_note_filters", - ), - path( - "filters/create", - views.edit_personal_note_filter, - name="create_personal_note_filter", - ), - path( - "filters/edit/<int:id_>", - views.edit_personal_note_filter, - name="edit_personal_note_filter", - ), - path( - "filters/delete/<int:id_>", - views.delete_personal_note_filter, - name="delete_personal_note_filter", - ), path("extra_marks/", views.ExtraMarkListView.as_view(), name="extra_marks"), path( "extra_marks/create/", diff --git a/aleksis/apps/alsijil/views.py b/aleksis/apps/alsijil/views.py index 1e109d7e55e0f22300b7a73f60bc65a828d23705..d97bbc24b45f5b75803436aee3098c498447f73a 100644 --- a/aleksis/apps/alsijil/views.py +++ b/aleksis/apps/alsijil/views.py @@ -24,13 +24,12 @@ from .forms import ( ExcuseTypeForm, ExtraMarkForm, LessonDocumentationForm, - PersonalNoteFilterForm, PersonalNoteFormSet, RegisterAbsenceForm, SelectForm, ) -from .models import ExcuseType, ExtraMark, LessonDocumentation, PersonalNoteFilter -from .tables import ExcuseTypeTable, ExtraMarkTable, PersonalNoteFilterTable +from .models import ExcuseType, ExtraMark, LessonDocumentation +from .tables import ExcuseTypeTable, ExtraMarkTable def lesson( @@ -392,24 +391,8 @@ def full_register_group(request: HttpRequest, id_: int) -> HttpResponse: } ) - # FIXME Move to manager - personal_note_filters = PersonalNoteFilter.objects.all() - for personal_note_filter in personal_note_filters: - persons = persons.annotate( - **{ - "_personal_notes_with_%s" - % personal_note_filter.identifier: Count( - "personal_notes__remarks", - filter=Q( - personal_notes__remarks__iregex=personal_note_filter.regex - ), - ) - } - ) - context["school_term"] = current_school_term context["persons"] = persons - context["personal_note_filters"] = personal_note_filters context["excuse_types"] = ExcuseType.objects.all() context["extra_marks"] = ExtraMark.objects.all() context["group"] = group @@ -451,59 +434,6 @@ def register_absence(request: HttpRequest) -> HttpResponse: return render(request, "alsijil/absences/register.html", context) -def list_personal_note_filters(request: HttpRequest) -> HttpResponse: - context = {} - - personal_note_filters = PersonalNoteFilter.objects.all() - - # Prepare table - personal_note_filters_table = PersonalNoteFilterTable(personal_note_filters) - RequestConfig(request).configure(personal_note_filters_table) - - context["personal_note_filters_table"] = personal_note_filters_table - - return render(request, "alsijil/personal_note_filter/list.html", context) - - -def edit_personal_note_filter( - request: HttpRequest, id_: Optional["int"] = None -) -> HttpResponse: - context = {} - - if id_: - personal_note_filter = PersonalNoteFilter.objects.get(id=id_) - context["personal_note_filter"] = personal_note_filter - personal_note_filter_form = PersonalNoteFilterForm( - request.POST or None, instance=personal_note_filter - ) - else: - personal_note_filter_form = PersonalNoteFilterForm(request.POST or None) - - if request.method == "POST": - if personal_note_filter_form.is_valid(): - personal_note_filter_form.save(commit=True) - - messages.success(request, _("The filter has been saved")) - return redirect("list_personal_note_filters") - - context["personal_note_filter_form"] = personal_note_filter_form - - return render(request, "alsijil/personal_note_filter/manage.html", context) - - -def delete_personal_note_filter(request: HttpRequest, id_: int) -> HttpResponse: - context = {} - - personal_note_filter = get_object_or_404(PersonalNoteFilter, pk=id_) - - PersonalNoteFilter.objects.filter(pk=id_).delete() - - messages.success(request, _("The filter has been deleted.")) - - context["personal_note_filter"] = personal_note_filter - return redirect("list_personal_note_filters") - - class ExtraMarkListView(SingleTableView, PermissionRequiredMixin): """Table of all extra marks."""