Skip to content

Commit 9c8366e

Browse files
committed
clean-up unused variable and improve placement. update for Django 3.2
1 parent 258117f commit 9c8366e

File tree

8 files changed

+18
-55
lines changed

8 files changed

+18
-55
lines changed

cc_legal_tools/settings/base.py

-4
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,6 @@
88
import colorlog # noqa: F401
99
from django.conf.locale import LANG_INFO
1010

11-
APP_NAME = "legal_tools"
12-
APP_LABEL = APP_NAME
13-
APP_VERBOSE_NAME = APP_NAME.replace("_", " ").title()
14-
1511
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
1612
# SETTINGS_DIR is where this settings file is
1713
SETTINGS_DIR = os.path.dirname(os.path.abspath(__file__))

legal_tools/__init__.py

-34
Original file line numberDiff line numberDiff line change
@@ -1,34 +0,0 @@
1-
# Standard library
2-
import re
3-
4-
default_app_config = "legal_tools.apps.LegalToolsConfig"
5-
6-
FREEDOM_LEVEL_MAX = 1
7-
FREEDOM_LEVEL_MID = 2
8-
FREEDOM_LEVEL_MIN = 3
9-
10-
FREEDOM_COLORS = {
11-
FREEDOM_LEVEL_MIN: "red",
12-
FREEDOM_LEVEL_MID: "yellow",
13-
FREEDOM_LEVEL_MAX: "green",
14-
}
15-
MISSING_LICENSES = [
16-
"http://creativecommons.org/licenses/by-nc/2.1/",
17-
"http://creativecommons.org/licenses/by-nd/2.1/",
18-
"http://creativecommons.org/licenses/by-nc-nd/2.1/",
19-
"http://creativecommons.org/licenses/by-sa/2.1/",
20-
"http://creativecommons.org/licenses/by-nc-sa/2.1/",
21-
"http://creativecommons.org/licenses/nc/2.0/",
22-
"http://creativecommons.org/licenses/nc-sa/2.0/",
23-
"http://creativecommons.org/licenses/by/2.1/",
24-
"http://creativecommons.org/licenses/nd-nc/2.0/",
25-
"http://creativecommons.org/licenses/by-nd-nc/2.0/",
26-
"http://creativecommons.org/licenses/nd/2.0/",
27-
"http://creativecommons.org/licenses/sa/2.0/",
28-
]
29-
30-
# These mostly APPEAR to have the format X.Y, where X and Y are digits.
31-
# To be forgiving, we accept any mix of digits and ".".
32-
# There's also at least one with an empty version (MIT).
33-
VERSION_REGEX_STRING = r"[0-9.]+|"
34-
VERSION_REGEX = re.compile(VERSION_REGEX_STRING)

legal_tools/apps.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,12 @@
88

99

1010
class LegalToolsConfig(AppConfig):
11-
# required: must be the Full dotted path to the app
12-
name = settings.APP_NAME
11+
# required: must be the full dotted path to the app
12+
name = "legal_tools"
1313
# optional: app label, must be unique in Django project
14-
label = settings.APP_LABEL
14+
label = name
1515
# optional: verbose name
16-
verbose_name = settings.APP_VERBOSE_NAME
16+
verbose_name = name.replace("_", " ").title()
1717

1818
def ready(self):
1919
setup_to_call_git()

legal_tools/models.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,12 @@
3131
map_django_to_redirects_language_codes,
3232
map_django_to_redirects_language_codes_lowercase,
3333
)
34-
from legal_tools import FREEDOM_LEVEL_MAX, FREEDOM_LEVEL_MID, FREEDOM_LEVEL_MIN
3534
from legal_tools.constants import EXCLUDED_LANGUAGE_IDENTIFIERS
3635

36+
FREEDOM_LEVEL_MAX = 1
37+
FREEDOM_LEVEL_MID = 2
38+
FREEDOM_LEVEL_MIN = 3
3739
MAX_LANGUAGE_CODE_LENGTH = 15
38-
3940
UNITS_LICENSES = [
4041
# Units are in all versions, unless otherwise noted:
4142
"by",

legal_tools/tests/test_models.py

+7-6
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,19 @@
88
from django.utils.translation import override
99

1010
# First-party/Local
11-
from legal_tools import FREEDOM_LEVEL_MAX, FREEDOM_LEVEL_MID, FREEDOM_LEVEL_MIN
12-
from legal_tools.models import LegalCode, Tool
11+
from legal_tools.models import (
12+
FREEDOM_LEVEL_MAX,
13+
FREEDOM_LEVEL_MID,
14+
FREEDOM_LEVEL_MIN,
15+
LegalCode,
16+
Tool,
17+
)
1318
from legal_tools.tests.factories import (
1419
LegalCodeFactory,
1520
ToolFactory,
1621
TranslationBranchFactory,
1722
)
1823

19-
# TODO: update as part of translation rewrite
20-
# from i18n.transifex import TransifexHelper
21-
# from legal_tools.tests.test_transifex import TEST_TRANSIFEX_SETTINGS
22-
2324

2425
class LegalCodeQuerySetTest(TestCase):
2526
def test_translated(self):

legal_tools/tests/test_views.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -416,9 +416,9 @@ def test_view_deed_template_body_certification(self):
416416

417417
def test_view_deed_template_body_unimplemented(self):
418418
lc = LegalCodeFactory(
419-
tool__canonical_url="https://creativecommons.org/licenses/x/0",
419+
tool__canonical_url="https://creativecommons.org/licenses/x/0.0",
420420
tool__unit="x",
421-
tool__version="0",
421+
tool__version="0.0",
422422
language_code="en",
423423
)
424424
url = lc.deed_url

legal_tools/urls.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313

1414
# First-party/Local
1515
from i18n import LANGUAGE_CODE_REGEX_STRING
16-
from legal_tools import VERSION_REGEX_STRING
1716
from legal_tools.views import view_deed, view_legal_code, view_metadata
1817

1918

@@ -73,7 +72,7 @@ def to_url(self, value):
7372

7473
class VersionConverter:
7574

76-
regex = VERSION_REGEX_STRING
75+
regex = r"[0-9]+[.][0-9]+" # X.Y
7776

7877
def to_python(self, value):
7978
return value

manage.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
# Third-party
88
from django.conf import settings
99

10-
LOG = logging.getLogger(f"{settings.APP_NAME}.management.commands")
10+
LOG = logging.getLogger(f"management.commands")
1111

1212

1313
def main():

0 commit comments

Comments
 (0)