-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #703 from sgfost/cc-licenses
deprecate CC licenses in the CML
- Loading branch information
Showing
8 changed files
with
282 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
105 changes: 105 additions & 0 deletions
105
django/curator/management/commands/send_emails_cc_license_authors.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
from django.core.management.base import BaseCommand | ||
from django.contrib.auth.models import User | ||
from django.conf import settings | ||
from django.urls import reverse | ||
from pathlib import Path | ||
|
||
from core.utils import send_markdown_email | ||
from library.models import CodebaseRelease | ||
import logging | ||
|
||
logger = logging.getLogger(__name__) | ||
|
||
# temp file to track which user ids have been sent emails | ||
# in case of failure, we can resume from where we left off | ||
SENT_EMAILS_FILE_PATH = Path(settings.SHARE_DIR, "sent_cc_emails.txt") | ||
|
||
CC_LICENSE_CHANGE_URL = settings.BASE_URL + reverse("library:cc-license-change") | ||
|
||
|
||
class Command(BaseCommand): | ||
help = """ | ||
Sends an email to all users who have submitted codebase releases | ||
that are currently licensed under a Creative Commons license | ||
""" | ||
|
||
def add_arguments(self, parser): | ||
parser.add_argument( | ||
"--test-user-id", | ||
type=int, | ||
required=False, | ||
help="If specified, only email the specified user about their releases", | ||
) | ||
|
||
def handle(self, *args, **options): | ||
self.send_emails(test_user_id=options["test_user_id"]) | ||
|
||
def send_emails(self, test_user_id=None): | ||
sent_user_ids = self._read_sent_user_ids() | ||
|
||
# get all unique user ids that have submitted codebases with CC licenses | ||
releases_with_cc = CodebaseRelease.objects.with_cc_license() | ||
unique_submitter_ids = set( | ||
releases_with_cc.values_list("submitter", flat=True).distinct() | ||
if not test_user_id | ||
else [test_user_id] | ||
) | ||
users = User.objects.filter(id__in=unique_submitter_ids) | ||
user_emails = [user.email for user in users if user.id not in sent_user_ids] | ||
try: | ||
# send email, if successful, append user id to temp file to mark as sent | ||
if user_emails: | ||
send_markdown_email( | ||
to=[settings.EDITOR_EMAIL], | ||
subject="CoMSES Net Codebase License Change", | ||
body=self._get_email_body(), | ||
bcc=[user_emails], | ||
) | ||
with SENT_EMAILS_FILE_PATH.open("a") as f: | ||
f.write("\n".join(map(str, unique_submitter_ids))) | ||
else: | ||
logger.info("No emails needed to be sent: %s", user_emails) | ||
except Exception as e: | ||
logger.error("Failed to send email", e) | ||
|
||
# check if all submitters have been sent an email | ||
sent_user_ids = self._read_sent_user_ids() | ||
unset_ids = unique_submitter_ids - sent_user_ids | ||
if unset_ids: | ||
logger.warning( | ||
f"Failed to send emails to the following user ids: {unset_ids}" | ||
) | ||
else: | ||
logger.info( | ||
f""" | ||
==================================================================== | ||
All emails sent successfully, {SENT_EMAILS_FILE_PATH} can be removed | ||
==================================================================== | ||
""" | ||
) | ||
|
||
def _read_sent_user_ids(self): | ||
# read temp file that tracks which user ids have been sent emails | ||
try: | ||
with SENT_EMAILS_FILE_PATH.open("r") as f: | ||
return {int(line.strip()) for line in f} | ||
except FileNotFoundError: | ||
return set() | ||
|
||
def _get_email_body(self): | ||
return f""" | ||
Dear CoMSES Member, | ||
We are planning to phase out Creative Commons licenses in the CoMSES Model Library due to their [unsuitability for software](https://creativecommons.org/faq/#can-i-apply-a-creative-commons-license-to-software) and have determined that one or more of your submissions to the CoMSES Computational Model Library currently use a Creative Commons license. In order to ensure that your published computational models are properly licensed for reuse, we strongly urge to consider selecting an alternate OSI-approved open source license for your computational models. | ||
We have set up a straightforward process to transition all of your submissions at once to an appropriate software license. You can access this service at the following link (you will need to sign in to comses.net first): | ||
[{CC_LICENSE_CHANGE_URL}]({CC_LICENSE_CHANGE_URL}) | ||
Thank you for helping us make model software more accessible and reusable, and do not hesitate to contact us if you have any questions or require further assistance. | ||
Sincerely, | ||
The CoMSES Net Team | ||
""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
{% extends "base.jinja" %} | ||
|
||
{% block title %}Model License Migration{% endblock %} | ||
|
||
{% block introduction %}<h1>Model License Migration</h1>{% endblock %} | ||
|
||
{% block content %} | ||
<div class="container mt-4"> | ||
{% if user_releases %} | ||
<p> | ||
We are phasing out Creative Commons licenses for computational models | ||
published in the CoMSES Model Library. Creative Commons offers excellent licenses for data and publications but | ||
<a href="https://creativecommons.org/faq/#can-i-apply-a-creative-commons-license-to-software"> | ||
explicitly state that they <em>do not recommend</em> their usage for software. | ||
</a> | ||
In order to ensure that software in our model library is properly licensed for reuse, we are providing an easy | ||
way to relicense your models all at once to an appropriate software license. If you prefer a different | ||
license to the default alternatives listed below, please edit your specific codebase release's metadata and | ||
update the license there. | ||
</p> | ||
<ul> | ||
<li> | ||
Most <a href='https://creativecommons.org/licenses/by/4.0/'>CC-BY</a>, CC-NC, and CC-ND licenses will be | ||
replaced with the <a href="https://opensource.org/license/MIT" target="_blank">MIT license</a>, a commonly | ||
used permissive license that preserves the attribution requirement but promotes maximum reuse. | ||
</li> | ||
<li> | ||
All CC ShareAlike licenses will be changed to the | ||
<a href="https://www.gnu.org/licenses/gpl-3.0.en.html" target="_blank"> | ||
GNU General Public License v3.0 (GPL-3.0-or-later) | ||
</a>, a widely used copyleft license that is closest in spirit to the | ||
<a href='https://creativecommons.org/licenses/by-sa/4.0/'>ShareAlike</a> restriction. There are no commonly | ||
used software licenses that offer the same restrictions as the NonCommercial or NoDerivatives clauses in the | ||
Creative Commons family of licenses. | ||
</li> | ||
</ul> | ||
<hr /> | ||
<p><strong> | ||
Please review the following changes to the licensing of your models stored in the model library. By pressing | ||
confirm, you will be relicensing your software which affects how others are legally allowed to use your code. | ||
</strong></p> | ||
<form method="post"> | ||
{{ csrf_input }} | ||
<table class="table"> | ||
<thead> | ||
<tr> | ||
<th>Model release</th> | ||
<th>Current license</th> | ||
<th>Change to new license</th> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
{% for release in user_releases %} | ||
<tr> | ||
<td><a href="{{ release.get_absolute_url() }}">{{ release.title }}</a></td> | ||
<td class="table-danger"> | ||
{{ release.license.name }} | ||
<a href="{{ release.license.url }}" target="_blank"><i | ||
class="small fas fa-external-link-alt"></i></a> | ||
</td> | ||
<td class="table-success"> | ||
{{ release.candidate_license.name }} <a href="{{ release.candidate_license.url }}" | ||
target="_blank"><i class="small fas fa-external-link-alt"></i></a> | ||
</td> | ||
</tr> | ||
{% endfor %} | ||
</tbody> | ||
</table> | ||
<button type="submit" class="btn btn-primary mb-5 mt-3">Confirm License Change</button> | ||
</form> | ||
{% else %} | ||
<div class="alert alert-info" role="alert"> | ||
You do not have any releases requiring license updates. | ||
</div> | ||
{% endif %} | ||
</div> | ||
{% endblock %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters