Skip to content

Commit 432fefd

Browse files
BLUEBUTTON-646 Application support contacts (#696)
* Store contact email and phone for apps * Provide form fields for app support email, phone * Order app support fields in form
1 parent ac1bdb0 commit 432fefd

File tree

3 files changed

+56
-2
lines changed

3 files changed

+56
-2
lines changed

apps/dot_ext/forms.py

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,21 @@ def __init__(self, user, *args, **kwargs):
2828

2929
class Meta:
3030
model = get_application_model()
31-
fields = ('name', 'client_type', 'authorization_grant_type', 'redirect_uris', 'logo_uri',
32-
'website_uri', 'description', 'policy_uri', 'tos_uri', 'contacts', 'agree')
31+
fields = (
32+
'name',
33+
'client_type',
34+
'authorization_grant_type',
35+
'redirect_uris',
36+
'logo_uri',
37+
'website_uri',
38+
'description',
39+
'policy_uri',
40+
'tos_uri',
41+
'support_email',
42+
'support_phone_number',
43+
'contacts',
44+
'agree',
45+
)
3346

3447
required_css_class = 'required'
3548

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# Generated by Django 2.1.2 on 2019-01-21 13:45
2+
3+
from django.conf import settings
4+
import django.core.validators
5+
from django.db import migrations, models
6+
import django.db.models.deletion
7+
8+
9+
class Migration(migrations.Migration):
10+
11+
dependencies = [
12+
('dot_ext', '0013_auto_20181221_2114'),
13+
]
14+
15+
operations = [
16+
migrations.AddField(
17+
model_name='application',
18+
name='support_email',
19+
field=models.EmailField(blank=True, max_length=254, null=True),
20+
),
21+
migrations.AddField(
22+
model_name='application',
23+
name='support_phone_number',
24+
field=models.CharField(blank=True, max_length=17, null=True, validators=[django.core.validators.RegexValidator(message="Phone number must be entered in the format: '+999999999'. Up to 15 digits allowed.", regex='^\\+?1?\\d{9,15}$')]),
25+
),
26+
]

apps/dot_ext/models.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
from django.db.models.signals import post_delete
1212
from django.utils.translation import ugettext_lazy as _
1313
from django.contrib.auth import get_user_model
14+
from django.core.validators import RegexValidator
1415

1516
from apps.capabilities.models import ProtectedCapability
1617
from oauth2_provider.models import (
@@ -47,6 +48,20 @@ class Application(AbstractApplication):
4748
contacts = models.TextField(default="", blank=True, max_length=512,
4849
verbose_name="Client's Contacts",
4950
help_text="This is typically an email")
51+
52+
support_email = models.EmailField(blank=True, null=True)
53+
54+
# FROM https://stackoverflow.com/questions/19130942/whats-the-best-way-to-store-phone-number-in-django-models
55+
phone_regex = RegexValidator(
56+
regex=r'^\+?1?\d{9,15}$',
57+
message="Phone number must be entered in the format: '+999999999'. Up to 15 digits allowed.")
58+
59+
support_phone_number = models.CharField(
60+
validators=[phone_regex],
61+
max_length=17,
62+
blank=True,
63+
null=True)
64+
5065
description = models.TextField(default="", blank=True, max_length=1000,
5166
verbose_name="Application Description",
5267
help_text="This is plain-text up to 1000 characters in length.",

0 commit comments

Comments
 (0)