Skip to content

Commit

Permalink
fix null google data
Browse files Browse the repository at this point in the history
  • Loading branch information
octavioamu committed Nov 12, 2020
1 parent 71e74d0 commit 3dd18a5
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 8 deletions.
19 changes: 19 additions & 0 deletions app/dashboard/migrations/0162_auto_20201112_1639.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Generated by Django 2.2.4 on 2020-11-12 16:39

import django.contrib.postgres.fields.jsonb
from django.db import migrations


class Migration(migrations.Migration):

dependencies = [
('dashboard', '0161_auto_20201111_1318'),
]

operations = [
migrations.AlterField(
model_name='profile',
name='identity_data_google',
field=django.contrib.postgres.fields.jsonb.JSONField(blank=True, default=dict, null=True),
),
]
6 changes: 3 additions & 3 deletions app/dashboard/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -1638,7 +1638,7 @@ def value_true(self):
return self.get_natural_value()

@property
def receive_tx_blockexplorer_link(self):
def receive_tx_blockexplorer_link(self):
if self.network == 'xdai':
return f"https://explorer.anyblock.tools/ethereum/poa/xdai/transaction/{self.receive_txid}"
if self.network == 'mainnet':
Expand Down Expand Up @@ -2930,7 +2930,7 @@ class Profile(SuperModel):
is_poap_verified=models.BooleanField(default=False)
twitter_handle=models.CharField(blank=True, null=True, max_length=15)
is_google_verified=models.BooleanField(default=False)
identity_data_google = JSONField(default=dict)
identity_data_google = JSONField(blank=True, default=dict, null=True)
bio = models.TextField(default='', blank=True, help_text=_('User bio.'))
interests = ArrayField(models.CharField(max_length=200), blank=True, default=list)
products_choose = ArrayField(models.CharField(max_length=200), blank=True, default=list)
Expand Down Expand Up @@ -5168,7 +5168,7 @@ class HackathonProject(SuperModel):
null=True,
blank=True,
on_delete=models.SET_NULL,
help_text=_('Link to grant if project is converted to grant')
help_text=_('Link to grant if project is converted to grant')
)

class Meta:
Expand Down
10 changes: 5 additions & 5 deletions app/dashboard/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -3033,8 +3033,8 @@ def connect_google():
import urllib.parse

return OAuth2Session(
settings.GOOGLE_CLIENT_ID,
scope=settings.GOOGLE_SCOPE,
settings.GOOGLE_CLIENT_ID,
scope=settings.GOOGLE_SCOPE,
redirect_uri=urllib.parse.urljoin(settings.BASE_URL, reverse(verify_user_google)),
)

Expand Down Expand Up @@ -3068,8 +3068,8 @@ def verify_user_google(request):
try:
google = connect_google()
google.fetch_token(
settings.GOOGLE_TOKEN_URL,
client_secret=settings.GOOGLE_CLIENT_SECRET,
settings.GOOGLE_TOKEN_URL,
client_secret=settings.GOOGLE_CLIENT_SECRET,
code=request.GET['code'],
)
r = google.get('https://www.googleapis.com/oauth2/v1/userinfo')
Expand All @@ -3083,7 +3083,7 @@ def verify_user_google(request):
'ok': False,
'message': 'Invalid code',
})

profile = profile_helper(request.user.username, True)
profile.is_google_verified = True
profile.identity_data_google = r.json()
Expand Down

0 comments on commit 3dd18a5

Please sign in to comment.