Skip to content

Commit

Permalink
fix: voltando ao deploy original
Browse files Browse the repository at this point in the history
  • Loading branch information
moonshinerd authored Aug 13, 2024
1 parent 369b4d5 commit 91ca355
Showing 1 changed file with 7 additions and 23 deletions.
30 changes: 7 additions & 23 deletions backend/server/app/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -239,25 +239,14 @@ def licitacao_maior_valor(request):
else:
return Response({'detail': 'Nenhuma licitação encontrada.'}, status=status.HTTP_404_NOT_FOUND)

ALLOWED_ORIGINS = [
'https://fastidious-daffodil-724e94.netlify.app',
'https://licitabsb.netlify.app'
]

@swagger_auto_schema(
method='post',
operation_description="Subscribe an email to a Mailchimp list.",
request_body=openapi.Schema(
type=openapi.TYPE_OBJECT,
properties={
'email_address': openapi.Schema(type=openapi.TYPE_STRING),
'status': openapi.Schema(type=openapi.TYPE_STRING),
'merge_fields': openapi.Schema(
type=openapi.TYPE_OBJECT,
properties={
'FNAME': openapi.Schema(type=openapi.TYPE_STRING),
'LNAME': openapi.Schema(type=openapi.TYPE_STRING)
}
)
},
required=['email_address', 'status']
),
responses={
200: "Subscription successful!",
500: "Subscription failed."
Expand All @@ -268,17 +257,13 @@ def subscribe_email(request):
origin = request.headers.get('Origin')

# Verifica se a requisição veio de um dos domínios permitidos
# if origin not in ALLOWED_ORIGINS:
# return Response({"detail": "Unauthorized origin."}, status=status.HTTP_403_FORBIDDEN)
if origin not in ALLOWED_ORIGINS:
return Response({"detail": "Unauthorized origin."}, status=status.HTTP_403_FORBIDDEN)

email = request.data.get('email_address')
status = request.data.get('status')
merge_fields = request.data.get('merge_fields')

if not email:
return Response({"detail": "Email is required."}, status=status.HTTP_400_BAD_REQUEST)
if not status:
return Response({"detail": "Status is required."}, status=status.HTTP_400_BAD_REQUEST)

mailchimp_url = settings.DJANGO_URL_CHIMP
mailchimp_api_key = settings.DJANGO_API
Expand All @@ -288,8 +273,7 @@ def subscribe_email(request):
mailchimp_url,
json={
'email_address': email,
'status': status,
'merge_fields': merge_fields
'status': 'subscribed',
},
auth=HTTPBasicAuth('anystring', mailchimp_api_key) # 'anystring' pode ser qualquer valor
)
Expand Down

0 comments on commit 91ca355

Please sign in to comment.