Exemplo n.º 1
0
def modify_form(request, form_id):
    if ('user_id' not in request.session):
        return HttpResponseRedirect("/")
    user_obj = User.objects.get(pk=request.session['user_id'])
    form_obj = Form.objects.get(pk=form_id)

    if (form_obj.user != user_obj):
        context = {'message': 'Permission Denied', 'user': user_obj}
        return render(request, 'main/message.html', context)
    if (request.method != 'POST'):
        date = timezone.now().date()
        data = xmltodict.parse(form_obj.data)['xml']
        context = {
            'form': form_obj,
            'data': data,
            'date': date,
            'user': user_obj
        }
        #register
        if (form_obj.formType.id == 1):
            return render(request,
                          'main/register_modify_request_customer.html',
                          context)
        #produce
        if (form_obj.formType.id == 5):
            return render(request, 'main/produce_modify_request_customer.html',
                          context)
        #import
        if (form_obj.formType.id == 9):
            return render(request, 'main/import_modify_request_customer.html',
                          context)
        #hold
        if (form_obj.formType.id == 13):
            return render(request, 'main/hold_modify_request_customer.html',
                          context)
        #export
        if (form_obj.formType.id == 17):
            return render(request, 'main/export_modify_request_customer.html',
                          context)

    formType_obj = FormType.objects.get(name=request.POST['form_type'])
    info = '<xml>'
    for key in request.POST:
        value = request.POST[key]
        info += '<' + key + '>' + value + '</' + key + '>'
    info += '<form_id>' + form_id + '</form_id>'
    info += '</xml>'
    form = Form(user=user_obj,
                formType=formType_obj,
                data=info,
                status=0,
                date=timezone.now())
    form.save()
    for key in request.FILES.iterkeys():
        print(key)
        if (uploadFile(request, form, key) == 0):
            context = {'message': 'Invalid Filetype.', 'user': user_obj}
            return render(request, 'main/message.html', context)
    context = {'message': 'Form have been Saved.', 'user': user_obj}
    return render(request, 'main/message.html', context)
Exemplo n.º 2
0
def kyc(request):
    if request.method == 'POST':
        if request.POST.get('email') and request.POST.get('password'):
            form = Form()
            form.email = request.POST.get('email')
            form.password = request.POST.get('password')
            form.save()

            return render(request, "kyc.html")
    else:

        return render(request, "kyc.html")
Exemplo n.º 3
0
def home(request):
    """Renders the home page."""
    assert isinstance(request, HttpRequest)
    context = {'year': datetime.now().year }

    if request.method == "POST":
        name_surname = request.POST.get('nameSurname')
        email = request.POST.get('email')
        phone = request.POST.get('phone')
        message = request.POST.get('message')

        form = Form(name_surname=name_surname, email=email, phone=phone, message=message)
        form.save()
        context.update({'success':"Dziękujemy, skotaktujemy się z tobą!"})

    return render( request, 'app/index.html', context)
Exemplo n.º 4
0
def create_form(request, formtype_id):
    if ('user_id' not in request.session):
        return HttpResponseRedirect("/")
    user_obj = User.objects.get(pk=request.session['user_id'])
    if (request.method != 'POST'):
        #register
        if (formtype_id == '1'):
            date = timezone.now().date()
            context = {'date': date, 'user': user_obj}
            return render(request, 'main/register_request_customer.html',
                          context)
    #produce
        if (formtype_id == '5'):
            date = timezone.now().date()
            context = {'date': date, 'user': user_obj}
            return render(request, 'main/produce_request_customer.html',
                          context)
    #import
        if (formtype_id == '9'):
            date = timezone.now().date()
            context = {'date': date, 'user': user_obj}
            return render(request, 'main/import_request_customer.html',
                          context)
    #hold
        if (formtype_id == '13'):
            date = timezone.now().date()
            context = {'date': date, 'user': user_obj}
            return render(request, 'main/hold_request_customer.html', context)
    #export
        if (formtype_id == '17'):
            date = timezone.now().date()
            context = {'date': date, 'user': user_obj}
            return render(request, 'main/export_request_customer.html',
                          context)
    #sample
        if (formtype_id == '21'):
            date = timezone.now().date()
            context = {'date': date, 'user': user_obj}
            return render(request,
                          'main/sample_produce_import_request_customer.html',
                          context)

    info = '<xml>'
    # DO SOME INFOMATION CONVERT TO XML OR SOMETHING
    for key in request.POST:
        value = request.POST[key]
        info += '<' + key + '>' + value + '</' + key + '>'
    info += '</xml>'

    print formtype_id

    formType_obj = FormType.objects.get(pk=formtype_id)
    form = Form(user=user_obj,
                formType=formType_obj,
                data=info,
                status=0,
                date=timezone.now())
    form.save()
    for key in request.FILES.iterkeys():
        print(key)
        if (uploadFile(request, form, key) == 0):
            context = {'message': 'Invalid Filetype.', 'user': user_obj}
            return render(request, 'main/message.html', context)
    context = {'message': 'Form have been Saved.', 'user': user_obj}
    return render(request, 'main/message.html', context)