Ejemplo n.º 1
0
    def post(self):
        if SQL.test_connect_to_dbo():
            req_data = request.get_json()

            password = ChangePasswordModel(req_data['userId'],
                                           req_data['password'])

            isUpdated = SQL.update_user_password(password)

            if isUpdated:
                response = app.response_class(response=json.dumps(
                    {"Message": "Success"}),
                                              status=200,
                                              mimetype='application/json')

                return response
            else:
                response = app.response_class(response=json.dumps(
                    {"Message": "Fail"}),
                                              status=424,
                                              mimetype='application/json')

                return response
        else:
            response = app.response_class(response=json.dumps(
                {"Message": "Fail"}),
                                          status=424,
                                          mimetype='application/json')

            return response
Ejemplo n.º 2
0
    def post(self):
        if SQL.test_connect_to_dbo():
            req_data = request.get_json()

            isApproved = req_data['IsApproved']
            id = req_data['Id']
            userId = req_data['UserId']

            isUpdated = SQL.update_submitted_item(isApproved, id, userId)

            if isUpdated:
                response = app.response_class(response=json.dumps(
                    {"Message": "Success"}),
                                              status=200,
                                              mimetype='application/json')

                return response
            else:
                response = app.response_class(response=json.dumps(
                    {"Message": "Failure"}),
                                              status=424,
                                              mimetype='application/json')
                return response
        else:
            response = app.response_class(response=json.dumps(
                {"Message": "Failure"}),
                                          status=424,
                                          mimetype='application/json')
            return response
Ejemplo n.º 3
0
    def post(self):
        if SQL.test_connect_to_dbo():
            req_data = request.get_json()

            profile = AccountProfile(req_data['AccountId'],
                                     req_data['AccountName'],
                                     req_data['CreateDate'],
                                     req_data['IsActive'])

            data = SQL.update_account(profile)

            if data:
                response = app.response_class(response=json.dumps(data),
                                              status=200,
                                              mimetype='application/json')

                return response
            else:
                response = app.response_class(status=200,
                                              mimetype='application/json')

                return response
        else:
            response = app.response_class(response=json.dumps(
                {"Message": "Failure"}),
                                          status=200,
                                          mimetype='application/json')

            return response
Ejemplo n.º 4
0
    def post(self):
        if SQL.test_connect_to_dbo():
            req_data = request.get_json()
            data = req_data['data']['FieldInfo']
            userId = req_data['userId']
            isNew = req_data['isNew']

            form = FormModel(data['FormKey'], data['FieldSchema'],
                             data['ActionLink'], data['IsActive'],
                             req_data['formName'])
            isUpdated = False

            if isNew:
                isUpdated = SQL.create_form(form, userId)
            else:
                isUpdated = SQL.update_form(form, userId)

            if isUpdated:
                response = app.response_class(response=json.dumps(
                    {"Message": "Success"}),
                                              status=200,
                                              mimetype='application/json')
                return response
            else:
                response = app.response_class(response=json.dumps(
                    {"Message": "Failure"}),
                                              status=424,
                                              mimetype='application/json')
                return response
        else:
            response = app.response_class(response=json.dumps(
                {"Message": "Failure"}),
                                          status=424,
                                          mimetype='application/json')
            return response
Ejemplo n.º 5
0
    def post(self):
        if SQL.test_connect_to_dbo():
            req_data = request.get_json()

            story = StoryModel(req_data[0]['Id'], req_data[0]['Title'],
                               req_data[0]['Story'],
                               req_data[0]['luS'][0]['ServerId'],
                               req_data[0]['IsActive'])

            updated = SQL.update_story(story)

            if updated:
                response = app.response_class(response=json.dumps(
                    {"Message": "Success"}),
                                              status=200,
                                              mimetype='application/json')
                return response
            else:
                response = app.response_class(response=json.dumps(
                    {"Message": "Failure"}),
                                              status=424,
                                              mimetype='application/json')
                return response
        else:
            response = app.response_class(response=json.dumps(
                {"Message": "Failure"}),
                                          status=424,
                                          mimetype='application/json')
            return response
