From 3974b9c7556552d0e6871d758ab4dee52a07dc74 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20H=C3=B8rl=C3=BCck=20Berg?= <36937807+henrikhorluck@users.noreply.github.com> Date: Sun, 28 Jul 2024 22:39:59 +0200 Subject: [PATCH] Fix various bugs related to marks - Remove the dashboard-view, could also have fixed it, but one should still be able to go through the admin-panel - Fix migration that did not properly update the cause - Add inlines on profiles so we can see all marks/suspensions a user has - Fix the template so that users can see their details again --- apps/authentication/admin.py | 57 +++- apps/marks/admin.py | 16 +- apps/marks/dashboard/__init__.py | 0 apps/marks/dashboard/forms.py | 9 - apps/marks/dashboard/urls.py | 11 - apps/marks/dashboard/views.py | 243 ------------------ ...k_weight_alter_mark_added_date_and_more.py | 2 +- ...mark_category_alter_mark_cause_and_more.py | 118 +++++++++ apps/marks/models.py | 35 ++- assets/dashboard/marks/index.js | 4 - assets/dashboard/marks/less/marks.less | 30 --- assets/dashboard/marks/marks.js | 109 -------- esbuild.mjs | 1 - onlineweb4/urls.py | 1 - templates/dashboard/dashboard.html | 1 - templates/dashboard_base.html | 14 - templates/marks/dashboard/index.html | 57 ---- templates/marks/dashboard/marks_details.html | 117 --------- templates/marks/dashboard/marks_edit.html | 57 ---- templates/marks/dashboard/marks_new.html | 61 ----- templates/profiles/marks.html | 10 +- 21 files changed, 217 insertions(+), 736 deletions(-) delete mode 100644 apps/marks/dashboard/__init__.py delete mode 100644 apps/marks/dashboard/forms.py delete mode 100644 apps/marks/dashboard/urls.py delete mode 100644 apps/marks/dashboard/views.py create mode 100644 apps/marks/migrations/0012_alter_mark_category_alter_mark_cause_and_more.py delete mode 100644 assets/dashboard/marks/index.js delete mode 100644 assets/dashboard/marks/less/marks.less delete mode 100644 assets/dashboard/marks/marks.js delete mode 100644 templates/marks/dashboard/index.html delete mode 100644 templates/marks/dashboard/marks_details.html delete mode 100644 templates/marks/dashboard/marks_edit.html delete mode 100644 templates/marks/dashboard/marks_new.html diff --git a/apps/authentication/admin.py b/apps/authentication/admin.py index 4ce9b5acf..0e70decd5 100644 --- a/apps/authentication/admin.py +++ b/apps/authentication/admin.py @@ -12,10 +12,36 @@ Position, SpecialPosition, ) +from apps.marks.models import MarkDelay, MarkUser, Suspended, Suspension, user_sanctions + + +class MarkUserInline(admin.TabularInline): + model = MarkUser + extra = 0 + fields = ("mark",) + readonly_fields = ("mark",) + + verbose_name = _("Prikk") + verbose_name_plural = _("Prikker") + + +class SuspensionInline(admin.TabularInline): + model = Suspension + extra = 0 + show_change_link = True + fields = ("title", "created_time", "expiration_date") + readonly_fields = ("title", "created_time", "expiration_date") + + verbose_name = _("Suspensjon") + verbose_name_plural = _("Suspensjoner") class OnlineUserAdmin(UserAdmin, VersionAdmin): model = OnlineUser + inlines = ( + MarkUserInline, + SuspensionInline, + ) list_display = [ "username", "first_name", @@ -62,10 +88,32 @@ class OnlineUserAdmin(UserAdmin, VersionAdmin): ) }, ), + ( + _("Sanksjoner"), + { + "fields": ("current_total_sanctions",), + }, + ), ) filter_horizontal = ("groups", "user_permissions") search_fields = ("first_name", "last_name", "username", "ntnu_username") - readonly_fields = ("mark_rules_accepted", "auth0_subject") + readonly_fields = ( + "mark_rules_accepted", + "auth0_subject", + "current_total_sanctions", + ) + + def current_total_sanctions(self, instance: OnlineUser): + match user_sanctions(instance): + case Suspended(): + return "Suspendert" + case MarkDelay(delay): + return _("Forsinket påmelding med %s") % delay + case None: + return "-" + + current_total_sanctions.str = True + current_total_sanctions.short_description = "Nåværende sanksjoner" def is_member(self, instance: OnlineUser): return instance.is_member @@ -77,6 +125,13 @@ def mark_rules_accepted(self, instance: OnlineUser): mark_rules_accepted.boolean = True + def get_queryset(self, *args, **kwargs): + return ( + super() + .get_queryset(*args, **kwargs) + .prefetch_related("marks", "suspension_set") + ) + admin.site.register(OnlineUser, OnlineUserAdmin) diff --git a/apps/marks/admin.py b/apps/marks/admin.py index fa16adc37..2acc2ae1a 100644 --- a/apps/marks/admin.py +++ b/apps/marks/admin.py @@ -15,7 +15,21 @@ class MarkUserInline(admin.TabularInline): @admin.register(Mark) class MarkAdmin(VersionAdmin): inlines = (MarkUserInline,) - list_display = ["__str__", "category", "added_date", "weight"] + fields = [ + "title", + "added_date", + "cause", + "weight", + "description", + "expiration_date", + "ruleset", + ] + + list_display = ["__str__", "category", "cause", "added_date", "weight"] + readonly_fields = ( + "expiration_date", + "ruleset", + ) search_fields = ("title",) def save_model(self, request, obj, form, change): diff --git a/apps/marks/dashboard/__init__.py b/apps/marks/dashboard/__init__.py deleted file mode 100644 index e69de29bb..000000000 diff --git a/apps/marks/dashboard/forms.py b/apps/marks/dashboard/forms.py deleted file mode 100644 index e46a8aae5..000000000 --- a/apps/marks/dashboard/forms.py +++ /dev/null @@ -1,9 +0,0 @@ -from django import forms - -from apps.marks.models import Mark - - -class MarkForm(forms.ModelForm): - class Meta: - model = Mark - fields = ["title", "weight", "description", "category"] diff --git a/apps/marks/dashboard/urls.py b/apps/marks/dashboard/urls.py deleted file mode 100644 index 3a576e590..000000000 --- a/apps/marks/dashboard/urls.py +++ /dev/null @@ -1,11 +0,0 @@ -from django.urls import re_path - -from apps.marks.dashboard import views - -urlpatterns = [ - re_path(r"^$", views.index, name="marks_index"), - re_path(r"^(?P\d+)/$", views.marks_details, name="marks_details"), - re_path(r"^(?P\d+)/delete/$", views.marks_delete, name="marks_delete"), - re_path(r"^(?P\d+)/edit/$", views.marks_edit, name="marks_edit"), - re_path(r"^new/$", views.marks_new, name="marks_new"), -] diff --git a/apps/marks/dashboard/views.py b/apps/marks/dashboard/views.py deleted file mode 100644 index f3a723d04..000000000 --- a/apps/marks/dashboard/views.py +++ /dev/null @@ -1,243 +0,0 @@ -import json - -from django.contrib import messages -from django.contrib.auth.decorators import login_required -from django.core.exceptions import PermissionDenied -from django.http import HttpResponse -from django.shortcuts import get_object_or_404, redirect, render -from django.utils import timezone -from guardian.decorators import permission_required - -from apps.authentication.models import OnlineUser as User -from apps.dashboard.tools import get_base_context, has_access -from apps.marks.dashboard.forms import MarkForm -from apps.marks.models import Mark - - -@login_required -@permission_required("marks.view_mark", return_403=True) -def index(request): - """ - Marks overview - """ - - # Check access - if not has_access(request): - raise PermissionDenied - - # Get context - context = get_base_context(request) - - # Find all marks and do additional fixes - marks_collection = [] - marks = Mark.objects.all().order_by("-added_date") - for mark in marks: - marks_temp = mark - marks_temp.users_num = len(mark.given_to.all()) - marks_temp.category_clean = mark.get_category_display() - - marks_collection.append(marks_temp) - - # Add collection to context - context["marks"] = marks_collection - - # Render view - return render(request, "marks/dashboard/index.html", context) - - -@login_required -@permission_required("marks.change_mark", return_403=True) -def marks_details(request, pk): - """ - Display details for a given Mark - """ - - # Check permission - if not has_access(request): - raise PermissionDenied - - # Get context - context = get_base_context(request) - - # Get object - mark = get_object_or_404(Mark, pk=pk) - mark.category_clean = mark.get_category_display() - context["mark"] = mark - - # Get users connected to the mark - context["mark_users"] = mark.given_to.all() - - # AJAX - if request.method == "POST": - if "action" in request.POST: - resp = {"status": 200} - - context, resp = _handle_mark_detail(request, context, resp) - - # Set mark - resp["mark"] = { - "last_changed_date": context["mark"].last_changed_date.strftime( - "%Y-%m-%d" - ), - "last_changed_by": context["mark"].last_changed_by.get_full_name(), - } - - # Return ajax - return HttpResponse(json.dumps(resp), status=resp["status"]) - - # Render view - return render(request, "marks/dashboard/marks_details.html", context) - - -@login_required -@permission_required("marks.add_mark", return_403=True) -def marks_new(request): - if not has_access(request): - raise PermissionDenied - - context = get_base_context(request) - - if request.method == "POST": - mark_form = MarkForm(request.POST) - if not mark_form.is_valid(): - messages.error(request, "Noen av de påkrevde feltene inneholder feil.") - else: - # Save the form data - new_mark = mark_form.save() - - # Save the additional mark data - new_mark.given_by = request.user - new_mark.last_changed_by = request.user - new_mark.save() - - # Add news - messages.success(request, "Prikken ble lagret.") - - return redirect(marks_details, pk=new_mark.id) - else: - context["form"] = MarkForm() - - return render(request, "marks/dashboard/marks_new.html", context) - - -@login_required -@permission_required("marks.change_mark", return_403=True) -def marks_edit(request, pk): - if not has_access(request): - raise PermissionDenied - - context = get_base_context(request) - - if request.method == "POST": - mark = get_object_or_404(Mark, pk=pk) - mark_form = MarkForm(request.POST, instance=mark) - if not mark_form.is_valid(): - messages.error(request, "Noen av de påkrevde feltene inneholder feil.") - else: - # Save the form data - new_mark = mark_form.save() - - # Save the additional mark data - new_mark.last_changed_by = request.user - new_mark.last_changed_date = timezone.now() - new_mark.save() - - # Add news - messages.success(request, "Prikken ble endret.") - - return redirect(marks_details, pk=new_mark.id) - else: - mark = get_object_or_404(Mark, pk=pk) - context["form"] = MarkForm(instance=mark) - - return render(request, "marks/dashboard/marks_edit.html", context) - - -@login_required -@permission_required("marks.delete_mark", return_403=True) -def marks_delete(request, pk): - """ - Display details for a given Mark - """ - - # Check permission - if not has_access(request): - raise PermissionDenied - - # Get object - mark = get_object_or_404(Mark, pk=pk) - - # Save message - messages.success(request, f"{mark.title} er ble slettet.") - - # Delete the mark - mark.delete() - - # Redirect user - return redirect(index) - - -def _handle_mark_detail(request, context, resp): - if request.POST["action"] == "remove_user": - # Get the correct user - user = get_object_or_404(User, pk=int(request.POST["user_id"])) - - # Remove from the set - mark_users_filtered = [] - for mark_user in context["mark_users"]: - if mark_user.user == user: - # Delete the object in the database - mark_user.delete() - else: - mark_users_filtered.append(mark_user) - - # Update mark - context["mark"].last_changed_date = timezone.now() - context["mark"].last_changed_by = request.user - context["mark"].save() - - # Set information to resp - resp["message"] = "{} ble fjernet fra {}".format( - user.get_full_name(), - context["mark"].title, - ) - resp["mark_users"] = [ - {"user": mu.user.get_full_name(), "id": mu.user.id} - for mu in mark_users_filtered - ] - - elif request.POST["action"] == "add_user": - user = get_object_or_404(User, pk=int(request.POST["user_id"])) - - # Check if user already is the lucky owner of this prikk - for context_mark_user in context["mark_users"]: - if context_mark_user.user == user: - resp = { - "status": 500, - "message": "{} har allerede prikken {}.".format( - user.get_full_name(), context["mark"].title - ), - } - - # Return ajax - return HttpResponse(json.dumps(resp), status=500) - - # Update mark - context["mark"].last_changed_date = timezone.now() - context["mark"].last_changed_by = request.user - context["mark"].users.add(user) - context["mark"].save() - - # Sort the list of mark users - resp["mark_users"] = [ - {"user": u.get_full_name(), "id": u.user.id} for u in context["mark"].users - ] - resp["mark_users"].sort(key=lambda x: x["user"]) - - # Set information to resp - resp["message"] = "{} ble tildelt prikken {}.".format( - user.get_full_name(), - context["mark"].title, - ) - - return context, resp diff --git a/apps/marks/migrations/0009_mark_weight_alter_mark_added_date_and_more.py b/apps/marks/migrations/0009_mark_weight_alter_mark_added_date_and_more.py index ff5893ad6..ce127c886 100644 --- a/apps/marks/migrations/0009_mark_weight_alter_mark_added_date_and_more.py +++ b/apps/marks/migrations/0009_mark_weight_alter_mark_added_date_and_more.py @@ -9,7 +9,7 @@ def migrate_mark_category(apps, schema_editor): Mark = apps.get_model("marks", "Mark") - marks = Mark.objects.iterator(chunk_size=50) + marks = list(Mark.objects.iterator(chunk_size=50)) for m in marks: for title, cause in [ ("Manglende oppmøte", MarkClass.Cause.NO_ATTENDANCE), diff --git a/apps/marks/migrations/0012_alter_mark_category_alter_mark_cause_and_more.py b/apps/marks/migrations/0012_alter_mark_category_alter_mark_cause_and_more.py new file mode 100644 index 000000000..7081fc859 --- /dev/null +++ b/apps/marks/migrations/0012_alter_mark_category_alter_mark_cause_and_more.py @@ -0,0 +1,118 @@ +# Generated by Django 5.0.7 on 2024-07-28 20:52 + +import django.db.models.deletion +import django.utils.timezone +from django.conf import settings +from django.db import migrations, models + +import apps.marks.models + + +class Migration(migrations.Migration): + dependencies = [ + ("marks", "0011_remove_suspension_active_and_more"), + migrations.swappable_dependency(settings.AUTH_USER_MODEL), + ] + + operations = [ + migrations.AlterField( + model_name="mark", + name="category", + field=models.SmallIntegerField( + choices=[ + (0, "Ingen"), + (1, "Sosialt"), + (2, "Bedriftspresentasjon"), + (3, "Kurs"), + (4, "Tilbakemelding"), + (5, "Kontoret"), + (6, "Betaling"), + ], + default=0, + editable=False, + verbose_name="kategori", + ), + ), + migrations.AlterField( + model_name="mark", + name="cause", + field=models.CharField( + choices=[ + ("sen avmelding", "Avmelding etter avmeldingsfrist"), + ( + "veldig sen avmelding", + "Avmelding under 2 timer før arrangementstart", + ), + ( + "sent oppmøte", + "Oppmøte etter arrangementets start eller innslipp er ferdig", + ), + ("manglende oppmøte", "Manglende oppmøte"), + ( + "manglende tilbakemelding", + "Svarte ikke på tilbakemeldingsskjema", + ), + ("manglende betaling", "Manglende betaling"), + ("annet", "Annet"), + ], + default="annet", + max_length=30, + verbose_name="årsak", + ), + ), + migrations.AlterField( + model_name="mark", + name="description", + field=models.TextField( + blank=True, + help_text="Settes automatisk basert på årsak.", + max_length=255, + verbose_name="beskrivelse", + ), + ), + migrations.AlterField( + model_name="mark", + name="ruleset", + field=models.ForeignKey( + default=apps.marks.models.MarkRuleSet.get_current_rule_set_pk, + editable=False, + on_delete=django.db.models.deletion.CASCADE, + to="marks.markruleset", + verbose_name="Gjeldene prikkregler", + ), + ), + migrations.AlterField( + model_name="mark", + name="weight", + field=models.PositiveSmallIntegerField( + blank=True, + help_text="Settes automatisk basert på årsak. Se prikkreglene for veiledning", + verbose_name="Vekting", + ), + ), + migrations.AlterField( + model_name="markuser", + name="user", + field=models.ForeignKey( + on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL + ), + ), + migrations.AlterField( + model_name="suspension", + name="created_time", + field=models.DateTimeField( + default=django.utils.timezone.now, + editable=False, + verbose_name="Utdelt tidspunkt", + ), + ), + migrations.AlterField( + model_name="suspension", + name="user", + field=models.ForeignKey( + editable=False, + on_delete=django.db.models.deletion.CASCADE, + to=settings.AUTH_USER_MODEL, + ), + ), + ] diff --git a/apps/marks/models.py b/apps/marks/models.py index b5b2a8a50..8e47404bc 100644 --- a/apps/marks/models.py +++ b/apps/marks/models.py @@ -117,7 +117,7 @@ class Cause(models.TextChoices): _("Svarte ikke på tilbakemeldingsskjema"), ) MISSED_PAYMENT = "manglende betaling", _("Manglende betaling") - OTHER = "annet", _("Ukjent grunn") + OTHER = "annet", _("Annet") def weight(self) -> int: match self: @@ -138,7 +138,11 @@ def weight(self) -> int: return 3 title = models.CharField(_("tittel"), max_length=155) - weight = models.SmallIntegerField(_("Vekting, se prikkreglene for veiledning")) + weight = models.PositiveSmallIntegerField( + _("Vekting"), + help_text="Settes automatisk basert på årsak. Se prikkreglene for veiledning", + blank=True, + ) added_date = models.DateField(_("utdelt dato"), default=date.today) given_by = models.ForeignKey( User, @@ -161,25 +165,25 @@ def weight(self) -> int: blank=False, on_delete=models.SET_NULL, ) - description = models.CharField( + description = models.TextField( _("beskrivelse"), max_length=255, - help_text=_( - "Hvis dette feltet etterlates blankt vil det fylles med en standard grunn for typen prikk som er valgt." - ), + help_text=_("Settes automatisk basert på årsak."), blank=True, ) category = models.SmallIntegerField( - _("kategori"), choices=Category.choices, default=0 + _("kategori"), choices=Category.choices, default=0, editable=False ) cause = models.CharField( _("årsak"), max_length=30, choices=Cause.choices, default=Cause.OTHER ) users = models.ManyToManyField(through="MarkUser", to=User, related_name="marks") ruleset = models.ForeignKey( + verbose_name=_("Gjeldene prikkregler"), to="MarkRuleSet", default=MarkRuleSet.get_current_rule_set_pk, on_delete=models.CASCADE, + editable=False, ) expiration_date = models.DateField(_("Utløpsdato")) @@ -192,9 +196,12 @@ def save(self, *args, **kwargs): self.added_date, self.added_date + self.ruleset.duration ) - if self.weight is None: + if not self.pk: self.weight = self.Cause(self.cause).weight() + if not self.description: + self.description = self.Cause(self.cause).label + return super().save(*args, **kwargs) def __str__(self): @@ -215,7 +222,7 @@ class MarkUser(models.Model): mark = models.ForeignKey( Mark, related_name="given_to", on_delete=models.CASCADE, editable=False ) - user = models.ForeignKey(User, on_delete=models.CASCADE, editable=False) + user = models.ForeignKey(User, on_delete=models.CASCADE) """this is here for historical reasons, the mark system used to have expirations build on each other""" expiration_date = models.DateField( @@ -223,7 +230,7 @@ class MarkUser(models.Model): ) def __str__(self): - return _("Mark entry for user: %s") % self.user.get_full_name() + return _("Prikk gitt til: %s") % self.user.get_full_name() def save(self, *args, **kwargs): now = timezone.now() @@ -290,10 +297,12 @@ def inactive_suspensions( return cls.objects.filter(user=user, expiration_date__lte=today) - user = models.ForeignKey(User, on_delete=models.CASCADE) + user = models.ForeignKey(User, on_delete=models.CASCADE, editable=False) title = models.CharField(_("tittel"), max_length=64) description = models.CharField(_("beskrivelse"), max_length=255) - created_time = models.DateTimeField(default=timezone.now, editable=False) + created_time = models.DateTimeField( + default=timezone.now, editable=False, verbose_name=_("Utdelt tidspunkt") + ) # the mark is active up to but _not including_ the expiry date expiration_date = models.DateField(_("utløpsdato"), null=True, blank=True) @@ -408,7 +417,7 @@ def should_be_suspended(u: User, today: date): raise InvalidOperation("Invalid sanction") -def user_sanctions(user: User, today: date | None) -> UserSanction | None: +def user_sanctions(user: User, today: date | None = None) -> UserSanction | None: if today is None: today = date.today() diff --git a/assets/dashboard/marks/index.js b/assets/dashboard/marks/index.js deleted file mode 100644 index 9d1bb8007..000000000 --- a/assets/dashboard/marks/index.js +++ /dev/null @@ -1,4 +0,0 @@ -import Marks from './marks'; -import './less/marks.less'; - -Marks.init(); diff --git a/assets/dashboard/marks/less/marks.less b/assets/dashboard/marks/less/marks.less deleted file mode 100644 index 0adb2febd..000000000 --- a/assets/dashboard/marks/less/marks.less +++ /dev/null @@ -1,30 +0,0 @@ -.marks_table_splitter { - border-right: 1px solid #ddd; -} - -.twitter-typeahead { - width: 100%; -} - -.tt-suggestions { - margin-top: -1px; - width: 300px; - border: 1px solid #66afe9; - border-radius: 4px; - box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075), 0 0 8px rgba(102, 175, 266, 0.6); - background-color: #fff; - - .user-meta h4 { - font-size: 14px; - padding-left: 5px; - line-height: 20px; - margin-top: 5px; - margin-bottom: 5px; - } - - .user-meta h4:hover { - background-color: #eee; - } -} - -.tt-hint { display: none; } diff --git a/assets/dashboard/marks/marks.js b/assets/dashboard/marks/marks.js deleted file mode 100644 index afd643243..000000000 --- a/assets/dashboard/marks/marks.js +++ /dev/null @@ -1,109 +0,0 @@ -import jQuery from 'jquery'; -import { plainUserTypeahead } from 'common/typeahead'; -import { ajax, showStatusMessage } from 'common/utils'; - -const Marks = (function PrivateMarks($) { - // Private helper method to draw the user table - // - // :param tbody: the ID of the element of the table - // :param data: the JSON parsed data returned by the server - const drawTable = (tbody, data) => { - let tbodyHtml = ''; - $(data.mark_users).each((i) => { - tbodyHtml += ` - - - ${data.mark_users[i].user} - - - - - `; - }); - $(`#${tbody}`).html(tbodyHtml); - - $(data.mark_users).each((i) => { - const user = data.mark_users[i]; - $(`#user_${user.id}`).on('click', (e) => { - e.preventDefault(); - Marks.user.remove(user.id); - }); - }); - }; - - // Private generic ajax handler. - // - // :param id: user ID in database - // :param action: either 'remove_user' or 'add_user' - const ajaxUsermod = (id, action) => { - const url = window.location.href.toString(); - const postData = { - user_id: id, - action, - }; - const success = (data) => { - if (action === 'remove_user' || action === 'add_user') { - const jsonData = JSON.parse(data); - const mark = jsonData.mark; - - drawTable('userlist', jsonData); - showStatusMessage(jsonData.message, 'alert-success'); - - $('#dashboard-marks-changed-by').html(mark.last_changed_by); - $('#dashboard-marks-changed-time').html(mark.last_changed_date); - } - }; - const error = (xhr) => { - const response = jQuery.parseJSON(xhr.responseText); - showStatusMessage(response.message, 'alert-danger'); - }; - - ajax('POST', url, postData, success, error, null); - }; - - return { - - // Bind them buttons here - init() { - // Bind add users button - $('#marks_details_users_button').on('click', (e) => { - e.preventDefault(); - $('#marks_details_users').slideToggle(200); - $('#usersearch').focus(); - }); - - // Bind remove user buttons - $('.remove-user').each(function removeUser() { - const userId = $(this).attr('id'); - $(this).on('click', (e) => { - e.preventDefault(); - Marks.user.remove(userId); - }); - }); - - /* Typeahead for user search */ - plainUserTypeahead($('#usersearch'), (e, datum) => { - ($(() => { - Marks.user.add(datum.id); - $('#usersearch').val(''); - })); - }); - }, - - // User module, has add and remove functions - user: { - remove(userId) { - if (confirm('Er du sikker på at du vil fjerne prikken fra denne brukeren?')) { - ajaxUsermod(userId, 'remove_user'); - } - }, - - add(userId) { - ajaxUsermod(userId, 'add_user'); - }, - }, - }; -}(jQuery)); - - -export default Marks; diff --git a/esbuild.mjs b/esbuild.mjs index 6a1292720..c95555fbc 100644 --- a/esbuild.mjs +++ b/esbuild.mjs @@ -18,7 +18,6 @@ let entryPoints = [ { out: 'dashboardGallery', in: 'assets/dashboard/gallery/index.js' }, { out: 'dashboardGroups', in: 'assets/dashboard/groups/index.js' }, { out: 'dashboardHobbies', in: 'assets/dashboard/hobbies/index.jsx' }, - { out: 'dashboardMarks', in: 'assets/dashboard/marks/index.js' }, { out: 'dashboardPosters', in: 'assets/dashboard/posters/index.js' }, { out: 'dashboardResources', in: 'assets/dashboard/resources/index.jsx' }, { out: 'dashboardWebshop', in: 'assets/dashboard/webshop/index.js' }, diff --git a/onlineweb4/urls.py b/onlineweb4/urls.py index ecbd4fb70..2d6a78787 100644 --- a/onlineweb4/urls.py +++ b/onlineweb4/urls.py @@ -156,7 +156,6 @@ def get_context_data(self, **kwargs): if "apps.marks" in settings.INSTALLED_APPS: urlpatterns += [ re_path(r"^marks/", include("apps.marks.urls")), - re_path(r"^dashboard/marks/", include("apps.marks.dashboard.urls")), ] if "apps.notifications" in settings.INSTALLED_APPS: diff --git a/templates/dashboard/dashboard.html b/templates/dashboard/dashboard.html index b8c46f743..400ea020f 100644 --- a/templates/dashboard/dashboard.html +++ b/templates/dashboard/dashboard.html @@ -29,7 +29,6 @@

