Beispiel #1
0
def get_weizoomcard_permission_own(request):
    post = request.POST
    user_id = int(post.get('user_id', ''))
    weizoomcardpermission = WeiZoomCardPermission.objects.filter(
        user_id=user_id)
    cur_weizoomcardpermission = []
    if weizoomcardpermission:
        cur_weizoomcardpermission = JsonResponse()
        cur_weizoomcardpermission.can_create_card = weizoomcardpermission[
            0].can_create_card
        cur_weizoomcardpermission.can_export_batch_card = weizoomcardpermission[
            0].can_export_batch_card
        cur_weizoomcardpermission.can_add_card = weizoomcardpermission[
            0].can_add_card
        cur_weizoomcardpermission.can_batch_stop_card = weizoomcardpermission[
            0].can_batch_stop_card
        cur_weizoomcardpermission.can_batch_active_card = weizoomcardpermission[
            0].can_batch_active_card
        cur_weizoomcardpermission.can_view_card_details = weizoomcardpermission[
            0].can_view_card_details
        cur_weizoomcardpermission.can_stop_card = weizoomcardpermission[
            0].can_stop_card
        cur_weizoomcardpermission.can_active_card = weizoomcardpermission[
            0].can_active_card
        cur_weizoomcardpermission.can_delay_card = weizoomcardpermission[
            0].can_delay_card
        cur_weizoomcardpermission.can_change_shop_config = weizoomcardpermission[
            0].can_change_shop_config
        cur_weizoomcardpermission.can_view_statistical_details = weizoomcardpermission[
            0].can_view_statistical_details
        cur_weizoomcardpermission.can_export_statistical_details = weizoomcardpermission[
            0].can_export_statistical_details
    response = create_response(200)
    response.data.items = cur_weizoomcardpermission
    return response.get_response()
Beispiel #2
0
def get_managers(request):
    count_per_page = int(request.GET.get('count_per_page', '1'))
    cur_page = int(request.GET.get('page', '1'))
    is_manage = 'manage' in request.GET
    if is_manage:
        card_managers = WeiZoomCardManager.objects.all()
    else:
        card_managers = WeiZoomCardManager.objects.exclude(
            user_id=request.user.id)
    pageinfo, card_managers = paginator.paginate(
        card_managers,
        cur_page,
        count_per_page,
        query_string=request.META['QUERY_STRING'])
    weizoomcardpermissions = WeiZoomCardPermission.objects.all()
    card_manager2weizoomcardpermission = {}
    for weizoomcardpermission in weizoomcardpermissions:
        card_manager2weizoomcardpermission[
            weizoomcardpermission.user_id] = weizoomcardpermission
    cur_card_managers = []
    for card_manager in card_managers:
        cur_card_manager = JsonResponse()
        cur_card_manager.id = card_manager.id
        cur_card_manager.user_id = card_manager.user_id
        cur_card_manager.username = card_manager.username
        cur_card_manager.nickname = card_manager.nickname
        try:
            cur_card_manager.can_create_card = card_manager2weizoomcardpermission[
                card_manager.user_id].can_create_card
            cur_card_manager.can_export_batch_card = card_manager2weizoomcardpermission[
                card_manager.user_id].can_export_batch_card
            cur_card_manager.can_add_card = card_manager2weizoomcardpermission[
                card_manager.user_id].can_add_card
            cur_card_manager.can_batch_stop_card = card_manager2weizoomcardpermission[
                card_manager.user_id].can_batch_stop_card
            cur_card_manager.can_batch_active_card = card_manager2weizoomcardpermission[
                card_manager.user_id].can_batch_active_card
            cur_card_manager.can_view_card_details = card_manager2weizoomcardpermission[
                card_manager.user_id].can_view_card_details
            cur_card_manager.can_stop_card = card_manager2weizoomcardpermission[
                card_manager.user_id].can_stop_card
            cur_card_manager.can_active_card = card_manager2weizoomcardpermission[
                card_manager.user_id].can_active_card
            cur_card_manager.can_delay_card = card_manager2weizoomcardpermission[
                card_manager.user_id].can_delay_card
            cur_card_manager.can_change_shop_config = card_manager2weizoomcardpermission[
                card_manager.user_id].can_change_shop_config
            cur_card_manager.can_view_statistical_details = card_manager2weizoomcardpermission[
                card_manager.user_id].can_view_statistical_details
            cur_card_manager.can_export_statistical_details = card_manager2weizoomcardpermission[
                card_manager.user_id].can_export_statistical_details
        except:
            pass
        cur_card_managers.append(cur_card_manager)
    response = create_response(200)
    response.data.items = cur_card_managers
    response.data.pageinfo = paginator.to_dict(pageinfo)
    return response.get_response()