Files
@ 26ac00e8641f
Branch filter:
Location: website/www/conservancy/apps/assignment/models.py - annotation
26ac00e8641f
2.2 KiB
text/x-python
assignment: Allow today's date.
a2675ee029a5 a2675ee029a5 0565f9b308ed 0565f9b308ed 0565f9b308ed a2675ee029a5 0565f9b308ed 0565f9b308ed 0565f9b308ed 0565f9b308ed 0565f9b308ed 0565f9b308ed 0565f9b308ed 0565f9b308ed 0565f9b308ed 0565f9b308ed 0565f9b308ed 0565f9b308ed 0565f9b308ed 0565f9b308ed 0565f9b308ed 0565f9b308ed 0565f9b308ed a2675ee029a5 a2675ee029a5 a2675ee029a5 2b1fd9ab90d9 2b1fd9ab90d9 0565f9b308ed a2675ee029a5 0565f9b308ed 0565f9b308ed 0565f9b308ed 530890f6ad9d 0565f9b308ed 0565f9b308ed a2675ee029a5 0565f9b308ed 530890f6ad9d 0565f9b308ed 0565f9b308ed 0565f9b308ed 0565f9b308ed 0565f9b308ed 0565f9b308ed a2675ee029a5 a2675ee029a5 0565f9b308ed 0565f9b308ed a2675ee029a5 a2675ee029a5 0565f9b308ed 0565f9b308ed 0565f9b308ed 0565f9b308ed 0565f9b308ed a2675ee029a5 0565f9b308ed a2675ee029a5 | from __future__ import unicode_literals
import uuid
from django.core.validators import URLValidator, ValidationError
from django.db import models
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)))
class Assignment(models.Model):
"""A copyright assignment to Conservancy."""
uuid = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False)
full_name = models.CharField(max_length=255)
email = models.EmailField('Email address (to contact you if we have questions)')
country_of_residence = CountryField()
repositories = models.TextField(
'Code repositories containing contributions of yours whose copyright you\'d like to assign',
help_text='List of URLs, one per line',
validators=[validate_mutiple_urls],
)
all_emails = models.TextField(
'All email addresses used by you to contribute to the above (i.e. in the commit logs)',
)
period_begins = models.DateField(
'Assignment period begins',
)
period_end_type = models.CharField(
'Time period to assign',
max_length=50,
choices=[
('all future contributions', 'all future contributions'),
('a specific past date', 'a specific past date'),
],
)
period_ends = models.DateField(
'Assignment period ends (if applicable)',
blank=True,
null=True,
)
attestation_of_copyright = models.BooleanField(
'I agree to be bound by the terms of the Copyright Assignment Agreement above, and that I own the copyright in the works defined above',
)
|