Beispiel #1
0
 def getNodeInfo(self):
     out = {"res":[]}
     if request.method == 'POST':
         q = request.POST.get('node')
         d = Session.query(
                     Dump.id.label('id'),\
                     Dump.name.label('name'),\
                     Dump.description.label('description'),\
                     Dump.history.label('history'),\
                     Dump.longitude.label('longitude'),\
                     Dump.latitude.label('latitude'),\
                     Comune.denominazione.label('com'),\
                     Comune.descrizione_provincia.label('prov')\
                     ).join(Comune).filter(Dump.id == q)
         r = d.one()
         out =   {"id":str(r.id),\
                  "title":r.name,\
                  "desc":r.description,\
                  "history":r.history,\
                  "longitude":str(r.longitude),\
                  "latitude":str(r.latitude),\
                  "com":r.com,\
                  "prov":r.prov\
                 }
         return out
Beispiel #2
0
 def getCoords(self):
     out = {"res": []}
     if request.method == "GET":
         q = request.GET.get("input")
         d = Session.query(Dump)
         res = d.all()
         out = {
             "res": [
                 {"id": str(r.id), "title": r.name, "longitude": str(r.longitude), "latitude": str(r.latitude)}
                 for r in res
             ]
         }
         return out
Beispiel #3
0
 def getCoords(self):
     out = {"res":[]}
     if request.method == 'GET':
         q = request.GET.get('input')
         d = Session.query(Dump)
         res = d.all()
         out = {"res":[\
                 {"id":str(r.id),\
                  "title":r.name,\
                  "longitude":str(r.longitude),\
                  "latitude":str(r.latitude)\
                 } for r in res ]}
         return out
Beispiel #4
0
    def submit(self):
        """
        Verify username and password
        """
        # Both fields filled?
        form_username = str(request.params.get('username'))
        form_password = str(request.params.get('password'))

        # Get user data from database
        s = Session()
        rset = s.query(User).filter(User.username == form_username).all()
        if len(rset) < 1: # User does not exist
            return render('/login/loginindex.mako')

        usr = rset[0]
        cparts = usr.password.split('$')
        salt = cparts[2]
        oldmd = funcs.md5crypt(form_password, salt)
        
        # Wrong password? (MD5 hashes used here)
        if oldmd  != usr.password:
            c.loginerror = True
            return render('/login/loginindex.mako')

        cookie_string = funcs.simplemd5(form_username + request.environ['REMOTE_ADDR'])
        # should set the cookie based here
        response.set_cookie('discsleftnet', cookie_string, expires='3600')
     
        # Mark user as logged in
        session['user'] = form_username
        session['custid'] = usr.id
        session['cur_cookie'] = cookie_string
        session.save()

        # Send user back to the page he originally wanted to get to
        if session.get('path_before_login'):
            redirect(session['path_before_login'])
        else: # if previous target is unknown just send the user to a welcome page
            return render('/login/loggedin.mako')
Beispiel #5
0
 def agent_jac(self):
     out = {"res":[]}
     if request.method == 'GET':
         name = request.GET.get('input')
         ac_q = Session.query(Agent)
         try:
             res = ac_q.filter(Agent.name.like("%"+name+"%")).limit(15)
         except:
             return out
         else:
             out = {"res":[{"id":str(r.id), "name":r.name} for r in res]}
             return out
     else:
         return out
Beispiel #6
0
 def comuni_jac(self):
     out = {"res":[]}
     if request.method == 'GET':
         name = request.GET.get('input')
         ac_q = Session.query(Comune)
         try:
             res = ac_q.filter(Comune.denominazione.like("%"+name+"%")).limit(15)
         except:
             return out
         else:
             out = {"res":[{"id":str(r.id), "name":r.denominazione} for r in res]}
             return out
     else:
         return out
Beispiel #7
0
 def status_jac(self):
     out = {"res":[]}
     if request.method == 'GET':
         udesc = request.GET.get('input')
         ac_q = Session.query(Status)
         try:
             res = ac_q.filter(Status.description.like("%"+udesc+"%")).limit(15)
         except:
             return out
         else:
             out = {"res":[{"id":str(r.id), "desc":r.description} for r in res]}
             return out
     else:
         return out
Beispiel #8
0
 def dumptype_jac(self):
     out = {"res":[]}
     if request.method == 'GET':
         name = request.GET.get('input')
         ac_q = Session.query(DumpType)
         try:
             res = ac_q.filter(DumpType.type.like("%"+name+"%")).limit(15)
         except:
             return out
         else:
             out = {"res":[{"id":str(r.id), "type":r.type} for r in res]}
             return out
     else:
         return out
Beispiel #9
0
 def getNodeCer(self):
     out = {"res":[]}
     if request.method == 'POST':
         q = request.POST.get('node')
         d = Session.query(\
                 CerCode.code.label('cer_code'),\
                 CerCode.description.label('cer_desc'),
             ).\
             join(CerDump).\
             filter(CerDump.id_dump == q).order_by(CerCode.code.asc())
         res = d.all()
         out = {"res":[\
                 {"code":r.cer_code,\
                  "desc":r.cer_desc\
                 } for r in res ]}
         return out
