replace available_suffixes by available_suffixes_more_info
This commit is contained in:
parent
7915a2abb9
commit
5a3b79b4cf
|
@ -3,7 +3,9 @@ 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 available_suffixes
|
from app.dashboard.views.custom_alias import (
|
||||||
|
available_suffixes_more_info,
|
||||||
|
)
|
||||||
from app.extensions import db
|
from app.extensions import db
|
||||||
from app.log import LOG
|
from app.log import LOG
|
||||||
from app.models import AliasUsedOn, Alias, User
|
from app.models import AliasUsedOn, Alias, User
|
||||||
|
@ -299,11 +301,10 @@ 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
|
||||||
|
|
||||||
# List of (is_custom_domain, alias-suffix, time-signed alias-suffix)
|
suffixes = available_suffixes_more_info(user)
|
||||||
suffixes = available_suffixes(user)
|
|
||||||
|
|
||||||
# custom domain should be put first
|
# custom domain should be put first
|
||||||
ret["suffixes"] = list([suffix[1], suffix[2]] for suffix in suffixes)
|
ret["suffixes"] = list([suffix.suffix, suffix.signed_suffix] for suffix in suffixes)
|
||||||
|
|
||||||
return jsonify(ret)
|
return jsonify(ret)
|
||||||
|
|
||||||
|
@ -371,12 +372,12 @@ 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
|
||||||
|
|
||||||
# List of (is_custom_domain, alias-suffix, time-signed alias-suffix)
|
suffixes = available_suffixes_more_info(user)
|
||||||
suffixes = available_suffixes(user)
|
|
||||||
|
|
||||||
# custom domain should be put first
|
# custom domain should be put first
|
||||||
ret["suffixes"] = [
|
ret["suffixes"] = [
|
||||||
{"suffix": suffix[1], "signed_suffix": suffix[2]} for suffix in suffixes
|
{"suffix": suffix.suffix, "signed_suffix": suffix.signed_suffix}
|
||||||
|
for suffix in suffixes
|
||||||
]
|
]
|
||||||
|
|
||||||
return jsonify(ret)
|
return jsonify(ret)
|
||||||
|
|
|
@ -109,11 +109,11 @@
|
||||||
style="padding-left: 5px">
|
style="padding-left: 5px">
|
||||||
<select class="form-control" name="suffix">
|
<select class="form-control" name="suffix">
|
||||||
{% for suffix in suffixes %}
|
{% for suffix in suffixes %}
|
||||||
<option value="{{ suffix[2] }}">
|
<option value="{{ suffix.signed_suffix }}">
|
||||||
{% if suffix[0] %}
|
{% if suffix.is_custom %}
|
||||||
{{ suffix[1] }} (your domain)
|
{{ suffix.suffix }} (your domain)
|
||||||
{% else %}
|
{% else %}
|
||||||
{{ suffix[1] }}
|
{{ suffix.suffix }}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</option>
|
</option>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
|
|
@ -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 available_suffixes, signer
|
from app.dashboard.views.custom_alias import signer, available_suffixes_more_info
|
||||||
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,8 +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()
|
||||||
]
|
]
|
||||||
# List of (is_custom_domain, alias-suffix, time-signed alias-suffix)
|
suffixes = available_suffixes_more_info(current_user)
|
||||||
suffixes = 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,
|
available_suffixes_more_info,
|
||||||
)
|
)
|
||||||
from app.extensions import db
|
from app.extensions import db
|
||||||
from app.models import (
|
from app.models import (
|
||||||
|
@ -108,13 +108,13 @@ 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(user)) > 0
|
assert len(available_suffixes_more_info(user)) > 0
|
||||||
|
|
||||||
# first suffix is custom domain
|
# first suffix is custom domain
|
||||||
first_suffix = available_suffixes(user)[0]
|
first_suffix = available_suffixes_more_info(user)[0]
|
||||||
assert first_suffix[0]
|
assert first_suffix.is_custom
|
||||||
assert first_suffix[1] == "@test.com"
|
assert first_suffix.suffix == "@test.com"
|
||||||
assert first_suffix[2].startswith("@test.com")
|
assert first_suffix.signed_suffix.startswith("@test.com")
|
||||||
|
|
||||||
|
|
||||||
def test_available_suffixes_default_domain(flask_client):
|
def test_available_suffixes_default_domain(flask_client):
|
||||||
|
@ -126,13 +126,13 @@ 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(user)[0]
|
first_suffix = available_suffixes_more_info(user)[0]
|
||||||
assert first_suffix[1].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(user)[0]
|
first_suffix = available_suffixes_more_info(user)[0]
|
||||||
assert first_suffix[1] == "@test.com"
|
assert first_suffix.suffix == "@test.com"
|
||||||
|
|
||||||
|
|
||||||
def test_add_already_existed_alias(flask_client):
|
def test_add_already_existed_alias(flask_client):
|
||||||
|
|
Loading…
Reference in a new issue