2021-11-30 05:15:59 +00:00
|
|
|
from __future__ import unicode_literals
|
|
|
|
|
2021-12-07 05:55:45 +00:00
|
|
|
import uuid
|
|
|
|
|
|
|
|
from django.core.validators import URLValidator, ValidationError
|
2021-11-30 05:15:59 +00:00
|
|
|
from django.db import models
|
2021-12-07 05:55:45 +00:00
|
|
|
from django_countries.fields import CountryField
|
|
|
|
|
|
|
|
|
|
|
|
def validate_mutiple_urls(value):
|
|
|
|
"""Map the URLValidator() over text containing multiple URLs."""
|
|
|
|
candidate_urls = [c.strip() for c in value.split()]
|
|
|
|
invalid_urls = []
|
|
|
|
# TODO: Improve this https://docs.djangoproject.com/en/3.2/ref/forms/validation/#raising-multiple-errors
|
|
|
|
validator = URLValidator()
|
|
|
|
for url in candidate_urls:
|
|
|
|
try:
|
|
|
|
validator(url)
|
|
|
|
except ValidationError:
|
|
|
|
invalid_urls.append(url)
|
|
|
|
print(invalid_urls)
|
|
|
|
if invalid_urls:
|
|
|
|
raise ValidationError('These don\'t seem to be complete URLs:\n{}'.format('\n'.join(invalid_urls)))
|
2021-11-30 05:15:59 +00:00
|
|
|
|
|
|
|
|
|
|
|
class Assignment(models.Model):
|
2021-12-06 22:27:17 +00:00
|
|
|
"""A copyright assignment to Conservancy."""
|
|
|
|
|
2021-12-07 05:55:45 +00:00
|
|
|
uuid = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False)
|
2021-11-30 05:15:59 +00:00
|
|
|
full_name = models.CharField(max_length=255)
|
2021-12-07 05:55:45 +00:00
|
|
|
email = models.EmailField('Email address (to contact you if we have questions)')
|
|
|
|
country_of_residence = CountryField()
|
|
|
|
repositories = models.TextField(
|
2021-12-16 22:50:41 +00:00
|
|
|
'Code repositories containing contributions of yours whose copyright you are assigning',
|
2021-12-07 05:55:45 +00:00
|
|
|
help_text='List of URLs, one per line',
|
|
|
|
validators=[validate_mutiple_urls],
|
2021-11-30 05:15:59 +00:00
|
|
|
)
|
2021-12-07 05:55:45 +00:00
|
|
|
all_emails = models.TextField(
|
2021-12-16 22:50:41 +00:00
|
|
|
'All email addresses or other unique user identities, such as nicknames or handles, used by you to contribute to the above (i.e. in the commit logs)',
|
2021-12-07 05:55:45 +00:00
|
|
|
)
|
|
|
|
period_begins = models.DateField(
|
|
|
|
'Assignment period begins',
|
|
|
|
)
|
|
|
|
period_end_type = models.CharField(
|
|
|
|
'Time period to assign',
|
2021-11-30 05:15:59 +00:00
|
|
|
max_length=50,
|
|
|
|
choices=[
|
2021-12-07 05:55:45 +00:00
|
|
|
('all future contributions', 'all future contributions'),
|
|
|
|
('a specific past date', 'a specific past date'),
|
2021-11-30 05:15:59 +00:00
|
|
|
],
|
|
|
|
)
|
2021-12-07 05:55:45 +00:00
|
|
|
period_ends = models.DateField(
|
|
|
|
'Assignment period ends (if applicable)',
|
|
|
|
blank=True,
|
|
|
|
null=True,
|
|
|
|
)
|
2021-11-30 05:15:59 +00:00
|
|
|
attestation_of_copyright = models.BooleanField(
|
2021-12-16 22:50:41 +00:00
|
|
|
'By checking the box below, I am confirming that I agree to be bound by the terms of the Copyright Assignment Agreement above.',
|
2021-11-30 05:15:59 +00:00
|
|
|
)
|