to the draft parser (incorporating patch from trunk), store the extracted country instead of trying to turn it into an ISO country code, add country and continent name models and add initial data for those, add helper function for cleaning the countries, add author country and continent charts, move the affiliation models to stats/models.py, fix a bunch of bugs. - Legacy-Id: 12846
42 lines
1.5 KiB
Python
42 lines
1.5 KiB
Python
from django.db import models
|
|
from ietf.name.models import CountryName
|
|
|
|
class AffiliationAlias(models.Model):
|
|
"""Records that alias should be treated as name for statistical
|
|
purposes."""
|
|
|
|
alias = models.CharField(max_length=255, help_text="Note that aliases will be matched case-insensitive and both before and after some clean-up.", unique=True)
|
|
name = models.CharField(max_length=255)
|
|
|
|
def __unicode__(self):
|
|
return u"{} -> {}".format(self.alias, self.name)
|
|
|
|
def save(self, *args, **kwargs):
|
|
self.alias = self.alias.lower()
|
|
super(AffiliationAlias, self).save(*args, **kwargs)
|
|
|
|
class Meta:
|
|
verbose_name_plural = "affiliation aliases"
|
|
|
|
class AffiliationIgnoredEnding(models.Model):
|
|
"""Records that ending should be stripped from the affiliation for statistical purposes."""
|
|
|
|
ending = models.CharField(max_length=255, help_text="Regexp with ending, e.g. 'Inc\\.?' - remember to escape .!")
|
|
|
|
def __unicode__(self):
|
|
return self.ending
|
|
|
|
class CountryAlias(models.Model):
|
|
"""Records that alias should be treated as country for statistical
|
|
purposes."""
|
|
|
|
alias = models.CharField(max_length=255, help_text="Note that lower-case aliases are matched case-insensitive while aliases with at least one uppercase letter is matched case-sensitive.")
|
|
country = models.ForeignKey(CountryName, max_length=255)
|
|
|
|
def __unicode__(self):
|
|
return u"{} -> {}".format(self.alias, self.country.name)
|
|
|
|
class Meta:
|
|
verbose_name_plural = "country aliases"
|
|
|