예제 #1
0
def save(user, name):
    exist_app_name = App.exist_app_name(name)

    if exist_app_name:
        raise MSException('Ja existe uma app com esse nome')

    active_apps = list_app_svc.listing(user.key.id())
    if len(active_apps) == 3:
        raise MSException('Ops voce ja possui 3 apps')

    app_key = App.save(user, name)
    app = app_key.get()
    return app.to_dict_json()
예제 #2
0
def save(user, name):
    exist_app_name = App.exist_app_name(name)

    if exist_app_name:
        raise MSException("Ja existe uma app com esse nome")

    active_apps = list_app_svc.listing(user.key.id())
    if len(active_apps) == 3:
        raise MSException("Ops voce ja possui 3 apps")

    app_key = App.save(user, name)
    app = app_key.get()
    return app.to_dict_json()
예제 #3
0
        def wrapper(self, *args, **kwargs):
            body = json.loads(self.request.body) if is_json(
                self.request.body) else {}
            token = self.request.GET.get('token') or self.request.POST.get(
                'token') or body.get('token')
            user_id = self.request.GET.get('user_id') or self.request.POST.get(
                'user_id') or body.get('user_id')

            if not token or not user_id:
                raise MSException(u'App token e o user_id devem ser enviados')

            app = App.query(App.token == token).get()
            user = User.get_by_id(user_id)

            if user_id != app.user_id:
                raise MSException(u'App token ou user_id invalido')

            if app and user and not app.deleted:
                self.app_data = {
                    'app': app.to_dict_json(),
                    'user': user.to_dict_json()
                }

                method(self, *args, **kwargs)

                ActivityLog.save(user_id=user_id,
                                 app_name=app.name,
                                 token=token,
                                 activity=activity)
            else:
                raise MSException(u'App token e o user_id invalido')
예제 #4
0
        def wrapper(self, *args, **kwargs):
            body = json.loads(self.request.body) if is_json(self.request.body) else {}
            token = self.request.GET.get('token') or self.request.POST.get('token') or body.get('token')
            user_id = self.request.GET.get('user_id') or self.request.POST.get('user_id') or body.get('user_id')

            if not token or not user_id:
                raise MSException(u'App token e o user_id devem ser enviados')

            app = App.query(App.token == token).get()
            user = User.get_by_id(user_id)

            if user_id != app.user_id:
                raise MSException(u'App token ou user_id invalido')

            if app and user and not app.deleted:
                self.app_data = {
                    'app': app.to_dict_json(),
                    'user': user.to_dict_json()
                }

                method(self, *args, **kwargs)

                ActivityLog.save(user_id=user_id, app_name=app.name,token=token, activity=activity)
            else:
                raise MSException(u'App token e o user_id invalido')
예제 #5
0
def listing(user_id, filters={}):
    """
        filters

        with_deleted: [True | False]
    """
    with_deleted = filters.get('with_deleted', False)

    query = App.query(App.user_id == user_id)
    apps = query.fetch()
    apps_json = [a.to_dict_json() for a in apps]

    if not with_deleted:
        apps_json = [a for a in apps_json if not a['deleted']]

    return apps_json
예제 #6
0
def delete(app_id):
    app = App.get_by_id(int(app_id))
    app.deleted = True
    app.put()
예제 #7
0
def delete(app_id):
    app = App.get_by_id(int(app_id))
    app.deleted = True
    app.put()