Ejemplo n.º 1
0
def fetch_all_fun_data(page, limit, order_by_names):
    """
    获取所有的功能信息
    :param page:
    :param limit:
    :return:
    """
    try:
        pager = Paginator(Device_Fun.objects.filter().order_by(order_by_names),
                          int(limit))
        dfs = pager.page(int(page))
        total_count = pager.count
        data = []
        for df in dfs:
            fun = json.loads(df.device_function)
            d = dict(
                id=df.df_id,
                key=df.device_key,
                name=fun["Stream_ID"],
                status=df.df_check_status,
                update_time=date2ymdhms(utctime2localtime(df.df_update_date)),
                create_time=date2ymdhms(utctime2localtime(df.df_create_date)),
            )
            data.append(d)
        result = dict(totalCount=total_count, items=data)
        return result
    except Exception as e:
        logging.getLogger("").error(e)
        return ""
Ejemplo n.º 2
0
def fetch_developer_list_data(page, limit, order_by_names):
    """
    获取所有开发者列表
    :param page:
    :param limit:
    :param order_by_names:
    :return:
    """
    try:
        pager = Paginator(
            Developer.objects.filter(
                developer_check_status=_convention.DEVELOPER_CHECKED).order_by(
                    order_by_names), int(limit))
        developers = pager.page(int(page))
        total_count = pager.count
        data = []
        for developer in developers:
            d = dict(id=developer.developer_id,
                     is_forbid=developer.developer_is_forbid,
                     factory=developer.developer_factory,
                     inc=developer.developer_inc,
                     site=developer.developer_site,
                     job=developer.developer_job,
                     person=developer.developer_person,
                     createtime=date2ymdhms(
                         utctime2localtime(developer.developer_update_date)))
            data.append(d)
        result = dict(totalCount=total_count, items=data)
        return result
    except Exception as e:
        logging.getLogger("").error(e)
        return ""
Ejemplo n.º 3
0
def fetch_user_list_user_data(search, page, limit, order_by_names):

    try:
        pager = Paginator(
            Account.objects.filter(
                account_id__icontains=search).order_by(order_by_names),
            int(limit))
        users = pager.page(int(page))
        total_count = pager.count
        data = []
        for user in users:
            d = dict(id=user.account_id,
                     f=user.account_from_id,
                     t=user.account_type,
                     email=user.account_email,
                     phone=user.account_phone,
                     nickname=user.account_nickname,
                     is_forbid=user.account_is_forbid,
                     createtime=date2ymdhms(user.account_create_date))
            data.append(d)
        result = dict(totalCount=total_count, items=data)
        return result
    except Exception as e:
        logging.getLogger("").error(e)
        return ""
Ejemplo n.º 4
0
def fetch_publishing_app_data(page, limit, order_by_names):
    """
    获取所有发布中的应用信息
    :param page:
    :param limit:
    :return:
    """
    try:
        pager = Paginator(
            App.objects.filter(check_status=_convention.APP_CHECKING).order_by(
                order_by_names), int(limit))
        apps = pager.page(int(page))
        total_count = pager.count
        data = []
        for app in apps:
            d = dict(id=app.app_id,
                     name=app.app_name,
                     logo=app.app_logo,
                     describe=app.app_describe,
                     site=app.app_site,
                     createtime=date2ymdhms(
                         utctime2localtime(app.app_update_date)))
            data.append(d)
        result = dict(totalCount=total_count, items=data)
        return result
    except Exception as e:
        logging.getLogger("").error(e)
        return ""
Ejemplo n.º 5
0
    def fetch(page, limit, order_by_names):
        """
        获取所有文档
        :param page:
        :param limit:
        :return:
        """
        try:
            pager = Paginator(Doc.objects.all().order_by(order_by_names),
                              int(limit))
            doc_set = pager.page(int(page))
            total_count = pager.count
            data = []

            for doc in doc_set:
                try:
                    api = doc.api_id
                    api_name = api.api_name
                except Exception as e:
                    logging.getLogger('').error(e)
                    api_name = ''
                d = dict(doc_id=doc.doc_id,
                         api_name=api_name,
                         doc_name=doc.doc_name,
                         doc_markdown=doc.doc_markdown,
                         doc_html=doc.doc_html,
                         doc_type=doc.doc_type,
                         doc_create_date=date2ymdhms(doc.doc_create_date),
                         doc_update_date=date2ymdhms(doc.doc_update_date))

                data.append(d)
            result = dict(totalCount=total_count, items=data)

            return result
        except Exception as e:
            logging.getLogger('').error(e)
            return ""
