コード例 #1
0
ファイル: views.py プロジェクト: clusterify/clusterify
def edit_profile(request):
    user = request.user
    # if it's the first time the user edits his profile, we'll need
    # to create the object
    profile, created = Profile.objects.get_or_create(user=user)
    
    if request.method == 'POST':
        form = ProfileForm(request.POST)
        if form.is_valid():
            user.email = form.cleaned_data['email']
            user.save()

            profile.description_markdown = form.cleaned_data['description']
            profile.set_tags(form.cleaned_data['tags'])
            profile.location = form.cleaned_data['location']
            
            profile.save()
            
            return HttpResponseRedirect('/accounts/profile/')
    else:
        form = ProfileForm(
                  initial={
                        'email': user.email,
                        'location': profile.location,
                        'description': profile.description_markdown,
                        'tags': profile.get_editable_tags()})

    return render_to_response('registration/edit_profile.html',
        {'form': form},
        context_instance=RequestContext(request))
コード例 #2
0
ファイル: views.py プロジェクト: LECARROU/gom-jabbar
def profile(request):
    if request.method == 'POST':
        form = ProfileForm(request.POST)
        if form.is_valid():
            user = request.user.id
            User.objects.filter(id=user).update(
                first_name=request.POST.get("first_name", ""),
                last_name=request.POST.get("last_name", ""),
                email=request.POST.get("email", ""))
            Customers.objects.filter(user_id=user).update(
                customer_type=request.POST.get("customer_type", ""),
                drink_preferences=request.POST.get("drink_preferences", ""),
                food_preferences=request.POST.get("food_preferences", ""))
            return redirect('home')
    else:
        form = ProfileForm()
    return render(request, 'registration/profile.html', {'form': form})
コード例 #3
0
ファイル: views.py プロジェクト: HarshChaudhari/Registration
def SaveProfile(request):
   saved = False
   
   if request.method == "POST":
      MyProfileForm = ProfileForm(request.POST)

      if MyProfileForm.is_valid():
         profile1 = Profile1()
         profile1.name = MyProfileForm.cleaned_data["username"]
         profile1.lastName = MyProfileForm.cleaned_data["lastName"]
         password = MyProfileForm.cleaned_data["password"]
         passwordAgain = MyProfileForm.cleaned_data["passwordAgain"]
         profile1.password = password
        # profile1.picture = MyProfileForm.cleaned_data["picture"]
         profile1.save()
         saved = True

   else:
      MyProfileForm = ProfileForm()
		
   return render(request, 'saved.html', locals())
コード例 #4
0
ファイル: views.py プロジェクト: Dosya97/dos
def profile(request):
    args = {}
    args.update(csrf(request))
    if request.method == 'POST':
        form = ProfileForm(request.POST, instance=request.user.profile)
        form.actual_user = request.user
        if form.is_valid():
            form.save()
            if(request.user.profile.real_birth.year==1000):
                # print("OK")
                b = Profile.objects.get(user=request.user)
                b.real_birth=request.user.profile.birth
                b.save()
            return redirect('mypage')
    else:
        user = request.user
        profile = user.profile
        form = ProfileForm(instance=profile)
        args['form'] = form
    return render(request,'profile.html',args)