Compare commits

...

5 commits

Author SHA1 Message Date
Jinx
bcf9d5339f
Merge 72bc34e4af into 7505cbe25a 2024-12-20 23:27:16 +01:00
Mickaël Schoentgen
7505cbe25a feat: Add a SITE_NAME setting and use it everywhere.
Some checks failed
CI / lint (push) Has been cancelled
CI / docs (push) Has been cancelled
Docker build / test (push) Has been cancelled
CI / test (mariadb, minimal, 3.11) (push) Has been cancelled
CI / test (mariadb, normal, 3.11) (push) Has been cancelled
CI / test (mariadb, normal, 3.9) (push) Has been cancelled
CI / test (postgresql, minimal, 3.11) (push) Has been cancelled
CI / test (postgresql, normal, 3.11) (push) Has been cancelled
CI / test (postgresql, normal, 3.9) (push) Has been cancelled
CI / test (sqlite, minimal, 3.10) (push) Has been cancelled
CI / test (sqlite, minimal, 3.11) (push) Has been cancelled
CI / test (sqlite, minimal, 3.12) (push) Has been cancelled
CI / test (sqlite, minimal, 3.9) (push) Has been cancelled
CI / test (sqlite, normal, 3.10) (push) Has been cancelled
CI / test (sqlite, normal, 3.11) (push) Has been cancelled
CI / test (sqlite, normal, 3.12) (push) Has been cancelled
CI / test (sqlite, normal, 3.8) (push) Has been cancelled
CI / test (sqlite, normal, 3.9) (push) Has been cancelled
Docker build / build_upload (push) Has been cancelled
2024-12-20 23:27:11 +01:00
Jinx
72bc34e4af Fixed the way the #1288 csv file test is loaded 2024-02-19 16:25:30 +08:00
Jinx
f9e1e9241c
Merge branch 'spiral-project:master' into master 2024-02-19 16:00:47 +08:00
Jinx
12c77b4850 Fixing the issue of garbled characters (Chinese characters) when opening the CSV export in Microsoft Excel. 2024-02-04 14:20:10 +08:00
8 changed files with 25 additions and 7 deletions

View file

@ -173,6 +173,14 @@ URL you want.
- **Default value:** `""` (empty string) - **Default value:** `""` (empty string)
- **Production value:** The URL of your chosing. - **Production value:** The URL of your chosing.
## SITE_NAME
It is possible to change the name of the site to something at your liking.
- **Default value:** `"I Hate Money"` (empty string)
- **Production value:** The name of your choosing
## Configuring email sending ## Configuring email sending
By default, Ihatemoney sends emails using a local SMTP server, but it's By default, Ihatemoney sends emails using a local SMTP server, but it's

View file

@ -3,6 +3,7 @@ DEBUG = SQLACHEMY_ECHO = False
SQLALCHEMY_DATABASE_URI = "sqlite:////tmp/ihatemoney.db" SQLALCHEMY_DATABASE_URI = "sqlite:////tmp/ihatemoney.db"
SQLALCHEMY_TRACK_MODIFICATIONS = False SQLALCHEMY_TRACK_MODIFICATIONS = False
SECRET_KEY = "tralala" SECRET_KEY = "tralala"
SITE_NAME = "I Hate Money"
MAIL_DEFAULT_SENDER = "Budget manager <admin@example.com>" MAIL_DEFAULT_SENDER = "Budget manager <admin@example.com>"
SHOW_ADMIN_EMAIL = True SHOW_ADMIN_EMAIL = True
ACTIVATE_DEMO_PROJECT = True ACTIVATE_DEMO_PROJECT = True

View file

@ -20,7 +20,7 @@
<!DOCTYPE html> <!DOCTYPE html>
<html class="h-100"> <html class="h-100">
<head> <head>
<title>{{ _("Account manager") }}{% block title %}{% endblock %}</title> <title>{{ SITE_NAME }} — {{ _("Account manager") }}{% block title %}{% endblock %}</title>
<meta http-equiv="content-type" content="text/html; charset=utf-8"> <meta http-equiv="content-type" content="text/html; charset=utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1"> <meta name="viewport" content="width=device-width, initial-scale=1">
<link rel=stylesheet type=text/css href="{{ url_for("static", filename='css/main.css') }}"> <link rel=stylesheet type=text/css href="{{ url_for("static", filename='css/main.css') }}">

View file

@ -238,7 +238,10 @@ class TestBudget(IhatemoneyTestCase):
url, data={"password": "pass", "password_confirmation": "pass"} url, data={"password": "pass", "password_confirmation": "pass"}
) )
resp = self.login("raclette", password="pass") resp = self.login("raclette", password="pass")
assert "<title>Account manager - raclette</title>" in resp.data.decode("utf-8") assert (
"<title>I Hate Money — Account manager - raclette</title>"
in resp.data.decode("utf-8")
)
# Test empty and null tokens # Test empty and null tokens
resp = self.client.get("/reset-password") resp = self.client.get("/reset-password")
assert "No token provided" in resp.data.decode("utf-8") assert "No token provided" in resp.data.decode("utf-8")

