Finally i was able to solve this problem! I used a session to carry forward 
the details of the company whose quotations I wanted to delete. It is 
finally working as I wanted. Thanks again Anthony, you previously hinted it 
but it didnt get it back then, when i went back to the problem a year later 
well rested I understood what you meant.

def View_Invoice():
    ref=session.ref2
    invoiceDetails=db.Client_Details(request.args(0, cast=int))
*    session.detailsInvoice=invoiceDetails*
    resCompany=db(db.resident_company).select()
    customer=db(db.invoice.customer==invoiceDetails.id).select(db.invoice.
ALL)
    pricing=db(db.invoice.customer==invoiceDetails.id).select(db.invoice.
totalPrice.sum().with_alias('total'))
    return locals()

def deleteInvoice():
*    if db(db.invoice.customer == session.detailsInvoice).delete():*
          redirect(URL('registeredClients'))
    return locals()

Regards;
Mostwanted

On Tuesday, January 8, 2019 at 7:44:48 AM UTC+2, mostwanted wrote:
>
> With regards to validation considering the scope of the app i'm working 
> on, i will be using @auth.requires_membership() to control and restrict who 
> does what but thanks for bringing up digitally signed URL, i will be 
> looking extensively in to that, its an interesting topic.
>
> I have changed my code, i have been specific with my ID:
> if db(db.invoice.id == request.args(0, cast=int)).delete():
>           redirect(URL('registeredClients'))
> It does the deleting but the thing is it deletes the items that appear in 
> my invoice one at a time, if i have 10 items i have to keep clicking the 
> delete link 10 times until the invoice is no more but it would be great if 
> i could be able to erase all the 10 items by clicking once, more like if i 
> were using this
> if db(db.invoice.id > 0).delete():
>           redirect(URL('registeredClients'))
>  but only specific to only one invoice for the selected client and not 
> erasing everything in the database
>
>
> On Tuesday, January 8, 2019 at 12:05:15 AM UTC+2, Anthony wrote:
>>
>> On Monday, January 7, 2019 at 2:06:43 AM UTC-5, mostwanted wrote:
>>>
>>> My delete function is not working, I think I am doing doing something 
>>> wrong but i'm not sure where, I thought the code below would get me home 
>>> but nothing is happening, nothing is getting deleted! Please advice:
>>>
>>> *DELETE FUNCTION CONTROLLER CODE:*
>>> def deleteInvoice():
>>>     query=db.invoice(request.args(0, cast=int))
>>>     remove=db(db.invoice.customer==query.id).delete()
>>>
>>
>> Again, the first line serves no purpose, as it is simply used to retrieve 
>> the ID that you already have. Just do:
>>
>>     if db(db.invoice.customer == request.args(0, cast=int)).delete():
>>         redirect(URL('registeredClients'))
>>
>> If that's not working, presumably request.args(0) is not the value of any 
>> "customer" in the db.invoice table, so your bug lies in the code that 
>> produces the URL that leads here.
>>
>> Also, it doesn't look like your code does any validation to determine if 
>> the user is allowed to delete all of these customer invoices. You should 
>> probably confirm that the customer ID submitted is the customer ID of the 
>> current user (you could use a digitally signed URL, a session variable, or 
>> do a lookup).
>>
>> Anthony
>>
>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/web2py/a51b3ce1-8118-4ae8-95de-85d85472f8fa%40googlegroups.com.

Reply via email to