|
After Width: | Height: | Size: 670 KiB |
|
After Width: | Height: | Size: 1.8 MiB |
|
After Width: | Height: | Size: 326 KiB |
|
After Width: | Height: | Size: 227 KiB |
|
After Width: | Height: | Size: 288 KiB |
|
After Width: | Height: | Size: 228 KiB |
|
After Width: | Height: | Size: 261 KiB |
|
After Width: | Height: | Size: 399 KiB |
|
After Width: | Height: | Size: 421 KiB |
|
After Width: | Height: | Size: 532 KiB |
|
After Width: | Height: | Size: 439 KiB |
|
After Width: | Height: | Size: 411 KiB |
|
After Width: | Height: | Size: 306 KiB |
|
After Width: | Height: | Size: 231 KiB |
|
After Width: | Height: | Size: 124 KiB |
|
After Width: | Height: | Size: 350 KiB |
@ -0,0 +1,36 @@ |
|||||||
|
# Generated by Django 5.1 on 2025-04-02 14:02 |
||||||
|
|
||||||
|
import django.db.models.deletion |
||||||
|
import django.utils.timezone |
||||||
|
from django.conf import settings |
||||||
|
from django.db import migrations, models |
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration): |
||||||
|
|
||||||
|
dependencies = [ |
||||||
|
('tournaments', '0113_tournament_team_count_limit'), |
||||||
|
] |
||||||
|
|
||||||
|
operations = [ |
||||||
|
migrations.AddField( |
||||||
|
model_name='purchase', |
||||||
|
name='creation_date', |
||||||
|
field=models.DateTimeField(default=django.utils.timezone.now, editable=False), |
||||||
|
), |
||||||
|
migrations.AddField( |
||||||
|
model_name='purchase', |
||||||
|
name='last_update', |
||||||
|
field=models.DateTimeField(default=django.utils.timezone.now), |
||||||
|
), |
||||||
|
migrations.AddField( |
||||||
|
model_name='purchase', |
||||||
|
name='last_updated_by', |
||||||
|
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='+', to=settings.AUTH_USER_MODEL), |
||||||
|
), |
||||||
|
migrations.AddField( |
||||||
|
model_name='purchase', |
||||||
|
name='related_user', |
||||||
|
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='+', to=settings.AUTH_USER_MODEL), |
||||||
|
), |
||||||
|
] |
||||||
@ -0,0 +1,45 @@ |
|||||||
|
# Generated by Django 5.1 on 2025-04-03 12:29 |
||||||
|
|
||||||
|
from django.db import migrations |
||||||
|
from ..utils.licence_validator import LicenseValidator |
||||||
|
|
||||||
|
def clean_license_ids(apps, schema_editor): |
||||||
|
# Get the historical model |
||||||
|
CustomUser = apps.get_model('tournaments', 'CustomUser') |
||||||
|
|
||||||
|
# Query all users |
||||||
|
users = CustomUser.objects.all() |
||||||
|
|
||||||
|
for user in users: |
||||||
|
if user.licence_id: |
||||||
|
# Clean up logic - examples: |
||||||
|
# 1. Strip whitespace |
||||||
|
cleaned_id = user.licence_id.strip() |
||||||
|
cleaned_id = cleaned_id.replace(' ', '').strip().upper() |
||||||
|
last_char = cleaned_id[-1] if cleaned_id else '' |
||||||
|
ends_with_non_alpha = not last_char.isalpha() |
||||||
|
if ends_with_non_alpha: |
||||||
|
key = LicenseValidator.get_computed_license_key(cleaned_id) |
||||||
|
if key: |
||||||
|
cleaned_id += key.upper() |
||||||
|
|
||||||
|
|
||||||
|
# Save the cleaned value |
||||||
|
if cleaned_id != user.licence_id: |
||||||
|
user.licence_id = cleaned_id |
||||||
|
user.save() |
||||||
|
|
||||||
|
def reverse_migration(apps, schema_editor): |
||||||
|
# Reversing this migration isn't generally needed for data cleanup |
||||||
|
pass |
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration): |
||||||
|
|
||||||
|
dependencies = [ |
||||||
|
('tournaments', '0114_purchase_creation_date_purchase_last_update_and_more'), |
||||||
|
] |
||||||
|
|
||||||
|
operations = [ |
||||||
|
migrations.RunPython(clean_license_ids, reverse_migration), |
||||||
|
] |
||||||