-
Notifications
You must be signed in to change notification settings - Fork 7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Show userprofile endpoint #79
Conversation
api/views.py
Outdated
|
||
|
||
FULL_SECRET_PATH = 'C:/Users/ruanc/OneDrive/Documentos/Workspace/bahea-cal/webapp/secrets.json' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Acho que pode definir o root path usando Pathlib, exemplo:
from pathlib import Path
import os
ROOT_FOLDER = Path().resolve().parent
FULL_SECRET_PATH = os.path.join(ROOT_FOLDER, "webapp", "secrets.json")
porque se estiver assim pode não funcionar pra outra máquina que tenha um path diferente
api/views.py
Outdated
|
||
|
||
FULL_SECRET_PATH = 'C:/Users/ruanc/OneDrive/Documentos/Workspace/bahea-cal/webapp/secrets.json' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove isso, precisa ser uma var de ambiente
api/views.py
Outdated
@@ -28,6 +34,7 @@ | |||
def calendar_init_view(request): | |||
config = get_secret(f"{settings.ENVIRONMENT}/google/calendar") | |||
creds = CredentialsService.init_for(request.user, scopes=SCOPES) | |||
print("cred= ", creds) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove
users/serializer.py
Outdated
user_email = serializers.EmailField() | ||
user_photo = serializers.ImageField() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pode ser só email e photo, a gente já sabe que é do user
users/serializer.py
Outdated
last_name = serializers.CharField() | ||
user_email = serializers.EmailField() | ||
user_photo = serializers.ImageField() | ||
choiced_teams = serializers.DictField(child=serializers.ListField(child=serializers.EmailField())) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
melhor selected_teams
api/views.py
Outdated
token=user.social_auth.get(provider='google-oauth2').access_token, | ||
refresh_token=user.social_auth.get(provider='google-oauth2').refresh_token, | ||
client_id=settings.SOCIAL_AUTH_GOOGLE_OAUTH2_KEY, | ||
client_secret=settings.SOCIAL_AUTH_GOOGLE_OAUTH2_SECRET, | ||
scopes=SCOPES | ||
) | ||
service_account_info = json.load(open(FULL_SECRET_PATH)) | ||
creds = Credentials.from_service_account_info(service_account_info, scopes=SCOPES) | ||
|
||
print(creds) | ||
calendar_service = build('calendar', 'v3', credentials=creds) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
creds = Credentials( | |
token=user.social_auth.get(provider='google-oauth2').access_token, | |
refresh_token=user.social_auth.get(provider='google-oauth2').refresh_token, | |
client_id=settings.SOCIAL_AUTH_GOOGLE_OAUTH2_KEY, | |
client_secret=settings.SOCIAL_AUTH_GOOGLE_OAUTH2_SECRET, | |
scopes=SCOPES | |
) | |
service_account_info = json.load(open(FULL_SECRET_PATH)) | |
creds = Credentials.from_service_account_info(service_account_info, scopes=SCOPES) | |
print(creds) | |
calendar_service = build('calendar', 'v3', credentials=creds) | |
user_creds = UserCredential.objects.get(user=request.user) | |
creds = Credentials.from_user_credentials(user_credentials) | |
calendar_service = googleapiclient.discovery.build('calendar', 'v3', credentials=creds) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Esse pedaço é para eu remover o bloco da linha 80 até a 91? e substituir pela de baixo n é?
choiced_teams = serializers.DictField(child=serializers.ListField(child=serializers.EmailField())) | ||
time_to_match = serializers.DictField( | ||
child=serializers.DateTimeField() | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pq um DictField
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pensei na possibilidade do usuário selecionar vários horários que qr ser alertado e aí seria uma lista ou um dicionário com o tempo até o alerta, 2 dias antes, 30 minutos, 2 horas etc
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pode ser
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
muda pra notify_before
(pra representar que o usuário será notificado X horas/dias/etc antes da partida.
choiced_teams = serializers.DictField(child=serializers.ListField(child=serializers.EmailField())) | ||
time_to_match = serializers.DictField( | ||
child=serializers.DateTimeField() | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
muda pra notify_before
(pra representar que o usuário será notificado X horas/dias/etc antes da partida.
user = request.user | ||
user_creds = UserCredential.objects.get(user=request.user) | ||
creds = Credentials.from_user_credentials(user_creds) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
parece estar certo agora. Testou com essa mudança?
this PR creates a new endpoint whose purpose is to return the user's profile information. The endpoint still needs to be tested and is not fully functional, this is just the first stage of it.