Skip to content

Commit ef5aaa6

Browse files
committed
add link to privacy policy
1 parent 0a54ef7 commit ef5aaa6

3 files changed

Lines changed: 40 additions & 3 deletions

File tree

pythonhere/ui_here/settings_here.kv

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,3 +24,7 @@
2424

2525
<StartServersettingbutton>:
2626
title: f"{tc('', 3)} Start the server"
27+
28+
29+
<ShowPolicySettingButton>:
30+
title: "Open privacy policy in browser"

pythonhere/ui_here/settings_here.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
"""Settings panel widgets."""
22
from typing import Any, Dict
3+
import webbrowser
34

45
from kivy.app import App
56
from kivy.config import Config
@@ -48,6 +49,17 @@
4849
]
4950
"""
5051

52+
SETTINGS_PRIVACY = """[
53+
{
54+
"type": "title",
55+
"title": "PythonHere is intended for use as-is with no warranty of any kind."
56+
},
57+
{
58+
"type": "show_policy_button"
59+
}
60+
]
61+
"""
62+
5163

5264
class PasswordLabel(Label):
5365
"""Label wit a hidden text."""
@@ -89,6 +101,14 @@ def on_release(self):
89101
app.root.switch_screen(ScreenName.here)
90102

91103

104+
class ShowPolicySettingButton(SettingButton):
105+
"""Button to show privacy policy."""
106+
107+
def on_release(self):
108+
"""Show the policy."""
109+
webbrowser.open("https://herethere.me/privacy_policy.html")
110+
111+
92112
class SettingsHere(Settings):
93113
"""Customized settings panel."""
94114

@@ -99,12 +119,14 @@ def __init__(self, *args, **kargs):
99119
self.interface.menu.remove_widget(self.interface.menu.ids.button)
100120
self.register_type("password", SettingPassword)
101121
self.register_type("start_server_button", StartServerSettingButton)
122+
self.register_type("show_policy_button", ShowPolicySettingButton)
102123

103124
Config.setdefaults(
104125
"pythonhere", {"username": "here", "password": "", "port": 8022}
105126
)
106127
self.add_json_panel("PythonHere", Config, data=SETTINGS_HERE)
107128
self.add_kivy_panel()
129+
self.add_json_panel("Privacy Policy", Config, data=SETTINGS_PRIVACY)
108130

109131
def get_pythonhere_config(self) -> Dict[str, Any]:
110132
"""Extract server parts of the config."""

tests/test_settings.py

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,19 @@
1-
from kivy.uix.settings import Settings
2-
3-
from ui_here.settings_here import SettingsHere
1+
from ui_here.settings_here import SettingsHere, ShowPolicySettingButton
42

53

64
def test_build_settings_password_type_added():
75
settings = SettingsHere()
86
assert 'password' in settings._types
7+
8+
9+
def test_can_navigate_to_privacy_policy(mocker):
10+
webbrowser = mocker.patch("webbrowser.open")
11+
settings = SettingsHere()
12+
13+
for uid in settings.interface.content.panels.keys():
14+
settings.interface.content.current_uid = uid
15+
for widget in settings.interface.content.walk():
16+
if isinstance(widget, ShowPolicySettingButton):
17+
widget.on_release()
18+
19+
webbrowser.assert_called_once()

0 commit comments

Comments
 (0)