当前位置: 首页>>代码示例>>Python>>正文


Python User.create_user方法代码示例

本文整理汇总了Python中mongoengine.django.auth.User.create_user方法的典型用法代码示例。如果您正苦于以下问题:Python User.create_user方法的具体用法?Python User.create_user怎么用?Python User.create_user使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在mongoengine.django.auth.User的用法示例。


在下文中一共展示了User.create_user方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: register

# 需要导入模块: from mongoengine.django.auth import User [as 别名]
# 或者: from mongoengine.django.auth.User import create_user [as 别名]
def register(request):
    # errors = []
    # if(request.POST.get('password','1') != request.POST.get('confirm_password','1')):
    #     errors.append('wrong_password')
    # if(request.POST.get('username', "field is empty") == "" or request.POST.get('email', "field is empty") == "" or request.POST.get('password',"field is empty") == ""):
    #     errors.append('empty_field')
    # if(len(errors) != 0):
    #     return render_to_response('profile/register.html', {'errors': errors}, RequestContext(request))
    # else:


    if request.user.is_authenticated():
         my_user = MyUser.objects.get(user=User.objects.get(id=request.user.id))
         return render_to_response('profile/profile.html', {'my_user': my_user}, RequestContext(request))
    users_from_database = User.objects.all()
    if request.POST:
        User.create_user(username=request.POST['username'], email=request.POST['email'], password=request.POST['password'])
        user = authenticate(username=request.POST['username'], password=request.POST['password'])
        my_user = MyUser(point=0.0,comment_count=0,disease_added_count=0,article_added_count=0,discussion_added_count=0,forum_present_count=0)
        my_user.user = user
        my_user.save()
        login(request, user)

        return render_to_response('profile/account.html',{'users': users_from_database}, RequestContext(request))
    else:
        return render_to_response('profile/register.html',{'users': users_from_database}, RequestContext(request))
开发者ID:Karolucha,项目名称:choroba,代码行数:28,代码来源:user_views.py

示例2: register

# 需要导入模块: from mongoengine.django.auth import User [as 别名]
# 或者: from mongoengine.django.auth.User import create_user [as 别名]
def register(req):
    if req.method == 'GET':
        return render(req, 'user/register.html')
    elif req.method == 'POST':
        form = req.POST
        User.create_user(username=form['username'], password=form['password'])
        return redirect('index')
开发者ID:jungledrum,项目名称:valentine,代码行数:9,代码来源:user.py

示例3: create_user

# 需要导入模块: from mongoengine.django.auth import User [as 别名]
# 或者: from mongoengine.django.auth.User import create_user [as 别名]
def create_user(user_name, password, email):
    user = User()
    try:
        # print user_name, password, email
        user.create_user(user_name, password, email)
        print "User Created!"
        new_user = User.objects.get(username=user_name)
        print "User Access Key", new_user.id
    except Exception,e:
        print "Error", e
开发者ID:Wilt,项目名称:rssi-system,代码行数:12,代码来源:create_user.py

示例4: register_page

# 需要导入模块: from mongoengine.django.auth import User [as 别名]
# 或者: from mongoengine.django.auth.User import create_user [as 别名]
def register_page(request):
    if request.method=='POST':
        form = RegistrationForm(request.POST)
        if form.is_valid():
            User.create_user(username=form.cleaned_data['username'],password=form.cleaned_data['password1'],email=form.cleaned_data['email'])
            return HttpResponseRedirect("/register/success")
    else:
        form = RegistrationForm()
    variables = RequestContext(request, {'form': form})
    return render_to_response('registration/register.html',variables)
开发者ID:datawinners,项目名称:HniSpike,代码行数:12,代码来源:views.py

示例5: register

# 需要导入模块: from mongoengine.django.auth import User [as 别名]
# 或者: from mongoengine.django.auth.User import create_user [as 别名]
def register(request):
    if request.method == 'POST':
        form = RegistrationForm(request.POST)
        if form.is_valid():
            User.create_user(form.cleaned_data['username'],form.cleaned_data['password1'])  
	    messages.success(request, form.cleaned_data['username'] + ' you have been successfully registered')
            return HttpResponseRedirect("/")	
    else:
        form = RegistrationForm()
    return render(request, "eventslist/register.html", {
        'form': form,
    })  
开发者ID:eltxabi,项目名称:proyecto,代码行数:14,代码来源:views.py

示例6: setup

