示例#1
0
def signUp(request):
    is_customer = Permission.objects.get(codename = 'is_customer')
    if (request.POST):
        f = CustomerForm(request.POST)
        if (f.is_valid()):
            f.instance.set_password(f.cleaned_data['password'])
            f.save()
            f.instance.user_permissions.add(is_customer)

            MarketBasket.createForCustomer(f.instance)
            # name = f.instance.Get['first_name']
            # ren
            context = {'first_name': f.cleaned_data['first_name'], 'last_name': f.cleaned_data['last_name']}

            render_and_email([f.cleaned_data['email']], u'ثبت کاربر جدید', u"عضو شدید", 'crm/signUp_email.html',
                             context)
            return success(request)
    else:
        f = CustomerForm()
    return render(request, 'crm/signUp.html', {'CustomerForm': f})
示例#2
0
def newUser(request):
    is_delivery = Permission.objects.get(codename = 'is_deliveryman')
    is_fnc = Permission.objects.get(codename = 'is_fnc')
    is_common = Permission.objects.get(codename = 'is_common')
    is_warehouseman = Permission.objects.get(codename = 'is_warehouseman')
    is_mng_warehouse = Permission.objects.get(codename = 'is_mng_warehouse')

    if (request.POST):
        f = userForm(request.POST)
        print("ghbale is")
        if (f.is_valid()):
            print("tu iffff")
            f.instance.set_password(f.cleaned_data['password'])
            f.instance.first_name = f.instance.first_name + " " + f.instance.last_name
            f.instance.last_name = f.cleaned_data['ssn']
            print f.instance.last_name
            f.save()

            if (f.cleaned_data['is_delivery']):
                f.instance.user_permissions.add(is_delivery)
            if (f.cleaned_data['is_wrh']):
                f.instance.user_permissions.add(is_warehouseman, is_mng_warehouse)
            if (f.cleaned_data['is_fnc']):
                f.instance.user_permissions.add(is_fnc, is_common)
            context = {'first_name': f.cleaned_data['first_name'], 'last_name': f.cleaned_data['last_name'],
                       'username': f.cleaned_data['username'], 'password': f.cleaned_data['password']}
            render_and_email([f.cleaned_data['email']], u'ثبت کاربر جدید', u"عضو شدید", 'mng/signUp_email.html',
                             context)
            return success(request)

    else:

        print"maaaaaaaaaan"
        f = userForm()

    return render(request, 'mng/mng-newUser.html', {'userForm': f})