From 2797a908f6bb7802f532c2c15bc60a33e6706c10 Mon Sep 17 00:00:00 2001 From: Ebru Yucesar Date: Tue, 21 May 2024 15:15:58 -0400 Subject: [PATCH] add ali materials to check against --- web/main/models.py | 32 +---- web/static/data/ali_materials.json | 210 +++++++++++++++++++++++++++++ web/tasks.py | 2 +- 3 files changed, 218 insertions(+), 26 deletions(-) create mode 100644 web/static/data/ali_materials.json diff --git a/web/main/models.py b/web/main/models.py index 589db6fea..4ceb0f99d 100644 --- a/web/main/models.py +++ b/web/main/models.py @@ -2,6 +2,7 @@ import logging import time +import json from datetime import datetime from enum import Enum from os.path import commonprefix @@ -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 diff --git a/web/static/data/ali_materials.json b/web/static/data/ali_materials.json new file mode 100644 index 000000000..de45d57ab --- /dev/null +++ b/web/static/data/ali_materials.json @@ -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" + ] + } +] \ No newline at end of file diff --git a/web/tasks.py b/web/tasks.py index 7b50ce34a..7246158c4 100644 --- a/web/tasks.py +++ b/web/tasks.py @@ -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"])