-
Notifications
You must be signed in to change notification settings - Fork 1
Adding Settings Menu #552
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adding Settings Menu #552
Changes from 4 commits
c4e102e
8d76417
c1fd7d9
d8653e0
701b0a7
7e4aedc
49bb332
33fc8ac
9c4dd4d
813bcd1
fc14808
c3f87f7
b52c7cd
85e0129
8acc7d7
c962278
c49b60a
06cade2
451ce4e
893a935
7697fe1
a42961f
0ffe07b
1fd2d8c
6f0aeaa
da9e056
33ccabe
7ffbf4c
27d4c46
b4c837a
42aac62
f905a24
cc450ca
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -11,6 +11,7 @@ | |
| import pandas as pd | ||
| import psutil | ||
|
|
||
| from django.http import QueryDict | ||
|
|
||
| # recipie from https://docs.python.org/3/library/itertools.html | ||
| def unique_justseen(iterable, key=None): | ||
|
|
@@ -138,7 +139,12 @@ def get_file_name_from_upload_path(upload_path: str) -> str: | |
| return f"{base_name}.{file_extension}" | ||
|
|
||
|
|
||
| def parameters_from_post(post): | ||
| def parameters_from_post(post: QueryDict) -> dict: | ||
| """ | ||
| Removes token from dict and converts the remaining entries into suitable data formats. | ||
| :param post: Django dict containing POST data. | ||
| :return: Dict containing the parameters in suitable formats. | ||
| """ | ||
| d = dict(post) | ||
| if "csrfmiddlewaretoken" in d: | ||
| del d["csrfmiddlewaretoken"] | ||
|
|
@@ -153,6 +159,11 @@ def parameters_from_post(post): | |
|
|
||
|
|
||
| def convert_str_if_possible(s): | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hier gerne auch doc-string und return type :)
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same as for
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Danke, dass du es trotzdem ergänzt hast ^^ |
||
| """ | ||
| Converts an input value into suitable representation as a string. | ||
| :param s: Input value. | ||
| :return: Converted input value. | ||
| """ | ||
| try: | ||
| f = float(s) | ||
| return int(f) if int(f) == f else f | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,41 @@ | ||
| import pytest | ||
| import plotly.graph_objects as go | ||
|
|
||
| from protzilla.constants.colors import PLOT_PRIMARY_COLOR, PLOT_SECONDARY_COLOR | ||
| from protzilla.constants.paths import SETTINGS_PATH | ||
| from ui.settings.plot_template import ( | ||
| determine_font, | ||
| resize_for_display, | ||
| get_scale_factor | ||
| ) | ||
|
|
||
|
|
||
| @pytest.fixture | ||
| def sample_params(): | ||
| return { | ||
| "section_id": "plots", | ||
| "file_format": "png", | ||
| "width": 85, | ||
| "height": 60, | ||
| "custom_font": "Ubuntu Mono", | ||
| "font": "Arial", | ||
| "heading_size": 11, | ||
| "text_size": 8 | ||
| } | ||
|
|
||
| def test_determine_font(sample_params): | ||
| assert determine_font(sample_params) == "Arial" | ||
| sample_params["font"] = "Custom" | ||
| assert determine_font(sample_params) == "Ubuntu Mono" | ||
|
|
||
| def test_resize_for_display(sample_params): | ||
| result = resize_for_display(sample_params) | ||
| assert result["display_width"] == 600 # SCALED_WIDTH | ||
| assert result["display_heading_size"] == 26 | ||
|
|
||
| def test_get_scale_factor(sample_params): | ||
| fig = go.Figure() | ||
| fig.update_layout(width=600) | ||
| scale = get_scale_factor(fig, sample_params) | ||
| assert isinstance(scale, float) | ||
| assert round(scale, 3) == 1.735 |
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sehr schön geschriebener Code finde ich!! |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -27,7 +27,10 @@ <h3>Manage Databases</h3> | |
| <form method="post" id="settings-form"> | ||
| {% csrf_token %} | ||
| <input type="hidden" name="section_id" value="{{ section_id }}"> | ||
| <!-- TO DO: Move database content to this page --> | ||
|
|
||
| <!-- PLEASE NOTE: This HTML is a placeholder. TO DO: Move "Manage databases" content to this page. --> | ||
| <p><b>Please note: This page is an placeholder for displaying the database management in the future.</b></p> | ||
|
|
||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ahh fair... Habe ich übersehen haha
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Alles fine, finde es so nochmal deutlich einleuchtender! (: |
||
| <div class="mb-2" id="settings-form"> | ||
| <h5>Datebases</h5> | ||
| <div class="field-wrapper"> | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,8 +1,8 @@ | ||
| custom_font: '' | ||
| file_format: png | ||
| font: Arial | ||
| heading_size: 22 | ||
| height: 40 | ||
|
||
| heading_size: 11 | ||
| height: 60 | ||
| section_id: plots | ||
| text_size: 16 | ||
| width: 60 | ||
| text_size: 8 | ||
| width: 85 | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Vielleicht noch hinzufügen was genau ein exportierter Plot ist, also ob es die raw files sind oder metadaten als Plot objekt oder so?