mirror of
https://gitlab.crans.org/bde/nk20
synced 2025-06-21 09:58:23 +02:00
Merge branch 'no_null_charfield' into 'beta'
Add __str__ to models, remove null=True in CharField and TextField See merge request bde/nk20!117
This commit is contained in:
17
apps/note/migrations/0003_replace_null_by_blank.py
Normal file
17
apps/note/migrations/0003_replace_null_by_blank.py
Normal file
@ -0,0 +1,17 @@
|
||||
from django.db import migrations
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('note', '0002_create_special_notes'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.RunSQL(
|
||||
"UPDATE note_note SET inactivity_reason = '' WHERE inactivity_reason IS NULL;"
|
||||
),
|
||||
migrations.RunSQL(
|
||||
"UPDATE note_transaction SET invalidity_reason = '' WHERE invalidity_reason IS NULL;"
|
||||
),
|
||||
]
|
23
apps/note/migrations/0004_remove_null_tag_on_charfields.py
Normal file
23
apps/note/migrations/0004_remove_null_tag_on_charfields.py
Normal file
@ -0,0 +1,23 @@
|
||||
# Generated by Django 2.2.16 on 2020-09-06 19:17
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('note', '0003_replace_null_by_blank'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterField(
|
||||
model_name='note',
|
||||
name='inactivity_reason',
|
||||
field=models.CharField(blank=True, choices=[('manual', 'The user blocked his/her note manually, eg. when he/she left the school for holidays. It can be reactivated at any time.'), ('forced', "The note is blocked by the the BDE and can't be manually reactivated.")], default='', max_length=255),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='transaction',
|
||||
name='invalidity_reason',
|
||||
field=models.CharField(blank=True, default='', max_length=255, verbose_name='invalidity reason'),
|
||||
),
|
||||
]
|
@ -70,8 +70,8 @@ class Note(PolymorphicModel):
|
||||
"It can be reactivated at any time.")),
|
||||
('forced', _("The note is blocked by the the BDE and can't be manually reactivated.")),
|
||||
],
|
||||
null=True,
|
||||
default=None,
|
||||
blank=True,
|
||||
default="",
|
||||
)
|
||||
|
||||
class Meta:
|
||||
|
@ -90,6 +90,9 @@ class TransactionTemplate(models.Model):
|
||||
def get_absolute_url(self):
|
||||
return reverse('note:template_update', args=(self.pk,))
|
||||
|
||||
def __str__(self):
|
||||
return self.name
|
||||
|
||||
|
||||
class Transaction(PolymorphicModel):
|
||||
"""
|
||||
@ -150,8 +153,7 @@ class Transaction(PolymorphicModel):
|
||||
invalidity_reason = models.CharField(
|
||||
verbose_name=_('invalidity reason'),
|
||||
max_length=255,
|
||||
default=None,
|
||||
null=True,
|
||||
default='',
|
||||
blank=True,
|
||||
)
|
||||
|
||||
@ -195,7 +197,7 @@ class Transaction(PolymorphicModel):
|
||||
|
||||
# When a transaction is declared valid, we ensure that the invalidity reason is null, if it was
|
||||
# previously invalid
|
||||
self.invalidity_reason = None
|
||||
self.invalidity_reason = ""
|
||||
|
||||
if source_balance > 9223372036854775807 or source_balance < -9223372036854775808\
|
||||
or dest_balance > 9223372036854775807 or dest_balance < -9223372036854775808:
|
||||
|
Reference in New Issue
Block a user