示例#1
0
def addNewProperty():
    return PropertyController.addNewProperty(request.form)
示例#2
0
def rentProperty():
    return PropertyController.rentProperty(request.form)
示例#3
0
def getPropertiesRentedByUser(username):
    return PropertyController.getRenterProperties(username)
示例#4
0
def getVendorProperties(username):
    return PropertyController.getVendorProperties(username)
示例#5
0
def getAll():
    return PropertyController.getAllAvailableProperties()
示例#6
0
def getById(id):
    #An ObjectId is not the same as its string representation
    return PropertyController.get(ObjectId(id))
示例#7
0
from Controllers.PropertyController import PropertyController
from Services.UserService import UserService
from Models.User import User

app = Flask(__name__)
CORS(app)
app.secret_key = "air bnb lite"
app.config['MONGO_DBNAME'] = 'airbnblite'
app.config['MONGO_URI'] = 'mongodb://localhost:27017/airbnblite'

mongo = PyMongo(app)

UserService = UserService()
User = User()
UserController = UserController()
PropertyController = PropertyController()
SessionService = LoginManager()
SessionService.init_app(app)

#Authentication setup
@SessionService.user_loader
def user_loader(username):
    if not UserService.isUser(username):
        return
    user = User
    user.id = username
    return user

@SessionService.request_loader
def request_loader(request):
    if not request.form: