コード例 #1
0
ファイル: service.py プロジェクト: mbalty/preventionconvid
    def signup(self, payload):
        """
        signup function
        :return:
        """

        try:
            check_email = email(check=True)
            payload["email"] = check_email(payload["email"])
        except Exception as ex:
            abort(400, Message="Invalid email")
        if payload.get('password') != payload.get('confirm_password'):
            abort(400, Message="Password does not match")
        count, records = base_obj.get(Collections.USERS,
                                      {"email": payload['email']})
        if count > 0:
            abort(400, Message="Email ID Already Exists")
        payload = custom_marshal(payload, user, 'create')
        payload['password'] = sha256_crypt.encrypt(payload['password'])
        _id = base_obj.insert(Collections.USERS, payload)
        print(_id, type(_id))
        link = ACTIVATION_MAIL.format(id=_id)
        print(link)
        send_mail([payload['email']], "Corona Location App Account Activation",
                  link, 'signup.html', {
                      'link': link,
                      'name': payload['first_name']
                  })
コード例 #2
0
ファイル: service.py プロジェクト: nosqlly/Todo-App
 def create_room(self, payload):
     """
     Create Room for an User
     :param payload:
     :return:
     """
     payload = custom_marshal(payload, room_record, 'create')
     _id = base_obj.insert(COLLECTIONS['ROOMS'], payload)
コード例 #3
0
ファイル: service.py プロジェクト: mbalty/preventionconvid
 def create_location(self, payload):
     """
     Create Location for an User
     :param payload:
     :return:
     """
     payload = custom_marshal(payload, location_record, 'create')
     _id = base_obj.insert(Collections.LOCATIONS, payload)
コード例 #4
0
 def create_task(self, id, payload):
     """
     Create a task in task room
     :param payload:
     :return:
     """
     payload = custom_marshal(payload, task_db_input, 'create')
     payload['_id'] = ObjectId()
     result = base_obj.update(COLLECTIONS['ROOMS'], {'_id': ObjectId(id)},
                              {"$push": {
                                  'tasks': payload
                              }})
コード例 #5
0
ファイル: service.py プロジェクト: nosqlly/Todo-App
 def update_room(self, id, payload):
     """
     Update Room
     :param payload:
     :return:
     """
     payload = custom_marshal(payload, room_request, 'update')
     email = get_jwt_identity()
     result = base_obj.update(COLLECTIONS['ROOMS'], {
         "_id": ObjectId(id),
         "meta.created_by": email
     }, {"$set": payload})
     print(result.modified_count)
     if not result.modified_count:
         abort(401, "Unauthorized")
コード例 #6
0
ファイル: service.py プロジェクト: gabrgomes/mongo_inventory
 def signup(self, payload):
     """
     signup function
     :return:
     """
     if payload.get('password') != payload.get('confirm_password'):
         abort(400, "Password does not match")
     count, records = base_obj.get(COLLECTIONS['USERS'],
                                   {"email": payload['email']})
     if count > 0:
         abort(400, "Email ID Already Exists")
     payload = custom_marshal(payload, user, 'create')
     payload['password'] = sha256_crypt.encrypt(payload['password'])
     _id = base_obj.insert(COLLECTIONS['USERS'], payload)
     print(_id, type(_id))
     link = ACTIVATION_MAIL.format(id=_id)
     print(link)
コード例 #7
0
ファイル: service.py プロジェクト: gabrgomes/mongo_inventory
 def create_inventory(self, payload):
     """
     Function to create inventory in mongo
     :param payload:
     :return:
     """
     count, records = base_obj.get(
         COLLECTIONS['INVENTORIES'], {
             "$and": [{
                 "inventory_name": payload['inventory_name']
             }, {
                 "sigla": payload['sigla']
             }]
         })
     if count > 0:
         abort(400, "Inventory Already Exists")
     payload = custom_marshal(payload, inventory_record, 'create')
     _id = base_obj.insert(COLLECTIONS['INVENTORIES'], payload)
     print(_id, type(_id))
コード例 #8
0
 def update_task(self, taskroom_id, task_id, payload):
     """
     Update the task id with payload
     :param taskroom_id:
     :param task_id:
     :param payload:
     :return:
     """
     email = get_jwt_identity()
     payload = custom_marshal(payload,
                              task_request,
                              'update',
                              prefix="tasks.$")
     result = base_obj.update(
         COLLECTIONS['ROOMS'], {
             '_id': ObjectId(taskroom_id),
             "tasks._id": ObjectId(task_id),
             "users": email
         }, {"$set": payload})
     print(payload, result)