diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000000000000000000000000000000000000..c4d5de34b9bff6eb0044bbc2b4d55df6fbbe63b8 --- /dev/null +++ b/requirements.txt @@ -0,0 +1,10 @@ +backports.functools-lru-cache==1.6.4 +beautifulsoup4==4.9.3 +bs4==0.0.1 +Django==1.11.29 +pytz==2021.3 +soupsieve==1.9.6 +html5lib==0.999999999 +future + +django_countries==5.5 # Supports both Python 2 and 3. diff --git a/www/conservancy/apps/assignment/__init__.py b/www/conservancy/apps/assignment/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/www/conservancy/apps/assignment/apps.py b/www/conservancy/apps/assignment/apps.py new file mode 100644 index 0000000000000000000000000000000000000000..9fe186c53eb4dfd298c494b4217a49b028ccc0d3 --- /dev/null +++ b/www/conservancy/apps/assignment/apps.py @@ -0,0 +1,7 @@ +from __future__ import unicode_literals + +from django.apps import AppConfig + + +class AssignmentConfig(AppConfig): + name = 'assignment' diff --git a/www/conservancy/apps/assignment/forms.py b/www/conservancy/apps/assignment/forms.py new file mode 100644 index 0000000000000000000000000000000000000000..1497e9783ff9a12ef818fa76faa48fa6f77997eb --- /dev/null +++ b/www/conservancy/apps/assignment/forms.py @@ -0,0 +1,72 @@ +import datetime + +from django import forms +from django.core.validators import ValidationError +from django.utils import timezone + +from .models import Assignment +from .terms import TERMS + + +def validate_in_past(value): + # Adding a day to allow the current date anywhere on earth, regardless of + # the server timezone. + if value > timezone.now().date() + datetime.timedelta(days=1): + raise ValidationError('Enter a date in the past') + + +class AssignmentForm(forms.ModelForm): + period_begins = forms.DateField( + label='Assign the copyright in my above contributions starting on', + help_text='You can use the day you first started contributing (or, equivalently, your date of birth), or any later date.', + required=True, + widget=forms.DateInput(attrs={'type': 'date'}), + validators=[validate_in_past], + ) + period_end_type = forms.ChoiceField( + label='and ending on', + choices=[ + ('all future contributions', 'all future contributions (no end date)'), + ('a specific past date', 'a specific past date (specify below)'), + ], + widget=forms.RadioSelect(), + initial='all future contributions', + ) + period_ends = forms.DateField( + label='Specific past date (if applicable)', + required=False, + widget=forms.DateInput(attrs={'type': 'date'}), + validators=[validate_in_past], + ) + agreement_terms = forms.CharField( + widget=forms.Textarea(attrs={'readonly': 'readonly'}), + initial=TERMS, + ) + + def __init__(self, *args, **kwargs): + super().__init__(*args, **kwargs) + self.fields['attestation_of_copyright'].required = True + + class Meta: + model = Assignment + fields = [ + 'full_name', + 'email', + 'country_of_residence', + 'repositories', + 'all_emails', + 'period_begins', + 'period_end_type', + 'period_ends', + 'agreement_terms', + 'attestation_of_copyright', + ] + + def clean_period_ends(self): + if 'period_begins' in self.cleaned_data and 'period_ends' in self.cleaned_data and self.cleaned_data['period_begins'] and self.cleaned_data['period_ends'] and self.cleaned_data['period_begins'] > self.cleaned_data['period_ends']: + raise ValidationError('End of period is before start') + + if self.cleaned_data['period_end_type'] == 'a specific past date' and not self.cleaned_data['period_ends']: + raise ValidationError('This field is required') + + return self.cleaned_data['period_ends'] diff --git a/www/conservancy/apps/assignment/migrations/0001_initial.py b/www/conservancy/apps/assignment/migrations/0001_initial.py new file mode 100644 index 0000000000000000000000000000000000000000..806a62c3e644be349ddb1fb09ed268346fa63582 --- /dev/null +++ b/www/conservancy/apps/assignment/migrations/0001_initial.py @@ -0,0 +1,28 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.10.7 on 2021-11-30 00:24 +from __future__ import unicode_literals + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + initial = True + + dependencies = [ + ] + + operations = [ + migrations.CreateModel( + name='Assignment', + fields=[ + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('full_name', models.CharField(max_length=255)), + ('email', models.EmailField(max_length=254)), + ('place_of_residence', models.TextField(blank=True, verbose_name='Country of citizenship or residential address')), + ('repository', models.URLField(blank=True, verbose_name='Code repository')), + ('coverage', models.CharField(choices=[('up to this year', 'One-off up to and including this year'), ('ongoing', 'All existing and new contributions')], default='up to this year', max_length=50, verbose_name='Time period to assign')), + ('attestation_of_copyright', models.BooleanField(verbose_name='I attest that I own the copyright on these works')), + ], + ), + ] diff --git a/www/conservancy/apps/assignment/migrations/0002_auto_20211206_2237.py b/www/conservancy/apps/assignment/migrations/0002_auto_20211206_2237.py new file mode 100644 index 0000000000000000000000000000000000000000..216de0ce9f6fc637b76ac45219011590872e5575 --- /dev/null +++ b/www/conservancy/apps/assignment/migrations/0002_auto_20211206_2237.py @@ -0,0 +1,74 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.11.29 on 2021-12-06 22:37 +from __future__ import unicode_literals + +import datetime +from django.db import migrations, models +import django_countries.fields + + +class Migration(migrations.Migration): + + dependencies = [ + ('assignment', '0001_initial'), + ] + + operations = [ + migrations.RemoveField( + model_name='assignment', + name='coverage', + ), + migrations.RemoveField( + model_name='assignment', + name='place_of_residence', + ), + migrations.RemoveField( + model_name='assignment', + name='repository', + ), + migrations.AddField( + model_name='assignment', + name='all_emails', + field=models.TextField(default='', verbose_name='All email addresses and/or names used by you to contribute to the above'), + preserve_default=False, + ), + migrations.AddField( + model_name='assignment', + name='country_of_residence', + field=django_countries.fields.CountryField(default='', max_length=2), + preserve_default=False, + ), + migrations.AddField( + model_name='assignment', + name='period_begins', + field=models.DateField(default=datetime.date(2021, 1, 1), verbose_name='Assignment period begins'), + preserve_default=False, + ), + migrations.AddField( + model_name='assignment', + name='period_end_type', + field=models.CharField(choices=[('all future contributions', 'all future contributions'), ('a specific past date', 'a specific past date')], default=datetime.date(2021, 1, 1), max_length=50, verbose_name='Time period to assign'), + preserve_default=False, + ), + migrations.AddField( + model_name='assignment', + name='period_ends', + field=models.DateField(blank=True, null=True, verbose_name='Assignment period ends (if applicable)'), + ), + migrations.AddField( + model_name='assignment', + name='repositories', + field=models.TextField(default='', help_text='List of URLs, one per line', verbose_name="Code repositories contributed to that you'd like to assign"), + preserve_default=False, + ), + migrations.AlterField( + model_name='assignment', + name='attestation_of_copyright', + field=models.BooleanField(verbose_name='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'), + ), + migrations.AlterField( + model_name='assignment', + name='email', + field=models.EmailField(max_length=254, verbose_name='Email address (to contact you if we have questions)'), + ), + ] diff --git a/www/conservancy/apps/assignment/migrations/0003_auto_20211206_2249.py b/www/conservancy/apps/assignment/migrations/0003_auto_20211206_2249.py new file mode 100644 index 0000000000000000000000000000000000000000..38d265aab9baa3849e9c0cfb106a6e178a5910ca --- /dev/null +++ b/www/conservancy/apps/assignment/migrations/0003_auto_20211206_2249.py @@ -0,0 +1,25 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.11.29 on 2021-12-06 22:49 +from __future__ import unicode_literals + +from django.db import migrations, models +import uuid + + +class Migration(migrations.Migration): + + dependencies = [ + ('assignment', '0002_auto_20211206_2237'), + ] + + operations = [ + migrations.RemoveField( + model_name='assignment', + name='id', + ), + migrations.AddField( + model_name='assignment', + name='uuid', + field=models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False), + ), + ] diff --git a/www/conservancy/apps/assignment/migrations/__init__.py b/www/conservancy/apps/assignment/migrations/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/www/conservancy/apps/assignment/models.py b/www/conservancy/apps/assignment/models.py new file mode 100644 index 0000000000000000000000000000000000000000..37317939b0f7c0ff4086855a0a905463cf261c61 --- /dev/null +++ b/www/conservancy/apps/assignment/models.py @@ -0,0 +1,59 @@ +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 are assigning', + help_text='List of URLs, one per line', + validators=[validate_mutiple_urls], + ) + all_emails = models.TextField( + '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)', + ) + 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( + 'By checking the box below, I am confirming that I agree to be bound by the terms of the Copyright Assignment Agreement above.', + ) diff --git a/www/conservancy/apps/assignment/terms.py b/www/conservancy/apps/assignment/terms.py new file mode 100644 index 0000000000000000000000000000000000000000..72988313442e2011624604ff74ee23a8e62e4e75 --- /dev/null +++ b/www/conservancy/apps/assignment/terms.py @@ -0,0 +1,55 @@ +import textwrap + +TERMS = textwrap.dedent("""\ + Copyright Assignment Agreement + + By checking the box below and submitting this form, you (``Assignor'') enter + into this Agreement between Assignor and the Software Freedom Conservancy, + Inc., a New York nonprofit corporation located in Brooklyn, New York, which + has received recognition of exemption from federal income tax under Section + 501(c)(3) of the Internal Revenue Code and classification as a public + charity (the ``Conservancy''). + + For good and valuable consideration, receipt of which is hereby + acknowledged, Assignor hereby transfers to the Conservancy their entire + right, title, and interest in the copyright in the works identified by the + repositories, email addresses, names, and time periods listed above (the + “Works”). To the extent that the Assignor is assigning future rights, and + the rights in future works do not vest in Conservancy upon the Works’ + creation, Assignor agrees to assign, immediately following the creation, all + rights to Conservancy and irrevocably appoint Conservancy as their + attorney-in-fact to take any necessary steps to perfect Conservancy’s rights + under this Agreement. + + The Conservancy will use its discretion for any relicensing of the Works + under other free and open source software licenses. Decisions about + relicensing made by Conservancy will apply to its assignees and successors. + If you have any questions about Conservancy's relicensing philosophy, and + what limitations it may have because it is a public charity, please contact + us at copyright-assignment@sfconservancy.org . + + The Conservancy hereby grants Assignor a royalty-free non-exclusive license + to use the interests assigned hereunder for any purpose. The Conservancy's + rights shall otherwise continue unchanged. + + Assignor hereby grants to the Conservancy and to recipients of software + distributed by the Conservancy a perpetual, worldwide, non-exclusive, + no-charge, royalty-free, irrevocable patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Works, where + such license applies only to those patent claims licensable by Assignor + that are necessarily infringed by the Works alone or by combination of + Assignor's contributions with the Works to which such contributions were + submitted. + + Assignor hereby represents and warrants that the email addresses and user + identities identified above are unique to the Assignor, that no one but the + Assignor has made contributions using the email addresses and user + identities identified above, that the Assignor is the sole copyright holder + for the Works assigned hereunder, and that the Assignor has the right and + power to enter into this contract. Assignor hereby indemnifies and holds + harmless the Conservancy, its officers, employees, agents, successors, and + assigns against any and all claims, actions or damages (including reasonable + attorney's fees) asserted by or paid to any party on account of a breach or + alleged breach of the foregoing warranty. Assignor makes no other express or + implied warranty (including without limitation any warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE).""") diff --git a/www/conservancy/apps/assignment/urls.py b/www/conservancy/apps/assignment/urls.py new file mode 100644 index 0000000000000000000000000000000000000000..0502b0ef4de5807ec9315c94d30877f1c17fbdab --- /dev/null +++ b/www/conservancy/apps/assignment/urls.py @@ -0,0 +1,9 @@ +from django.conf.urls import url + +from .views import AssignmentCreateView, AssignmentThanksView + + +urlpatterns = [ + url(r'^$', AssignmentCreateView.as_view(), name='assignement-add'), + url(r'^(?P[\w-]+)/$', AssignmentThanksView.as_view(), name='assignment-thanks'), +] diff --git a/www/conservancy/apps/assignment/views.py b/www/conservancy/apps/assignment/views.py new file mode 100644 index 0000000000000000000000000000000000000000..c782a61eaaaf4a6ab692637e352f0572ea13b591 --- /dev/null +++ b/www/conservancy/apps/assignment/views.py @@ -0,0 +1,39 @@ +from django.core.mail import send_mail +from django.urls import reverse_lazy +from django.views.generic import DetailView +from django.views.generic.edit import CreateView + +from .forms import AssignmentForm +from .models import Assignment + +class AssignmentCreateView(CreateView): + """Show a form for the initial copyright assignment.""" + + form_class = AssignmentForm + template_name = 'assignment/assignment_form.html' + + def form_valid(self, form): + intro = 'The following copyright assignment has been submitted:\n\n' + body = intro + '\n'.join(['{}: {}'.format(k, v) for k, v in form.cleaned_data.items() if k != 'agreement_terms']) + send_mail( + 'Copyright assignment form: {}'.format(form.cleaned_data['full_name']), + body, + 'ben@sturm.com.au', + ['denver@sfconservancy.org', 'bsturmfels@sfconservancy.org'], + ) + return super().form_valid(form) + + def get_success_url(self, *args, **kwargs): + return reverse_lazy('assignment-thanks', kwargs={'pk': str(self.object.uuid)}) + + +class AssignmentThanksView(DetailView): + model = Assignment + template_name = 'assignment/thanks.html' + + def get_context_data(self, **kwargs): + context = super().get_context_data(**kwargs) + context['form'] = AssignmentForm(instance=self.object) + for _, field in context['form'].fields.items(): + field.widget.attrs['disabled'] = 'disabled' + return context diff --git a/www/conservancy/settings.py b/www/conservancy/settings.py index 85ebceb471abe37be65e0dafd4285225fc510f1e..4d23f849e2ad61e12817ca55280d8ef4b83edb70 100644 --- a/www/conservancy/settings.py +++ b/www/conservancy/settings.py @@ -84,3 +84,25 @@ LOGGING = { 'level': 'INFO', }, } + +INSTALLED_APPS = [ + 'django.contrib.auth', + 'django.contrib.contenttypes', + 'django.contrib.sessions', + 'django.contrib.sites', + 'django.contrib.admin', + 'django.contrib.messages', + 'django.contrib.humanize', + # 'django.contrib.staticfiles', + 'conservancy.apps.blog', + 'conservancy.apps.contacts', + 'conservancy.apps.contractpatch', + 'conservancy.apps.events', + 'conservancy.apps.news', + 'conservancy.apps.staff', + # 'conservancy.apps.summit_registration', + 'conservancy.apps.worldmap', + 'conservancy.apps.supporters', + 'conservancy.apps.fundgoal', + 'conservancy.apps.assignment', +] diff --git a/www/conservancy/templates/assignment/assignment_form.html b/www/conservancy/templates/assignment/assignment_form.html new file mode 100644 index 0000000000000000000000000000000000000000..5ef7433866005b059a5b86655a766eaa2c654828 --- /dev/null +++ b/www/conservancy/templates/assignment/assignment_form.html @@ -0,0 +1,54 @@ +{% extends "assignment/base_assignment.html" %} +{% block category %}Copyright Assignment{% endblock %} +{% block outercontent %} +

