Skip to content
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

Closed

Conversation

ruanclaudio
Copy link
Collaborator

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.

api/views.py Outdated


FULL_SECRET_PATH = 'C:/Users/ruanc/OneDrive/Documentos/Workspace/bahea-cal/webapp/secrets.json'
Copy link
Contributor

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'
Copy link
Collaborator

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)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove

Comment on lines 7 to 8
user_email = serializers.EmailField()
user_photo = serializers.ImageField()
Copy link
Collaborator

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

last_name = serializers.CharField()
user_email = serializers.EmailField()
user_photo = serializers.ImageField()
choiced_teams = serializers.DictField(child=serializers.ListField(child=serializers.EmailField()))
Copy link
Collaborator

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
Comment on lines 80 to 91
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)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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)

Copy link
Collaborator Author

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()
)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pq um DictField ?

Copy link
Collaborator Author

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

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pode ser

Copy link
Collaborator

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()
)
Copy link
Collaborator

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)
Copy link
Collaborator

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants