Esempio n. 1
0
 def post(self, request, *args, **kwargs):
     username = request.POST.get('username', None)
     email = request.POST.get('email', None)
     password = request.POST.get('password', None)
     first_name = request.POST.get('first_name', None)
     last_name = request.POST.get('last_name', None)
     role_choosen = request.POST.get('group',None)
     if password is not None:
         user = User.objects.create_user(username,email,password)
     else:
         user = User.objects.create_user(username,email)
     user.first_name = first_name
     user.last_name = last_name
     user.save()
     account = Accounts()
     account.user = user
     avatar = request.FILES.get('avatar',None)
     if avatar is None:
         pass
     else:
         account.avatar = avatar
     account.role = Roles.objects.get(pk=role_choosen)
     account.save()
     messages.success(request,_("Customer Added"))
     return redirect('/admin/customers')
Esempio n. 2
0
    def post(self, request, *args, **kwargs):
        #add a node
        redirect_to = request.POST.get("redirect",None)
        username = request.POST.get('username',None)
        password = request.POST.get('password',None)
        email = request.POST.get('email')
        first_name = request.POST.get('first_name',None)
        last_name = request.POST.get('last_name',None)
        mobile = request.POST.get('mobile',None)
        telephone = request.POST.get('telephone',None)
        street = request.POST.get('street',None)
        zip = request.POST.get('zip',None)
        city = request.POST.get('city',None)
        province = request.POST.get('province',None)
        nation = request.POST.get('nation',None)
        domain = request.get_host()

        account = Accounts()
        if username is None:
            username = email

        if password is None:
            user = User.objects.create_user(username,email)
        else:
            user = User.objects.create_user(username,email,password)
        user.first_name = first_name
        user.last_name = last_name
        user.save()
        account.user = user
        account.street = street
        account.zip = zip
        account.city = city
        account.province = province
        account.nation = nation
        account.mobile = mobile
        account.telephone = telephone
        account.role = Roles.objects.get(role="authorized")
        account.save()
        messages.success(request,_("Thank's to subscribe"))
        if redirect_to is None:
            return redirect('/')
        else:
            redirect(redirect_to)