[web2py] Re: SQlite to Postgres insert problems

2015-11-19 Thread Carla Raquel
Problem solved!Everything is working fine now!

quarta-feira, 18 de Novembro de 2015 às 15:35:32 UTC, Carla Raquel escreveu:
>
> I'm having some troubles importing from csv files while using a Postgres 
> connection, when a table has one or more references to other tables like so:
>
> db.define_table('Extension',
> Field('Person',db.auth_user),
> Field('Supervisor',db.auth_user),
> Field('Number','integer'),
> Field('Description','text')
>
>
>
> I have created this and the auth_user table on Postgres and imported the 
> auth_user contents from the csv file with no problems. I also have no 
> problems importing to other tables that have no external references. I have 
> the following error: ('Error', '23503','insert or update on table 
> "extensao" violates foreign key constraint "extension_person_fkey"'). Any 
> ideas?
>

-- 
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.
For more options, visit https://groups.google.com/d/optout.


[web2py] SQlite to Postgres insert problems

2015-11-18 Thread Carla Raquel
I'm having some troubles importing from csv files while using a Postgres 
connection, when a table has one or more references to other tables like so:

db.define_table('Extension',
Field('Person',db.auth_user),
Field('Supervisor',db.auth_user),
Field('Number','integer'),
Field('Description','text')



I have created this and the auth_user table on Postgres and imported the 
auth_user contents from the csv file with no problems. I also have no 
problems importing to other tables that have no external references. I have 
the following error: ('Error', '23503','insert or update on table 
"extensao" violates foreign key constraint "extension_person_fkey"'). Any 
ideas?

-- 
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.
For more options, visit https://groups.google.com/d/optout.


[web2py] SQL grid "edit" page not as intended

2015-11-09 Thread Carla Raquel
I'm using an SQL grid to display values from two distinct tables. This is 
what I have:
   
def manageUsers():

 query = (db.Extension.Person == db.auth_user.id )
 grid = SQLFORM.grid(query,csv = False,paginate=25,user_signature=True)
 return (grid = grid)

The grid shows perfectly fine with both tables fields' associating with 
each other,the problem is, when I click the "edit" button and I want to be 
able to edit fields from both tables, but the fields from the table 
"Extension" appear with "None" attributes. Looking at the link in the 
"Edit" button, only the auth_user table is being sent, like this 
"...manageUsers/edit/auth_user.." so this is why probably the other tables' 
fields show as "None". In my view I access the fields like this:

{{=grid.update_form.custom.widget.name_of_field}}

My question is, how can I edit fields from both tables when I click the 
edit button?

-- 
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.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: Inserting in db and summing with default values

2015-10-21 Thread Carla Raquel
Well, it seems I had to add db.cTable.cost.*default *to make it work and 
retrieve the default value, as db.cTable.cost is a field object. The case 
is now closed,then.

quarta-feira, 21 de Outubro de 2015 às 10:36:05 UTC+1, Carla Raquel 
escreveu:
>
> I'm trying to add(or update in case it isn't alreadythere) some records to 
> a db in a loop and I want to fill the entries with the sum of the default 
> db values with some other values, but somehow, when trying to insert,it's 
> not working. It's something like this:
>
>  db.cTable.update_or_insert((db.cTable.User == row.id)  & (db.cTable.Year 
> == int(datatemp[2])) &
> (db.cTable.Month == int(datatemp[1])), User = 
> row.id, 
> Year = int(datatemp[2]), Month = int(datatemp[1]), 
> cost = db.cTable.cost + data[t][0])
>
>
> Any ideas?
>

-- 
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.
For more options, visit https://groups.google.com/d/optout.


[web2py] Submenu of submenu not working?

2015-10-21 Thread Carla Raquel
I want to implement a submenu of a submenu within Web2py, but as it is, no 
submenu of submenu 'Communications' is showing. Below is my code:

response.menu = []
submenu=[]
submenu2=[]  

response.menu += [[(SPAN(_class='glyphicon 
glyphicon-wrench',_style='padding:0px 
5px;color:black;'),(T('Management'))), False,URL(app, 'default', ''), 
submenu]]
submenu.append([(SPAN(_class='glyphicon 
glyphicon-user',_style='padding:0px 5px;color:black;'),T('Users')), False, 
 URL(app, 'default', 'userManagement')])
submenu.append([(SPAN(_class='glyphicon 
glyphicon-phone',_style='padding:0px 
5px;color:black;'),T('Communications')), False,  URL(app, 'default', 
'view'), submenu2])
submenu2.append([(SPAN(_class='glyphicon 
glyphicon-file',_style='padding:0px 5px;color:black;'),T('Mobile')), False, 
 URL(app, 'default', 'viewMobile',args=['movel'])])
submenu2.append([(SPAN(_class='glyphicon 
glyphicon-file',_style='padding:0px 5px;color:black;'),T('Phone')), False, 
 URL(app, 'default', 'viewPhone',args=['fixo'])])




What am I possibly missing?

-- 
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.
For more options, visit https://groups.google.com/d/optout.


[web2py] Inserting in db and summing with default values

2015-10-21 Thread Carla Raquel
I'm trying to add(or update in case it isn't alreadythere) some records to 
a db in a loop and I want to fill the entries with the sum of the default 
db values with some other values, but somehow, when trying to insert,it's 
not working. It's something like this:

 db.cTable.update_or_insert((db.cTable.User == row.id)  & (db.cTable.Year 
== int(datatemp[2])) &
(db.cTable.Month == int(datatemp[1])), User = 
row.id, 
Year = int(datatemp[2]), Month = int(datatemp[1]), 
cost = db.cTable.cost + data[t][0])


Any ideas?

-- 
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.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: Self-referencing tables and queries

2015-09-17 Thread Carla Raquel
*So what? You should future proof the app. Some day there might be 
extensions in India or something.*

Actually, the extensions are internal to the company, either phone numbers 
or mobile numbers, so your scenario won't ever apply.

*Do you mean the extensions of the persons he supervises?*

That is what he already does, which is what I don't want it to do. I'll 
give an example,so that you can visualize it better:

Supervisor X has two extensions: 5589,5590
Supervisor X supervises two people: A and B
A has two extensions: 4572,4573
B has one extension: 4321

My current query returns: 5589,5590,4572,4573,4321
What I want it to returns: 5589,5590

Conclusion: Just the Supervisor extensions


quarta-feira, 16 de Setembro de 2015 às 18:15:53 UTC+1, Leonel Câmara 
escreveu:
>
> > I think in this case they won't be strings since I read the numbers from 
> a XML and they don't have the '+' character
>
> So what? You should future proof the app. Some day there might be 
> extensions in India or something.
>
> > Not all the supervisors.I want to get the extensions of a particular 
> supervisor
>
> Do you mean the extensions of the persons he supervises? If so:
>
> the_supervised = db(db.auth_user.Supervisor == 
> ParticularSupervisor.id)._select(db.auth_user.id)
> extensions_of_the_supervised = 
> db(db.Extension.Person.belongs(the_supervised)).select()
>
> This will give you the extensions of everyone that is supervised by this 
> person.  
>
>
>

-- 
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.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: Self-referencing tables and queries

2015-09-16 Thread Carla Raquel
*They should be strings (otherwise how do you store the '+' character)*.

I think in this case they won't be strings since I read the numbers from a 
XML and they don't have the '+' character.

*Then you want to get the extensions of all the supervisors? *

Not all the supervisors.I want to get the extensions of a particular 
supervisor (hence I had the first and last name in the query). Something 
like this:  when a user logs in the system checks who has logged in and 
feeds a table with info(calls details,extensions,etc.) about the specific 
user, who can be a supervisor or a regular person.

quarta-feira, 16 de Setembro de 2015 às 17:09:48 UTC+1, Leonel Câmara 
escreveu:
>
> Ohh ok I had no idea extensions were phone numbers, phone numbers should 
> not be integers, they should be strings (otherwise how do you store the '+' 
> character). Then extensions should be just this:
>
> db.define_table('Extension',
> Field('Person' ,db.auth_user, requires =  IS_IN_DB(db,'
> auth_user.id')),
> Field('Extension_number','string',required = True))
>
> There's no need for an extension to have a supervisor, because the 
> supervisor is already stored in Person. 
>
> Then you want to get the extensions of all the supervisors? (did I get 
> that right)
>
> The easiest way would then be to use belongs:
>
> supervisors = db(db.auth_user.id  > 
> 0)._select(db.auth_user.Supervisor, distinct=True)
> supervisor_extensions = 
> db(db.Extension.Person.belongs(supervisors)).select()
>
> This way you will have the extensions of all the supervisors.
>

-- 
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.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: Self-referencing tables and queries

2015-09-16 Thread Carla Raquel
I guess my code is  more messed up than I thought. I'll try and clarify 
your points:

*What am I trying to achieve?*

In the db there are people (given by the auth_user table). From those 
people there are ones who are hierarchically above them and supervise 
them.They are called Supervisors. All people have mobile and phone 
extensions(numbers) . As far as my query goes, I'm getting the Supervisor' 
numbers and the people's numbers associated with the Supervisor. What I'm 
trying to accomplish: returning only the Supervisor' numbers.

*Would it make more sense to have it like this?*

I'm curious,why would a second table(extension_member) be needed?I think I 
will also need the extension_number in the 'extension' table since that 
table stores all the phone and mobile extensions.

*Why would you check the first name and last name when you already compared 
the ID with person?*

Now I am the one a bit confused. The comparison between the ID and the 
person was to connect both tables and then I would filter by the user I 
wanted. But now I'm not sure If I've been doing this correctly...? 

*Why would you use "like" for an integer field?*

It's the only way I know to check if a number begins as 9 or ~9 . Is there 
a simpler/optimised way?Also, as an aside, is there a way to use regular 
expressions in queries?

Thank you for all the help!

quarta-feira, 16 de Setembro de 2015 às 15:18:31 UTC+1, Leonel Câmara 
escreveu:
>
> This is the answer to the first problem:
>
> db.auth_user.Supervisor.requires=IS_EMPTY_OR(IS_IN_DB(db,'auth_user.id',
> db.auth_user._format))
>
> You can just remove it as it will use the format for auth_user anyway as 
> that's the default. So it becomes only:
>
> db.auth_user.Supervisor.requires=IS_EMPTY_OR(IS_IN_DB(db,'auth_user.id')
>
> As for the Extensions I'm very confused with what you're trying to achieve 
> and your table structure doesn't seem very good. Would it make more sense 
> to have it like this?
>
> db.define_table('extension',,
> Field('Supervisor' , 'reference auth_user', requires = 
> IS_EMPTY_OR(IS_IN_DB(db,'auth_user.id','%(first_name)s %(last_name)s'))),
> Field('Extension_number','integer',required = True))
>
> db.define_table('extension_member',
> Field('extension' , 'reference extension'),
> Field('member' , 'reference auth_user'),
> 
>
> I ask this because your query is utterly confusing, why would you check 
> the first name and last name when you already compared the ID with person, 
> why would you use "like" for an integer field. So many questions.
>
> In your questions you need to tells us *what* you're trying to achieve 
> not just *how*.
>

-- 
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.
For more options, visit https://groups.google.com/d/optout.


[web2py] Self-referencing tables and queries

2015-09-16 Thread Carla Raquel
Hello,

I'm currently tring to solve a problem regarding a table da references 
itself. The default auth_user table has an extra field called 'Supervisor' 
that references that same table, since Supervisor is an user(a 
specialization of it,to be more specific).I have the following parameters 
added on db.py:

auth.settings.extra_fields['auth_user']= [Field('Supervisor','reference 
auth_user')]
db.auth_user.Supervisor.requires=IS_EMPTY_OR(IS_IN_DB(db,'auth_user.id',db.auth_user._format))

I also have another table that stores the user' numbers like so:

db.define_table('Extension',
Field('Person' ,db.auth_user, requires = 
 IS_IN_DB(db,'auth_user.id')),
Field('Supervisor' ,db.auth_user, requires = 
IS_EMPTY_OR(IS_IN_DB(db,'auth_user.id','%(first_name)s %(last_name)s'))),
Field('Extension_number','integer',required = True))

I've tried to query my db for the extension of a person which is a 
supervisor like this:

query = ((db.auth_user.id == db.Extension.Person) & 
(db.auth_user.first_name == fname) & (db.auth_user.last_name == lname) & 
(~(db.Extension.Extension.like('9%'

The problem is, all the extensions associated with the supervisor (both his 
and the people he is a supervisor) are returned. This is wrong, since I 
only want his extensions and not those from the people he is a supervisor. 
What I'm I possibly missing on my query to make this work?  I hope I have 
made any sense here.


-- 
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.
For more options, visit https://groups.google.com/d/optout.


[web2py] Pylint with web2py in sublime error

2015-08-31 Thread Carla Raquel
I'm using Pylint in sublime but it gives me some errors on web2py specific 
variables(request,response,etc.). I've read somewhere that to solve this 
you had to do something like: 

if 0:
from gluon import *

The problem is, I'm getting the error 'Unable to import gluon'. Do you know 
of any fix for this or if there's another way to end the web2py errors?



Regards,
Carla

-- 
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.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: JSON and url vars

2015-07-10 Thread Carla Raquel

This piece of code throws me some unicode problems on "Março". I've 
searched for a solution but didn't find one.
{{for m in [datetime.date(2000, m, 1).strftime('%B') for m in range(1, 13
)]:}}
{{=m}}
{{pass}}

-- 
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.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: JSON and url vars

2015-07-09 Thread Carla Raquel

I don't mind at all Leonel! It is always good to learn from more seasoned 
coders and put the newfound knowledge into practice.
Anyway, I have a dictionary because when the page loads I want the previous 
month to be displayed. Since  this code
month = T(request.now.strftime("%B"))
gives me the current month's full name, that's not exactly what I want. 
Also I have the months appear on a dropdown box like this


Seleccione mes:
{{for m in meses:}}
 {{=m}}
{{pass}}




When you say I can now remove the newlist variable from the view,I should 
replace it by "colaboradores",but wouldn't that still get me into trouble 
if I run out of space?I'm not quite sure what should I do to solve this.

-- 
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.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: JSON and url vars

2015-07-08 Thread Carla Raquel

Thanks for your reply Massimo!I have a question though, why do you say JSON 
by itself won't help?Wouldn't it solve the problem 1)?


-- 
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.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: JSON and url vars

2015-07-08 Thread Carla Raquel
So, you're saying I should avoid sending vars on the URL and instead use 
json?

-- 
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.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: How to insert data in data base by xml file

2015-07-07 Thread Carla Raquel
This is how I dealt with my xml files:

doc = xml.dom.minidom.parse("...my_xml.xml")// Here you parse the xml file


for node in doc.getElementsByTagName("recipe")://Here you read in a cycle the 
tags which contain  numerous attributes each

t=node.getAttribute("name")//Each attribute is stored as a string in a 
variable that you can add to the db
d=node.getAttribute("creator")


try:
db.Recipe.update_or_insert(Name=t,Creator=d)//each time you cycle through 
each node you are adding the name and creator to the db if both aren't already 
there
except:
pass


Hope it helped.

quarta-feira, 1 de Julho de 2015 às 15:01:19 UTC+1, Sai Harsh Tondomker 
escreveu:
>
>
> My project is to make simple quizzing site.
>
> I have made data base in web2py.
>
> with Question, options and Correct answer.
>
> The data will be xml file. From XML file I need to take data and store in 
> data base 
>
> Please help me to solve the problem.
>
> Waiting for your response.
>
> Best Regards
> T.Sai Harsh 
>

-- 
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.
For more options, visit https://groups.google.com/d/optout.


[web2py] JSON and url vars

2015-07-07 Thread Carla Raquel
I'm passing a few variables from the controller(including one of them a 
list) to the view and I have a link that is built using those 
variables.Below is the controller function:

def indexResumo():
meses = 
{'Janeiro':1,'Fevereiro':2,'Março':3,'Abril':4,'Maio':5,'Junho':6,'Julho':7,'Agosto':8,'Setembro':9,'Outubro':10,'Novembro':11,'Dezembro':12}
newlist=[]
year =request.now.year
name = session.auth.user.first_name + ' ' + session.auth.user.last_name
month = (list(meses.keys())[list(meses.values()).index(request.now.month - 
1)])
query = (db.auth_user.Supervisor == session.auth.user.id)
colaboradores = 
db(query).select(db.auth_user.first_name,db.auth_user.last_name)
for x in colaboradores:
newlist.append(x.first_name + ' ' + x.last_name)

return locals()


And here is part of the view "indexResumo" that matters:






When the above link loads, I have a javascript function that reads each of 
the variables passed:

getUrlVars()["name_of_the_var"];


My question is,what would be better: reading the variables this way, or 
move the code in the function "indexResumo" to both functions 
"resumoMensalTMN" and "resumoMensalLocal",have no variables sent in the 
url, and read those via json on my view? I hope I made any sense here.

-- 
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.
For more options, visit https://groups.google.com/d/optout.


[web2py] Request.vars based on dropdown

2015-06-26 Thread Carla Raquel
I have two dropdown lists like the ones below and I would like to compose 
my URL using the month and year as vars, after I click a certain link.How 
can I change my current request.vars to the selected values?


Select month:
{{for m in months:}}
 {{=m}}
{{pass}}




 Select year:
{{for y in years:}}
{{=y}}
{{pass}}
 


-- 
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.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: Ajax and table with queried values

2015-06-25 Thread Carla Raquel
Since I have the values stored inside tables in a db, I am doing the 
queries I need and calculating values in the appropriate controllers and I 
am showing these values in the view like this:
total_cost["_extra"]["SUM(Call.Cost)"]

Otherwise, how can I do it in javascript on the client side?


quinta-feira, 25 de Junho de 2015 às 14:36:49 UTC+1, Leonel Câmara escreveu:
>
> You can also just use regular jquery ajax call instead of web2py's ajax 
> and put the new row on the table with jquery. Something like:
> $.get(
>  "{{=URL('default','calculate_cost')}}",
>  $('#myForm').serialize(),
>  function(newrow) {
> $('#my_table tbody').append(newrow);
>  }
> );
>
>
> This assumes my_function is returning the HTML of the new row. You can 
> return json, use getJSON and make the HTML on the client.
>
> If you want to get fancy you can use ractive for this as it was really 
> made for this kind of stuff.
>
> On the other had why would you need to go to the web2py server to 
> calculate these values can't you do it client side in javascript?
>

-- 
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.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: Ajax and table with queried values

2015-06-25 Thread Carla Raquel

I've read through the chapter and the web2py appliances but I'm failing to 
comprehend.Currently, I have managed to add the code below on the 
javascript section, and the div with an id of 'here' is where's the 
bootstrap panel.In the controller I have a calculate_cost function that 
returns something like this in the div
Calculate Cost
200€
request stats 



ajax('{{=URL('default','calculate_cost')}}',['month','year','name'],'here');



I have now idea why it shows like that and how can I plot the values I want 
individually in each of the td of the table. Also will I need to do an ajax 
request for each thing I want to calculate(like call duration,types of 
services,etc.) or I can do all in one?

quarta-feira, 24 de Junho de 2015 às 11:39:39 UTC+1, Carla Raquel escreveu:
>
>
> I'm having a bit of trouble figuring out how to add info to a bootstrap 
> table in a panel, through ajax.This's a phone call register system and I 
> have the following code in the html:
>
> resumoMensal.html
>
>  style="border-collapse:collapse;">
>
> 
>class="accordion-toggle">
>  class="glyphicon 
> glyphicon-eye-open">  Extensions
>   
> 
>   
> 
>   
>   
>   {{for x in extension:}}
> 
> {{=x.Extension}}
> {{pass}}
>   
>
>
> 
>
>
>  class="accordion-toggle">
>   Total 
> Cost
> {{if total_cost["_extra"]["SUM(Call.Cost)"]!=None:}}
> 
> €{{=total_cost["_extra"]["SUM(Call.Cost)"]}}
> {{else:}}
>  €0
> {{pass}}
>
> 
> 
> 
>   
>   
>   {{for x in cost_types:}}
> 
> {{=x["Call"]["Type_service"]}}<
>
> ...

-- 
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.
For more options, visit https://groups.google.com/d/optout.


[web2py] Ajax and table with queried values

2015-06-24 Thread Carla Raquel

I'm having a bit of trouble figuring out how to add info to a bootstrap 
table in a panel, through ajax.This's a phone call register system and I 
have the following code in the html:

resumoMensal.html




  
  Extensions
  

  

  
  
  {{for x in extension:}}

{{=x.Extension}}
{{pass}}
  
   
   




  Total 
Cost
{{if total_cost["_extra"]["SUM(Call.Cost)"]!=None:}}

€{{=total_cost["_extra"]["SUM(Call.Cost)"]}}
{{else:}}
 €0
{{pass}}




  
  
  {{for x in cost_types:}}

{{=x["Call"]["Type_service"]}}€{{=x["_extra"]["SUM(Call.Cost)"]}}
{{pass}}
  
   

   





  Total (min)
{{if min_total["_extra"]["SUM(Call.Duration)"]!=None:}}

{{=min_total["_extra"]["SUM(Call.Duration)"]}}
{{else:}}
 0
{{pass}}


 
  
   {{for x in cost_type:}}

{{=x["Call"]["Type_service"]}} (min){{=x["_extra"]["SUM(Call.Duration)"]}}
{{pass}}
  
   











When you click a certain link, the username, month and year is passed 
through as vars.Something along the lines of 
/resumoMensal?year=2015&month=April&name=John . After that, the 
What I want to do is exactly this: db is queried for the appropriate 
info(total cost,call duration,etc.,like represented in the code above) and 
through ajax I want to add the values retrieved, and display them in each 
of the td. How can I accomplish this?

-- 
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.
For more options, visit https://groups.google.com/d/optout.


[web2py] Customizable forms in "user" function

2015-06-18 Thread Carla Raquel
How can I, in the "user" function, customize the forms in a way that when I 
click the "Profile" like it shows all the fields pertaining to the profile 
and, when I click on "Password" I can see the "old Password", etc?Currently 
I have something like:

{{=T( request.args(0).replace('_',' ').capitalize() )}}



{{

...

{{pass}}

{{=form.custom.begin}}









     Editar 
Perfil


Primeiro Nome:

  {{=form.custom.widget.first_name}}

   Último Nome: 

  {{=form.custom.widget.last_name}}

   E-mail: 

  

  {{=form.custom.widget.email}}

  


{{=form.custom.submit}}






 {{=form.custom.end}}




Right now I have the first_name,last_name and email fields showing. But now I'm 
wondering, how can I get the old password,new password and verify password?I 
have no idea where this "password" action is called in the code and I don't 
know where I can put code to get the password fields to show up in a way the 
above does.

I hope I've made some sense with all this rambling.

-- 
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.
For more options, visit https://groups.google.com/d/optout.


[web2py] Navbar icon

2015-05-18 Thread Carla Raquel
How can one add an icon before the 'Welcome' message in the navbar,just 
like the one next to the 'Profile' in the drop-down? I tried using 
something like  in 
auth.navbar('Welcome',mode='dropdown'), unfortunately to no avail.
Any help would be much appreciated!

-- 
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.
For more options, visit https://groups.google.com/d/optout.


[web2py] Querying in appadmin

2015-04-16 Thread Carla Raquel
I'm having some troubles making a sum query in appadmin.I want to sum all 
the values of field 'Custo' and then group by type of service, much like 
you would do in a dal query.I tried db.Chamada.Custo.sum() just to start, 
but that doesn't work.It gives me a 'misuse of aggregate: SUM()' error. Any 
help would be appreciated.


















Cheers,
Carla

-- 
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.
For more options, visit https://groups.google.com/d/optout.


[web2py] Format option in extra_fields

2015-04-07 Thread Carla Raquel
Hi!

I'm trying to do something like the code below, but it prompts me the 
following error : 'SyntaxError: invalid syntax'

auth.settings.extra_fields['auth_user']= [Field('Supervisor', 'reference 
auth_user'),
  format = '%(db.auth_user.first_name)s 
%(db.auth_user.last_name)s']



What am I missing here?




Cheers,

Carla

-- 
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.
For more options, visit https://groups.google.com/d/optout.