Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions web/src/p2k16/web/core_blueprint.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import io
import logging
import os
import re
from typing import List, Optional, Mapping, Iterable, Set, Any, Dict

import flask
Expand Down Expand Up @@ -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
Expand All @@ -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)]
Expand Down
4 changes: 4 additions & 0 deletions web/src/p2k16/web/static/front-page.html
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,10 @@ <h4 class="panel-title">Bitraf is open 24/7</h4>
</div>
</section>

<div
ng-if="!ctrl.hasValidPhoneNumber" class="alert alert-warning text-center" role="alert">
<strong>Please add a valid phone number to your <a href="#!/my-profile">profile</a></strong>
</div>

<section ng-if="ctrl.doorsAvailable">
<h2 class="text-center">Open a door</h2>
Expand Down
1 change: 1 addition & 0 deletions web/src/p2k16/web/static/p2k16/p2k16.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down