Ejemplo n.º 1
0
def profile_basic(request, profile_id=0, template_name='_current.html'):        
    try:
        instance = UserProfile.objects.get(pk=profile_id)
    except UserProfile.DoesNotExist:
        instance = UserProfile()
        
    if request.method == "POST":
        form = UserProfileForm(request.POST, request.FILES)
        if form.is_valid():                            
            opts = {}
            opts['user']=request.user
            opts['instance']=instance
            if(request.user.userprofiles.has_default_profile() == False):
                opts['is_default']=True
            else:
                opts['is_default']=None
            
            form.save(**opts)
            save_file(request.FILES['profile_photo'])
            
            post_action_redirect = reverse('profile_company', kwargs={'profile_id':instance.id})
            
            if instance.current_status == 'S':
                post_action_redirect = reverse('profile_education', kwargs={'profile_id':instance.id})
            return HttpResponseRedirect(post_action_redirect)            
    else:
        form = UserProfileForm(instance=instance)
    return render_to_response(template_name, {'form':form,'user': request.user,'profile_id':profile_id}, 
                              context_instance=RequestContext(request))
Ejemplo n.º 2
0
def profile(request, template_name='profile.html'):
    user = get_object_or_404(SiteUser, id=request.user.id)
    post_signup_redirect = reverse('app.users.settings.views.settings')
            
    try:
        instance = UserSettings.objects.get(pk=user.id)
    except UserSettings.DoesNotExist:
        instance = UserSettings()
        
    if request.method == "POST":
        form = UserProfileForm(request.POST)
        if form.is_valid():                            
            opts = {}
            opts['user']=user                            
            form.save(**opts)
            return HttpResponseRedirect(post_signup_redirect)            
    else:        
        form = UserProfileForm(instance=instance)
    return render_to_response(template_name, {'form':form,'user': user}, 
                              context_instance=RequestContext(request))