Skip to content
Snippets Groups Projects
Commit d6f00e09 authored by Benjamin Hättasch's avatar Benjamin Hättasch
Browse files

Do not track changes of AK interest counter

This fixes #97
Exclude interest_counter from AK history
Prevent saving of history record when increasing interest counter

Run the following action after applying the change/migration to remove existing duplicate history records (the ones without changes to tracked fields, hence caused by either saving without changing any field or especially the ones created due to changes of the now ignored interest_counter):
python manage.py clean_duplicate_history AKModel.ak
parent 0f93fa7f
No related branches found
No related tags found
No related merge requests found
# Generated by Django 3.1.5 on 2021-01-29 15:44
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
('AKModel', '0043_akslot_fixed_improve_verbose_name'),
]
operations = [
migrations.RemoveField(
model_name='historicalak',
name='interest_counter',
),
]
...@@ -233,7 +233,7 @@ class AK(models.Model): ...@@ -233,7 +233,7 @@ class AK(models.Model):
event = models.ForeignKey(to=Event, on_delete=models.CASCADE, verbose_name=_('Event'), event = models.ForeignKey(to=Event, on_delete=models.CASCADE, verbose_name=_('Event'),
help_text=_('Associated event')) help_text=_('Associated event'))
history = HistoricalRecords() history = HistoricalRecords(excluded_fields=['interest_counter'])
class Meta: class Meta:
verbose_name = _('AK') verbose_name = _('AK')
...@@ -272,7 +272,9 @@ class AK(models.Model): ...@@ -272,7 +272,9 @@ class AK(models.Model):
def increment_interest(self): def increment_interest(self):
self.interest_counter += 1 self.interest_counter += 1
self.skip_history_when_saving = True
self.save() self.save()
del self.skip_history_when_saving
@property @property
def availabilities(self): def availabilities(self):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment