I i'm trying to use one chart to alternate between two forms. A user logs 
in data in the morning hrs, meaning the form should be active and the 
evening form inactive. When the time comes ....after 12 pm the morning form 
is inactive and the evening form is active.
While trying out this morning, both are inactive all through.
Here is the code:

def mg_sugar_chart():
    response.files.append(URL('e_dextrose','static/js/pygal-tooltips.min.js'
))
    response.headers['Content-Type']='image/svg+xml'


    custom_style = Style(
        background='transparent',
        plot_background='transparent',
        foreground='#53E89B',
        foreground_strong='#53A0E8',
        foreground_subtle='#630C0D',
        opacity='.6',
        opacity_hover='.9',
        transition='400ms ease-in',
        colors=('#E853A0', '#E8537A', '#E95355', '#E87653', '#E89B53')
        )
    chart = pygal.Line(fill=True, interpolate='cubic', style=BlueStyle, 
x_label_rotation=45, print_values=True, show_y_guides=False, 
print_values_position='top')
    data = db(db.amg_sugar).select()
    data1 = db(db.pmg_sugar).select()
    
    chart.x_labels = al_date
    chart.x_labels = pl_date
    chart.add('AM', [i.am_dext for i in data])
    chart.add('PM', [i.pm_dext for i in data1])

    return chart.render()


#***sugar***
@auth.requires_login()
def mgSugar():
    db.amg_sugar.modified_on.readable = db.amg_sugar.modified_on.writable =
False
    db.pmg_sugar.modified_on.readable = db.pmg_sugar.modified_on.writable =
False
    chart= URL('e_dextrose', 'mg_sugar_chart')
    row = db(db.amg_sugar.author == auth.user_id).select().first()


    #***open and close for sugar logs***
    early_str = '05::00::00'
    late_str = '22::00::00'
    am_str = '11::59::00'
    pm_str = '12::00::00'
    am_line = dt.strptime(am_str, '%H::%M::%S').time()#deadline to post 
sugar
    pm_line = dt.strptime(pm_str, '%H::%M::%S').time()#deadline to post 
sugar
    early_line = dt.strptime(early_str, '%H::%M::%S').time()#deadline to 
post sugar
    late_line = dt.strptime(late_str, '%H::%M::%S').time()#deadline to post 
sugar


    #***check if row is empty***
    am_row = [r.am_dext for r in db(db.amg_sugar.author == auth.user.id).
select(db.amg_sugar.ALL)[-1:]]
    pm_row = [r.pm_dext for r in db(db.pmg_sugar.author == auth.user.id).
select(db.pmg_sugar.ALL)[-1:]]
    #***AM logs***
    if request.now.date():# == amd.date():
        form = SQLFORM(db.amg_sugar)
        form.add_button('Edit', URL('edit_amgSugar'))
        am_row1 = [r.am_dext for r in db(db.amg_sugar.author == auth.user.id
).select(db.amg_sugar.ALL)[-1:]]
        if request.now.time() >= early_line and am_row1[0] == None:        
            form = SQLFORM(db.amg_sugar, submit_button=T('Submit')).process
()
            form.add_button('Edit', URL('edit_amgSugar'))
    else:
        session.flash = ''.join(str(item) for item in ["Your next sugar log 
is in the next morning. "])
        form = session.flash


    if request.now.date():# == amd.date():
        form1 = SQLFORM(db.pmg_sugar)
        form1.add_button('Edit', URL('edit_pmgSugar'))
        pm_row1 = [r.pm_dext for r in db(db.pmg_sugar.author == auth.user.id
).select(db.pmg_sugar.ALL)[-1:]]
        if request.now.time() >= pm_line and pm_row1[0] ==None:        
            form1 = SQLFORM(db.pmg_sugar, submit_button=T('Submit')).process
()
            form1.add_button('Edit', URL('edit_pmgSugar'))
    else:
        session.flash = ''.join(str(item) for item in ["Your next sugar log 
is in the next afternoon. "])
        form1 = session.flash

    return dict(chart = chart,form=form, form1=form1)


Could someone give me a better idea/solution.
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 [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/web2py/54c3d82a-87b1-4ec2-9a53-ab1351bb925a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to