示例#1
0
 def __init__(self):
     self.log = logging
     self.log.basicConfig(level=logging.DEBUG, format=LOG_FORMAT)
     # client = MongoClient(
     #     "mongodb+srv://zed:[email protected]/" \
     #     "test?retryWrites=true&w=majority")
     #
     # db = client.apt
     self.collection = db.user
     self.theme_db_api = theme_db_api()
     server_status_result = db.command("serverStatus")
     self.log.info(server_status_result)
示例#2
0
from flask_restful import Resource, reqparse
from flask import request, render_template, make_response
from libs.strings import gettext
from models.user_db_api import user_db_api
from models.theme_db_api import theme_db_api
from models.report_db_api import report_db_api

theme_api = theme_db_api()
from libs import JSONEncoder


class ViewMain(Resource):

    def get(self):
        # can obtain data if refreshing page
        theme = list(theme_api.get_all_theme())
        if len(theme) == 0:
            # when theme list is empty; 'length' is needed in html
            return make_response(render_template('view.html', theme=theme, length=len(theme)), 200)

        return make_response(render_template(
                'view.html', theme=theme, length=len(theme)
            ), 200)
    # def get(self, t_name):
    #     curr_theme = theme_api.get_theme_by_name(t_name)
    #     if not curr_theme:
    #         return {"message": gettext("theme_not_found")}, 404
    #
    #     return {'theme name': str(curr_theme['t_name'])}, 200

class ViewOne(Resource):
示例#3
0
import datetime
from flask_restful import Resource, reqparse
from flask import render_template, make_response, request, redirect, session, jsonify
import logging
from urllib.error import HTTPError
from libs.strings import gettext
from models.theme_db_api import theme_db_api
from models.report_db_api import report_db_api
from models.user_db_api import user_db_api
from flask_jwt_extended import jwt_required
from bson.objectid import ObjectId
from resources.notification import send_notifications

theme_server = theme_db_api()
report_server = report_db_api()
user_server = user_db_api()
test_user_id = "5da733a794196bf0ff5f06db"
#
# _report_parser = reqparse.RequestParser()
# _report_parser.add_argument('user_id', type=str, required=True,
#                             help="this field cannot be left blank")
# _report_parser.add_argument('report_title', type=str, required=True,
#                             help="this field cannot be left blank")
# _report_parser.add_argument('report_image', type=str, required=True,
#                             help="this field cannot be left blank")
# _report_parser.add_argument('report_time', type=str, required=True,
#                             help="this field cannot be left blank")
# _report_parser.add_argument('report_theme', type=str, required=True,
#                             help="this field cannot be left blank")
# _report_parser.add_argument('report_location', type=str, required=True,
#                             help="this field cannot be left blank")