Copyright Assignment

+ +
+

Thank you for considering assigning your copyright to the Software Freedom Conservancy. Your assignment helps us enforce free and open source software licenses.

+ +

By filling in and submitting the below form, you agree to assign your copyrights in the specified projects to Software Freedom Conservancy, which means that Conservancy can enforce the licenses for your code in court, minimizing the need for you to be involved. Conservancy agrees to keep your code under a free and open source license.

+ +

If you have any questions about assigning your copyright to Conservancy, please don't hesitate to email us at copyright-assignment@sfconservancy.org.

+ +
+ {% csrf_token %} + + {% if form.errors %} +

Please review the errors below.

+ {% endif %} + + {{ form.as_p }} + +

Please be aware that your employer or a contractor may own the rights in your work by virtue of their employment of you or by explicit transfer of ownership in an agreement. We recommend you review any relevant agreements or consult with a lawyer if you are not sure.

+ +

After submitting this agreement, if you would like to make any changes, you must let us know within 7 days by emailing copyright-assignment@sfconservancy.org, which is also where you can reach us if you have any questions.

+

+
+
+ + +{% endblock %} diff --git a/www/conservancy/templates/assignment/base_assignment.html b/www/conservancy/templates/assignment/base_assignment.html new file mode 100644 index 0000000000000000000000000000000000000000..1af63a6c64c63647060f4eb60958904f4fd5346e --- /dev/null +++ b/www/conservancy/templates/assignment/base_assignment.html @@ -0,0 +1,49 @@ +{% extends "base_conservancy.html" %} +{% block category %}Copyright Assignment{% endblock %} +{% block head %} + {{ block.super }} + +{% endblock %} diff --git a/www/conservancy/templates/assignment/thanks.html b/www/conservancy/templates/assignment/thanks.html new file mode 100644 index 0000000000000000000000000000000000000000..04a916a517f9ff49b24db24d172f5898b59de921 --- /dev/null +++ b/www/conservancy/templates/assignment/thanks.html @@ -0,0 +1,15 @@ +{% extends "assignment/base_assignment.html" %} +{% load static %} +{% block category %}Copyright Assignment{% endblock %} +{% block outercontent %} +

Thanks!

+ +
+

Thank you for assigning your copyright to Software Freedom Conservancy! We have recorded the below information regarding the assignment and the works.

+

We will be sending out verification emails to the email addresses you used to contribute, as specified below, in the coming weeks. Please follow the instructions there to complete the verification at that time.

+

If you would like to make any changes, you must let us know within 7 days by emailing copyright-assignment@sfconservancy.org, which is also where you can reach us if you have any questions.

+
+ {{ form.as_p }} +
+
+{% endblock %} diff --git a/www/conservancy/urls.py b/www/conservancy/urls.py index 0cd95c4875d080a59eb3763dac55af8f40124e02..f22c3357980137785800beb4494928470072d14b 100644 --- a/www/conservancy/urls.py +++ b/www/conservancy/urls.py @@ -59,4 +59,5 @@ urlpatterns = [ url(r'^coming-soon.html', static_views.index), url(r'^fundraiser_data', fundgoal_views.view), url(r'^ccs-upload/', include('conservancy.apps.ccs_upload.urls', namespace='ccs_upload')), + url(r'^assignment/', include('conservancy.apps.assignment.urls')), ]