# 需要导入模块: from mongoengine.django.auth import User [as 别名]
# 或者: from mongoengine.django.auth.User import create_user [as 别名]
def setup(request, template='socialregistration/setup.html',
    form_class=UserForm, extra_context=dict()):
    """
    Setup view to create a username & set email address after authentication
    """
    try:
        social_user = request.session['socialregistration_user']
        social_profile = request.session['socialregistration_profile']
    except KeyError:
        return render_to_response(
            template, dict(error=True), context_instance=RequestContext(request))

    if not GENERATE_USERNAME:
        # User can pick own username
        if not request.method == "POST":
            form = form_class(social_user, social_profile)
        else:
            form = form_class(social_user, social_profile, request.POST)
            
            if form.is_valid():
                form.save(request=request)
                user = form.profile.authenticate()
                login(request, user)

                del request.session['socialregistration_user']
                del request.session['socialregistration_profile']

                return HttpResponseRedirect(_get_next(request))

        extra_context.update(dict(form=form))

        return render_to_response(template, extra_context,
            context_instance=RequestContext(request))
        
    else:
        # Generate user and profile
        #social_user.username = str(uuid.uuid4())[:30]
        #social_user.save()

        #social_profile.user = social_user
        #social_profile.save()

        # Authenticate and login
        #user = social_profile.authenticate()
        User.create_user(user_data['username'], user_data['password'], user_data['email'])
        login(request, user)

        # Clear & Redirect
        del request.session['socialregistration_user']
        del request.session['socialregistration_profile']
        return HttpResponseRedirect(_get_next(request))
开发者ID:taras1k,项目名称:Let-eat-bee,代码行数:53,代码来源:views.py

示例7: __init__

# 需要导入模块: from mongoengine.django.auth import User [as 别名]
# 或者: from mongoengine.django.auth.User import create_user [as 别名]
 def __init__(self, bootstrap=False):
     self.db = settings._MONGODB
     if bootstrap:
         # load bootstrap data
         self.db.user.remove()
         User.create_user(username='[email protected]', email='[email protected]', password='[email protected]')
         self.db.menus.remove()
         self.db.menus.insert(menus)
         self.db.items.remove()
         self.db.items.insert(items)
         self.db.clients.remove()
         self.db.clients.insert(clients)
         self.db.orders.remove()
         self.db.django_session.remove()
开发者ID:diegoromero,项目名称:geekbar,代码行数:16,代码来源:mongo.py

示例8: create

# 需要导入模块: from mongoengine.django.auth import User [as 别名]
# 或者: from mongoengine.django.auth.User import create_user [as 别名]
def create(request):
  user = User.create_user('dispenser', 'password', '[email protected]')
  #user.groups = ['patient']
  user.save()
  ion_user = IonUser(user=user, group='dispenser', birthdate=datetime.datetime.now())
  ion_user.save()
  return HttpResponse("Account create successful")
开发者ID:ludi1001,项目名称:IonMedicationSystem,代码行数:9,代码来源:views.py

示例9: get_or_create

# 需要导入模块: from mongoengine.django.auth import User [as 别名]
# 或者: from mongoengine.django.auth.User import create_user [as 别名]
    def get_or_create(cls, loginza_response):

        identity_qs = cls.objects.filter(identity=loginza_response['identity'])

        if identity_qs.count():
            identity = identity_qs.get()
        else:
            user_qs = User.objects.filter(
                username=loginza_response['identity'])

            if user_qs.count():
                user = user_qs.get()
            else:
                user = User.create_user(
                    username=loginza_response['identity'],
                    password=UNUSABLE_PASSWORD,
                    email=loginza_response.get('email'))

            identity = Identity(identity=loginza_response['identity'],
                user=user)

        del loginza_response['identity']
        identity.info = loginza_response

        identity.save()

        return identity
开发者ID:MechanisM,项目名称:django-loginza-me,代码行数:29,代码来源:documents.py

示例10: create

# 需要导入模块: from mongoengine.django.auth import User [as 别名]
# 或者: from mongoengine.django.auth.User import create_user [as 别名]
def create(request):
    form = NewAccountForm(request.POST or None)
    if form.is_valid():
        # also attach the contact information to the anonymous request.user
        new_user.first_name = request.POST['first_name']
        new_user.last_name = request.POST['last_name']
        username = request.POST['username']
        email = request.POST['email']
        password = request.POST['password2']
        new_user = User.create_user(username=username, email=email,
                                    password=password)
        new_user.save()

        # create the account instance
        new_account = Account()
        new_account.company = request.POST['company_name']
        new_account.admin = new_user
        new_account.save()
        messages.success(request, new_account)

        # now authenticate and login user
        auth_user = authenticate(username=username, password=password)
        login(request=request, user=auth_user)
        messages.success(request, 'Successfully logged in as %s' % \
                                                           auth_user.username)
        return HttpResponseRedirect('/welcome/')

    data = {'title': 'Kolabria - Create a new Account ', 'form': form, }
    return render_to_response('account/create.html', data,
                              context_instance=RequestContext(request))
