def main():
    global users
    global User
    global UserAccount
    global Languages
    for user in users:
        if User.objects.filter(username="******" % user[0]).count():
            #print "User \"" + user[0] + "\" exists in database. Skipping."
            pass
        else:
            new_user = User.objects.create_user(username="******" % user[0],
                                         email="%s" % user[4],
                                         password="******" % user[1],
                                         first_name="%s" % user[2],
                                         last_name="%s" % user[3])
            lang = Languages.objects.get(abbr="%s" % user[6])
            extra_info = UserAccount(user_id=new_user.pk,
                                     is_contentmgr=user[5],
                                     native_lang=lang)
            extra_info.save()
Example #2
0
def UserRegistration(request):
    if request.user.is_authenticated():
        return HttpResponseRedirect('/photos/')
    elif request.method == 'POST':
        form = RegistrationForm(request.POST)
        if form.is_valid():
            user = User.objects.create_user(username=form.cleaned_data['username'],
                                            email=form.cleaned_data['email'],
                                            password=form.cleaned_data['password'])
            user.save()
            user_account = UserAccount(user=user,
                                       username=form.cleaned_data['username'],
                                       email=form.cleaned_data['email'],
                                       password=form.cleaned_data['password'])
            user_account.save()
            return HttpResponseRedirect('/photos/' , {'form' : form})
        else:
            return render(request , 'register.html' , {'form': form})
    else:
        '''user is'nt submitting the form, show them a blank registration form'''
        form = RegistrationForm()
        return render(request,'register.html', {'form' : form})
Example #3
0
def registration(request):

    if request.method == 'POST':
        form = RegistrationForm(request.POST)

        if form.is_valid():
            user = UserAccount(email = form.cleaned_data['email'],
                           type = 1,
                           status=1,
                           username = form.cleaned_data['username'],
                           password = form.cleaned_data['password'],
                           on_announce_list = form.cleaned_data['on_announce_list'])
            user.save()
            login_user(request, user)
            copy_folder(get_object_or_404(Folder, user=settings.DEFAULT_USER_ID, default_folder=True), user)
    else:
        form = RegistrationForm()

    if request.is_logged_in:
        return render_to_response('register-confirm.html', context_instance=RequestContext(request))

    return render_to_response('register.html', { 'form': form }, context_instance=RequestContext(request))
Example #4
0
def user_reg(request):
    """
    The register views checks if the user has submitted information and displays
    the corresponding page after processing the information.
    """
    form = AccountCreateForm(request.POST)

    if request.method == 'POST':
        #if form.is_valid():
            new_user = User.objects.create_user(
                username=request.POST.get('username'),
                email=request.POST.get('email'),
                password=request.POST.get('password1'),
                first_name=request.POST.get('first_name'),
                last_name=request.POST.get('last_name'))
            lang = Languages.objects.get(name=request.POST.get('native_lang'))
            extra_info = UserAccount(user_id=new_user.pk, native_lang=lang)
            extra_info.save()
            return HttpResponseRedirect('/')
    else:
        form = AccountCreateForm()

    return render(request, 'users/register.html', {'form': form})
Example #5
0
 def setUp(self):
     create_test_product(create_test_account().id)
     ta_2 = UserAccount(username="******",
                        password="******",
                        email="*****@*****.**",
                        first_name="penguin",
                        last_name="rider",
                        bio="Hi im a penguinrider",
                        profile_picture=DEFAULT_IMAGE_UUID)
     ta_2.set_password('password123')
     ta_2.save()
Example #6
0
def create_test_account():
    ta = UserAccount(username="******",
                     password="******",
                     email="*****@*****.**",
                     first_name="penguin",
                     last_name="rider",
                     bio="Hi im a penguinrider",
                     profile_picture=DEFAULT_IMAGE_UUID)
    ta.set_password('password123')
    ta.save()
    return ta
Example #7
0
def registration_view(request):
    redirect_to = "/"
    if request.method == 'POST':
        form = RegistrationForm(request.POST)
        email = request.POST.get("email")
        username = request.POST.get("username")
        password = request.POST.get("password")
        first_name = request.POST.get("first_name")
        last_name = request.POST.get("last_name")
        email = request.POST.get("email")
        if password == request.POST.get("repeat_password") and form.is_valid():
            acc = UserAccount()
            user = User.objects.create_user(username=username,
                                            password=password,
                                            first_name=first_name,
                                            last_name=last_name,
                                            email=email)
            acc.user = user
            acc.phone_number = request.POST.get("phone_number")
            acc.save()
            return HttpResponseRedirect(redirect_to)
    form = RegistrationForm()
    context = {'form': form}
    return render(request, "registration.html", context)
Example #8
0
def _create_anonymous_user(request):
    user = UserAccount(type=1, status=1)
    user.save()
    login_user(request,user)
    return utils.copy_folder(get_object_or_404(folder_models.Folder, user=settings.DEFAULT_USER_ID, default_folder=True), user)