Ejemplo n.º 6
0
 def get():
     ret = {"code": 10000}
     api_id = request.GET.get("id", "")
     if not api_id:
         return HttpResponse("")
     api = fetch_api_data(api_id)
     if api:
         api_name = api.api_name if api.api_id else ""
         api_describe = api.api_describe if api.api_describe else ""
         api_url = api.api_url if api.api_url else ""
         api_request_type = api.api_request_type if api.api_request_type else ""
         api_type = api.api_type if api.api_type is not None else ""
         api_params = api.api_params if api.api_params else ""
         api_return = api.api_return if api.api_return else ""
         api_doc_url = api.api_doc_url if api.api_doc_url else ""
         api_action_url = api.api_action_url if api.api_action_url else ""
         api_port = api.api_port if api.api_port is not None else "80"
         api_classify = api.api_classify if api.api_classify else ""
         api_function = api.api_function if api.api_function else ""
         api_level = api.api_level if api.api_level is not None else ""
         api_group = api.api_group if api.api_group is not None else ""
         api_invoke_total = api.api_invoke_total if api.api_invoke_total is not None else ""
         api_is_forbid = api.api_is_forbid if api.api_is_forbid is not None else ""
         api_create_date = api.api_create_date if api.api_create_date else ""
         data = dict(api_name=api_name,
                     api_describe=api_describe,
                     api_url=api_url,
                     api_request_type=api_request_type,
                     api_type=api_type,
                     api_params=api_params,
                     api_return=api_return,
                     api_doc_url=api_doc_url,
                     api_action_url=api_action_url,
                     api_port=api_port,
                     api_classify=api_classify,
                     api_function=api_function,
                     api_level=api_level,
                     api_group=api_group,
                     api_invoke_total=api_invoke_total,
                     api_is_forbid=api_is_forbid,
                     api_create_date=date2ymdhms(api_create_date))
         ret["data"] = data
         if data:
             return HttpResponse(json.dumps(ret, separators=(",", ":")))
     else:
         return HttpResponse("")
Ejemplo n.º 7
0
def fetch_all_app_data(page, limit, order_by_names):
    """
    获取所有的应用信息
    :param page:
    :param limit:
    :return:
    """
    try:
        pager = Paginator(App.objects.filter().order_by(order_by_names),
                          int(limit))
        apps = pager.page(int(page))
        total_count = pager.count
        data = []

        for app in apps:
            try:
                an = Account.objects.filter(
                    account_id__contains=app.developer.developer_id[2:]).extra(
                        order_by=('account_create_date', ))[0:1]
                nickname = an[0].account_nickname
                if not nickname:
                    nickname = app.developer.developer_id
            except Exception as e:
                print(e)
                nickname = ''
                pass

            d = dict(id=app.app_id,
                     name=app.app_name,
                     logo=app.app_logo,
                     describe=app.app_appid[-8:],
                     site=app.app_site,
                     nickname=nickname,
                     createtime=date2ymdhms(
                         utctime2localtime(app.app_update_date)))

            data.append(d)

        result = dict(totalCount=total_count, items=data)
        return result
    except Exception as e:
        print(e)
        logging.getLogger("").error(e)
        return ""
Ejemplo n.º 8
0
def fetch_api_list_data(page, limit, order_by_names):
    try:
        pager = Paginator(Api.objects.all().order_by(order_by_names),
                          int(limit))
        api_list = pager.page(int(page))
        total_count = pager.count
        data = []
        for api in api_list:
            d = dict(id=api.api_id,
                     name=api.api_name,
                     method=api.api_request_type.upper()
                     if api.api_request_type else "",
                     describe=api.api_describe,
                     doc=api.api_doc_url,
                     createtime=date2ymdhms(api.api_create_date))
            data.append(d)
        result = dict(totalCount=total_count, items=data)
        return result
    except Exception as e:
        logging.getLogger("").error(e)
        return ""
