Skip to content

Commit

Permalink
add ali materials to check against
Browse files Browse the repository at this point in the history
  • Loading branch information
teovin committed May 21, 2024
1 parent 18c2dd3 commit 2797a90
Show file tree
Hide file tree
Showing 3 changed files with 218 additions and 26 deletions.
32 changes: 7 additions & 25 deletions web/main/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import logging
import time
import json
from datetime import datetime
from enum import Enum
from os.path import commonprefix
Expand Down Expand Up @@ -1657,38 +1658,19 @@ def export_content(self, request):
return self.resource.content

def get_ali_license_text(self):
licensed_materials = [
{
"title": "Restatements of the Law",
"copyright_year": 2014,
"match_words": [
"restatement",
"restatements",
"contracts",
"restatements of the law",
],
},
{
"title": "Principles of the Law",
"copyright_year": 2015,
"match_words": ["principle", "principles", "principles of the law"],
},
{
"title": "Model Penal Code",
"copyright_year": 2016,
"match_words": ["model penal code", "mpc"],
},
]
with open(f"{settings.STATIC_ROOT}/data/ali_materials.json", "r") as file:
licensed_materials = json.load(file)

license_txt = ""
title = self.title.lower()
license_txt = ""

for item in licensed_materials:
if any(word.lower() in title for word in item["match_words"]):
if all(word in title for word in item["match_words"]):
license_txt = (
f"{item['title']}, copyright @ {item['copyright_year']} by the American Law Institute. "
f"{item['title']}, copyright @ {item['years']} by the American Law Institute. "
f"Reproduced with permission, not as part of a Creative Commons license."
)

return license_txt

@property
Expand Down
210 changes: 210 additions & 0 deletions web/static/data/ali_materials.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,210 @@
[
{
"title": "Restatement of the Law, Agency",
"years": "2006-2023",
"match_words": [
"restatement",
"agency"
]
},
{
"title": "Restatement of the Law, The Law of American Indians",
"years": "2022-2023",
"match_words": [
"restatement",
"the law of american indians"
]
},
{
"title": "Restatement of the Law, Charitable Nonprofit Organizations",
"years": "2021-2023",
"match_words": [
"restatement",
"charitable nonprofit organizations"
]
},
{
"title": "Restatement of the Law, Conflict of Laws",
"years": "1971-2023",
"match_words": [
"restatement",
"conflict of laws"
]
},
{
"title": "Restatement of the Law, Contracts",
"years": "1981-2023",
"match_words": [
"restatement",
"contracts"
]
},
{
"title": "Restatement of the Law, Employment Law",
"years": "2015-2023",
"match_words": [
"restatement",
"employment law"
]
},
{
"title": "Restatement of the Law, Foreign Relations Law of the United States",
"years": "1987-2023",
"match_words": [
"restatement",
"foreign relations law of the united states"
]
},
{
"title": "Restatement of the Law, Judgments",
"years": "1982-2023",
"match_words": [
"restatement",
"judgments"
]
},
{
"title": "Restatement of the Law, The Law Governing Lawyers",
"years": "2000-2023",
"match_words": [
"restatement",
"the law governing lawyers"
]
},
{
"title": "Restatement of the Law, Liability Insurance",
"years": "2019-2023",
"match_words": [
"restatement",
"liability insurance"
]
},
{
"title": "Restatement of the Law, Property",
"years": "1977-2023",
"match_words": [
"restatement",
"property"
]
},
{
"title": "Restatement of the Law, Restitution and Unjust Enrichment",
"years": "2011-2023",
"match_words": [
"restatement",
"restitution and unjust enrichment"
]
},
{
"title": "Restatement of the Law, Suretyship and Guaranty",
"years": "1996-2023",
"match_words": [
"restatement",
"suretyship and guaranty"
]
},
{
"title": "Restatement of the Law, Torts",
"years": "1965-2023",
"match_words": [
"restatement",
"torts"
]
},
{
"title": "Restatement of the Law, Trusts",
"years": "2003-2023",
"match_words": [
"restatement",
"trusts"
]
},
{
"title": "Restatement of the Law, Unfair Competition",
"years": "1995-2023",
"match_words": [
"restatement",
"unfair competition"
]
},
{
"title": "Restatement of the Law, The U.S. Law of International Commercial and Investor-State Arbitration",
"years": "2023",
"match_words": [
"restatement",
"the u.s. law of international commercial and investor-state arbitrationn"
]
},
{
"title": "Principle of the Law, Aggregate Litigation",
"years": "2010-2023",
"match_words": [
"restatement",
"aggregate litigation"
]
},
{
"title": "Principle of the Law, Corporate Governance",
"years": "1994-2023",
"match_words": [
"restatement",
"corporate governance"
]
},
{
"title": "Principle of the Law, Data Privacy",
"years": "2020",
"match_words": [
"restatement",
"data privacy"
]
},
{
"title": "Principle of the Law, Election Administration: Non-Precinct Voting and Resolution of Ballot-Counting Disputes",
"years": "2019-2023",
"match_words": [
"restatement",
"election administration: non-precinct voting and resolution of ballot-counting disputes"
]
},
{
"title": "Principle of the Law, Family Dissolution",
"years": "2002-2023",
"match_words": [
"restatement",
"family dissolution"
]
},
{
"title": "Principle of the Law, Intellectual Property: Principles Governing Jurisdiction, Choice of Law, and Judgments in Transnational Disputes",
"years": "2008",
"match_words": [
"restatement",
"intellectual property: principles governing jurisdiction, choice of law, and judgments in transnational disputes"
]
},
{
"title": "Principle of the Law, Software Contracts",
"years": "2010",
"match_words": [
"restatement",
"software contracts"
]
},
{
"title": "Model Penal Code, Sentencing",
"years": "2023",
"match_words": [
"model penal code",
"sentencing"
]
},
{
"title": "Model Penal Code, Sexual Assault and Related Offenses",
"years": "2021-2022",
"match_words": [
"model penal code",
"sexual assault and related offenses"
]
}
]
2 changes: 1 addition & 1 deletion web/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -478,4 +478,4 @@ def populate_ali_licensed(ctx):
for node in ContentNode.objects.all():
if node.get_ali_license_text():
node.ali_licensed = True
node.save()
node.save(update_fields=["ali_licensed"])

0 comments on commit 2797a90

Please sign in to comment.