Beispiel #1
0
def custom_menu_get(request):
    if not request.user.is_authenticated():
        return HttpResponseRedirect(s_reverse_admin_home())
    if not request.user.is_superuser:
        return HttpResponseRedirect(s_reverse_activity_list())
    custom_buttons = get_custom_menu()
    current_menu = []
    for button in custom_buttons:
        sbtns = button.get('sub_button', [])
        if len(sbtns) > 0:
            tmpkey = sbtns[0].get('key', '')
            if (not tmpkey.startswith(WEIXIN_BOOK_HEADER + 'W')
                ) and tmpkey.startswith(WEIXIN_BOOK_HEADER):
                current_menu = sbtns
                break
    if auto_clear_old_menus(current_menu):
        modify_custom_menu(
            json.dumps(get_custom_menu_with_book_acts(current_menu),
                       ensure_ascii=False).encode('utf8'))
    wrap_menu = []
    for menu in current_menu:
        wrap_menu += [{
            'name': menu['name'],
            'id': int(menu['key'].split('_')[-1]),
        }]
    return HttpResponse(json.dumps(wrap_menu), content_type='application/json')
Beispiel #2
0
def custom_menu_modify_post(request):
    ### add by xiaohe###
    raise Http404
    ### end by xiaohe ##
    if not request.user.is_authenticated():
        raise Http404
    if not request.user.is_superuser:
        raise Http404
    if not request.POST:
        raise Http404
    if not 'menus' in request.POST:
        raise Http404
    menus = json.loads(request.POST.get('menus', ''))
    sub_button = []
    for menu in menus:
        sub_button += [{
            'type': 'click',
            'name': menu['name'],
            'key': 'TSINGHUA_BOOK_' + str(menu['id']),
            'sub_button': [],
        }]
    return HttpResponse(modify_custom_menu(
        json.dumps(get_custom_menu_with_book_acts(sub_button),
                   ensure_ascii=False).encode('utf8')),
                        content_type='application/json')
Beispiel #3
0
def custom_menu_get(request):
    if not request.user.is_authenticated():
        return HttpResponseRedirect(s_reverse_admin_home())
    if not request.user.is_superuser:
        return HttpResponseRedirect(s_reverse_activity_list())
    custom_buttons = get_custom_menu()
    current_menu = []
    for button in custom_buttons:
        sbtns = button.get("sub_button", [])
        if len(sbtns) > 0:
            tmpkey = sbtns[0].get("key", "")
            if (not tmpkey.startswith(WEIXIN_BOOK_HEADER + "W")) and tmpkey.startswith(WEIXIN_BOOK_HEADER):
                current_menu = sbtns
                break
    if auto_clear_old_menus(current_menu):
        modify_custom_menu(json.dumps(get_custom_menu_with_book_acts(current_menu), ensure_ascii=False).encode("utf8"))
    wrap_menu = []
    for menu in current_menu:
        wrap_menu += [{"name": menu["name"], "id": int(menu["key"].split("_")[-1])}]
    return HttpResponse(json.dumps(wrap_menu), content_type="application/json")
Beispiel #4
0
def custom_menu_get(request):
    if not request.user.is_authenticated():
        return HttpResponseRedirect(s_reverse_admin_home())
    if not request.user.is_superuser:
        return HttpResponseRedirect(s_reverse_activity_list())
    custom_buttons = get_custom_menu()
    current_menu = []
    for button in custom_buttons:
        sub_button = button.get('sub_button', [])
        if len(sub_button) > 0:
            temp_key = sub_button[0].get('key', '')
            if (not temp_key.startswith(WEIXIN_BOOK_HEADER + 'W')) and temp_key.startswith(WEIXIN_BOOK_HEADER):
                current_menu = sub_button
                break
    if auto_clear_old_menus(current_menu):
        modify_custom_menu(json.dumps(get_custom_menu_with_book_acts(current_menu), ensure_ascii=False).encode('utf8'))
    wrap_menu = []
    for menu in current_menu:
        wrap_menu += [{
            'name': menu['name'],
            'id': int(menu['key'].split('_')[-1]),
        }]
    return HttpResponse(json.dumps(wrap_menu), content_type='application/json')
Beispiel #5
0
def custom_menu_modify_post(request):
    if not request.user.is_authenticated():
        raise Http404
    if not request.user.is_superuser:
        raise Http404
    if not request.POST:
        raise Http404
    if not "menus" in request.POST:
        raise Http404
    menus = json.loads(request.POST.get("menus", ""))
    sub_button = []
    for menu in menus:
        sub_button += [
            {"type": "click", "name": menu["name"], "key": "TSINGHUA_BOOK_" + str(menu["id"]), "sub_button": []}
        ]
    return HttpResponse(
        modify_custom_menu(json.dumps(get_custom_menu_with_book_acts(sub_button), ensure_ascii=False).encode("utf8")),
        content_type="application/json",
    )
Beispiel #6
0
def custom_menu_modify_post(request):
    if not request.user.is_authenticated():
        raise Http404
    if not request.user.is_superuser:
        raise Http404
    if not request.POST:
        raise Http404
    if not 'menus' in request.POST:
        raise Http404
    menus = json.loads(request.POST.get('menus', ''))
    sub_button = []
    for menu in menus:
        sub_button += [{
                           'type': 'click',
                           'name': menu['name'],
                           'key': 'TSINGHUA_BOOK_' + str(menu['id']),
                           'sub_button': [],
                       }]
    return HttpResponse(modify_custom_menu(json.dumps(get_custom_menu_with_book_acts(sub_button), ensure_ascii=False).encode('utf8')),
                        content_type='application/json')