1
0
mirror of https://gitlab.crans.org/bde/nk20 synced 2025-06-21 01:48:21 +02:00

Make erdnaxe be happy

This commit is contained in:
Yohann D'ANELLO
2020-03-07 22:28:59 +01:00
parent 3eb0c185f2
commit d0206fb790
30 changed files with 215 additions and 205 deletions

View File

@ -9,6 +9,7 @@ from django.core.validators import RegexValidator
from django.db import models
from django.utils.translation import gettext_lazy as _
from polymorphic.models import PolymorphicModel
"""
Defines each note types
"""
@ -27,7 +28,7 @@ class Note(PolymorphicModel):
help_text=_('in centimes, money credited for this instance'),
default=0,
)
last_negative= models.DateTimeField(
last_negative = models.DateTimeField(
verbose_name=_('last negative date'),
help_text=_('last time the balance was negative'),
null=True,
@ -98,7 +99,7 @@ class Note(PolymorphicModel):
# Alias exists, so check if it is linked to this note
if aliases.first().note != self:
raise ValidationError(_('This alias is already taken.'),
code="same_alias",)
code="same_alias", )
else:
# Alias does not exist yet, so check if it can exist
a = Alias(name=str(self))
@ -231,12 +232,12 @@ class Alias(models.Model):
sim_alias = Alias.objects.get(normalized_name=normalized_name)
if self != sim_alias:
raise ValidationError(_('An alias with a similar name already exists: {} '.format(sim_alias)),
code="same_alias"
)
code="same_alias"
)
except Alias.DoesNotExist:
pass
self.normalized_name = normalized_name
def delete(self, using=None, keep_parents=False):
if self.name == str(self.note):
raise ValidationError(_("You can't delete your main alias."),

View File

@ -2,9 +2,9 @@
# SPDX-License-Identifier: GPL-3.0-or-later
from django.db import models
from django.urls import reverse
from django.utils import timezone
from django.utils.translation import gettext_lazy as _
from django.urls import reverse
from polymorphic.models import PolymorphicModel
from .notes import Note, NoteClub
@ -44,7 +44,7 @@ class TransactionTemplate(models.Model):
verbose_name=_('name'),
max_length=255,
unique=True,
error_messages={'unique':_("A template with this name already exist")},
error_messages={'unique': _("A template with this name already exist")},
)
destination = models.ForeignKey(
NoteClub,
@ -63,7 +63,7 @@ class TransactionTemplate(models.Model):
max_length=31,
)
display = models.BooleanField(
default = True,
default=True,
)
description = models.CharField(
verbose_name=_('description'),
@ -75,7 +75,7 @@ class TransactionTemplate(models.Model):
verbose_name_plural = _("transaction templates")
def get_absolute_url(self):
return reverse('note:template_update', args=(self.pk, ))
return reverse('note:template_update', args=(self.pk,))
class Transaction(PolymorphicModel):
@ -168,6 +168,7 @@ class TemplateTransaction(Transaction):
on_delete=models.PROTECT,
)
class MembershipTransaction(Transaction):
"""
Special type of :model:`note.Transaction` associated to a :model:`member.Membership`.