Exemplo n.º 1
0
 def getAssetDetails(self,  pid, assetname):
     ''' Retrieves an asset matching assetname '''
     # connect to database
     db = Database()
     db.open()
     # query to retrieve asset details
     assetname = common.getDbString( assetname )
     query = "SELECT pid, assetname, assettype FROM projectassets WHERE pid=%s AND assetname='%s' " % (pid, assetname)
         
     # get rows returned by query
     rows = db.execSelectQuery( query )
     
     # get asset details from record and assign to object attrbutes
     num = len(rows)
     if (num != 0):
         exists = True
         for row in rows:
            self.pid = pid
            self.name = common.getViewString( row[1] )
            self.type = common.getViewString( row[2] )
     else:
        exists = False
    
     # close database connection
     db.close()
     return exists
Exemplo n.º 2
0
 def getIncomeSourceDetails(self,  pid, incomesourcename):
     ''' Retrieves a incomesource object corresponding to the given incomesourcename from database '''
     # connect to database
     db = Database()
     db.open()
     # query to retrieve incomesource details
     incomesourcename = common.getDbString( incomesourcename )
     query = "SELECT pid, incomesource, incometype FROM projectincomesources WHERE pid=%s AND incomesource='%s' " % (pid, incomesourcename)
         
     # get rows returned by query
     rows = db.execSelectQuery( query )
     
     # get incomesource details from record and assign to object attrbutes
     num = len(rows)
     if (num != 0):
         exists = True
         for row in rows:
            self.pid = pid
            self.name = common.getViewString( row[1] )
            self.type = common.getViewString( row[2] )
     else:
        exists = False
    
     # close database connection
     db.close()
     return exists
Exemplo n.º 3
0
 def deleteProjectAsset(self,  assetname):
     ''' Remove an asset from project '''
     db = Database()
     db.open() 
     
     assetname = common.getDbString( assetname )
     query = "DELETE FROM projectassets WHERE pid=%s AND assetname='%s'" % (self.pid, assetname)
     db.execUpdateQuery( query )
         
     db.close()
Exemplo n.º 4
0
 def deleteIncomeSources(self,  incomesources):
     ''' Deletes incomesources matching names in the array incomesources from database '''
     db = Database()
     db.open() 
     
     for incomesourcename in incomesources:
         incomesourcename = common.getDbString( incomesourcename )
         query = "DELETE FROM projectincomesources WHERE pid=%s AND incomesource='%s'" % (self.pid, incomesourcename)
         db.execUpdateQuery( query )
         
     db.close()
Exemplo n.º 5
0
 def createAsset( self,  pid, assetname,  assettype ):
     ''' Adds a new incomesource object '''
     # connect to database
     db = Database()           
     db.open()
     
     # create INSERT INTO query
     assetname = common.getDbString( assetname )
     assettype = common.getDbString( assettype )
     query = '''INSERT INTO projectassets(pid,assetname,assettype) VALUES(%s,'%s','%s')''' % (pid,assetname,assettype)
    
     # execute query
     db.execUpdateQuery(query)
     
     # close database connection
     db.close()
    
     # set asset attributes to saved values
     self.name = common.getViewString( assetname )
     self.type = common.getViewString( assettype )
     self.pid = pid
Exemplo n.º 6
0
 def editData( self,  assetname,  assettype ):
     ''' edits the assetname and assettype of the asset object '''
     # connect to database
     db = Database()           
     db.open()
     
     # create INSERT INTO query
     assetname = common.getDbString( assetname )
     oldname = common.getDbString( self.name )
     assettype = common.getDbString( assettype )
     query = '''UPDATE projectassets SET assetname='%s', assettype='%s',
     WHERE pid=%s AND assetname='%s' ''' % (assetname, assettype, self.pid, oldname)
    
     # execute query
     db.execUpdateQuery(query)
     
     # close database connection
     db.close()
    
     # set asset attributes to saved values
     self.name = common.getViewString( assetname )
     self.type = common.getViewString( assettype )
Exemplo n.º 7
0
 def editIncomeSource( self,  incomesourcename,  incometype ):
     ''' edits the incomesourcename and category of the current incomesource object '''
     # connect to database
     db = Database()           
     db.open()
     
     # create INSERT INTO query
     incomesourcename = common.getDbString( incomesourcename )
     oldname = common.getDbString( self.name )
     incometype = common.getDbString( incometype )
     query = '''UPDATE projectincomesources SET incomesource='%s', incometype='%s',
     WHERE pid=%s AND incomesourcename='%s' ''' % (incomesourcename, incometype, self.pid, oldname)
    
     # execute query
     db.execUpdateQuery(query)
     
     # close database connection
     db.close()
    
     # set incomesource attributes to saved values
     self.name = common.getViewString( incomesourcename )
     self.type = common.getViewString( incometype )
Exemplo n.º 8
0
 def getIncomeSources(self, incometype=""):
     ''' Retrieves all incomesources from the database and returns an array of incomesource objects '''
     
     # create filtering condition		 
     incometype = common.getDbString( incometype )
     condition = "AND incometype LIKE '%"+incometype+"%' " if incometype != "" else ""
         
     query = "SELECT incomesource FROM projectincomesources WHERE pid=%s %s ORDER BY incomesource" % (self.pid, condition)
     
     db = Database()
     db.open() 
     records = db.execSelectQuery( query )
     
     incomesources = []
     for rec in records:
        incomesourcename = rec[0]
        incomesource = IncomeSource(self.pid, incomesourcename)
        incomesources.append( incomesource )
        
     db.close()
     return incomesources
Exemplo n.º 9
0
 def getProjectAssets(self, assettype=""):
     ''' Retrieves all project assets from the database and returns an array of project asset objects '''
     
     # create filtering condition		 
     assettype = common.getDbString( assettype )
     condition = "AND assettype LIKE '%"+assettype+"%' " if assettype != "" and assettype != "All" else ""
         
     query = "SELECT assetname, assettype FROM projectassets WHERE pid=%s %s ORDER BY assettype, assetname" % (self.pid, condition)
     
     db = Database()
     db.open() 
     records = db.execSelectQuery( query )
     
     assets = []
     for rec in records:
        assetname = rec[0]
        projectasset = ProjectAsset(self.pid, assetname)
        assets.append( projectasset )
        
     db.close()
     return assets