Esempio n. 1
0
def print_bill(request):
    """
        :param request:
        :return:
    """
    user = request.user
    bill_id = request.GET['bill_id']
    bill_type = request.GET['bill_type']

    if bill_id and bill_type:
        if bill_type == 'quarter_salary':
            file_name, binary_pdf = generate_quarter_salary_pdf(user, bill_id)
            response = HttpResponse(content_type='application/pdf')
            response[
                'Content-Disposition'] = 'attachment;filename="{}.pdf"'.format(
                    file_name)
            response.write(binary_pdf)
        else:
            data = dict()
            code = ApiCode.success.code
            mess = ApiCode.success.mess
            response = HttpResponse(content_type='application/json')
            response.write(JsonResponse(code, mess, data))
    else:
        data = dict()
        code = ApiCode.success.code
        mess = ApiCode.success.mess
        response = HttpResponse(content_type='application/json')
        response.write(JsonResponse(code, mess, data))
    return response
Esempio n. 2
0
    def get_context(self, request, *args, **kwargs):

        model = request.params.model

        code, mess, data = get_menus_permission(request.user, model)

        return JsonResponse(code, mess, data)
Esempio n. 3
0
    def get_context(self, request, *args, **kwargs):

        user = request.user

        id = request.params.id
        name = request.params.name
        short_name = request.params.short_name
        supplier = request.params.supplier
        customer = request.params.customer
        phone = request.params.phone
        society_code = request.params.society_code
        link_man = request.params.link_man
        link_man_phone = request.params.link_man_phone
        send_man = request.params.send_man
        send_man_phone = request.params.send_man_phone
        address = request.params.address

        if not id:
            code, mess, data = user_add_partner(user, name, short_name,
                                                supplier, customer, phone,
                                                society_code, link_man,
                                                link_man_phone, send_man,
                                                send_man_phone, address)
        else:
            code, mess, data = user_change_partner(user, id, name, short_name,
                                                   supplier, customer, phone,
                                                   society_code, link_man,
                                                   link_man_phone, send_man,
                                                   send_man_phone, address)
        return JsonResponse(code, mess, data)
Esempio n. 4
0
    def get_context(self, request, *args, **kwargs):

        user = request.user

        name = request.params.name
        length = request.params.length
        length_unit = request.params.length_unit
        wide = request.params.wide
        wide_unit = request.params.wide_unit
        height = request.params.height
        height_unit = request.params.height_unit
        diam = request.params.diam
        diam_unit = request.params.diam_unit
        bulk = request.params.bulk
        bulk_unit = request.params.bulk_unit
        weight = request.params.weight
        weight_unit = request.params.weight_unit

        id = request.params.id

        if id:
            code, mess, data = user_update_material(user, id, name, length,
                                                    length_unit, wide,
                                                    wide_unit, height,
                                                    height_unit, diam,
                                                    diam_unit, bulk, bulk_unit,
                                                    weight, weight_unit)
        else:
            code, mess, data = user_add_material(user, name, length,
                                                 length_unit, wide, wide_unit,
                                                 height, height_unit, diam,
                                                 diam_unit, bulk, bulk_unit,
                                                 weight, weight_unit)

        return JsonResponse(code, mess, data)
Esempio n. 5
0
    def get_context(self, request, *args, **kwargs):

        user = request.user
        id = request.params.id

        code, mess, data = user_get_material(user, id)

        return JsonResponse(code, mess, data)
Esempio n. 6
0
    def get_context(self, request, *args, **kwargs):

        user = request.user
        id = request.params.id

        code, mess, data = get_pact_price_by_id(user, id)

        return JsonResponse(code, mess, data)
Esempio n. 7
0
    def get_context(self, request, *args, **kwargs):

        id = request.params.id
        user = request.user

        code, mess, data = user_get_employee_by_id(user, id)

        return JsonResponse(code, mess, data)
Esempio n. 8
0
    def get_context(self, request, *args, **kwargs):

        user = request.user
        term = request.params.term

        code, mess, data = user_get_employee_by_term(user, term)

        return JsonResponse(code, mess, data)
Esempio n. 9
0
    def get_context(self, request, *args, **kwargs):

        id = request.params.id
        avatar = request.params.avatar
        password = request.params.password

        code, mess, data = change_user_info(request.user, id, avatar, password)

        return JsonResponse(code, mess, data)
Esempio n. 10
0
    def get_context(self, request, *args, **kwargs):

        user = request.user

        id = request.params.id

        code, mess, data = user_audit_quarter_salary(user, id)

        return JsonResponse(code, mess, data)
Esempio n. 11
0
    def get_context(self, request, *args, **kwargs):

        user = request.user
        name = request.params.name
        phone = request.params.phone
        pagesize = request.params.pagesize
        pagenum = request.params.pagenum
        sortdatafield = request.params.sortdatafield
        sortorder = request.params.sortorder

        code, mess, data = user_get_employees_pager(user, pagesize, pagenum,
                                                    name, phone, sortdatafield,
                                                    sortorder)

        return JsonResponse(code, mess, data)