Velkommen til Online Dashboard

  • Karrieremuligheter
  • Artikler
  • Plakatbestilling
  • -
  • Prikker
  • diff --git a/templates/dashboard_base.html b/templates/dashboard_base.html index 165875a95..08f2cd5ce 100644 --- a/templates/dashboard_base.html +++ b/templates/dashboard_base.html @@ -185,20 +185,6 @@

    Velkommen
    {{ request.user.first_name {% endif %} - {% if 'marks.view_mark' in user_permissions %} -
  • - - Prikker - - - -
  • - {% endif %} {% if 'resourcecenter.change_resource' in user_permissions %}
  • diff --git a/templates/marks/dashboard/index.html b/templates/marks/dashboard/index.html deleted file mode 100644 index dd4ad79b3..000000000 --- a/templates/marks/dashboard/index.html +++ /dev/null @@ -1,57 +0,0 @@ -{% extends 'dashboard_base.html' %} -{% load render_bundle from webpack_loader %} -{% block title %}Prikker - Online Dashboard{% endblock %} - -{% block styles %} - {{ block.super }} - {% render_bundle 'dashboardMarks' 'css' %} -{% endblock %} - -{% block js %} - {{ block.super }} - {% render_bundle 'dashboardMarks' 'js' attrs='async type="module"' %} -{% endblock %} - -{% block page-header %} -Prikker -{% endblock %} - -{% block breadcrumbs %} -
  • Prikker
  • -{% endblock %} - -{% block content %} - -
    -
    -
    -

    Her finner du en oversikt over alle utdelte prikker.

    - - - - - - - - - - - - {% for mark in marks %} - - - - - - - - {% endfor %} - -
    TittelAntall mottakereGittKategoriBeskrivelse
    {{ mark.title }}{{ mark.users_num }}{{ mark.added_date|date:'Y-m-d' }}{{ mark.category_clean }}{{ mark.description }}
    -
    -
    -{% endblock %} diff --git a/templates/marks/dashboard/marks_details.html b/templates/marks/dashboard/marks_details.html deleted file mode 100644 index c76f08c55..000000000 --- a/templates/marks/dashboard/marks_details.html +++ /dev/null @@ -1,117 +0,0 @@ -{% extends 'dashboard_base.html' %} -{% load render_bundle from webpack_loader %} -{% block title %}Prikker - Online Dashboard{% endblock %} - -{% block styles %} - {{ block.super }} - {% render_bundle 'dashboardMarks' 'css' %} -{% endblock %} - -{% block js %} - {{ block.super }} - {% render_bundle 'dashboardMarks' 'js' attrs='async type="module"' %} -{% endblock %} - - -{% block page-header %} -{{ mark.title }} -{% endblock %} - -{% block breadcrumbs %} -
  • Prikker
  • -
  • {{ mark.title }}
  • -{% endblock %} - -{% block content %} -
    -
    - Legg til - Endre - Slett - -
    -
    -
    -
    -
    -
    -
    -

    - Gitt til -

    -
    -
    -

    Oversikt over brukere som har fått denne prikken.

    - - - - - - - - {% for m_user in mark_users %} - - - - {% endfor %} - -
    Navn
    - {{ m_user.user.get_full_name }} - - - -
    -
    -
    -
    -
    -
    -
    -

    - Detaljer -

    -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    Tittel{{ mark.title }}Kategori{{ mark.category_clean }}
    Gitt av{{ mark.given_by.get_full_name }}Gitt den{{ mark.added_date|date:'Y-m-d' }}
    Sist endret av{{ mark.last_changed_by.get_full_name }}Sist endret{{ mark.last_changed_date|date:'Y-m-d' }}
    Vekt{{ mark.weight }}
    Årsak{{ mark.get_cause_display }}
    Detaljer{{ mark.description }}
    -
    -
    -
    -
    - -{% endblock %} diff --git a/templates/marks/dashboard/marks_edit.html b/templates/marks/dashboard/marks_edit.html deleted file mode 100644 index cc6041638..000000000 --- a/templates/marks/dashboard/marks_edit.html +++ /dev/null @@ -1,57 +0,0 @@ -{% extends 'dashboard_base.html' %} -{% load render_bundle from webpack_loader %} -{% load crispy_forms_tags %} -{% load addcss %} - -{% block title %}Ny prikk - Online Dashboard{% endblock %} - -{% block styles %} - {{ block.super }} - {% render_bundle 'dashboardMarks' 'css' %} -{% endblock %} - -{% block js %} - {{ block.super }} - {% render_bundle 'dashboardMarks' 'js' attrs='async type="module"' %} -{% endblock %} - -{% block page-header %} -Ny prikk -{% endblock %} - -{% block breadcrumbs %} -
  • Prikker
  • -
  • Ny prikk
  • -{% endblock %} - -{% block content %} -
    - {% csrf_token %} -
    -
    - -
    -
    -
    -
    -
    -
    -
    - {% for field in form %} -
    - -
    - Navn - {{ field|addclass:"form-control" }} - {% if field.errors %} -

    {{ field.errors }}

    - {% endif %} -
    -
    - {% endfor %} -
    -
    -
    -
    -
    -{% endblock %} diff --git a/templates/marks/dashboard/marks_new.html b/templates/marks/dashboard/marks_new.html deleted file mode 100644 index bb9a17507..000000000 --- a/templates/marks/dashboard/marks_new.html +++ /dev/null @@ -1,61 +0,0 @@ -{% extends 'dashboard_base.html' %} -{% load render_bundle from webpack_loader %} -{% load crispy_forms_tags %} -{% load addcss %} - -{% block title %}Ny prikk - Online Dashboard{% endblock %} - -{% block styles %} - {{ block.super }} - {% render_bundle 'dashboardMarks' 'css' %} -{% endblock %} - -{% block js %} - {{ block.super }} - {% render_bundle 'dashboardMarks' 'js' attrs='async type="module"' %} -{% endblock %} - - -{% block page-header %} -Ny prikk -{% endblock %} - -{% block breadcrumbs %} -
  • Prikker
  • -
  • Ny prikk
  • -{% endblock %} - -{% block content %} -
    - {% csrf_token %} -
    -
    - -
    -
    -
    -
    -
    -
    -
    -

    Detaljer

    -
    -
    - {% for field in form %} -
    - -
    - Navn - {{ field|addclass:"form-control" }} - {% if field.errors %} -

    {{ field.errors }}

    - {% endif %} -
    -
    - {% endfor %} -
    -
    -
    -
    -
    -{% endblock %} diff --git a/templates/profiles/marks.html b/templates/profiles/marks.html index 714c6fa5c..feadfc573 100644 --- a/templates/profiles/marks.html +++ b/templates/profiles/marks.html @@ -32,13 +32,13 @@

    {{ heading|capfirst }}
    {% if mark_list|length == 0 %} Du har ingen {{ heading }}. {% endif %} - {% for mark_user in mark_list %} + {% for m in mark_list %}
    -

    {{ mark_user.mark.title }} {{ mark_user.mark.added_date }}

    -

    {{ mark_user.mark.description}}

    -

    Kategori: {{ mark_user.mark.get_category_display }}

    -

    Utløpsdato: {{ mark_user.expiration_date }}

    +

    {{ m.title }} {{ m.added_date }}

    +

    {{ m.description}}

    +

    Årsak: {{ m.get_cause_display }}

    +

    Utløpsdato: {{ m.expiration_date }}

    {% endfor %}