Mohammedallyl commited on
Commit
5ea1351
·
verified ·
1 Parent(s): a97e60d

Update Logic/Locations/SetLocationForUser.py

Browse files
Files changed (1) hide show
  1. Logic/Locations/SetLocationForUser.py +43 -43
Logic/Locations/SetLocationForUser.py CHANGED
@@ -1,44 +1,44 @@
1
- from fastapi import APIRouter
2
- import sqlite3
3
- from passlib.context import CryptContext
4
- from pydantic import BaseModel
5
- class DataType(BaseModel):
6
- Email:str
7
- Password:str
8
- Longtude:str
9
- Lattitude:str
10
- Day:str
11
- Houre:str
12
- UserAddLocationRouter=APIRouter(prefix="/Location")
13
- @UserAddLocationRouter.post("/AddLocation")
14
- def adduser(Data:DataType):
15
- try:
16
-
17
- State=False
18
-
19
- pwd_context=CryptContext(schemes=["bcrypt"],deprecated="auto")
20
-
21
-
22
- connect=sqlite3.connect("DataBase/DataBase.bd")
23
- cursor=connect.execute(f'''
24
- SELECT UserId,Password FROM Users where Email='{Data.Email}'
25
- ''')
26
- Data=cursor.fetchall()
27
- if len(Data) !=0 :
28
- if Data[0][0]==None:
29
- return {"Status":True,"Message":"User Is Not Defined Before"}
30
- HasedPassword=Data[0][1]
31
- UserId=Data[0][0]
32
- State=Data.Password==HasedPassword
33
- if State:
34
- connect.execute(f'''
35
- INSERT INTO TrackeringPoints (UserId,Longtude ,Lattitude,Day,Houre) VALUES ({UserId},{float(Data.Longtude)},{float(Data.Lattitude)},'{Data.Day}','{Data.Houre}')
36
- ''')
37
- connect.commit()
38
- connect.close()
39
- return {"State":True}
40
- else:
41
- return {"State":False}
42
- except Exception as e :
43
- return {"Status":False,"Message":e}
44
 
 
1
+ from fastapi import APIRouter
2
+ import sqlite3
3
+ from passlib.context import CryptContext
4
+ from pydantic import BaseModel
5
+ class DataType(BaseModel):
6
+ Email:str
7
+ Password:str
8
+ Longtude:str
9
+ Lattitude:str
10
+ Day:str
11
+ Houre:str
12
+ UserAddLocationRouter=APIRouter(prefix="/Location")
13
+ @UserAddLocationRouter.post("/AddLocation")
14
+ def adduser(Data:DataType):
15
+ # try:
16
+
17
+ State=False
18
+
19
+ pwd_context=CryptContext(schemes=["bcrypt"],deprecated="auto")
20
+
21
+
22
+ connect=sqlite3.connect("DataBase/DataBase.bd")
23
+ cursor=connect.execute(f'''
24
+ SELECT UserId,Password FROM Users where Email='{Data.Email}'
25
+ ''')
26
+ Data=cursor.fetchall()
27
+ if len(Data) !=0 :
28
+ if Data[0][0]==None:
29
+ return {"Status":True,"Message":"User Is Not Defined Before"}
30
+ HasedPassword=Data[0][1]
31
+ UserId=Data[0][0]
32
+ State=Data.Password==HasedPassword
33
+ if State:
34
+ connect.execute(f'''
35
+ INSERT INTO TrackeringPoints (UserId,Longtude ,Lattitude,Day,Houre) VALUES ({UserId},{float(Data.Longtude)},{float(Data.Lattitude)},'{Data.Day}','{Data.Houre}')
36
+ ''')
37
+ connect.commit()
38
+ connect.close()
39
+ return {"State":True}
40
+ else:
41
+ return {"State":False}
42
+ # except Exception as e :
43
+ # return {"Status":False,"Message":e}
44