Ejemplo n.º 6
0
    def post(self):
        if SQL.test_connect_to_dbo():
            req_data = request.get_json()

            user = RegisterAccountUser(req_data['accountid'],
                                       req_data['username'],
                                       req_data['firstname'],
                                       req_data['lastname'],
                                       req_data['discorduserid'],
                                       req_data['password'])
            isAuth = SQL.registerUser(user)

            if isAuth:
                response = app.response_class(response=json.dumps(
                    {"Message": "Register Success"}),
                                              status=200,
                                              mimetype='application/json')
                return response
            else:
                response = app.response_class(response=json.dumps(
                    {"Message": "Failure"}),
                                              status=200,
                                              mimetype='application/json')
                return response
        else:
            response = app.response_class(status=424,
                                          mimetype='application/json')
            return response
Ejemplo n.º 7
0
    def post(self):
        if SQL.test_connect_to_dbo():
            req_data = request.get_json()

            title = ''
            data_dic = json.loads(json.dumps(req_data))
            titleExists = "title" in data_dic

            if titleExists:
                title = req_data['title']
            else:
                title = "NULL"

            suggestion = Suggestion(req_data['typeId'], title,
                                    req_data['story'], req_data['serverId'],
                                    req_data['discordUserId'])

            isSubmitted = SQL.submit_item_suggestion(suggestion)

            if isSubmitted:
                response = app.response_class(response=json.dumps(
                    {"Message": "Success"}),
                                              status=200,
                                              mimetype='application/json')
                return response
            else:
                response = app.response_class(response=json.dumps(
                    {"Message": "Failure"}),
                                              status=424,
                                              mimetype='application/json')
                return response
Ejemplo n.º 8
0
    def post(self):
        if SQL.test_connect_to_dbo():
            data = request.get_json()
            data = data[0]
            role = data['r'][0]
            role = role['Role']

            discordUserId = None

            data_dic = json.loads(json.dumps(data))
            discordExists = "DiscordUserId" in data_dic

            if discordExists:
                discordUserId = data['DiscordUserId']
            else:
                discordUserId = "NULL"

            userInfo = UserProfile(data['Username'], data['FirstName'],
                                   data['LastName'], discordUserId,
                                   data['IsActive'], data['IsLocked'], role)

            SQL.update_user(userInfo)

            response = app.response_class(response=json.dumps(
                {"Message": "Success"}),
                                          status=200,
                                          mimetype='application/json')

            return response
        else:
            response = app.response_class(status=424,
                                          mimetype='application/json')
            return response
Ejemplo n.º 9
0
 def get(self):
     if SQL.test_connect_to_dbo():
         pageId = request.args.get('pageId')
         forms = SQL.get_all_forms_by_pageId(pageId)
         forms = forms[0]
         response = app.response_class(response=json.dumps(forms),
                                       status=200,
                                       mimetype='application/json')
         return response
     else:
         response = app.response_class(status=424,
                                       mimetype='application/json')
         return response
Ejemplo n.º 10
0
    def get(self):
        if SQL.test_connect_to_dbo():
            data = SQL.get_all_roles()

            response = app.response_class(response=json.dumps(data),
                                          status=200,
                                          mimetype='application/json')

            return response
        else:
            response = app.response_class(status=424,
                                          mimetype='application/json')
            return response
Ejemplo n.º 11
0
    def get(self):
        if SQL.test_connect_to_dbo():
            formKey = request.args.get('formKey')
            data = SQL.get_form_name(formKey)

            response = app.response_class(response=json.dumps(data),
                                          status=200,
                                          mimetype='application/json')

            return response
        else:
            response = app.response_class(status=424,
                                          mimetype='application/json')
            return response
Ejemplo n.º 12
0
    def get(self):
        if SQL.test_connect_to_dbo():
            userId = request.args.get('userId')
            data = SQL.get_user_by_id(userId)

            response = app.response_class(response=json.dumps(data),
                                          status=200,
                                          mimetype='application/json')

            return response
        else:
            response = app.response_class(status=424,
                                          mimetype='application/json')
            return response
