mirror of
https://github.com/simple-login/app.git
synced 2024-11-16 00:48:32 +01:00
rename available_suffixes_more_info -> get_available_suffixes
This commit is contained in:
parent
95f3db6aa5
commit
33dd6083c7
4 changed files with 12 additions and 12 deletions
|
@ -4,7 +4,7 @@ from sqlalchemy import desc
|
||||||
from app.api.base import api_bp, require_api_auth
|
from app.api.base import api_bp, require_api_auth
|
||||||
from app.config import ALIAS_DOMAINS, DISABLE_ALIAS_SUFFIX
|
from app.config import ALIAS_DOMAINS, DISABLE_ALIAS_SUFFIX
|
||||||
from app.dashboard.views.custom_alias import (
|
from app.dashboard.views.custom_alias import (
|
||||||
available_suffixes_more_info,
|
get_available_suffixes,
|
||||||
)
|
)
|
||||||
from app.extensions import db
|
from app.extensions import db
|
||||||
from app.log import LOG
|
from app.log import LOG
|
||||||
|
@ -301,7 +301,7 @@ def options_v4():
|
||||||
domain_name = convert_to_id(domain_name)
|
domain_name = convert_to_id(domain_name)
|
||||||
ret["prefix_suggestion"] = domain_name
|
ret["prefix_suggestion"] = domain_name
|
||||||
|
|
||||||
suffixes = available_suffixes_more_info(user)
|
suffixes = get_available_suffixes(user)
|
||||||
|
|
||||||
# custom domain should be put first
|
# custom domain should be put first
|
||||||
ret["suffixes"] = list([suffix.suffix, suffix.signed_suffix] for suffix in suffixes)
|
ret["suffixes"] = list([suffix.suffix, suffix.signed_suffix] for suffix in suffixes)
|
||||||
|
@ -372,7 +372,7 @@ def options_v5():
|
||||||
domain_name = convert_to_id(domain_name)
|
domain_name = convert_to_id(domain_name)
|
||||||
ret["prefix_suggestion"] = domain_name
|
ret["prefix_suggestion"] = domain_name
|
||||||
|
|
||||||
suffixes = available_suffixes_more_info(user)
|
suffixes = get_available_suffixes(user)
|
||||||
|
|
||||||
# custom domain should be put first
|
# custom domain should be put first
|
||||||
ret["suffixes"] = [
|
ret["suffixes"] = [
|
||||||
|
|
|
@ -40,7 +40,7 @@ class SuffixInfo:
|
||||||
is_premium: bool
|
is_premium: bool
|
||||||
|
|
||||||
|
|
||||||
def available_suffixes_more_info(user: User) -> [SuffixInfo]:
|
def get_available_suffixes(user: User) -> [SuffixInfo]:
|
||||||
"""
|
"""
|
||||||
Similar to as available_suffixes() but also return whether the suffix comes from a premium domain
|
Similar to as available_suffixes() but also return whether the suffix comes from a premium domain
|
||||||
Note that is-premium-domain is only relevant for SL domain
|
Note that is-premium-domain is only relevant for SL domain
|
||||||
|
@ -98,7 +98,7 @@ def custom_alias():
|
||||||
return redirect(url_for("dashboard.index"))
|
return redirect(url_for("dashboard.index"))
|
||||||
|
|
||||||
user_custom_domains = [cd.domain for cd in current_user.verified_custom_domains()]
|
user_custom_domains = [cd.domain for cd in current_user.verified_custom_domains()]
|
||||||
suffixes = available_suffixes_more_info(current_user)
|
suffixes = get_available_suffixes(current_user)
|
||||||
at_least_a_premium_domain = False
|
at_least_a_premium_domain = False
|
||||||
for suffix in suffixes:
|
for suffix in suffixes:
|
||||||
if not suffix.is_custom and suffix.is_premium:
|
if not suffix.is_custom and suffix.is_premium:
|
||||||
|
|
|
@ -7,7 +7,7 @@ from itsdangerous import SignatureExpired
|
||||||
|
|
||||||
from app.alias_utils import check_alias_prefix
|
from app.alias_utils import check_alias_prefix
|
||||||
from app.config import EMAIL_DOMAIN
|
from app.config import EMAIL_DOMAIN
|
||||||
from app.dashboard.views.custom_alias import signer, available_suffixes_more_info
|
from app.dashboard.views.custom_alias import signer, get_available_suffixes
|
||||||
from app.extensions import db
|
from app.extensions import db
|
||||||
from app.jose_utils import make_id_token
|
from app.jose_utils import make_id_token
|
||||||
from app.log import LOG
|
from app.log import LOG
|
||||||
|
@ -112,7 +112,7 @@ def authorize():
|
||||||
user_custom_domains = [
|
user_custom_domains = [
|
||||||
cd.domain for cd in current_user.verified_custom_domains()
|
cd.domain for cd in current_user.verified_custom_domains()
|
||||||
]
|
]
|
||||||
suffixes = available_suffixes_more_info(current_user)
|
suffixes = get_available_suffixes(current_user)
|
||||||
|
|
||||||
return render_template(
|
return render_template(
|
||||||
"oauth/authorize.html",
|
"oauth/authorize.html",
|
||||||
|
|
|
@ -5,7 +5,7 @@ from app.config import EMAIL_DOMAIN
|
||||||
from app.dashboard.views.custom_alias import (
|
from app.dashboard.views.custom_alias import (
|
||||||
signer,
|
signer,
|
||||||
verify_prefix_suffix,
|
verify_prefix_suffix,
|
||||||
available_suffixes_more_info,
|
get_available_suffixes,
|
||||||
)
|
)
|
||||||
from app.extensions import db
|
from app.extensions import db
|
||||||
from app.models import (
|
from app.models import (
|
||||||
|
@ -108,10 +108,10 @@ def test_available_suffixes(flask_client):
|
||||||
|
|
||||||
CustomDomain.create(user_id=user.id, domain="test.com", verified=True)
|
CustomDomain.create(user_id=user.id, domain="test.com", verified=True)
|
||||||
|
|
||||||
assert len(available_suffixes_more_info(user)) > 0
|
assert len(get_available_suffixes(user)) > 0
|
||||||
|
|
||||||
# first suffix is custom domain
|
# first suffix is custom domain
|
||||||
first_suffix = available_suffixes_more_info(user)[0]
|
first_suffix = get_available_suffixes(user)[0]
|
||||||
assert first_suffix.is_custom
|
assert first_suffix.is_custom
|
||||||
assert first_suffix.suffix == "@test.com"
|
assert first_suffix.suffix == "@test.com"
|
||||||
assert first_suffix.signed_suffix.startswith("@test.com")
|
assert first_suffix.signed_suffix.startswith("@test.com")
|
||||||
|
@ -126,12 +126,12 @@ def test_available_suffixes_default_domain(flask_client):
|
||||||
user.default_alias_public_domain_id = sl_domain.id
|
user.default_alias_public_domain_id = sl_domain.id
|
||||||
|
|
||||||
# first suffix is SL Domain
|
# first suffix is SL Domain
|
||||||
first_suffix = available_suffixes_more_info(user)[0]
|
first_suffix = get_available_suffixes(user)[0]
|
||||||
assert first_suffix.suffix.endswith(f"@{sl_domain.domain}")
|
assert first_suffix.suffix.endswith(f"@{sl_domain.domain}")
|
||||||
|
|
||||||
user.default_alias_public_domain_id = None
|
user.default_alias_public_domain_id = None
|
||||||
# first suffix is custom domain
|
# first suffix is custom domain
|
||||||
first_suffix = available_suffixes_more_info(user)[0]
|
first_suffix = get_available_suffixes(user)[0]
|
||||||
assert first_suffix.suffix == "@test.com"
|
assert first_suffix.suffix == "@test.com"
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue