Exemple #1
0
def create(request):
    form = CreateForm()
    if request.method == 'POST':
        form = CreateForm(request.POST)
        if form.is_valid():
            u = User()
            u.username = form.cleaned_data.get('username')
            u.first_name = form.cleaned_data.get('first_name')
            u.last_name = form.cleaned_data.get('last_name')
            u.address1 = form.cleaned_data.get('address1')
            u.address2 = form.cleaned_data.get('address2')
            u.birth = form.cleaned_data.get('birth')
            u.set_password(form.cleaned_data.get('password'))
            u.save()

            u.groups.clear()
            u.user_permissions.clear()
            # print('Group name:', form.cleaned_data['groups'])
            for group in form.cleaned_data['groups']:
                print(group)  # For debugging
                u.groups.add(group)
            for permission in form.cleaned_data['permissions']:
                print(permission)  # For debugging
                u.user_permissions.add(permission)
            u.save()
            return HttpResponseRedirect('/manager/users/')

    template_vars = {
        'form':form,
}
    return dmp_render_to_response(request, 'users.create.html', template_vars)
Exemple #2
0
def process_request(request):
  
  #process the form
  form = SignupForm()
  if request.method == 'POST':  # just submitted the form
    form = SignupForm(request.POST)
    if form.is_valid():
      u = User()
      u.username = form.cleaned_data.get('username')
      u.first_name = form.cleaned_data.get('first_name')
      u.last_name = form.cleaned_data.get('last_name')
      u.address1 = form.cleaned_data.get('address1')
      u.address2 = form.cleaned_data.get('address2')
      u.set_password(form.cleaned_data.get('password'))
      u.save()
      # authenticate(username=form.cleaned_data.get('username'),password=form.cleaned_data.get('password'))
      # login(request, form.user)    
      # create a user object
      # fill the user object with the data from the form
      return HttpResponseRedirect('/homepage/index/')
      
  template_vars = {
    'form': form,
  }
  return dmp_render_to_response(request, 'signup.html', template_vars)
Exemple #3
0
def process_request(request):
    print('>>>>>>>>>>>>>>>>>>>>> THIS IS SIGNUP.PY')

    clientemail = request.POST.get('first_name')
    clientmessage = request.POST.get('last_name')
    print('>>>>>>>>>> fname was', clientemail)
    print('>>>>>>>>>> lname was', clientmessage)

    # process the form (ie validation)
    form = SignupForm()
    if request.method == 'POST': # just submitted the form
        form = SignupForm(request.POST)
        if form.is_valid():
            print('>>>>>>>>>>>>>>>>>> THE FORM IS VALID?')
            u = User()
            u.username = form.cleaned_data.get('username')
            u.first_name = form.cleaned_data.get('first_name')
            u.last_name = form.cleaned_data.get('last_name')
            u.email = form.cleaned_data.get('email')
            u.set_password(form.cleaned_data.get('password'))
            u.address1 = form.cleaned_data.get('address')
            u.address2 = form.cleaned_data.get('address2')
            u.save()
            return HttpResponseRedirect('/homepage/index/')

    template_vars = {
        'form': form,
    }
    return dmp_render_to_response(request, 'signup.html', template_vars)
Exemple #4
0
def new(request):
    form = CreateUserForm()

    if request.method == "POST":
        form = CreateUserForm(request.POST)
        if form.is_valid():
            user = User()

            user.username = form.cleaned_data.get('username')
            user.set_password(form.cleaned_data.get('password'))
            user.first_name = form.cleaned_data.get('first_name')
            user.last_name = form.cleaned_data.get('last_name')
            user.address1 = form.cleaned_data.get('address1')
            user.address2 = form.cleaned_data.get('address2')
            user.birth = form.cleaned_data.get('birth')
            user.phone_number = form.cleaned_data.get('phone_number')

            user.save()

            return HttpResponseRedirect('/manager/users')

    template_vars = {
        'form': form,
    }
    return dmp_render_to_response(request, 'users.new.html', template_vars)
Exemple #5
0
def process_request(request):
    print('>>>>>>>>>>>>>>>>>>>>> THIS IS SIGNUP.PY')

    clientemail = request.POST.get('first_name')
    clientmessage = request.POST.get('last_name')
    print('>>>>>>>>>> fname was', clientemail)
    print('>>>>>>>>>> lname was', clientmessage)

    # process the form (ie validation)
    form = SignupForm()
    if request.method == 'POST':  # just submitted the form
        form = SignupForm(request.POST)
        if form.is_valid():
            print('>>>>>>>>>>>>>>>>>> THE FORM IS VALID?')
            u = User()
            u.username = form.cleaned_data.get('username')
            u.first_name = form.cleaned_data.get('first_name')
            u.last_name = form.cleaned_data.get('last_name')
            u.email = form.cleaned_data.get('email')
            u.set_password(form.cleaned_data.get('password'))
            u.address1 = form.cleaned_data.get('address')
            u.address2 = form.cleaned_data.get('address2')
            u.save()
            return HttpResponseRedirect('/homepage/index/')

    template_vars = {
        'form': form,
    }
    return dmp_render_to_response(request, 'signup.html', template_vars)
