def graph(): """This is new interactive graph using D3 still very much work in progress mainly based on http://bl.ocks.org/cjrd/6863459 but there have been a fair number of amendments to meet perceived needs""" # This is currently loaded only by search but will probably also look to use this with newindex redraw = "true" numlevels = request.args(0, cast=int, default=1) basequest = request.args(1, cast=int, default=0) if session.networklist is False: idlist = [basequest] else: idlist = session.networklist if not idlist: redirect(URL('no_questions')) projid = 0 eventrowid = 0 quests, nodes, links, resultstring = getd3graph('search', idlist, 'open', numlevels) return dict(resultstring=resultstring, eventmap=quests, links=links, nodes=nodes, projid=projid, eventrowid=eventrowid, redraw=redraw, eventowner='false')
def viewprojectmapd3v4(): # Now somewhat duplicated with network/network function # but that is graph only and this also lists the event so # will reluctantly keep here for now projid = request.args(0, cast=int, default=0) if not projid: # get the next upcoming project datenow = datetime.datetime.utcnow() query = (db.project.startdate > datenow) projects = db(query).select(db.project.id, orderby=[db.evt.startdatetime]).first() if projects: projid = projects.id else: response.view = 'noproject' return dict(resultstring='No Project') projectrow = db(db.project.id == projid).select().first() quests, nodes, links, resultstring = getd3graph('project', projid, 'Open') # set if moves on the diagram are written back - only owner for now if auth.user and projectrow.proj_owner == auth.user.id: editable = 'true' else: editable = 'false' session.projid = projid return dict(resultstring=resultstring, projectrow=projectrow, eventmap=quests, eventowner=editable, links=links, nodes=nodes, projid=projid)
def network(): # may still limit options if from home screen - but basis is vieweventmapd3v4 and this is for home screen for now eventid = request.args(0, cast=int, default=0) redraw = 'false' if not eventid: # get the next upcoming event datenow = datetime.datetime.utcnow() query = (db.evt.enddatetime > datenow) events = db(query).select(db.evt.id, orderby=[db.evt.startdatetime]).first() if events: eventid = events.id else: redirect(URL('event', 'noevent')) eventrow = db(db.evt.id == eventid).select().first() quests, nodes, links, resultstring = getd3graph('event', eventid, eventrow.status) # set if moves on the diagram are written back - only owner for now if auth.user and eventrow.evt_owner == auth.user.id: editable = 'true' else: editable = 'false' session.eventid = eventid session.projid = eventrow.projid return dict(resultstring=resultstring, eventrow=eventrow, eventid=eventid, eventmap=quests, eventowner=editable, links=links, nodes=nodes, projid=eventrow.projid, eventrowid=eventrow.id, redraw=redraw)
def vieweventmapd3(): # Now somewhat duplicated with network/network function # but that is graph only and this also lists the event so # will reluctantly keep here for now resultstring = '' eventid = request.args(0, cast=int, default=0) eventlevel = request.args(1, cast=int, default=0) # so think we report <= to this parentquest = request.args(2, cast=int, default=0) # so if not zero then we show subs of this only if parentquest>0: parquest = db(db.question.id==parentquest).select().first() else: parquest = None # would also be a summary question redraw = 'false' if not eventid: # get the next upcoming event datenow = datetime.datetime.utcnow() query = (db.evt.startdatetime > datenow) events = db(query).select(db.evt.id, orderby=[db.evt.startdatetime]).first() if events: eventid = events.id else: response.view = 'noevent' return dict(resultstring='No Event') eventrow = db(db.evt.id == eventid).select().first() quests, nodes, links, resultstring = getd3graph('event', eventid, eventrow.status, 1, eventlevel, parentquest) # set if moves on the diagram are written back - only owner for now if auth.user and eventrow.evt_owner == auth.user.id: editable = 'true' else: editable = 'false' session.eventid = eventid session.projid = eventrow.projid return dict(resultstring=resultstring, eventrow=eventrow, eventid=eventid, eventmap=quests, eventowner=editable, links=links, nodes=nodes, projid=eventrow.projid, eventrowid=eventrow.id, redraw=redraw,eventlevel=eventlevel,parquest=parquest)