mirror of
https://gitlab.com/animath/si/plateforme.git
synced 2025-07-18 13:00:20 +02:00
Move apps in main directory
Signed-off-by: Emmy D'Anello <emmy.danello@animath.fr>
This commit is contained in:
api
locale/fr/LC_MESSAGES
logs
participation
__init__.pyadmin.pytests.pyurls.pyviews.py
api
apps.pyforms.pymanagement
__init__.py
commands
migrations
models.pysearch_indexes.pysignals.pytables.pytemplates
participation
chat.htmlcreate_team.htmljoin_team.html
mails
request_validation.htmlrequest_validation.txtteam_not_validated.htmlteam_not_validated.txtteam_validated.htmlteam_validated.txt
note_form.htmlparticipation_detail.htmlpassage_detail.htmlpassage_form.htmlpool_detail.htmlpool_form.htmlteam_detail.htmlteam_leave.htmlteam_list.htmltournament_detail.htmltournament_form.htmltournament_list.htmlupdate_team.htmlupload_motivation_letter.htmlupload_notes.htmlupload_solution.htmlupload_synthesis.htmlsearch
indexes
registration
__init__.pyadmin.py
api
apps.pyauth.pyfixtures
forms.pymigrations
0001_initial.py0002_auto_20230110_2031.py0003_alter_participantregistration_zip_code.py0004_volunteer_admin.py0005_studentregistration_vaccine_sheet.py__init__.py
models.pysearch_indexes.pysignals.pytables.pytemplates
registration
add_organizer.htmlemail_validation_complete.htmlemail_validation_email_sent.html
mails
password_change_done.htmlpassword_change_form.htmlpassword_reset_complete.htmlpassword_reset_confirm.htmlpassword_reset_done.htmlpassword_reset_form.htmlpayment_form.htmlsignup.htmltex
Autorisation_droit_image_majeur.texAutorisation_droit_image_mineur.texAutorisation_parentale.texInstructions.tex
update_user.htmlupload_health_sheet.htmlupload_parental_authorization.htmlupload_photo_authorization.htmlupload_vaccine_sheet.htmluser_detail.htmluser_list.htmlsearch
templatetags
tests.pyurls.pyviews.pytfjm
tox.ini
88
logs/models.py
Normal file
88
logs/models.py
Normal file
@ -0,0 +1,88 @@
|
||||
# Copyright (C) 2018-2020 by BDE ENS Paris-Saclay
|
||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
from django.conf import settings
|
||||
from django.contrib.contenttypes.models import ContentType
|
||||
from django.core.exceptions import ValidationError
|
||||
from django.db import models
|
||||
from django.utils import timezone
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
|
||||
|
||||
class Changelog(models.Model):
|
||||
"""
|
||||
Store each modification in the database (except sessions and logging),
|
||||
including creating, editing and deleting models.
|
||||
"""
|
||||
|
||||
user = models.ForeignKey(
|
||||
settings.AUTH_USER_MODEL,
|
||||
on_delete=models.PROTECT,
|
||||
null=True,
|
||||
verbose_name=_('user'),
|
||||
)
|
||||
|
||||
ip = models.GenericIPAddressField(
|
||||
null=True,
|
||||
blank=True,
|
||||
verbose_name=_("IP Address")
|
||||
)
|
||||
|
||||
model = models.ForeignKey(
|
||||
ContentType,
|
||||
on_delete=models.PROTECT,
|
||||
null=False,
|
||||
blank=False,
|
||||
verbose_name=_('model'),
|
||||
)
|
||||
|
||||
instance_pk = models.CharField(
|
||||
max_length=255,
|
||||
null=False,
|
||||
blank=False,
|
||||
verbose_name=_('identifier'),
|
||||
)
|
||||
|
||||
previous = models.TextField(
|
||||
blank=True,
|
||||
default="",
|
||||
verbose_name=_('previous data'),
|
||||
)
|
||||
|
||||
data = models.TextField(
|
||||
blank=True,
|
||||
default="",
|
||||
verbose_name=_('new data'),
|
||||
)
|
||||
|
||||
action = models.CharField( # create, edit or delete
|
||||
max_length=16,
|
||||
null=False,
|
||||
blank=False,
|
||||
choices=[
|
||||
('create', _('create')),
|
||||
('edit', _('edit')),
|
||||
('delete', _('delete')),
|
||||
],
|
||||
default='edit',
|
||||
verbose_name=_('action'),
|
||||
)
|
||||
|
||||
timestamp = models.DateTimeField(
|
||||
null=False,
|
||||
blank=False,
|
||||
default=timezone.now,
|
||||
name='timestamp',
|
||||
verbose_name=_('timestamp'),
|
||||
)
|
||||
|
||||
def delete(self, using=None, keep_parents=False):
|
||||
raise ValidationError(_("Logs cannot be destroyed."))
|
||||
|
||||
class Meta:
|
||||
verbose_name = _("changelog")
|
||||
verbose_name_plural = _("changelogs")
|
||||
|
||||
def __str__(self):
|
||||
return _("Changelog of type \"{action}\" for model {model} at {timestamp}").format(
|
||||
action=self.get_action_display(), model=str(self.model), timestamp=str(self.timestamp))
|
Reference in New Issue
Block a user