Skip to content

Commit

Permalink
Merge pull request #2205 from IFRCGo/fix/sentry-issue
Browse files Browse the repository at this point in the history
Fix Sentry issues
  • Loading branch information
szabozoltan69 authored Jul 9, 2024
2 parents 6c59164 + 8675641 commit 492feeb
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# Generated by Django 4.2.13 on 2024-07-09 04:48

from django.db import migrations


def delete_ids(apps, schema_editor):
CountryDirectory = apps.get_model("api", "CountryDirectory")
CountryKeyDocument = apps.get_model("api", "CountryKeyDocument")
NSDInitiatives = apps.get_model("api", "NSDInitiatives")
try:
CountryDirectory.objects.all().delete()
CountryKeyDocument.objects.all().delete()
NSDInitiatives.objects.all().delete()
except Exception as e:
print("Error while deleting ids", str(e))


class Migration(migrations.Migration):

dependencies = [
("api", "0210_profile_accepted_montandon_license_terms"),
]

operations = [
migrations.RunPython(delete_ids, reverse_code=migrations.RunPython.noop),
migrations.AlterUniqueTogether(
name="countrydirectory",
unique_together={("country", "first_name", "last_name", "position")},
),
migrations.AlterUniqueTogether(
name="countrykeydocument",
unique_together={("country", "url")},
),
migrations.AlterUniqueTogether(
name="nsdinitiatives",
unique_together={("country", "year", "fund_type")},
),
]
11 changes: 9 additions & 2 deletions api/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,9 @@ class CountryDirectory(models.Model):
last_name = models.CharField(verbose_name=_("Last Name"), max_length=255, null=True, blank=True)
position = models.CharField(verbose_name=_("Position"), max_length=255, null=True, blank=True)

class Meta:
unique_together = ("country", "first_name", "last_name", "position")

def __str__(self):
return f"{self.country.name} - {self.first_name}"

Expand Down Expand Up @@ -349,7 +352,9 @@ class CountryKeyDocument(models.Model):
end_year = models.DateField(verbose_name=_("End Year"), null=True, blank=True)
year_text = models.CharField(verbose_name=_("Year Text"), max_length=255, null=True, blank=True)

# TODO: Add unique_together country, url
class Meta:
unique_together = ("country", "url")

def __str__(self):
return f"{self.country.name} - {self.name}"

Expand Down Expand Up @@ -392,7 +397,9 @@ class NSDInitiatives(models.Model):
funding_period = models.IntegerField(verbose_name=_("Funding Period in Month"))
categories = ArrayField(models.CharField(max_length=255), verbose_name=_("Funding categories"), default=list, null=True)

# TODO: Add unique_together country, year, fund_type
class Meta:
unique_together = ("country", "year", "fund_type")

def __str__(self):
return f"{self.country.name} - {self.title}"

Expand Down

0 comments on commit 492feeb

Please sign in to comment.