Ejemplo n.º 13
0
    def get(self):
        if SQL.test_connect_to_dbo():
            accountId = request.args.get('accountId')

            servers = SQL.get_servers_by_account(accountId)

            response = app.response_class(response=json.dumps(servers),
                                          status=200,
                                          mimetype='application/json')

            return response
        else:
            response = app.response_class(status=424,
                                          mimetype='application/json')
            return response
Ejemplo n.º 14
0
    def get(self):
        if SQL.test_connect_to_dbo():
            id = request.args.get('id')

            wisdom = SQL.get_wisdom_by_id(id)

            response = app.response_class(response=json.dumps(wisdom),
                                          status=200,
                                          mimetype='application/json')

            return response
        else:
            response = app.response_class(status=424,
                                          mimetype='application/json')
            return response
Ejemplo n.º 15
0
    def get(self):
        if SQL.test_connect_to_dbo():
            paginationModel = PaginationHelper(
                request.args, 'FormKey', ["FormKey", "FormName", "IsActive"])

            forms = SQL.get_all_forms(paginationModel)

            response = app.response_class(response=json.dumps(forms),
                                          status=200,
                                          mimetype='application/json')
            return response
        else:
            response = app.response_class(status=424,
                                          mimetype='application/json')
            return response
Ejemplo n.º 16
0
    def get(self):
        if SQL.test_connect_to_dbo():
            paginationModel = PaginationHelper(request.args, 'Title',
                                               ["Title", "Story", "IsActive"])

            stories = SQL.get_all_stories(paginationModel)

            response = app.response_class(response=json.dumps(stories),
                                          status=200,
                                          mimetype='application/json')

            return response
        else:
            response = app.response_class(status=424,
                                          mimetype='application/json')
            return response
Ejemplo n.º 17
0
    def get(self):
        if SQL.test_connect_to_dbo():
            accountId = request.args.get('accountId')
            isMaster = request.args.get('isMaster')

            accountInformation = SQL.get_account_info_by_id(accountId)

            response = app.response_class(
                response=json.dumps(accountInformation),
                status=200,
                mimetype='application/json')

            return response
        else:
            response = app.response_class(status=424,
                                          mimetype='application/json')
            return response
Ejemplo n.º 18
0
    def get(self):
        if SQL.test_connect_to_dbo():

            paginationModel = PaginationHelper(request.args, 'CreateDate', [
                "Title", "CreateDate", "ItemType", "IsApproved", "IsReviewed"
            ])

            items = SQL.get_submitted_items(paginationModel)

            response = app.response_class(response=json.dumps(items),
                                          status=200,
                                          mimetype='application/json')
            return response
        else:
            response = app.response_class(status=424,
                                          mimetype='application/json')
            return response
Ejemplo n.º 19
0
    def get(self):
        if SQL.test_connect_to_dbo():
            helpContentKey = request.args.get('helpContentKey')
            isAdmin = request.args.get('isAdmin')

            #do something here
            helpContent = SQL.get_documentation(helpContentKey, isAdmin)

            response = app.response_class(response=json.dumps(helpContent),
                                          status=200,
                                          mimetype='application/json')

            return response
        else:
            response = app.response_class(status=424,
                                          mimetype='application/json')
            return response
Ejemplo n.º 20
0
    def post(self):
        if SQL.test_connect_to_dbo():
            req_data = request.get_json()

            user = User(req_data['username'], req_data['password'])

            isAuth = SQL.login(user)

            if isAuth:
                response = app.response_class(response=json.dumps(isAuth),
                                              status=200,
                                              mimetype='application/json')
                return response
            else:
                response = app.response_class(status=424,
                                              mimetype='application/json')
                return response
Ejemplo n.º 21
0
    def get(self):
        if SQL.test_connect_to_dbo():
            paginationModel = PaginationHelper(
                request.args, 'HelpContentKey',
                ["HelpContentKey", "HelpTitle", "HelpContent", "IsActive"])

            content = SQL.get_all_documentation(paginationModel)

            response = app.response_class(response=json.dumps(content),
                                          status=200,
                                          mimetype='application/json')

            return response
        else:
            response = app.response_class(status=424,
                                          mimetype='application/json')
            return response
