🎨 Format Python code with Black
This commit is contained in:
committed by
github-actions[bot]
parent
318a1f6a93
commit
1e969d51a9
83
store/app.py
83
store/app.py
@ -149,7 +149,14 @@ def star_app(app_id, action):
|
||||
if app_id not in get_catalog()["apps"] and app_id not in get_wishlist():
|
||||
return _("App %(app_id) not found", app_id=app_id), 404
|
||||
if not session.get("user", {}):
|
||||
return _("You must be logged in to be able to star an app") + "<br/><br/>" + _("Note that, due to various abuses, we restricted login on the app store to 'trust level 1' users.<br/><br/>'Trust level 1' is obtained after interacting a minimum with the forum, and more specifically: entering at least 5 topics, reading at least 30 posts, and spending at least 10 minutes reading posts."), 401
|
||||
return (
|
||||
_("You must be logged in to be able to star an app")
|
||||
+ "<br/><br/>"
|
||||
+ _(
|
||||
"Note that, due to various abuses, we restricted login on the app store to 'trust level 1' users.<br/><br/>'Trust level 1' is obtained after interacting a minimum with the forum, and more specifically: entering at least 5 topics, reading at least 30 posts, and spending at least 10 minutes reading posts."
|
||||
),
|
||||
401,
|
||||
)
|
||||
|
||||
app_star_folder = os.path.join(".stars", app_id)
|
||||
app_star_for_this_user = os.path.join(
|
||||
@ -192,7 +199,13 @@ def add_to_wishlist():
|
||||
if request.method == "POST":
|
||||
user = session.get("user", {})
|
||||
if not user:
|
||||
errormsg = _("You must be logged in to submit an app to the wishlist") + "<br/><br/>" + _("Note that, due to various abuses, we restricted login on the app store to 'trust level 1' users.<br/><br/>'Trust level 1' is obtained after interacting a minimum with the forum, and more specifically: entering at least 5 topics, reading at least 30 posts, and spending at least 10 minutes reading posts.")
|
||||
errormsg = (
|
||||
_("You must be logged in to submit an app to the wishlist")
|
||||
+ "<br/><br/>"
|
||||
+ _(
|
||||
"Note that, due to various abuses, we restricted login on the app store to 'trust level 1' users.<br/><br/>'Trust level 1' is obtained after interacting a minimum with the forum, and more specifically: entering at least 5 topics, reading at least 30 posts, and spending at least 10 minutes reading posts."
|
||||
)
|
||||
)
|
||||
return render_template(
|
||||
"wishlist_add.html",
|
||||
locale=get_locale(),
|
||||
@ -220,12 +233,33 @@ def add_to_wishlist():
|
||||
website = request.form["website"].strip().replace("\n", "")
|
||||
license = request.form["license"].strip().replace("\n", "")
|
||||
|
||||
boring_keywords_to_check_for_people_not_reading_the_instructions = ["free", "open source", "open-source", "self-hosted", "simple", "lightweight", "light-weight", "léger", "best", "most", "fast", "rapide", "flexible", "puissante", "puissant", "powerful", "secure"]
|
||||
boring_keywords_to_check_for_people_not_reading_the_instructions = [
|
||||
"free",
|
||||
"open source",
|
||||
"open-source",
|
||||
"self-hosted",
|
||||
"simple",
|
||||
"lightweight",
|
||||
"light-weight",
|
||||
"léger",
|
||||
"best",
|
||||
"most",
|
||||
"fast",
|
||||
"rapide",
|
||||
"flexible",
|
||||
"puissante",
|
||||
"puissant",
|
||||
"powerful",
|
||||
"secure",
|
||||
]
|
||||
|
||||
checks = [
|
||||
(
|
||||
check_wishlist_submit_ratelimit(session['user']['username']) is True and session['user']['bypass_ratelimit'] is False,
|
||||
_("Proposing wishlist additions is limited to once every 15 days per user. Please try again in a few days.")
|
||||
check_wishlist_submit_ratelimit(session["user"]["username"]) is True
|
||||
and session["user"]["bypass_ratelimit"] is False,
|
||||
_(
|
||||
"Proposing wishlist additions is limited to once every 15 days per user. Please try again in a few days."
|
||||
),
|
||||
),
|
||||
(len(name) >= 3, _("App name should be at least 3 characters")),
|
||||
(len(name) <= 30, _("App name should be less than 30 characters")),
|
||||
@ -259,13 +293,22 @@ def add_to_wishlist():
|
||||
_("App name contains special characters"),
|
||||
),
|
||||
(
|
||||
all(keyword not in description.lower() for keyword in boring_keywords_to_check_for_people_not_reading_the_instructions),
|
||||
_("Please focus on what the app does, without using marketing, fuzzy terms, or repeating that the app is 'free' and 'self-hostable'.")
|
||||
all(
|
||||
keyword not in description.lower()
|
||||
for keyword in boring_keywords_to_check_for_people_not_reading_the_instructions
|
||||
),
|
||||
_(
|
||||
"Please focus on what the app does, without using marketing, fuzzy terms, or repeating that the app is 'free' and 'self-hostable'."
|
||||
),
|
||||
),
|
||||
(
|
||||
description.lower().split()[0] != name and (len(description.split()) == 1 or description.lower().split()[1] not in ["is", "est"]),
|
||||
_("No need to repeat the name of the app. Focus on what the app does.")
|
||||
)
|
||||
description.lower().split()[0] != name
|
||||
and (
|
||||
len(description.split()) == 1
|
||||
or description.lower().split()[1] not in ["is", "est"]
|
||||
),
|
||||
_("No need to repeat the name of the app. Focus on what the app does."),
|
||||
),
|
||||
]
|
||||
|
||||
for check, errormsg in checks:
|
||||
@ -300,7 +343,8 @@ def add_to_wishlist():
|
||||
successmsg=None,
|
||||
errormsg=_(
|
||||
"An entry with the name %(slug)s already exists in the wishlist, instead, you can <a href='%(url)s'>add a star to the app to show your interest</a>.",
|
||||
slug=slug, url=url,
|
||||
slug=slug,
|
||||
url=url,
|
||||
),
|
||||
)
|
||||
|
||||
@ -324,7 +368,7 @@ def add_to_wishlist():
|
||||
url = "https://github.com/YunoHost/apps/pulls?q=is%3Apr+is%3Aopen+wishlist"
|
||||
errormsg = _(
|
||||
"Failed to create the pull request to add the app to the wishlist… Maybe there's already <a href='%(url)s'>a waiting PR for this app</a>? Else, please report the issue to the YunoHost team.",
|
||||
url=url
|
||||
url=url,
|
||||
)
|
||||
return render_template(
|
||||
"wishlist_add.html",
|
||||
@ -378,7 +422,7 @@ Description: {description}
|
||||
url=url,
|
||||
)
|
||||
|
||||
save_wishlist_submit_for_ratelimit(session['user']['username'])
|
||||
save_wishlist_submit_for_ratelimit(session["user"]["username"])
|
||||
|
||||
return render_template(
|
||||
"wishlist_add.html",
|
||||
@ -445,10 +489,17 @@ def sso_login_callback():
|
||||
|
||||
uri_to_redirect_to_after_login = session.get("uri_to_redirect_to_after_login")
|
||||
|
||||
if "trust_level_1" not in user_data['groups'][0].split(','):
|
||||
return _("Unfortunately, login was denied.") + "<br/><br/>" + _("Note that, due to various abuses, we restricted login on the app store to 'trust level 1' users.<br/><br/>'Trust level 1' is obtained after interacting a minimum with the forum, and more specifically: entering at least 5 topics, reading at least 30 posts, and spending at least 10 minutes reading posts."), 403
|
||||
if "trust_level_1" not in user_data["groups"][0].split(","):
|
||||
return (
|
||||
_("Unfortunately, login was denied.")
|
||||
+ "<br/><br/>"
|
||||
+ _(
|
||||
"Note that, due to various abuses, we restricted login on the app store to 'trust level 1' users.<br/><br/>'Trust level 1' is obtained after interacting a minimum with the forum, and more specifically: entering at least 5 topics, reading at least 30 posts, and spending at least 10 minutes reading posts."
|
||||
),
|
||||
403,
|
||||
)
|
||||
|
||||
if "staff" in user_data['groups'][0].split(','):
|
||||
if "staff" in user_data["groups"][0].split(","):
|
||||
bypass_ratelimit = True
|
||||
else:
|
||||
bypass_ratelimit = False
|
||||
|
@ -1,13 +1,14 @@
|
||||
import os
|
||||
|
||||
install_dir = os.path.dirname(__file__)
|
||||
command = f'{install_dir}/venv/bin/gunicorn'
|
||||
command = f"{install_dir}/venv/bin/gunicorn"
|
||||
pythonpath = install_dir
|
||||
workers = 4
|
||||
user = 'appstore'
|
||||
bind = f'unix:{install_dir}/sock'
|
||||
pid = '/run/gunicorn/appstore-pid'
|
||||
errorlog = '/var/log/appstore/error.log'
|
||||
accesslog = '/var/log/appstore/access.log'
|
||||
user = "appstore"
|
||||
bind = f"unix:{install_dir}/sock"
|
||||
pid = "/run/gunicorn/appstore-pid"
|
||||
errorlog = "/var/log/appstore/error.log"
|
||||
accesslog = "/var/log/appstore/access.log"
|
||||
access_log_format = '%({X-Real-IP}i)s %({X-Forwarded-For}i)s %(h)s %(l)s %(u)s %(t)s "%(r)s" %(s)s %(b)s "%(f)s" "%(a)s"'
|
||||
loglevel = 'warning'
|
||||
loglevel = "warning"
|
||||
capture_output = True
|
||||
|
@ -93,6 +93,7 @@ def get_stars():
|
||||
get_stars.cache_checksum = None
|
||||
get_stars()
|
||||
|
||||
|
||||
def check_wishlist_submit_ratelimit(user):
|
||||
|
||||
dir_ = os.path.join(".wishlist_ratelimit")
|
||||
@ -101,7 +102,10 @@ def check_wishlist_submit_ratelimit(user):
|
||||
|
||||
f = os.path.join(dir_, md5(user.encode()).hexdigest())
|
||||
|
||||
return not os.path.exists(f) or (time.time() - os.path.getmtime(f)) > (15 * 24 * 3600) # 15 days
|
||||
return not os.path.exists(f) or (time.time() - os.path.getmtime(f)) > (
|
||||
15 * 24 * 3600
|
||||
) # 15 days
|
||||
|
||||
|
||||
def save_wishlist_submit_for_ratelimit(user):
|
||||
|
||||
@ -178,9 +182,9 @@ def get_app_md_and_screenshots(app_folder, infos):
|
||||
if entry.is_file() and ext in ("png", "jpg", "jpeg", "webp", "gif"):
|
||||
with open(entry.path, "rb") as img_file:
|
||||
data = base64.b64encode(img_file.read()).decode("utf-8")
|
||||
infos[
|
||||
"screenshot"
|
||||
] = f"data:image/{ext};charset=utf-8;base64,{data}"
|
||||
infos["screenshot"] = (
|
||||
f"data:image/{ext};charset=utf-8;base64,{data}"
|
||||
)
|
||||
break
|
||||
|
||||
ram_build_requirement = infos["manifest"]["integration"]["ram"]["build"]
|
||||
|
Reference in New Issue
Block a user