adding a single user GET
This commit is contained in:
parent
573fbcc7ea
commit
2c00caa023
4 changed files with 30 additions and 10 deletions
22
README.md
22
README.md
|
@ -12,7 +12,6 @@ update, delete, and be reminded of events with additional advanced features.
|
|||
- location
|
||||
- The User will be abale to create/update a new event
|
||||
- The User will be able to login/out
|
||||
- The User can `Attend`/`UnAttend` to an event
|
||||
- The Anonymous User will be able to create a new user
|
||||
|
||||
- Event:
|
||||
|
@ -25,9 +24,7 @@ update, delete, and be reminded of events with additional advanced features.
|
|||
|
||||
# Backend-reminder
|
||||
- The Users will be able to be reminded of upcoming events.
|
||||
- The backend will Send reminders 30 minutes before the event's scheduled time.
|
||||
|
||||
|
||||
- The backend will Send reminders 30 minutes before the event's scheduled time based on there location and the event location.
|
||||
|
||||
|
||||
|
||||
|
@ -49,10 +46,9 @@ update, delete, and be reminded of events with additional advanced features.
|
|||
- DueDate (string, required)
|
||||
- User_id (string, required, foreign key)
|
||||
|
||||
- User Event Association (Many to Many)
|
||||
- User_id (string, required, foreign key)
|
||||
- Event_id (Integer, required, foreign key)
|
||||
- Notifiyed Made (bool, default: false)
|
||||
- User Event Association (Many to Many) - this table will hold the notifyed users to the event
|
||||
- User_id (string, required, foreign key, primary key)
|
||||
- Event_id (Integer, required, foreign key, primary key)
|
||||
|
||||
|
||||
# API EndPoints
|
||||
|
@ -62,9 +58,19 @@ update, delete, and be reminded of events with additional advanced features.
|
|||
- PUT /events/{id} - update an event (Auth + authorized)
|
||||
- DELETE /events/{id} - (Soft)delete an event (Auth + authorized)
|
||||
|
||||
- GET /user - returns all users
|
||||
- GET /user/{id} - returns a single user
|
||||
- POST /user - create a new user (Auth)
|
||||
- PUT /user/{id} - update an user (Auth + authorized)
|
||||
- DELETE /user/{id} - (Soft)delete an user (Auth + authorized)
|
||||
|
||||
|
||||
|
||||
# Application init flow
|
||||
- init schaduler
|
||||
- run the flask app
|
||||
|
||||
|
||||
# how to run?
|
||||
- pip install -r requirements.txt
|
||||
- flask db upgrade
|
||||
|
|
3
app.py
3
app.py
|
@ -27,7 +27,8 @@ class App:
|
|||
self.scheduler.init_app(self.app)
|
||||
self.scheduler.start()
|
||||
# Schedule the job
|
||||
self.scheduler.add_job(id='notifyUpcommingEvents', func=self.notifyUpcommingEvents, trigger='interval', seconds=1)
|
||||
self.scheduler.add_job(id='notifyUpcommingEvents', func=self.notifyUpcommingEvents, trigger='interval', minutes=30)
|
||||
print("Scheduler started")
|
||||
|
||||
|
||||
def set_config(self):
|
||||
|
|
|
@ -11,6 +11,16 @@ def allUsers():
|
|||
users = UserService.get_all_users()
|
||||
return jsonify(users), 200
|
||||
|
||||
@userRoutes.route('/<string:user_id>', methods=['GET'])
|
||||
def getUser(user_id):
|
||||
user = UserService.get_user_by_id(user_id)
|
||||
if user:
|
||||
return jsonify(user), 200
|
||||
else:
|
||||
return jsonify({'error': 'User not found'}), 404
|
||||
|
||||
|
||||
|
||||
@userRoutes.route('/', methods=['POST'])
|
||||
@userRoutes.route('', methods=['POST'])
|
||||
@validate_user_post_request
|
||||
|
|
|
@ -28,7 +28,10 @@ class UserService:
|
|||
|
||||
@staticmethod
|
||||
def get_user_by_id(user_id):
|
||||
return User.query.get(user_id)
|
||||
user = User.query.filter_by(id=user_id).first()
|
||||
if user:
|
||||
return user.to_dict()
|
||||
return
|
||||
|
||||
@staticmethod
|
||||
def verify_user(data):
|
||||
|
|
Loading…
Reference in a new issue