开发者ID:kolabria,项目名称:Kolabria-lite,代码行数:32,代码来源:views.py

示例11: patientinfo

# 需要导入模块: from mongoengine.django.auth import User [as 别名]
# 或者: from mongoengine.django.auth.User import create_user [as 别名]
def patientinfo(request):
   message = ""
   if request.method == 'POST':
      if request.POST['requestType'] == 'newPatient':
         firstName = request.POST['firstName']
         lastName = request.POST['lastName']
         birthDate = request.POST['birthDate']
         
         if(helper.validate(birthDate)):
            username = firstName + lastName         
            userNum = len(User.objects(__raw__={'username':{'$regex': '^' + username, '$options' : 'i'}}))

            user = User.create_user(username + str(userNum), 'password')
            user.first_name = firstName
            user.last_name = lastName
            user.save()
            ion_user = IonUser(user=user, group='patient', birthdate=birthDate)
            ion_user.save()
       
            newPatient = patient(firstName=firstName, lastName=lastName, activeMeds = [], user=ion_user)
            newPatient.save()
         else:
            message = "Invalid birth date format. (should be mm-dd-yyyy)"

      if request.POST['requestType'] == 'deletePatient':
         id = request.POST['id']
         patient.objects(id=id)[0].delete()
         # don't know if we actually want to give people the ability to delete medical records...
   return render_to_response('patientinfo.html', {'Patients': patient.objects, 'message': message},
                              context_instance=RequestContext(request))
开发者ID:ludi1001,项目名称:IonMedicationSystem,代码行数:32,代码来源:views.py

示例12: user_register

# 需要导入模块: from mongoengine.django.auth import User [as 别名]
# 或者: from mongoengine.django.auth.User import create_user [as 别名]
def user_register(request):
    if request.method == 'POST':
        uemail = request.POST.get('email', None)
        upassword = request.POST.get('password', None)
        if (not uemail) or (not upassword):
            return {
                'error': 'All fields are required',
                'email': uemail
            }
        try:
            user = User.create_user(uemail, upassword, request.POST['email'])
            user.backend = 'mongoengine.django.auth.MongoEngineBackend'
            login(request, user)
            request.session.set_expiry(60 * 60 * 10) # 10 hour timeout
            return redirect('project_list')
        except NotUniqueError:
            return {
                'error': 'User with this email already exist',
                'email': uemail
            }
        except ValidationError:
            return {
                'error': 'Incorrect email',
                'email': uemail
            }
    else:
        return {}
开发者ID:dizballanze,项目名称:debugmail,代码行数:29,代码来源:views.py

示例13: create_user

# 需要导入模块: from mongoengine.django.auth import User [as 别名]
# 或者: from mongoengine.django.auth.User import create_user [as 别名]
def create_user(request):
    if request.method == 'POST':
        user = User.create_user(request.POST['username'], request.POST['password'], request.POST['email'])
        if user.is_active == True:
            print('True')
            return redirect('/techtopics/list')
    elif request.method == 'GET':
        return TemplateResponse(request, 'techtopics/user_create.html')
开发者ID:sanloft,项目名称:techtopics,代码行数:10,代码来源:views.py

示例14: register

# 需要导入模块: from mongoengine.django.auth import User [as 别名]
# 或者: from mongoengine.django.auth.User import create_user [as 别名]
def register(request):
    error = False
    if request.method == 'POST':
        username = request.POST.get('username')
        password = request.POST.get('password')
        email = request.POST.get('email')
        user = User.objects(username=username)
        if not username or not password or not email or not len(user)==0 :
            error = True
            return render_to_response("registration/register.html",{'error':error},context_instance=RequestContext(request))
        else:
            User.create_user(username=username, password=password,email=email)
            newuser = auth.authenticate(username=username, password=password)
            auth.login(request, newuser)
            return HttpResponseRedirect("/")
    else:
        return render_to_response("registration/register.html",{'error':error},context_instance=RequestContext(request))
开发者ID:lhyfree,项目名称:django-bbs,代码行数:19,代码来源:views.py

示例15: register

# 需要导入模块: from mongoengine.django.auth import User [as 别名]
# 或者: from mongoengine.django.auth.User import create_user [as 别名]
def register(request):
    if request.method == 'POST':
        username = request.POST['username']
        password = request.POST['password']
        User_save = User.create_user(username=username,email=None,password=password)
        User_save.save()
        return HttpResponseRedirect('/theweber.in/')
    else:
        return render(request,'register.html')
开发者ID:,项目名称:,代码行数:11,代码来源:


注:本文中的mongoengine.django.auth.User.create_user方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。