コード例 #1
0
ファイル: user_actions.py プロジェクト: akivab/WeSoSmart
    def post(self):
        self.um = UserManagement(self)
        self.user = self.um.getUser()

        status = self.request.get("type")
        book = self.request.get("book")
        price = self.request.get("price")
        book_id = self.getBook(book)
        toreturn = self.setAction(book_id, self.WANT if status == "want" else self.HAVE, price)
        self.response.out.write(simplejson.dumps(toreturn))
コード例 #2
0
async def sign_up():
    if request.method == 'GET':
        return 'Sign up here.'
    elif request.method == 'POST':
        request_dict = await request.form
        print(request_dict)
        user_management = UserManagement(request_dict)
        sign_up = await user_management.sign_up()
        print(sign_up)
        return sign_up
    else:
        return 'Error. Sign up here.'
コード例 #3
0
ファイル: user_actions.py プロジェクト: akivab/WeSoSmart
class UserAction(webapp.RequestHandler):
    def __init__(self, handler=None):
        self.WANT, self.HAVE = range(2)

    def post(self):
        self.um = UserManagement(self)
        self.user = self.um.getUser()

        status = self.request.get("type")
        book = self.request.get("book")
        price = self.request.get("price")
        book_id = self.getBook(book)
        toreturn = self.setAction(book_id, self.WANT if status == "want" else self.HAVE, price)
        self.response.out.write(simplejson.dumps(toreturn))

    # update a price or add a book/status
    def setAction(self, book, status, price=None):
        user = self.user
        if not user:
            raise Exception("Not signed in")
        ub = UserBooks.gql("WHERE user_id = :1 AND book_id = :2 AND status=:3", user, book, status).get()
        if not ub:
            ub = UserBooks(user_id=user, book_id=book, status=status, price=price)
            ub.put()
            self.sendMessages(ub)
        elif price:
            ub.price = price
            ub.put()
        return [str(ub.key()), ub.price]

    def sendMessages(self, ub):
        status = self.HAVE if ub.status == self.WANT else self.WANT
        for j in UserBooks.gql("WHERE book_id=:1 AND status=:2", ub.book_id, status):
            response = "match found"
            UserUsers.addMessage(j.user_id, ub, response)
            UserUsers.addMessage(ub.user_id, j, response)

    def getBook(self, book_str):
        return Book.get(Key(book_str))

    def getActions(self, book, status):
        ub = UserBooks.gql("WHERE status=:1 AND book_id=:2", status, book)
コード例 #4
0
mqttclient.connect("mosquitto")
mqttclient.loop_start()

##############################################
# Api instance
##############################################
middleware = falcon_auth0.Auth0Middleware(cfg, claims)
app = falcon.App(middleware=[middleware])
app.req_options.auto_parse_form_urlencoded = True

##############################################
# Routes
##############################################
app.add_route("/api/v1/login", Login(auth0, middleware))
app.add_route("/api/v1/recoverpassword", RecoverPassword(auth0))
app.add_route("/api/v1/user", UserManagement(db, auth0))

app.add_route("/api/v1/users/{userId}", Users(db, auth0))
app.add_route("/api/v1/users/{userId}/changepassword", ChangePassword(auth0))
app.add_route("/api/v1/users/{userId}/permissionvalidation",
              ValidateLocationPermissions(db))
app.add_route("/api/v1/users/{userId}/mqttauth", MqttUserToken())
app.add_route("/api/v1/users/{userId}/locations",
              UserLocations(db, mqttclient))
app.add_route("/api/v1/users/{userId}/weather", Weather())
app.add_route("/api/v1/users/{userId}/sunschedule", SunSchedule())
app.add_route("/api/v1/users/{userId}/sensors", UserSensors(db))
app.add_route("/api/v1/users/{userId}/permissions/{shareId}",
              LocationPermission(db))
app.add_route("/api/v1/users/{userId}/bitcoin/current", BitcoinCurrent())
app.add_route("/api/v1/users/{userId}/bitcoin/historical", BitcoinHistorical())
コード例 #5
0
def get_current_users_files():
    user_management = UserManagement(request, mongo)
    result = user_management.get_users_files()
    return result
コード例 #6
0
def login():
    user_management = UserManagement(request, mongo)
    result = user_management.login()
    return result
コード例 #7
0
def signup():
    user_management = UserManagement(request, mongo)
    result = user_management.signup()
    return result