diff --git a/web/src/p2k16/web/core_blueprint.py b/web/src/p2k16/web/core_blueprint.py index fc245f4..4a13925 100644 --- a/web/src/p2k16/web/core_blueprint.py +++ b/web/src/p2k16/web/core_blueprint.py @@ -3,6 +3,7 @@ import io import logging import os +import re from typing import List, Optional, Mapping, Iterable, Set, Any, Dict import flask @@ -185,6 +186,11 @@ def account_to_json(account: Account): "phone": account.phone, }} +def is_valid_phone_number(phone_number): + if not phone_number: + return False + number_validator = re.compile(r'\+?\d{8,}') + return number_validator.match(phone_number) is not None def profile_to_json(account: Account, circles: List[Circle], badges: Optional[List[AccountBadge]], full=False, doors=False): from .badge_blueprint import badge_to_json @@ -201,6 +207,7 @@ def profile_to_json(account: Account, circles: List[Circle], badges: Optional[Li json["has_door_access"] = authz_management.can_haz_door_access(account) json["is_paying_member"] = StripePayment.is_account_paying_member(account.id) json["is_employed"] = Company.is_account_employed(account.id) + json["has_valid_phone_number"] = is_valid_phone_number(account.phone) if doors: json["available_doors"] = [{"key": door.key, "name": door.name} for door in authz_management.available_doors(account)] diff --git a/web/src/p2k16/web/static/front-page.html b/web/src/p2k16/web/static/front-page.html index a4f587f..7e1f8c5 100644 --- a/web/src/p2k16/web/static/front-page.html +++ b/web/src/p2k16/web/static/front-page.html @@ -55,6 +55,10 @@

Bitraf is open 24/7

+

Open a door

diff --git a/web/src/p2k16/web/static/p2k16/p2k16.js b/web/src/p2k16/web/static/p2k16/p2k16.js index f5deefb..ef28b07 100644 --- a/web/src/p2k16/web/static/p2k16/p2k16.js +++ b/web/src/p2k16/web/static/p2k16/p2k16.js @@ -679,6 +679,7 @@ self.availableDoors = profile.available_doors; self.payingMember = profile.is_paying_member; self.employed = profile.is_employed; + self.hasValidPhoneNumber = profile.has_valid_phone_number; self.membership_tiers = membership_tiers; self.recent_events = recent_events;