View file

@ -3,6 +3,7 @@
DEBUG = False DEBUG = False
SQLALCHEMY_DATABASE_URI = 'sqlite:///budget.db' SQLALCHEMY_DATABASE_URI = 'sqlite:///budget.db'
SQLACHEMY_ECHO = DEBUG SQLACHEMY_ECHO = DEBUG
SITE_NAME = "I Hate Money"
SECRET_KEY = "supersecret" SECRET_KEY = "supersecret"

View file

@ -442,7 +442,7 @@ class TestExport(IhatemoneyTestCase):
'2016-12-31,red wine,Expense,XXX,200.0,jeanne,1.0,"zorglub, tata"', '2016-12-31,red wine,Expense,XXX,200.0,jeanne,1.0,"zorglub, tata"',
'2016-12-31,à raclette,Expense,10.0,XXX,zorglub,2.0,"zorglub, jeanne, tata, pépé"', '2016-12-31,à raclette,Expense,10.0,XXX,zorglub,2.0,"zorglub, jeanne, tata, pépé"',
] ]
received_lines = resp.data.decode("utf-8").split("\n") received_lines = resp.data.decode("utf-8-sig").split("\n")
for i, line in enumerate(expected): for i, line in enumerate(expected):
assert set(line.split(",")) == set(received_lines[i].strip("\r").split(",")) assert set(line.split(",")) == set(received_lines[i].strip("\r").split(","))
@ -476,7 +476,7 @@ class TestExport(IhatemoneyTestCase):
"55.34,XXX,jeanne,tata", "55.34,XXX,jeanne,tata",
"127.33,XXX,jeanne,zorglub", "127.33,XXX,jeanne,zorglub",
] ]
received_lines = resp.data.decode("utf-8").split("\n") received_lines = resp.data.decode("utf-8-sig").split("\n")
for i, line in enumerate(expected): for i, line in enumerate(expected):
assert set(line.split(",")) == set(received_lines[i].strip("\r").split(",")) assert set(line.split(",")) == set(received_lines[i].strip("\r").split(","))
@ -682,7 +682,7 @@ class TestExport(IhatemoneyTestCase):
"date,what,bill_type,amount,currency,payer_name,payer_weight,owers", "date,what,bill_type,amount,currency,payer_name,payer_weight,owers",
"2016-12-31,'=COS(36),Expense,10.0,EUR,zorglub,1.0,zorglub", "2016-12-31,'=COS(36),Expense,10.0,EUR,zorglub,1.0,zorglub",
] ]
received_lines = resp.data.decode("utf-8").split("\n") received_lines = resp.data.decode("utf-8-sig").split("\n")
for i, line in enumerate(expected): for i, line in enumerate(expected):
assert set(line.split(",")) == set(received_lines[i].strip("\r").split(",")) assert set(line.split(",")) == set(received_lines[i].strip("\r").split(","))

View file

@ -194,7 +194,7 @@ def list_of_dicts2csv(dict_to_convert):
writer = csv.writer(csv_file) writer = csv.writer(csv_file)
writer.writerows(csv_data) writer.writerows(csv_data)
csv_file.seek(0) csv_file.seek(0)
csv_file = BytesIO(csv_file.getvalue().encode("utf-8")) csv_file = BytesIO(csv_file.getvalue().encode("utf-8-sig"))
return csv_file return csv_file
@ -202,7 +202,7 @@ def csv2list_of_dicts(csv_to_convert):
"""Take a csv in-memory file and turns it into """Take a csv in-memory file and turns it into
a list of dictionnaries a list of dictionnaries
""" """
csv_file = TextIOWrapper(csv_to_convert, encoding="utf-8") csv_file = TextIOWrapper(csv_to_convert, encoding="utf-8-sig")
reader = csv.DictReader(csv_file) reader = csv.DictReader(csv_file)
result = [] result = []
for r in reader: for r in reader:

View file

@ -137,6 +137,11 @@ def set_show_admin_dashboard_link(endpoint, values):
g.logout_form = LogoutForm() g.logout_form = LogoutForm()
@main.context_processor
def add_template_variables():
return {"SITE_NAME": current_app.config.get("SITE_NAME")}
@main.url_value_preprocessor @main.url_value_preprocessor
def pull_project(endpoint, values): def pull_project(endpoint, values):
"""When a request contains a project_id value, transform it directly """When a request contains a project_id value, transform it directly