Web2py Rating Widget

16 views
Skip to first unread message

Mário Gomes

unread,
Jun 24, 2013, 6:55:43 AM6/24/13
to web...@googlegroups.com

I have a new problem.

I already done my widget but now i want 5 rating widget's for 5 categories in my database.

I have this column in my database (named places.categ):

places.categ
       a
       b
       c
       d
       a
       e
       ....

I have 21 markers in my Google Maps and each one of them as a category. (a,b,c,d or e).

How can i associate 5 rating widgets to those 21 markers by category? All i could do was this:

db.define_table('product',
Field('A', 'integer',requires=IS_IN_SET(range(1,6))), 
   Field('B', 'integer',requires=IS_IN_SET(range(1,6))),
   Field('C', 'integer',requires=IS_IN_SET(range(1,6))),
   Field('D', 'integer',requires=IS_IN_SET(range(1,6))),
   Field('E', 'integer',requires=IS_IN_SET(range(1,6))))

I have this code in my models/db.py and this one in my controllers/default.py:

from plugin_rating_widget import RatingWidget

# Inject the widgets
db.product.A.widget = RatingWidget()
db.product.B.widget = RatingWidget()
db.product.C.widget = RatingWidget()
db.product.D.widget = RatingWidget()
db.product.E.widget = RatingWidget()




# form2 = SQLFORM.factory(
   # Field('Rating','integer',widget=SQLFORM.widgets.RatingWidget))

   # if form2.process().accepted:
   #     print form2.vars.search



form2 = SQLFORM(db.product)
if form2.accepts(request.vars, session):
    session.flash = 'submitted %s' % form2.vars
    redirect(URL('index'))

I have 5 rating widget but they are not associated to my database and they are vertical (in 5 lines) and not in 1 line, like i wanted too.

TIA.

P.S.: I have the plugin rating widget uploaded.

(i posted this on stackoverflow but got no answer.)

Reply all
Reply to author
Forward
0 new messages