Esempio n. 12
0
 def wrap(*args, **kwargs):
     request = args[0]
     key = 'view_never_submit_{}_{}.{}'.format(request.user.id,
                                               view.__module__,
                                               view.__name__)
     with cache.lock(key):
         if cache.get(key):
             logger.info("u={} f={}".format(request.user, view.__name__))
             response_context = JsonResponse(ApiCode.submitsecond.code,
                                             ApiCode.submitsecond.mess, {})
             return Response(response_context)
         cache.set(key, True, 15)
     ret = view(*args, **kwargs)
     cache.delete(key)
     return ret
Esempio n. 13
0
    def get_context(self, request, *args, **kwargs):

        user = request.user
        code = request.params.code
        name = request.params.name
        pagesize = request.params.pagesize
        pagenum = request.params.pagenum
        sort_field = request.params.sortdatafield
        sort_order = request.params.sortorder

        code, mess, data = user_get_partners_pager(user, pagesize, pagenum,
                                                   code, name, sort_field,
                                                   sort_order)

        return JsonResponse(code, mess, data)
Esempio n. 14
0
    def get_context(self, request, *args, **kwargs):

        user = request.user

        if isinstance(user, AnonymousUser):
            request.session.save()
            wid = request.params.wid
            hei = request.params.hei

            code, mess, data, vcode = generate_code_image(wid, hei)

            request.session['vcode'] = vcode
        else:
            code = ApiCode.userhadlogin.code
            mess = ApiCode.userhadlogin.mess
            data = dict()
        return JsonResponse(code, mess, data)
Esempio n. 15
0
    def get_context(self, request, *args, **kwargs):

        user = request.user

        code = request.params.code
        name = request.params.name
        help = request.params.help

        pagesize = request.params.pagesize
        pagenum = request.params.pagenum
        sortdatafield = request.params.sortdatafield
        sortorder = request.params.sortorder

        code, mess, data = user_get_materials_pager(user, pagesize, pagenum,
                                                    sortdatafield, sortorder,
                                                    code, name, help)
        return JsonResponse(code, mess, data)
Esempio n. 16
0
    def get_context(self, request, *args, **kwargs):

        user = request.user

        year = request.params.year
        quarter = request.params.quarter
        name = request.params.name

        pagesize = request.params.pagesize
        pagenum = request.params.pagenum
        sortdatafield = request.params.sortdatafield
        sortorder = request.params.sortorder

        code, mess, data = user_get_quarter_salary_pager(
            user, pagesize, pagenum, sortdatafield, sortorder,
            year, quarter, name
        )
        return JsonResponse(code, mess, data)
Esempio n. 17
0
    def get_context(self, request, *args, **kwargs):

        user = request.user

        id = request.params.id
        year = request.params.year
        employee = request.params.employee
        quarter = request.params.quarter
        remarks = request.params.remarks
        items = request.params.items

        if not id:
            code, mess, data = user_add_quarter_salary(
                user, year, employee, quarter, remarks, items
            )
        else:
            code, mess, data = user_update_quarter_salary(
                user, id, year, employee, quarter, remarks, items
            )
        return JsonResponse(code, mess, data)
Esempio n. 18
0
    def get_context(self, request, *args, **kwargs):

        user = request.user
        name = request.params.name
        phone = request.params.phone
        gender = request.params.gender
        email = request.params.email
        status = request.params.status
        address = request.params.address

        id = request.params.id

        if id:
            code, mess, data = user_update_employee(user, id, name, phone,
                                                    gender, email, status,
                                                    address)
        else:
            code, mess, data = user_add_employee(user, name, phone, gender,
                                                 email, status, address)

        return JsonResponse(code, mess, data)
Esempio n. 19
0
    def get_context(self, request, *args, **kwargs):

        user = request.user

        id = request.params.id
        pact_type = request.params.pact_type
        partner = request.params.partner
        partner_code = request.params.partner_code
        send_man = request.params.send_man
        send_man_phone = request.params.send_man_phone
        send_address = request.params.send_address
        remarks = request.params.remarks
        items = request.params.items

        if id:
            code, mess, data = cha_pact_price(user, id, pact_type, partner, partner_code,
        send_man, send_man_phone, send_address, remarks, items)
        else:
            code, mess, data = add_pact_price(user, pact_type, partner, partner_code,
        send_man, send_man_phone, send_address, remarks, items)

        return JsonResponse(code, mess, data)
Esempio n. 20
0
    def get_context(self, request, *args, **kwargs):

        vcode = request.params.vcode

        username = request.params.username
        password = request.params.password

        back_vcode = request.session['vcode'] if request.session.has_key(
            'vcode') else None

        if back_vcode and vcode.upper() == back_vcode:
            code, mess, data = user_login(request, username, password)
            del request.session['vcode']

        elif not back_vcode:
            data = dict()
            code = ApiCode.logincodeerr.code
            mess = ApiCode.logincodeerr.mess

        else:
            data = dict()
            code = ApiCode.unkonwnerror.code
            mess = ApiCode.unkonwnerror.mess
        return JsonResponse(code, mess, data)
Esempio n. 21
0
    def get_context(self, request, *args, **kwargs):

        code, mess, data = user_login_out(request)

        return JsonResponse(code, mess, data)
Esempio n. 22
0
    def get_context(self, request, *args, **kwargs):

        code, mess, data = get_user_menus(request.user)

        return JsonResponse(code, mess, data)