Ejemplo n.º 22
0
    def get(self):
        if SQL.test_connect_to_dbo():
            id = request.args.get('id')

            suggestion = SQL.get_submitted_item_by_id(id)

            if suggestion:
                response = app.response_class(response=json.dumps(suggestion),
                                              status=200,
                                              mimetype='application/json')
                return response
            else:
                response = app.response_class(status=424,
                                              mimetype='application/json')
                return response
        else:
            response = app.response_class(status=424,
                                          mimetype='application/json')
            return response
Ejemplo n.º 23
0
    def post(self):
        if SQL.test_connect_to_dbo():
            req_data = request.get_json()

            id = 0
            data_dic = json.loads(json.dumps(req_data))
            idExists = "Id" in data_dic

            if idExists:
                id = req_data['Id']
            else:
                id = 0

            serverData = AccountServerModel(req_data['Id'],
                                            req_data['ServerId'],
                                            req_data['AccountId'],
                                            req_data['Nickname'],
                                            req_data['DailyWisdom'],
                                            req_data['WeeklyStory'])

            isSuccess = SQL.update_server(serverData)

            if isSuccess:
                response = app.response_class(response=json.dumps(
                    {"Message": "Success"}),
                                              status=200,
                                              mimetype='application/json')

                return response
            else:
                response = app.response_class(response=json.dumps(
                    {"Message": "Failure"}),
                                              status=424,
                                              mimetype='application/json')

                return response
        else:
            response = app.response_class(response=json.dumps(
                {"Message": "Failure"}),
                                          status=424,
                                          mimetype='application/json')

            return response
Ejemplo n.º 24
0
    def get(self):
        if SQL.test_connect_to_dbo():
            isMaster = request.args.get('isMaster')
            paginationModel = PaginationHelper(request.args, 'Username', [
                "Id", "Username", "FirstName", "LastName", "IsActive",
                "CreateDate"
            ])

            data = SQL.get_all_users(isMaster, paginationModel)

            response = app.response_class(response=json.dumps(data),
                                          status=200,
                                          mimetype='application/json')

            return response
        else:
            response = app.response_class(status=424,
                                          mimetype='application/json')
            return response
Ejemplo n.º 25
0
    def get(self):
        if SQL.test_connect_to_dbo():
            accountId = request.args.get('accountId')
            isMaster = request.args.get('masterAdmin')
            paginationModel = PaginationHelper(request.args, "Username", [
                "Username", "FirstName", "LastName", "IsActive", "IsLocked",
                "CreateDate"
            ])

            accountInformation = SQL.get_account_users(accountId, isMaster,
                                                       paginationModel)

            response = app.response_class(
                response=json.dumps(accountInformation),
                status=200,
                mimetype='application/json')

            return response
        else:
            response = app.response_class(status=424,
                                          mimetype='application/json')
            return response
Ejemplo n.º 26
0
    def post(self):
        if SQL.test_connect_to_dbo():
            req_data = request.get_json()
            #do something here

            documentation = Documentation(req_data['helpContentKey'],
                                          req_data['helpTitle'],
                                          req_data['helpContent'],
                                          req_data['isActive'],
                                          req_data['userId'],
                                          req_data['admin'])

            helpContent = SQL.update_documentation(documentation)

            response = app.response_class(response=json.dumps(helpContent),
                                          status=200,
                                          mimetype='application/json')

            return response
        else:
            response = app.response_class(status=424,
                                          mimetype='application/json')
            return response
Ejemplo n.º 27
0
    def get(self):
        if SQL.test_connect_to_dbo():
            serverId = request.args.get('id')

            selectItem = SQL.get_select_item(serverId)

            sql = Helpers.built_select_item_query(selectItem)

            items = SQL.execute_built_query(sql)

            nameValueKey = Helpers.get_name_and_value_columns(selectItem)

            itemsToReturn = {"Items": items, "NameValueCols": nameValueKey}

            response = app.response_class(response=json.dumps(itemsToReturn),
                                          status=200,
                                          mimetype='application/json')

            return response
        else:
            response = app.response_class(status=424,
                                          mimetype='application/json')
            return response