physionet-build
physionet-build copied to clipboard
Mismatch between maximum length of affiliation in the Affiliation and Contact models
When a project is published, an error is raised in cases when a user has added an affiliation of over 150 characters and he/she is the contact author (or an error should be raised...SQLLite seems to overlook max lengths, so the issue is not reproducible on a local sqlite setup).
The problem is a mismatch between the following two models in /project/models.py
(no idea why 202 was chosen for affiliations):
class Affiliation(models.Model):
"""
Affiliations belonging to an author
"""
name = models.CharField(max_length=202, validators=[validate_affiliation])
author = models.ForeignKey('project.Author', related_name='affiliations',
on_delete=models.CASCADE)
...
class Contact(models.Model):
"""
Contact for a PublishedProject
"""
name = models.CharField(max_length=120)
affiliations = models.CharField(max_length=150)
email = models.EmailField(max_length=255)
project = models.OneToOneField('project.PublishedProject',
related_name='contact', on_delete=models.CASCADE)
When a project is published, the Affiliation.name
is copied to the Contact.affiliations
which errors if the length is >150. A fix would be to bump up the max_length of the Contact.affiliations
field.