Integrate Initial Email Support 87/48487/2
authorSawyer Bergeron <sbergeron@iol.unh.edu>
Wed, 6 Dec 2017 21:48:31 +0000 (16:48 -0500)
committerSawyer Bergeron <sbergeron@iol.unh.edu>
Thu, 7 Dec 2017 20:14:01 +0000 (15:14 -0500)
JIRA: None

Integrate ability for users to change email presented to admins
with field initially filled with user's Jira associated email address
This amend takes into account a streamlining change
suggested by Parker Berbarian

Change-Id: I677ce669f200e5cad70c198737118f0b7925bac5
Signed-off-by: Sawyer Bergeron <sbergeron@iol.unh.edu>
dashboard/src/account/forms.py
dashboard/src/account/models.py
dashboard/src/account/views.py

index 7653e2b..3b9c627 100644 (file)
@@ -17,6 +17,6 @@ from account.models import UserProfile
 class AccountSettingsForm(forms.ModelForm):
     class Meta:
         model = UserProfile
-        fields = ['company', 'ssh_public_key', 'pgp_public_key', 'timezone']
+        fields = ['company', 'email_addr', 'ssh_public_key', 'pgp_public_key', 'timezone']
 
     timezone = forms.ChoiceField(choices=[(x, x) for x in pytz.common_timezones], initial='UTC')
index c2e9902..bfc0bbe 100644 (file)
@@ -20,6 +20,7 @@ class UserProfile(models.Model):
     timezone = models.CharField(max_length=100, blank=False, default='UTC')
     ssh_public_key = models.FileField(upload_to=upload_to, null=True, blank=True)
     pgp_public_key = models.FileField(upload_to=upload_to, null=True, blank=True)
+    email_addr = models.CharField(max_length=300, blank=false, default='email@mail.com')
     company = models.CharField(max_length=200, blank=False)
 
     oauth_token = models.CharField(max_length=1024, blank=False)
index 17fbdc3..e6a0e5d 100644 (file)
@@ -119,6 +119,7 @@ class JiraAuthenticatedView(RedirectView):
 
         jira = JIRA(server=settings.JIRA_URL, oauth=oauth_dict)
         username = jira.current_user()
+        email = jira.user(username).emailAddress
         url = '/'
         # Step 3. Lookup the user or create them if they don't exist.
         try:
@@ -130,6 +131,7 @@ class JiraAuthenticatedView(RedirectView):
             profile = UserProfile()
             profile.user = user
             profile.save()
+            user.userprofile.email_addr = email
             url = reverse('account:settings')
         user.userprofile.oauth_token = access_token['oauth_token']
         user.userprofile.oauth_secret = access_token['oauth_token_secret']