updates from beta testing
This commit is contained in:
@@ -101,6 +101,7 @@ class UserRegisterView(generics.CreateAPIView):
|
||||
queryset = User.objects.all()
|
||||
serializer_class = UserRegisterSerializer
|
||||
permission_classes = [permissions.AllowAny]
|
||||
authentication_classes = ()
|
||||
|
||||
def perform_create(self, serializer):
|
||||
# This will save the user instance and return the object
|
||||
@@ -115,7 +116,10 @@ class UserRegisterView(generics.CreateAPIView):
|
||||
|
||||
# Call the email-sending function with the newly created user object
|
||||
# and the activation link.
|
||||
EmailService.send_registration_email(user, activation_link)
|
||||
try:
|
||||
EmailService.send_registration_email(user, activation_link)
|
||||
except Exception as e:
|
||||
print(e)
|
||||
|
||||
# You can optionally modify the response data here if needed.
|
||||
# For example, to not return all user data.
|
||||
@@ -1061,3 +1065,71 @@ class FAQViewSet(viewsets.ModelViewSet):
|
||||
queryset = FAQ.objects.all()
|
||||
serializer_class = FAQSerializer
|
||||
permission_classes = [permissions.IsAuthenticated]
|
||||
|
||||
|
||||
API_KEY = "AIMLOPERATIONSLLC-a7ce-7525-b38f-cf8b4d52ca70"
|
||||
|
||||
|
||||
class PropertDetailProxyView(APIView):
|
||||
def post(self, request, *args, **kwargs):
|
||||
if not API_KEY:
|
||||
return Response(
|
||||
{"detail": "API KEY is missing"},
|
||||
status=status.HTTP_500_INTERNAL_SERVER_ERROR,
|
||||
)
|
||||
|
||||
external_headers = {
|
||||
"accept": "application/json",
|
||||
"Content-Type": "application/json",
|
||||
"X-API-Key": API_KEY, # SENSITIVE KEY: Used on server-side only
|
||||
"X-User-Id": "UniqueUserIdentifier",
|
||||
}
|
||||
payload = request.data
|
||||
print(payload)
|
||||
try:
|
||||
response = requests.post(
|
||||
"https://api.realestateapi.com/v2/PropertyDetail",
|
||||
headers=external_headers,
|
||||
json=payload, # Send the data as JSON
|
||||
)
|
||||
print("we have a response")
|
||||
print(response)
|
||||
response.raise_for_status()
|
||||
return Response(response.json(), status=response.status_code)
|
||||
except Exception as e:
|
||||
return Response(
|
||||
{"detail": f"External API Error: {e.response.text}"},
|
||||
status=e.response.status_code,
|
||||
)
|
||||
|
||||
|
||||
class AutoCompleteProxyView(APIView):
|
||||
def post(self, request, *args, **kwargs):
|
||||
if not API_KEY:
|
||||
return Response(
|
||||
{"detail": "API KEY is missing"},
|
||||
status=status.HTTP_500_INTERNAL_SERVER_ERROR,
|
||||
)
|
||||
|
||||
# 1
|
||||
external_headers = {
|
||||
"Content-Type": "application/json",
|
||||
"X-API-Key": API_KEY, # SENSITIVE KEY: Used on server-side only
|
||||
"X-User-Id": "UniqueUserIdentifier",
|
||||
}
|
||||
# 2. Extract data (e.g., search query) from the request sent by React
|
||||
# You can forward the entire body or specific parameters
|
||||
payload = request.data
|
||||
try:
|
||||
response = requests.post(
|
||||
"https://api.realestateapi.com/v2/AutoComplete",
|
||||
headers=external_headers,
|
||||
json=payload, # Send the data as JSON
|
||||
)
|
||||
response.raise_for_status()
|
||||
return Response(response.json(), status=response.status_code)
|
||||
except Exception as e:
|
||||
return Response(
|
||||
{"detail": f"External API Error: {e.response.text}"},
|
||||
status=e.response.status_code,
|
||||
)
|
||||
|
||||
@@ -226,3 +226,10 @@ TEST_DISCOVER_PATTERN = "test_*.py"
|
||||
|
||||
# Realestate api
|
||||
REAL_ESTATE_API_KEY = "AIMLOPERATIONSLLC-a7ce-7525-b38f-cf8b4d52ca70"
|
||||
|
||||
# SMTP2GO
|
||||
EMAIL_HOST = "mail.smtp2go.com"
|
||||
EMAIL_HOST_USER = "info.aimloperations.com"
|
||||
EMAIL_HOST_PASSWORD = "ZDErIII2sipNNVMz"
|
||||
EMAIL_PORT = 2525
|
||||
EMAIL_USE_TLS = True
|
||||
|
||||
@@ -31,6 +31,8 @@ from core.views import (
|
||||
PropertyDescriptionView,
|
||||
CreateDocumentView,
|
||||
RetrieveDocumentView,
|
||||
AutoCompleteProxyView,
|
||||
PropertDetailProxyView,
|
||||
)
|
||||
from django.conf import settings
|
||||
from django.conf.urls.static import static
|
||||
@@ -41,6 +43,16 @@ urlpatterns = [
|
||||
path("api/token/", CustomTokenObtainPairView.as_view(), name="token_obtain_pair"),
|
||||
path("api/token/refresh/", TokenRefreshView.as_view(), name="token_refresh"),
|
||||
path("api/logout/", LogoutView.as_view(), name="logout"),
|
||||
path(
|
||||
"api/autocomplete-proxy/",
|
||||
AutoCompleteProxyView.as_view(),
|
||||
name="autocomplete-proxy",
|
||||
),
|
||||
path(
|
||||
"api/property-details-proxy/",
|
||||
PropertDetailProxyView.as_view(),
|
||||
name="property-details-proxy",
|
||||
),
|
||||
path("api/register/", UserRegisterView.as_view(), name="register"),
|
||||
path(
|
||||
"api/password-reset/", PasswordResetRequestView.as_view(), name="password_reset"
|
||||
|
||||
@@ -23,6 +23,7 @@ django-filter==25.1
|
||||
djangorestframework==3.16.0
|
||||
djangorestframework_simplejwt==5.5.0
|
||||
filelock==3.18.0
|
||||
gunicorn==23.0.0
|
||||
h11==0.16.0
|
||||
httpcore==1.0.9
|
||||
httpx==0.28.1
|
||||
@@ -45,6 +46,7 @@ pathspec==0.12.1
|
||||
pillow==11.3.0
|
||||
platformdirs==4.3.8
|
||||
pre_commit==4.2.0
|
||||
psycopg2-binary==2.9.11
|
||||
pyasn1==0.6.1
|
||||
pyasn1_modules==0.4.2
|
||||
pycparser==2.22
|
||||
|
||||
Reference in New Issue
Block a user