Ejemplo n.º 9
0
    def get():
        developer_id = request.GET.get("id", "")
        modal_title = "开发者信息"
        modal_content = "数据加载失败"
        template = """
        <div class="modal-dialog">
          <div class="modal-content">
            <div class="modal-header">
              <button type="button" class="close" data-dismiss="modal">&times;</button>
              <h4 class="modal-title">{0}</h4>
            </div>
            <div class="modal-body">
              {1}
            </div>
            <div class="modal-footer">
              <a href="#" class="btn btn-default btn-s-xs" data-dismiss="modal">关闭</a>
            </div>
          </div><!-- /.modal-content -->
        </div><!-- /.modal-dialog -->
        """
        content_template = """
        <form class="form-horizontal">
        <div class="form-group">
            <label class="col-lg-3 control-label">开发者账号</label>
            <div class="col-lg-9">
            <p class="form-control-static">{}</p>
            </div>
        </div>
        <div class="line line-dashed b-b line-lg pull-in"></div>
        <div class="form-group">
            <label class="col-lg-3 control-label">用户账号</label>
            <div class="col-lg-9">
            <p class="form-control-static">{}</p>
            </div>
        </div>
        <div class="line line-dashed b-b line-lg pull-in"></div>
        <div class="form-group">
            <label class="col-lg-3 control-label">用户来源</label>
            <div class="col-lg-9">
            <p class="form-control-static">{}</p>
            </div>
        </div>
        <div class="line line-dashed b-b line-lg pull-in"></div>
        <div class="form-group">
            <label class="col-lg-3 control-label">唯一标识</label>
            <div class="col-lg-9">
            <p class="form-control-static">{}</p>
            </div>
        </div>
        <div class="line line-dashed b-b line-lg pull-in"></div>
        <div class="form-group">
            <label class="col-lg-3 control-label">是否禁用</label>
            <div class="col-lg-9">
            <p class="form-control-static">{} (1: 禁用, 0: 不禁用)</p>
            </div>
        </div>
        <div class="line line-dashed b-b line-lg pull-in"></div>
        <div class="form-group">
            <label class="col-lg-3 control-label">厂家</label>
            <div class="col-lg-9">
            <p class="form-control-static">{}</p>
            </div>
        </div>
        <div class="line line-dashed b-b line-lg pull-in"></div>
        <div class="form-group">
            <label class="col-lg-3 control-label">公司</label>
            <div class="col-lg-9">
            <p class="form-control-static">{}</p>
            </div>
        </div>
        <div class="line line-dashed b-b line-lg pull-in"></div>
        <div class="form-group">
            <label class="col-lg-3 control-label">网站</label>
            <div class="col-lg-9">
            <p class="form-control-static">{}</p>
            </div>
        </div>
        <div class="line line-dashed b-b line-lg pull-in"></div>
        <div class="form-group">
            <label class="col-lg-3 control-label">职位</label>
            <div class="col-lg-9">
            <p class="form-control-static">{}</p>
            </div>
        </div>
        <div class="line line-dashed b-b line-lg pull-in"></div>
        <div class="form-group">
            <label class="col-lg-3 control-label">团队人数</label>
            <div class="col-lg-9">
            <p class="form-control-static">{}</p>
            </div>
        </div>
        <div class="line line-dashed b-b line-lg pull-in"></div>
        <div class="form-group">
            <label class="col-lg-3 control-label">真实姓名</label>
            <div class="col-lg-9">
            <p class="form-control-static">{}</p>
            </div>
        </div>
        <div class="line line-dashed b-b line-lg pull-in"></div>
        <div class="form-group">
            <label class="col-lg-3 control-label">地址</label>
            <div class="col-lg-9">
            <p class="form-control-static">{}</p>
            </div>
        </div>
        <div class="line line-dashed b-b line-lg pull-in"></div>
        <div class="form-group">
            <label class="col-lg-3 control-label">手机号</label>
            <div class="col-lg-9">
            <p class="form-control-static">{}</p>
            </div>
        </div>
        <div class="line line-dashed b-b line-lg pull-in"></div>
        <div class="form-group">
            <label class="col-lg-3 control-label">邮箱</label>
            <div class="col-lg-9">
            <p class="form-control-static">{}</p>
            </div>
        </div>
        <div class="line line-dashed b-b line-lg pull-in"></div>
        <div class="form-group">
            <label class="col-lg-3 control-label">更新时间</label>
            <div class="col-lg-9">
            <p class="form-control-static">{}</p>
            </div>
        </div>
        <div class="line line-dashed b-b line-lg pull-in"></div>
        <div class="form-group">
            <label class="col-lg-3 control-label">创建时间</label>
            <div class="col-lg-9">
            <p class="form-control-static">{}</p>
            </div>
        </div>
        </form>
        """
        if developer_id:
            developer = fetch_developer_data(developer_id=developer_id)
            if developer:
                account = developer.developer_account if developer.developer_account else ""
                factory = developer.developer_factory if developer.developer_factory else ""
                inc = developer.developer_inc if developer.developer_inc else ""
                site = developer.developer_site if developer.developer_site else ""
                job = developer.developer_job if developer.developer_job else ""
                person = developer.developer_person if developer.developer_person else "0"
                developer_from = developer.developer_from if developer.developer_from else ""
                symbol = developer.developer_symbol if developer.developer_symbol else ""
                is_forbid = developer.developer_is_forbid if developer.developer_is_forbid is not None else ""
                address = developer.developer_address if developer.developer_address else ""
                real_name = developer.developer_realname if developer.developer_realname else ""
                mobile = developer.developer_mobile if developer.developer_mobile else ""
                email = developer.developer_email if developer.developer_email else ""
                developer_create_date = date2ymdhms(
                    utctime2localtime(developer.developer_create_date))
                developer_update_date = date2ymdhms(
                    utctime2localtime(developer.developer_update_date))

                modal_content = content_template.format(
                    developer_id, account, developer_from, symbol, is_forbid,
                    factory, inc, site, job, person, real_name, address,
                    mobile, email, developer_update_date,
                    developer_create_date)
        ret = template.format(modal_title, modal_content)
        return HttpResponse(ret)