intrgrating suggestions after betta 1
This commit is contained in:
@@ -2,6 +2,7 @@ from flask import Blueprint, request, jsonify
|
||||
from models.destinations import Destinations
|
||||
from flask_jwt_extended import jwt_required, get_jwt_identity
|
||||
from utils.maps import AdressCoordinates
|
||||
from models.user import Users
|
||||
|
||||
destinations_bp = Blueprint("destinations", __name__, url_prefix="/destinations")
|
||||
|
||||
@@ -10,6 +11,10 @@ destinations_bp = Blueprint("destinations", __name__, url_prefix="/destinations"
|
||||
def list_destinations():
|
||||
destinations_db = Destinations()
|
||||
user_id = get_jwt_identity()
|
||||
users = Users()
|
||||
user = users.get_user_by_id(user_id)
|
||||
if user['user_role'] == 'company_user':
|
||||
user_id = user['company_id']
|
||||
destinations = destinations_db.get_all_by_user(user_id)
|
||||
return jsonify([dict(d) for d in destinations]), 200
|
||||
|
||||
@@ -18,6 +23,10 @@ def list_destinations():
|
||||
def create_destination():
|
||||
destinations_db = Destinations()
|
||||
user_id = get_jwt_identity()
|
||||
users = Users()
|
||||
user = users.get_user_by_id(user_id)
|
||||
if user['user_role'] == 'company_user':
|
||||
user_id = user['company_id']
|
||||
data = request.get_json()
|
||||
destination_id = destinations_db.create(user_id, data.get("name"), data.get("address"))
|
||||
# coordinates = AdressCoordinates(data.get("address"))
|
||||
@@ -33,6 +42,10 @@ def create_destination():
|
||||
def update_destination(id):
|
||||
destinations_db = Destinations()
|
||||
user_id = get_jwt_identity()
|
||||
users = Users()
|
||||
user = users.get_user_by_id(user_id)
|
||||
if user['user_role'] == 'company_user':
|
||||
user_id = user['company_id']
|
||||
data = request.get_json()
|
||||
destinations_db.update(id, user_id, data.get("name"), data.get("address"))
|
||||
coordinates = AdressCoordinates(data.get("address"))
|
||||
|
||||
Reference in New Issue
Block a user