Exemple #6
0
def process_request(request):
    # if already logged in.
    if request.user.is_authenticated():
        return HttpResponseRedirect('/account/manage/')

    # Process the form
    form = SignupForm()
    if request.method == 'POST': # Just submitted the form
        form = SignupForm(request.POST)
        if form.is_valid():
            # create a user object
            u = User()
            # fill the user object with the data from the form
            u.username = form.cleaned_data.get('username')
            u.first_name = form.cleaned_data.get('first_name')
            u.last_name = form.cleaned_data.get('last_name')
            u.address1 = form.cleaned_data.get('address1')
            u.address2 = form.cleaned_data.get('address2')
            u.set_password(form.cleaned_data.get('password'))
            u.birth = form.cleaned_data.get('birth')
            u.phone_number = form.cleaned_data.get('phone_number')
            u.save()
            u2 = authenticate(username=form.cleaned_data.get('username'), password=form.cleaned_data.get('password'))
            login(request, u2)
            return HttpResponseRedirect('/homepage/index/')

    template_vars = {
        'SignupForm': form
    }

    return dmp_render_to_response(request, 'signup.html', template_vars)
Exemple #7
0
def process_request(request):
  
  #process the form
  form = CreateUserForm()
  if request.method == 'POST':  # just submitted the form
    form = CreateUserForm(request.POST)
    if form.is_valid():
      u = User()
      u.username = form.cleaned_data.get('username')
      u.first_name = form.cleaned_data.get('first_name')
      u.last_name = form.cleaned_data.get('last_name')
      u.address1 = form.cleaned_data.get('address1')
      u.address2 = form.cleaned_data.get('address2')
      u.set_password(form.cleaned_data.get('password'))
      u.email = form.cleaned_data.get('email')
      u.birth = form.cleaned_data.get('birthdate')
      u.phone_number = form.cleaned_data.get('phone_number')
      
      perms = form.cleaned_data.get('user_permissions')
      groups = form.cleaned_data.get('groups')
      u.save()
      
      u.user_permissions.clear()
      for x in perms:
        u.user_permissions.add(x)
        print(x)
        
      u.groups.clear()
      for x in groups:
        u.groups.add(x)
        print(x)
      u.save()
      
     
      
      #u2 = UserUserGroups()
      
      #u2.user_id = u.id
      #u2.permission_id = form.cleaned_data.get('user_permissions')
      #u2.group = form.cleaned_data.get('groups')
      
      #u.save()
      #u2.save()
      # authenticate(username=form.cleaned_data.get('username'),password=form.cleaned_data.get('password'))
      # login(request, form.user)    
      # create a user object
      # fill the user object with the data from the form
      return HttpResponseRedirect('/manager/users/')
      
  template_vars = {
    'form': form,
  }
  return dmp_render_to_response(request, 'userscreate.html', template_vars)
Exemple #8
0
def process_request(request):
    form = SignupForm()
    if request.method == 'POST':
        form = SignupForm(request.POST)
        if form.is_valid():
            u = User()
            u.username = form.cleaned_data.get('username')
            u.first_name = form.cleaned_data.get('first_name')
            u.last_name = form.cleaned_data.get('last_name')
            u.address1 = form.cleaned_data.get('address1')
            u.address2 = form.cleaned_data.get('address2')
            u.set_password(form.cleaned_data.get('password'))
            u.save()
            return HttpResponseRedirect('/homepage/index/')

    #Show HTML
    template_vars = {
        'form':form,
}
    return dmp_render_to_response(request, 'signup.html', template_vars)
Exemple #9
0
def process_request(request):
    form = SignupForm()
    if request.method == 'POST':
        form=SignupForm(request.POST)
        if form.is_valid():
            u = User()
            u.username = form.cleaned_data.get('username')
            u.first_name = form.cleaned_data.get('firstName')
            u.last_name = form.cleaned_data.get('lastName')
            u.email = form.cleaned_data.get('email')
            u.address1 = form.cleaned_data.get('address1')
            u.address2 = form.cleaned_data.get('address2')
            u.set_password(form.cleaned_data.get('password'))
            u.save()
            user = authenticate(username=form.cleaned_data.get('username'), password=form.cleaned_data.get('password'))
            login(request, user)
            return HttpResponseRedirect('/homepage/index/')
    
    template_vars = {
        'form': form,
    }
    return dmp_render_to_response(request, 'signup.html', template_vars)
Exemple #10
0
# This list is for choosing random users for other model associations
users = []

# Delete existing user objects
User.objects.all().delete()

# Create my superuser
u = User()
u.username = '******'
u.email = '*****@*****.**'
u.set_password('qwer1234')
u.first_name = 'Andy'
u.last_name = 'Mockler'
u.address1 = '850 N University Ave'
u.address2 = '303'
u.birth = datetime.datetime.now()
u.phone_number = '(801) 388-8448'
u.is_staff = True
u.is_superuser = True
u.save()
for group in Group.objects.all():
    u.groups.add(group)

# Create generic users
for i in range(1, 10):
    u = User()
    u.username = '******' % i
    u.email = '*****@*****.**' % i
    u.first_name = 'First%i' % i
    u.last_name = 'Last%i' % i