コード例 #1
0
ファイル: users_views.py プロジェクト: none-da/Favmeal
def _process_restfood_account_information(userprofile,request,account_template):
    password = _request_param_post(request, 'password')
    mobile = _request_param_post(request, 'mobile')
    office_place = _request_param_post(request, 'office_place')
    office_landmark = _request_param_post(request, 'office_landmark')
    office_area = _request_param_post(request, 'office_area')
    office_zip = _request_param_post(request, 'office_zip')
    from users.forms import AccountForm
    accountform = AccountForm({'mobile':mobile,'password':password,
                               'home_place':userprofile.source.place,'home_landmark':userprofile.source.landmark,'home_area':userprofile.source.area,'home_zip':userprofile.source.zip,
                               'office_place':office_place,'office_landmark':office_landmark,'office_area':office_area,'office_zip':office_zip})
    if not accountform.is_valid():
        _add_errormsg(request, 'Please valid information in all the required fields')
        return response(account_template,locals(),request)
    password = accountform.cleaned_data.get('password')
    print 'password:%s' % password
    userprofile.set_password(password)
    print 'password reset done'
    mobile = accountform.cleaned_data.get('mobile')
    userprofile.mobile = mobile
    userprofile.save()
    office_place = accountform.cleaned_data.get('office_place')
    office_landmark = accountform.cleaned_data.get('office_landmark')
    office_area = accountform.cleaned_data.get('office_area')
    office_zip = accountform.cleaned_data.get('office_zip')
    userprofile.set_destination_address(destination_place=office_place,destination_area=office_area,destination_landmark=office_landmark,destination_zip=office_zip)
    _add_successmsg(request, 'Account Information saved Successfully')
    return response(account_template,locals(),request)
コード例 #2
0
ファイル: views.py プロジェクト: brutasse-archive/wombat
def add_account(request):
    if request.method == 'POST':
        account_form = AccountForm(data=request.POST)
        smtp_form = SMTPForm(data=request.POST, prefix='smtp')
        imap_form = IMAPForm(data=request.POST, prefix='imap')
        if all([form.is_valid() for form in (account_form,
                                             smtp_form,
                                             imap_form)]):
            # Create an Account, attach it an IMAP and an SMTP instance.
            account = account_form.save(commit=False)
            account.profile = request.user.get_profile()
            account.imap = imap_form.save()
            account.smtp = smtp_form.save()
            account.save()
            messages.success(request, _('Your account has been successfully '
                                       'created'))
            return redirect(reverse('edit_account', args=[account.id]))
    else:
        account_form = AccountForm()
        smtp_form = SMTPForm(prefix='smtp')
        imap_form = IMAPForm(prefix='imap')
    context = {
        'account': account_form,
        'imap': imap_form,
        'smtp': smtp_form
    }
    return render(request, 'users/add_account.html', context)
コード例 #3
0
ファイル: views.py プロジェクト: brutasse-archive/wombat
def edit_account(request, id):
    account = get_object_or_404(Account, id=id)

    if request.method == 'POST':
        account_form = AccountForm(data=request.POST, instance=account)
        smtp_form = SMTPForm(data=request.POST, prefix='smtp',
                             instance=account.smtp)
        imap_form = IMAPForm(data=request.POST, prefix='imap',
                             instance=account.imap)
        if all([form.is_valid() for form in (account_form, smtp_form,
                                             imap_form)]):
            account_form.save()
            imap_form.save()
            smtp_form.save()
            messages.success(request, _('Your account have been successfully'
                                        ' updated.'))
            return redirect(reverse('accounts'))
    else:
        account_form = AccountForm(instance=account)
        smtp_form = SMTPForm(prefix='smtp', instance=account.smtp)
        imap_form = IMAPForm(prefix='imap', instance=account.imap)

    context = {
        'account': account,
        'account_form': account_form,
        'imap': imap_form,
        'smtp': smtp_form
    }
    return render(request, 'users/edit_account.html', context)
コード例 #4
0
ファイル: users_views.py プロジェクト: none-da/Favmeal
def _process_homefood_account_information(userprofile,request,account_template):
    from users.forms import AccountForm
    accountform = AccountForm(post_data(request))
    if not accountform.is_valid():
        _add_errormsg(request, 'Please valid information in all the required fields')
        return response(account_template,locals(),request)
    password = accountform.cleaned_data.get('password')
    userprofile.set_password(password)
    mobile = accountform.cleaned_data.get('mobile')
    userprofile.mobile = mobile
    home_place = accountform.cleaned_data.get('home_place')
    home_landmark = accountform.cleaned_data.get('home_landmark')
    home_area = accountform.cleaned_data.get('home_area')
    home_zip = accountform.cleaned_data.get('home_zip')
    userprofile.set_source_address(source_place=home_place,source_area=home_area,source_landmark=home_landmark,source_zip=home_zip)
    office_place = accountform.cleaned_data.get('office_place')
    office_landmark = accountform.cleaned_data.get('office_landmark')
    office_area = accountform.cleaned_data.get('office_area')
    office_zip = accountform.cleaned_data.get('office_zip')
    userprofile.set_destination_address(destination_place=office_place,destination_area=office_area,destination_landmark=office_landmark,destination_zip=office_zip)
    _add_successmsg(request, 'Account Information saved Successfully')
    return response(account_template,locals(),request)
コード例 #5
0
ファイル: views.py プロジェクト: kurigohan/toolshare
def edit_account(request, template_name='users/edit_account.html'):
    """
    Change profile and personal info
    """
    #user = request.user
    if request.method == 'POST':
        form = AccountForm(data=request.POST)
        if form.is_valid():
            request.user.first_name = form.cleaned_data['first_name']
            request.user.last_name = form.cleaned_data['last_name']
            request.user.email = form.cleaned_data['email']
            request.user.save()
            messages.success(request, 'Account updated')
            return redirect('edit_account')
    else:
        form = AccountForm(
            initial={
                'first_name': request.user.first_name,
                'last_name': request.user.last_name,
                'email': request.user.email
            })
    return render(request, template_name, {'form': form})
コード例 #6
0
ファイル: views.py プロジェクト: skinnyMan/toolshare
def edit_account(request, template_name="users/edit_account.html"):
    """
    Change profile and personal info
    """
    # user = request.user
    if request.method == "POST":
        form = AccountForm(data=request.POST)
        if form.is_valid():
            request.user.first_name = form.cleaned_data["first_name"]
            request.user.last_name = form.cleaned_data["last_name"]
            request.user.email = form.cleaned_data["email"]
            request.user.save()
            messages.success(request, "Account updated")
            return redirect("edit_account")
    else:
        form = AccountForm(
            initial={
                "first_name": request.user.first_name,
                "last_name": request.user.last_name,
                "email": request.user.email,
            }
        )
    return render(request, template_name, {"form": form})