def Sign_up(request): # POST객체로 받아온것들 변수에 저장 uesr_id = request.POST['user_id'] pw = request.POST['password'] name = request.POST['name'] current_residence = request.POST['current_residence'] preferred_residence = request.POST['preferred_residence'] check_id = '' try: check = Member.objects.get(user_id=uesr_id) check_id = check.user_id except ObjectDoesNotExist: check_id = '' # 아이디가 같을경우 안됨 yes_or_no = '' print('받아온 id : ' + uesr_id) print('확인할 id : ' + check_id) if uesr_id == check_id: yes_or_no = '아이디가 중복되었습니다. 수정이 필요합니다.' print('아이디 중복') # 성공했을 경우 메세지 출력 (디비에 데이터 넣음) else: data = Member(user_id=uesr_id, pw=pw, name=name, current_residence=current_residence, preferred_residence=preferred_residence) data.save() print('디비 들어감') yes_or_no = '회원가입 완료!' print(yes_or_no) return render(request, 'member/check.html', {'data': yes_or_no})
def post(self, request): name = request.POST.get('name') group = request.POST.get('group') member = Member(name=name, group=group) member.save() data = {'success': True, 'id': member.id} return JsonResponse(data)
def add(request): if not require_login_or_key(request): return redirect('/') ssn = request.GET.get('ssn') username = request.GET.get('username') name = request.GET.get('name') email = request.GET.get('email') added = request.GET.get('added', '') groups = request.GET.getlist('group', []) member = Member() member.ssn = ssn member.username = username member.name = name member.email = email member.added = added try: member.save() member = Member.objects.get(id=member.id) for group in groups: member.groups.add(Group.objects.get(techname=group)) except IntegrityError as e: return json_error(e) response_data = { 'success': True, 'data': member_to_dict(member) } return HttpResponse(json.dumps(response_data), content_type='application/json')
def member_register(request): if request.method == 'POST': form = MemberRegisterForm(request.POST) if form.is_valid(): print form.cleaned_data user = User.objects.create_user( username = form.cleaned_data['member_username'], email = form.cleaned_data['member_email'], password = form.cleaned_data['member_password'] ) member = Member(user = user, member_displayname = form.cleaned_data['member_real_name']) member.save() new_user = auth.authenticate(username=form.cleaned_data['member_username'], password=form.cleaned_data['member_password']) auth.login(request, new_user) return HttpResponseRedirect(reverse('project-list')) else: form = MemberRegisterForm() if request.is_ajax(): template = 'member/register_ajax.html' else: template = 'member/register.html' return render_to_response(template, { 'form':form.as_table() }, context_instance=RequestContext(request) )
def form_valid(self, form): # print(form.cleaned_data) member = Member(email=form.data.get('email'), password=make_password(form.data.get('password')), level='user') member.save() return super().form_valid(form)
def create_a_team_and_join(self, member: Member, name_ch='队名', name_en='team name'): team = Team.objects.create(name_ch=name_ch, name_en=name_en) member.team = team member.save(update_fields=['team']) return team
def insert(request): data = request.POST m = Member(mid=data['mid'], pw=data['pw'], nickname=data['nickname'], gender=data['gender'], country=data['country'], email=data['email']) m.save() return render(request, 'home.html')
def insert(request): # post 방식 전송되기 위해서는 form 안에 {% csrf_token %} 작성 # post방식 전송되는 파라미터추출해서 Member 모델 객체 생성 mem = Member( name=request.POST.get("name"), addr=request.POST.get("addr"), ) # DB에 반영 mem.save() # 리다일렉트 이동하라고 응답 return HttpResponseRedirect('/member/list/')
def handle(self, *args, **options): fname = os.path.join(settings.BASE_DIR, 'etc/4class.csv') lines = file(fname).readlines() now = timezone.now() for line in lines: l = line.split(',') try: Member.objects.get(number=l[0]) except Exception: member = Member(username=l[1], email=l[3], classnum=4, number=l[0], weixin='xx', mobile=l[2], \ birthday=datetime.date.today(), gender='m',is_active=True, qq=l[4], is_superuser=False, last_login=now) member.set_password('123') member.save() print 'create %s' % l[1]
def edit_member_profile(request): try: if Member.objects.filter(user=request.user): member = Member.objects.filter(user=request.user)[0] else: member = Member(user=request.user) except Exception as e: print e return HttpResponseRedirect('/sorry') form_profile_photo = edit_profile_photo_form() form_first_and_last_name = edit_profile_first_and_last_name_form( initial={ 'first_name': request.user.first_name, 'last_name': request.user.last_name }) if request.method == 'POST' and 'profile_photo' in request.POST: form_profile_photo = edit_profile_photo_form(request.POST, request.FILES) if form_profile_photo.is_valid(): try: member.photo = request.FILES["photo"] member.save() print member.photo return HttpResponseRedirect('/member/member_profile') except Exception as e: print e return HttpResponseRedirect('/sorry') elif request.method == 'POST' and 'name_form' in request.POST: # password form form_first_and_last_name = edit_profile_first_and_last_name_form( request.POST) if form_first_and_last_name.is_valid(): try: first_name = request.POST.get('first_name') last_name = request.POST.get('last_name') request.user.first_name = first_name request.user.last_name = last_name request.user.save() return HttpResponseRedirect('/member/member_profile') except Exception as e: print e return HttpResponseRedirect('/sorry') return render_to_response('edit_member_profile.html', locals(), context_instance=RequestContext(request))
def register_member(self, reg): random_string = generate_random_string() while Member.objects.filter(temporary_web_id=random_string).count() > 0: # Preventing duplication errors random_string = generate_random_string() # Make the 'added' date timezone-aware. added_date = datetime.strptime(reg['date'], '%Y-%m-%d %H:%M:%S') # Create and configure member member = Member() member.added = pytz.timezone(settings.TIME_ZONE).localize(added_date) member.ssn = reg['ssn'] member.name = reg['name'] member.email = reg['email'] merge_national_registry_info(member, reg['national'], timezone.now()) member.temporary_web_id = random_string member.temporary_web_id_timing = timezone.now() # Save member to database stdout.write('* Registering member...') stdout.flush() member.save() stdout.write(' done\n') self.process_groups(reg, member) # Send confirmation message message = InteractiveMessage.objects.get(interactive_type='registration_received', active=True) body = message.produce_links(member.temporary_web_id) # Save the start of the delivery attempt delivery = InteractiveMessageDelivery() delivery.interactive_message = message delivery.member = member delivery.email = member.email delivery.timing_start = timezone.now() delivery.save() # Actually send the message stdout.write('* Sending confirmation email...') stdout.flush() quick_mail(member.email, message.subject, body) stdout.write(' done\n') # Update the delivery delivery.timing_end = timezone.now() delivery.save()
def update(request): member = Member( num=request.POST.get("num"), name=request.POST.get("name"), addr=request.POST.get("addr"), ) # .save() 메소드는 data 가 있으면 수정 반영, 없으면 insert member.save() return render( request, 'member/alert.html', { "msg": u"수정했습니다.", "url": "/member/list/" }, )
def member_edit(request, member_id=None): if member_id: member = get_object_or_404(Member, pk=member_id) title = "顧客編集" else: member = Member() title = "顧客追加" if request.method == 'POST': form = MemberForm(request.POST, instance=member) if form.is_valid(): member = form.save(commit=False) member.save() return redirect('member:member_list') else: form = MemberForm(instance=member) return render(request, 'member/edit.html', dict(form=form, member_id=member_id, title=title))
def registerv(request): if request.method == 'POST': form = UserCreationForm(request.POST) if form.is_valid(): new_user = form.save() new_member=Member(member=new_user,name='Blank',surname='Blank',billingaddress='Blank') new_member.save() return HttpResponseRedirect("/account/") else: form = UserCreationForm() return render(request, 'register.html', { 'form': form, 'error':'INVALID FORM', }) else: request.user.is_authenticated=False form = UserCreationForm() return render(request, 'register.html', { 'form': form, })
def update(self, instance: Member, validated_data: dict) -> Filter: original_password = validated_date['original_password'] new_password = validated_data['new_password'] confirm_password = validated_data['confirm_password'] first_name = validated_data['first_name'] last_name = validated_data['last_name'] if instance.user.check_password( original_password) and new_password == confirm_password: instance.user.set_password(new_password) if validated_data['first_name']: instance.user.first_name = first_name if validated_data['last_name']: instance.user.last_name = last_name state = "Verified" instance.state = state instance.save() return instance
def MemberCreate_fin(request): id = request.POST['id'] pw = request.POST['pw'] # pw=bcrypt.hashpw(request.POST['pw'].encode('UTF-8'),bcrypt.gensalt()) #비밀번호 보안 처리 name = request.POST['name'] tel = request.POST['tel'] add = request.POST['add'] email = request.POST['email'] birth = request.POST['birth'] gender = request.POST['gender'] member = Member(id=id, pw=pw, name=name, tel=tel, add=add, email=email, birth=birth, gender=gender) member.save() request.session["id"] = id return render(request, 'member/member_create_fin.html', {'name': name})
def MemberRegistration(request): if request.user.is_authenticated(): return HttpResponseRedirect('/profile/') if 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 = User.objects.create_user( username=form.cleaned_data['username'],password=form.cleaned_data['password'],email=form.cleaned_data['email'],) user.save() member = Member(user=user,name = form.cleaned_data['name'],email=form.cleaned_data['email'],) member.save() return HttpResponseRedirect('/profile/(?P<pk>\w+)/') # http://mayukhsaha.wordpress.com/2013/05/09/simple-login-and-user-registration-application-using-django/ # http://runnable.com/UqLQLKmXsSAmAAd5/user-registration-form-with-captcha-using-django-simple-captcha-for-python else: return render_to_response('register.html', {'form':form}, context_instance=RequestContext(request)) else: """ User is not submitting the form , Show them a blank registration form """ form = RegistrationForm() context = {'form':form} return render_to_response('register.html', context,context_instance=RequestContext(request))
def create_random_member(self, is_admin=False): first_name = self.Faker.first_name() last_name = self.Faker.last_name() username=self.Faker.user_name() email = self.Faker.email() phone = self.Faker.phone_number() password = ''.join(random.SystemRandom().choice(string.uppercase + string.digits) for _ in xrange(10)) date = self.Faker.date() city = self.Faker.city() postcode = self.Faker.postcode() adress = self.Faker.street_address() mem = Member(username=email, first_name=first_name, last_name=last_name, email=email, nick=username, birthdate=date, phone=phone, mobile='', street=adress, city=city, country_id="AF", zip=postcode, careof='', socialsecuritynumber='', refreshedon=datetime.now(pytz.timezone("GMT")), is_opt_in=self.Faker.boolean(90), password=make_password(password, None, 'md5'), # Hang on, md5? Yes. Django uses secure hashing by default, which without specifying a weak hashing algorithm makes this script take several minutes to run. is_superuser=is_admin, is_moderator=is_admin, is_staff=is_admin ) #mem.set_password(dodemopassword) mem.save() self.members.append(mem) return {"member": mem, "password": password }
def _(sender, instance: Member = None, created=False, **kwargs): if created: instance.user.role = User.Role.MEMBER instance.save()
def signupform(request): # POST 방식이면, 데이터가 담긴 제출된 폼으로 간주합니다. if request.method == 'POST': # request에 담긴 데이터로, 클래스 폼을 생성합니다. form = SignupForm(request.POST) # 폼에 담긴 데이터가 유효한지 체크한다 if form.is_valid(): # (1)비밀번호와 비밀번호확인이 일치하는지 비교한다 if request.POST['member_pw'] == request.POST['member_pw_r']: # (2)아이디중복인지 확인하기 if Member.objects.filter(member_id=request.POST['member_id']): form = SignupForm() message = "아이디중복" return render( request, 'member/signup.html', { 'form': form, 'message': message, 'member_id': request.POST['member_id'], 'member_pw': request.POST['member_pw'], 'member_pw_r': request.POST['member_pw_r'], 'nickname': request.POST['nickname'], 'member_name': request.POST['member_name'], 'address': request.POST['address'], 'address_in': request.POST['address_in'], 'phone_no': request.POST['phone_no'], 'email': request.POST['email'], }) # (2)else문 else: # (3)아이디, 비밀번호 글자 제한 (영문자, 숫자만 가능) id_check = [ 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9' ] pw_check=['A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z','a',\ 'b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z','0','1',\ '2','3','4','5','6','7','8','9'] id_value = "" pw_value = "" # 아이디 검사 for i in list(request.POST['member_id']): if i in id_check: id_value += i else: continue if (request.POST['member_id'] != id_value): #영소문자,숫자가 아니니 에러메시지를 띄운다. form = SignupForm() message = "아이디글자제한" return render( request, 'member/signup.html', { 'form': form, 'message': message, 'member_id': request.POST['member_id'], 'member_pw': request.POST['member_pw'], 'member_pw_r': request.POST['member_pw_r'], 'nickname': request.POST['nickname'], 'member_name': request.POST['member_name'], 'address': request.POST['address'], 'address_in': request.POST['address_in'], 'phone_no': request.POST['phone_no'], 'email': request.POST['email'], }) # 비밀번호 검사 for i in list(request.POST['member_pw']): if i in pw_check: pw_value += i else: continue if (request.POST['member_pw'] != pw_value): #영대소문자,숫자가 아니니 에러메시지를 띄운다. form = SignupForm() message = "비밀번호글자제한" return render( request, 'member/signup.html', { 'form': form, 'message': message, 'member_id': request.POST['member_id'], 'member_pw': request.POST['member_pw'], 'member_pw_r': request.POST['member_pw_r'], 'nickname': request.POST['nickname'], 'member_name': request.POST['member_name'], 'address': request.POST['address'], 'address_in': request.POST['address_in'], 'phone_no': request.POST['phone_no'], 'email': request.POST['email'], }) #(추가)닉네임중복인지 확인하기 if Member.objects.filter( nickname=request.POST['nickname']): form = SignupForm() message = "닉네임중복" return render( request, 'member/signup.html', { 'form': form, 'message': message, 'member_id': request.POST['member_id'], 'member_pw': request.POST['member_pw'], 'member_pw_r': request.POST['member_pw_r'], 'nickname': request.POST['nickname'], 'member_name': request.POST['member_name'], 'address': request.POST['address'], 'address_in': request.POST['address_in'], 'phone_no': request.POST['phone_no'], 'email': request.POST['email'], }) # 모든 에러검사를 넘겨 회원가입을 완료한다. obj = Member(member_id=request.POST['member_id'], member_pw=request.POST['member_pw'], nickname=request.POST['nickname'], member_name=request.POST['member_name'], address=request.POST['address'], address_in=request.POST['address_in'], phone_no=request.POST['phone_no'], email=request.POST['email']) obj.save() # 회원가입 완료시 완료화면으로 이동한다. return redirect('member:signup_result', pk=obj.pk) #(1)else문 # 비밀번호와 비밀번호확인 일치 실패시 '비밀번호' 문구를보낸다. # 현재까지 입력된 form값을 모두 다같이 담아 보낸다. # 받은 form값을 input.value로 넣어준다. else: form = SignupForm() message = "비밀번호일치" return render( request, 'member/signup.html', { 'form': form, 'message': message, 'member_id': request.POST['member_id'], 'member_pw': request.POST['member_pw'], 'member_pw_r': request.POST['member_pw_r'], 'nickname': request.POST['nickname'], 'member_name': request.POST['member_name'], 'address': request.POST['address'], 'address_in': request.POST['address_in'], 'phone_no': request.POST['phone_no'], 'email': request.POST['email'], }) # 잘못된 입력값 else: form = SignupForm() message = "잘못된입력값" return render( request, 'member/signup.html', { 'form': form, 'message': message, 'member_id': request.POST['member_id'], 'member_pw': request.POST['member_pw'], 'member_pw_r': request.POST['member_pw_r'], 'nickname': request.POST['nickname'], 'member_name': request.POST['member_name'], 'address': request.POST['address'], 'address_in': request.POST['address_in'], 'phone_no': request.POST['phone_no'], 'email': request.POST['email'], }) else: # GET 방식 form = SignupForm() message = "GET" return render(request, 'member/signup.html', { 'form': form, 'message': message })
def register_member(request): form = RegisterForm(request.POST or None, request.FILES or None) trainers = User.objects.filter(profile__user_grup="Eğitmen") print("************************ username: "******"************************ password: "******"************************ confirm: ", request.POST.get('confirm')) print("************************ first_name: ", request.POST.get('first_name')) print("************************ last_name: ", request.POST.get('last_name')) print("************************ gender: ", request.POST.get('gender')) print("************************ birthday: ", request.POST.get('birthday')) print("************************ phone_number: ", request.POST.get('phone_number')) print("************************ image_profile: ", request.POST.get('image_profile')) if form.is_valid(): password = form.cleaned_data.get("password") first_name = form.cleaned_data.get("first_name").capitalize() last_name = form.cleaned_data.get("last_name").capitalize() gender = form.cleaned_data.get("gender") birthday = form.cleaned_data.get("birthday") phone_number = form.cleaned_data.get("phone_number") image_profile = form.cleaned_data.get("image_profile") username = first_name.lower() + "." + last_name.lower() try: newUser = User(username=username, first_name=first_name, last_name=last_name) newUser.set_password(password) newUser.save() print("************************ newUser.id", newUser.id) newProfile = Profile.objects.get(user_id=newUser.id) newProfile.image_profile = image_profile newProfile.user_grup = "Uye" newProfile.phone_number = phone_number newProfile.birthday = birthday newProfile.gender = gender newProfile.save() newMember = Member(user=newUser) newMember.save() # login(request, newUser) #newMember = Member(member=newUser, gender=gender, birthday=birthday, phone_number=phone_number,image_profile=image_profile) #newMember.save() messages.success(request, 'Kullanıcı başarı ile kayıt edildi.') return redirect("user:dashboard") except: if User.objects.filter(username=username).exists(): messages.info(request, 'Böyle bir kullancı var') else: raise else: if request.POST: messages.info(request, 'Kullanıcı kayıt edilemedi.') context = {"form": form} for x in form: print(x.value()) return render(request, "user/register.html", context=context) context = {"form": form, "user_grup": "Member", 'trainers': trainers} return render(request, "user/register.html", context=context)