Skip to content

Commit bae071a

Browse files
committed
[1432] Review corrections; removed underline from icon
1 parent 3f71920 commit bae071a

File tree

3 files changed

+106
-71
lines changed

3 files changed

+106
-71
lines changed

bin/check_celery_worker_liveness.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -59,4 +59,4 @@
5959
sys.exit(1)
6060

6161
print("Celery worker heartbeat found: OK.")
62-
sys.exit(0)
62+
sys.exit(0)

bootstrap.py

+99-69
Original file line numberDiff line numberDiff line change
@@ -13,26 +13,36 @@
1313
Set up my development environment for me!
1414
"""
1515

16-
project_name = 'open_inwoner'
16+
project_name = "open_inwoner"
1717

1818
parser = argparse.ArgumentParser(description=description)
19-
parser.add_argument('target', choices=['production', 'staging', 'test', 'jenkins', 'dev'],
20-
help='production/staging/test/jenkins/dev')
21-
parser.add_argument('--project', default=project_name,
22-
help='Name of the project in your src directory, "%s" by default' % project_name)
23-
parser.add_argument('--init', action='store_true',
24-
help='Initialize a fresh "startproject" by pinning the requirements using pip-tools compile. '
25-
'Automatically done if requirements/base.txt does not yet exist.')
26-
parser.add_argument('--env', default='env',
27-
help='Directory name for virtualenv, "env" by default')
19+
parser.add_argument(
20+
"target",
21+
choices=["production", "staging", "test", "jenkins", "dev"],
22+
help="production/staging/test/jenkins/dev",
23+
)
24+
parser.add_argument(
25+
"--project",
26+
default=project_name,
27+
help='Name of the project in your src directory, "%s" by default' % project_name,
28+
)
29+
parser.add_argument(
30+
"--init",
31+
action="store_true",
32+
help='Initialize a fresh "startproject" by pinning the requirements using pip-tools compile. '
33+
"Automatically done if requirements/base.txt does not yet exist.",
34+
)
35+
parser.add_argument(
36+
"--env", default="env", help='Directory name for virtualenv, "env" by default'
37+
)
2838

2939
args = parser.parse_args()
3040

3141

3242
def replace_or_append(file_path, search_val, replace_val):
3343
file_handle, abs_path = mkstemp()
34-
new_file = open(abs_path, 'w')
35-
old_file = open(file_path, 'r')
44+
new_file = open(abs_path, "w")
45+
old_file = open(file_path, "r")
3646
found = False
3747
for line in old_file:
3848
if line.startswith(search_val):
@@ -51,89 +61,109 @@ def replace_or_append(file_path, search_val, replace_val):
5161

5262

5363
def replace_wsgi_settings(target):
54-
path = os.path.join('src', project_name, 'wsgi.py')
64+
path = os.path.join("src", project_name, "wsgi.py")
5565
replace_or_append(
56-
path, 'os.environ.setdefault',
57-
'os.environ.setdefault("DJANGO_SETTINGS_MODULE", "%s.conf.%s")\n' % (project_name, target)
66+
path,
67+
"os.environ.setdefault",
68+
'os.environ.setdefault("DJANGO_SETTINGS_MODULE", "%s.conf.%s")\n'
69+
% (project_name, target),
5870
)
5971

6072

6173
def replace_manage_settings(target):
62-
path = os.path.join('src', project_name, 'manage.py')
74+
path = os.path.join("src", project_name, "manage.py")
6375
replace_or_append(
64-
path, ' os.environ.setdefault',
65-
' os.environ.setdefault("DJANGO_SETTINGS_MODULE", "%s.conf.%s")\n' % (project_name, target)
76+
path,
77+
" os.environ.setdefault",
78+
' os.environ.setdefault("DJANGO_SETTINGS_MODULE", "%s.conf.%s")\n'
79+
% (project_name, target),
6680
)
6781

6882

6983
def append_settings_activate(project, target, env):
70-
if os.name == 'posix':
71-
path = '%s/bin/activate' % env
72-
replace_or_append(path, 'export DJANGO_SETTINGS_MODULE=',
73-
'export DJANGO_SETTINGS_MODULE=\'%s.conf.%s\'\n' %
74-
(project, target))
75-
elif os.name == 'nt':
76-
path = '%s\\Scripts\\activate.bat' % env
77-
replace_or_append(path, 'set DJANGO_SETTINGS_MODULE=',
78-
'set DJANGO_SETTINGS_MODULE=%s.conf.%s\n' %
79-
(project, target))
80-
path = '%s\\Scripts\\deactivate.bat' % env
81-
replace_or_append(path, 'set DJANGO_SETTINGS_MODULE=',
82-
'set DJANGO_SETTINGS_MODULE=\n')
84+
if os.name == "posix":
85+
path = "%s/bin/activate" % env
86+
replace_or_append(
87+
path,
88+
"export DJANGO_SETTINGS_MODULE=",
89+
"export DJANGO_SETTINGS_MODULE='%s.conf.%s'\n" % (project, target),
90+
)
91+
elif os.name == "nt":
92+
path = "%s\\Scripts\\activate.bat" % env
93+
replace_or_append(
94+
path,
95+
"set DJANGO_SETTINGS_MODULE=",
96+
"set DJANGO_SETTINGS_MODULE=%s.conf.%s\n" % (project, target),
97+
)
98+
path = "%s\\Scripts\\deactivate.bat" % env
99+
replace_or_append(
100+
path, "set DJANGO_SETTINGS_MODULE=", "set DJANGO_SETTINGS_MODULE=\n"
101+
)
83102

84103

85104
def pip_compile_pin_requirements(virtualenv):
86-
print('\n== Compiling base requirements ==\n')
87-
if os.name == 'posix':
88-
pip_path = os.path.join(virtualenv, 'bin', 'pip')
89-
elif os.name == 'nt':
90-
pip_path = os.path.join(virtualenv, 'Scripts', 'pip')
91-
cmd_tpl = '{pip} install pip-tools'.format(pip=pip_path)
105+
print("\n== Compiling base requirements ==\n")
106+
if os.name == "posix":
107+
pip_path = os.path.join(virtualenv, "bin", "pip")
108+
elif os.name == "nt":
109+
pip_path = os.path.join(virtualenv, "Scripts", "pip")
110+
cmd_tpl = "{pip} install pip-tools".format(pip=pip_path)
92111
call(cmd_tpl, shell=True)
93-
print('Error: Run `. env/bin/activate && ./bin/compile_dependencies.sh` to ensure you have requirements/base.txt and requirements/dev.txt')
94-
print('After that rerun bootstrap.py')
112+
print(
113+
"Error: Run `. env/bin/activate && ./bin/compile_dependencies.sh` to ensure you have requirements/base.txt and requirements/dev.txt"
114+
)
115+
print("After that rerun bootstrap.py")
95116
sys.exit(1)
96117

118+
97119
def main():
98120
virtualenv = args.env
99-
if not hasattr(sys, 'real_prefix'):
100-
print('\n== Creating virtual environment ==\n')
101-
call('virtualenv {0} --python=python3 --prompt="({1}-{2}) "'.format(
102-
virtualenv, args.project, args.target
103-
), shell=True)
104-
print('\n== Set "%s.conf.%s" as default settings ==\n' % (args.project, args.target))
121+
if not hasattr(sys, "real_prefix"):
122+
print("\n== Creating virtual environment ==\n")
123+
call(
124+
'virtualenv {0} --python=python3 --prompt="({1}-{2}) "'.format(
125+
virtualenv, args.project, args.target
126+
),
127+
shell=True,
128+
)
129+
print(
130+
'\n== Set "%s.conf.%s" as default settings ==\n' % (args.project, args.target)
131+
)
105132
append_settings_activate(args.project, args.target, args.env)
106133

107-
if os.name == 'posix':
134+
if os.name == "posix":
108135
# Make manage.py executable
109-
st = os.stat('src/manage.py')
110-
os.chmod('src/manage.py', st.st_mode | stat.S_IEXEC)
111-
django_admin_symlink = os.path.join(virtualenv, 'bin', 'django')
136+
st = os.stat("src/manage.py")
137+
os.chmod("src/manage.py", st.st_mode | stat.S_IEXEC)
138+
django_admin_symlink = os.path.join(virtualenv, "bin", "django")
112139
if not os.path.exists(django_admin_symlink):
113-
os.symlink('../../src/manage.py', django_admin_symlink)
114-
115-
print('\n== Upgrading Pip ==\n')
116-
if os.name == 'posix':
117-
pip_path = os.path.join(virtualenv, 'bin', 'pip')
118-
elif os.name == 'nt':
119-
pip_path = os.path.join(virtualenv, 'Scripts', 'pip')
120-
cmd_tpl = '{pip} install --upgrade pip'.format(pip=pip_path)
140+
os.symlink("../../src/manage.py", django_admin_symlink)
141+
142+
print("\n== Upgrading Pip ==\n")
143+
if os.name == "posix":
144+
pip_path = os.path.join(virtualenv, "bin", "pip")
145+
elif os.name == "nt":
146+
pip_path = os.path.join(virtualenv, "Scripts", "pip")
147+
cmd_tpl = "{pip} install --upgrade pip".format(pip=pip_path)
121148
call(cmd_tpl, shell=True)
122149

123-
if args.init \
124-
or not os.path.exists(os.path.join('requirements', 'base.txt')) \
125-
or not os.path.exists(os.path.join('requirements', 'dev.txt')):
150+
if (
151+
args.init
152+
or not os.path.exists(os.path.join("requirements", "base.txt"))
153+
or not os.path.exists(os.path.join("requirements", "dev.txt"))
154+
):
126155
pip_compile_pin_requirements(virtualenv)
127156

128-
print('\n== Installing %s requirements ==\n' % args.target)
129-
if os.name == 'posix':
130-
os.environ['TMPDIR'] = '/var/tmp/'
131-
pip_path = os.path.join(virtualenv, 'bin', 'pip')
132-
cmd_tpl = '{pip} install -r requirements/{target}.txt'
133-
elif os.name == 'nt':
134-
pip_path = os.path.join(virtualenv, 'Scripts', 'pip')
135-
cmd_tpl = '{pip} install -r requirements\\{target}.txt'
157+
print("\n== Installing %s requirements ==\n" % args.target)
158+
if os.name == "posix":
159+
os.environ["TMPDIR"] = "/var/tmp/"
160+
pip_path = os.path.join(virtualenv, "bin", "pip")
161+
cmd_tpl = "{pip} install -r requirements/{target}.txt"
162+
elif os.name == "nt":
163+
pip_path = os.path.join(virtualenv, "Scripts", "pip")
164+
cmd_tpl = "{pip} install -r requirements\\{target}.txt"
136165
return call(cmd_tpl.format(pip=pip_path, target=args.target), shell=True)
137166

138-
if __name__ == '__main__':
167+
168+
if __name__ == "__main__":
139169
sys.exit(main())

src/open_inwoner/utils/ckeditor.py

+6-1
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,12 @@ def get_rendered_content(content: str) -> str:
5555
if element.name == "a" and element.attrs.get("href", "").startswith("http"):
5656
# icon & screenreader support
5757
icon = soup.new_tag("span")
58-
icon.attrs.update({"aria-hidden": "true", "class": "material-icons"})
58+
icon.attrs.update(
59+
{
60+
"aria-hidden": "true",
61+
"class": "material-icons text-decoration-none",
62+
}
63+
)
5964
icon.append("open_in_new")
6065

6166
screen_reader_only_text = soup.new_tag("span")

0 commit comments

Comments
 (0)