示例#1
0
def sregister(request):
    if request.method == 'POST':
        if request.POST['username'] != "" and request.POST['first_name'] != "" and request.POST['last_name'] != "" and request.POST['email'] != "" and request.POST['password'] != "":
            if request.POST['password'] == request.POST['confirmed_password']:
                try:
                    user = SUser.objects.all().get(login=request.POST['username'])
                    return render_to_response('registration/registration_form.html',{'error':"User with such username already exists"},context_instance=RequestContext(request))
                except SUser.DoesNotExist:
                    cur_user = SUser()
                    cur_user.login = request.POST['username']
                    cur_user.first_name = request.POST['first_name']
                    cur_user.last_name = request.POST['last_name']
                    date = request.POST['birthday']
                    
                    cur_user.birthday = request.POST['birthday']
                    cur_user.country = request.POST['country']
                    cur_user.city = request.POST['city']
                    cur_user.street = request.POST['street']
                    cur_user.email = request.POST['email']
                    cur_user.password = request.POST['password']
                    cur_user.get_spam = request.POST['get_spam']
                    cur_user.is_staff = 0
                    if request.POST.__contains__('get_spam'):
                        cur_user.getSpam = 1
                    else:
                        cur_user.getSpam = 0
                    cur_user.save()                      
                    return render_to_response('registration/registration_complete.html', context_instance=RequestContext(request))
            else:
                return render_to_response('registration/registration_form.html',{'error':"Wrong confirmed password"},context_instance=RequestContext(request))
        else:
            return render_to_response('registration/registration_form.html',{'error':"Please, fill all the necessary fields"},context_instance=RequestContext(request))
    else:
        return render_to_response('registration/registration_form.html',{'error':""},context_instance=RequestContext(request))
示例#2
0
def create_admin():
     try:
        admin = SUser.objects.all().get(login='******')
     except SUser.DoesNotExist: 
        admin = SUser()
        admin.login = '******'
        admin.first_name = 'admin'
        admin.last_name = 'admin'    
        admin.birthday = '2012-12-21'            
        admin.country = 'Adminland'
        admin.city = 'Admin-city'
        admin.street = 'Admin str, 10'
        admin.email = '*****@*****.**'
        admin.password = '******'
        admin.getSpam = 0
        admin.is_staff = 1
        admin.save()
示例#3
0
def create_courier():
    try:
        courier = SUser.objects.all().get(login='******')
    except SUser.DoesNotExist: 
        courier = SUser()
        courier.login = '******'
        courier.first_name = 'courier'
        courier.last_name = 'courier'  
        courier.birthday = '2012-12-21'              
        courier.country = 'Courierland'
        courier.city = 'Courier-city'
        courier.street = 'Courier str, 10'
        courier.email = '*****@*****.**'
        courier.password = '******'
        courier.getSpam = 0
        courier.is_staff = 1
        courier.save()