Source code for nlpmed_portal.management.models

# SPDX-FileCopyrightText: Copyright (C) 2026 Omid Jafari <omidjafari.com>
# SPDX-License-Identifier: AGPL-3.0-or-later
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

from auditlog.registry import auditlog
from django.db import models
from simple_history.models import HistoricalRecords
from simple_history.models import HistoricForeignKey

from nlpmed_portal.users.models import User as MainUser


[docs] class User(models.Model): class Meta: permissions = (("can_impersonate", "Can impersonate other users"),)
[docs] class Group(models.Model): pass
[docs] class Backend(models.Model): pass
[docs] class Job(models.Model): pass
[docs] class Feedback(models.Model): user = HistoricForeignKey(MainUser, on_delete=models.CASCADE) message = models.TextField() created_at = models.DateTimeField(auto_now_add=True) def __str__(self): return f"Feedback #{self.pk} by {self.user}"
[docs] class SystemMessage(models.Model): message = models.TextField( blank=True, help_text=("HTML or plain text shown at the top of every page; leave blank to hide."), ) history = HistoricalRecords() class Meta: verbose_name = "System Message" def __str__(self): return "System Message"
[docs] @classmethod def solo(cls): obj, _ = cls.objects.get_or_create(pk=1) return obj
auditlog.register( Feedback, exclude_fields=( "created_at", "updated_at", "history", "last_seen_at", "last_update", ), mask_fields=("password",), ) auditlog.register( SystemMessage, exclude_fields=( "created_at", "updated_at", "history", "last_seen_at", "last_update", ), mask_fields=("password",), )