Beispiel #10
0
 def cer_jac(self):
     out = {"res":[]}
     if request.method == 'GET':
         udesc = request.GET.get('input')
         ac_q = Session.query(CerCode)
         try:
             res = ac_q.filter(or_(CerCode.description.like('%'+udesc+'%'),CerCode.code.like("%"+udesc+"%"))).\
                     limit(20)
             #res = ac_q.filter(Cer.description.like("%"+udesc+"%")).\
             #        all().limit(30)
         except:
             return out
         else:
             out = {"res":[{"id":str(r.id), "desc":r.code+' '+r.description, "code":r.code} for r in res]}
             return out
     else:
         return out
Beispiel #11
0
 def getNodeBiblio(self):
     out = {"res":[]}
     if request.method == 'POST':
         q = request.POST.get('node')
         d = Session.query(\
                 BibMedia.description.label('bm_desc'),\
                 BibMedia.url.label('bm_url'),\
                 BibMedia.type.label('bm_type'),\
                 BibMedia.date_ref.label('bm_dref')\
             ).\
             filter(BibMedia.id_dump == q).order_by(BibMedia.date_ref.desc())
         res = d.all()
         out = {"res":[\
                 {"desc":r.bm_desc,\
                  "url":r.bm_url,\
                  "type":r.bm_type,\
                  "date":str(r.bm_dref.day)+"/"+str(r.bm_dref.month)+"/"+str(r.bm_dref.year)\
                 } for r in res ]}
         return out
Beispiel #12
0
 def getNodeQuantity(self):
     out = {"res":[]}
     if request.method == 'POST':
         q = request.POST.get('node')
         d = Session.query(\
                 Quantity.start_date.label('start_date'),\
                 Quantity.end_date.label('end_date'),
                 Quantity.notes.label('notes'),
                 Quantity.quantity.label('qty')\
             ).\
             filter(Quantity.id_dump == q).order_by(Quantity.start_date.desc())
         res = d.all()
         out = {"res":[\
                 {"sd":str(r.start_date.month)+'/'+str(r.start_date.year),\
                  "ed":(str(r.end_date.month)+'/'+str(r.end_date.year)) if r.end_date else None,\
                  "qty":r.qty,\
                  "notes":r.notes\
                 } for r in res ]}
         return out
Beispiel #13
0
 def getNodeAgent(self):
     out = {"res":[]}
     if request.method == 'POST':
         q = request.POST.get('node')
         d = Session.query(\
                 AgentDump.start_date.label('start_date'),\
                 AgentDump.end_date.label('end_date'),
                 AgentDump.notes.label('notes'),
                 Agent.name.label('name')\
             ).\
             join(Agent).\
             filter(AgentDump.id_dump == q).order_by(AgentDump.start_date.desc())
         res = d.all()
         out = {"res":[\
                 {"sd":str(r.start_date.month)+'/'+str(r.start_date.year),\
                  "ed":(str(r.end_date.month)+'/'+str(r.end_date.year)) if r.end_date else None,\
                  "name":r.name,\
                  "notes":r.notes\
                 } for r in res ]}
         return out
Beispiel #14
0
 def getNodeDest(self):
     out = {"res":[]}
     if request.method == 'POST':
         q = request.POST.get('node')
         d = Session.query(\
                 Reallocation.start_date.label('start_date'),\
                 Reallocation.end_date.label('end_date'),
                 Reallocation.notes.label('notes'),
                 DumpType.type.label('type')\
             ).\
             join(DumpType).\
             filter(Reallocation.id_dump == q).order_by(Reallocation.start_date.desc())
         res = d.all()
         out = {"res":[\
                 {"sd":str(r.start_date.month)+'/'+str(r.start_date.year),\
                  "ed":(str(r.end_date.month)+'/'+str(r.end_date.year)) if r.end_date else None,\
                  "type":r.type,\
                  "notes":r.notes\
                 } for r in res ]}
         return out
Beispiel #15
0
 def getNodeStatus(self):
     out = {"res":[]}
     if request.method == 'POST':
         q = request.POST.get('node')
         d = Session.query(\
                 StatusDump.start_date.label('start_date'),\
                 StatusDump.end_date.label('end_date'),
                 StatusDump.notes.label('notes'),
                 Status.description.label('desc')\
             ).\
             join(Status).\
             filter(StatusDump.id_dump == q).order_by(StatusDump.start_date.desc())
         res = d.all()
         out = {"res":[\
                 {"sd":str(r.start_date.month)+'/'+str(r.start_date.year),\
                  "ed":(str(r.end_date.month)+'/'+str(r.end_date.year)) if r.end_date else None,\
                  "desc":r.desc,\
                  "notes":r.notes\
                 } for r in res ]}
         return out
Beispiel #16
0
def init_model(engine):
    """Call me before using any of the tables or classes in the model"""
    Session.configure(bind=engine)