Spaces:
Running
Running
mailing list
#27
by
Nattyboi
- opened
- app.py +9 -0
- controller/imports.py +4 -1
app.py
CHANGED
@@ -256,8 +256,17 @@ def get_user_details(authorization: str = Header(...)):
|
|
256 |
user_info = user_details_func(db_uri=MONGO_URI,document=doc)
|
257 |
return { "userInfo": user_info}
|
258 |
|
|
|
|
|
|
|
|
|
259 |
|
|
|
|
|
260 |
|
|
|
|
|
|
|
261 |
|
262 |
@app.get("/protected-route")
|
263 |
def protected_route(authorization: str = Header(...)):
|
|
|
256 |
user_info = user_details_func(db_uri=MONGO_URI,document=doc)
|
257 |
return { "userInfo": user_info}
|
258 |
|
259 |
+
@app.post("/mailing/list",tags=["guest"])
|
260 |
+
def add_new_member_to_mailing_list(document: MailingList):
|
261 |
+
from pymongo import ASCENDING
|
262 |
+
collection = db['MailingList']
|
263 |
|
264 |
+
# Ensure the email field has a unique index
|
265 |
+
collection.create_index([('email', ASCENDING)], unique=True)
|
266 |
|
267 |
+
# Insert the document
|
268 |
+
collection.insert_one(document.model_dump())
|
269 |
+
|
270 |
|
271 |
@app.get("/protected-route")
|
272 |
def protected_route(authorization: str = Header(...)):
|
controller/imports.py
CHANGED
@@ -20,7 +20,7 @@ from bson.json_util import dumps
|
|
20 |
import threading
|
21 |
import concurrent.futures
|
22 |
from gamification.pointLogic import get_all_simple_points_func,get_dream_job
|
23 |
-
from pydantic import BaseModel
|
24 |
from datetime import datetime
|
25 |
from bson import ObjectId
|
26 |
import os
|
@@ -73,6 +73,9 @@ class UserCourse(BaseModel):
|
|
73 |
timeframeToAchieveDreamRole:str
|
74 |
recommendedCourses: Optional[List[RecommendedCourse]]=None
|
75 |
|
|
|
|
|
|
|
76 |
class LeaderBoardRanking(BaseModel):
|
77 |
userId:str
|
78 |
firstName:str
|
|
|
20 |
import threading
|
21 |
import concurrent.futures
|
22 |
from gamification.pointLogic import get_all_simple_points_func,get_dream_job
|
23 |
+
from pydantic import BaseModel, EmailStr
|
24 |
from datetime import datetime
|
25 |
from bson import ObjectId
|
26 |
import os
|
|
|
73 |
timeframeToAchieveDreamRole:str
|
74 |
recommendedCourses: Optional[List[RecommendedCourse]]=None
|
75 |
|
76 |
+
|
77 |
+
class MailingList(BaseModel):
|
78 |
+
email:EmailStr
|
79 |
class LeaderBoardRanking(BaseModel):
|
80 |
userId:str
|
81 |
firstName:str
|