| 1 |
"""
|
| 2 |
|
| 3 |
MCP_Console
|
| 4 |
|
| 5 |
Created by
|
| 6 |
Emanuel Borges
|
| 7 |
08.28.2010
|
| 8 |
|
| 9 |
This will be the interface to add, edit and archive cases.
|
| 10 |
|
| 11 |
Should this work as one large GUI and you pick the below or read from argv and let you
|
| 12 |
just call it with what you want, making these three look like separate apps.
|
| 13 |
|
| 14 |
|
| 15 |
"""
|
| 16 |
|
| 17 |
import MCP_Lib,os,shutil,ConcordanceHelperTools, time,directorySize2
|
| 18 |
|
| 19 |
class MainConsole:
|
| 20 |
def __init__(self):
|
| 21 |
## Gather the case list
|
| 22 |
|
| 23 |
print "connecting to matter tracking access db..."
|
| 24 |
## Production version
|
| 25 |
self.accessDB = MCP_Lib.AccessDBConnection(r"\\chiads01\app\DS_CaseTrack\TPM_CaseTracking.mdb")
|
| 26 |
self.tPMName, self.tPMID, self.tPMOffice = MCP_Lib.GetTPMInfo()
|
| 27 |
#responsibleCases,casesDir = MCP_Lib.GetCaseList('',self.accessDB)
|
| 28 |
myCases, myActiveCases,officeCases, allCases,casesDir= MCP_Lib.GetCaseList('',self.accessDB)
|
| 29 |
|
| 30 |
## Testing version
|
| 31 |
#self.accessDB = MCP_Lib.AccessDBConnection(r"W:\Manny\testing\TPM_CaseTracking.mdb")
|
| 32 |
#responsibleCases,casesDir = MCP_Lib.GetCaseList(r"C:\Documents and Settings\eborges\My Documents\My Dropbox\Dev\Python\NinoCode\Active_prgs\Concordance\MCP",self.accessDB)
|
| 33 |
#self.tPMName, self.tPMID, self.tPMOffice = MCP_Lib.GetTPMInfo(r"C:\Documents and Settings\eborges\My Documents\My Dropbox\Dev\Python\NinoCode\Active_prgs\Concordance\MCP")
|
| 34 |
|
| 35 |
print "connected to DB."
|
| 36 |
|
| 37 |
self.responsibleCasesList = myCases
|
| 38 |
self.casesDir = casesDir
|
| 39 |
|
| 40 |
|
| 41 |
def AddNewCase(self, caseName, clientMatter, chargable = False, reviewPlatform = "", responsibleProcessingVendor = "",
|
| 42 |
responsibleScanningVendor = "",responsibleHostingVendor = ""):
|
| 43 |
## TODO: add a verification somehwere where it verify that the proposed name does not include characters that cant be used in a folder name.
|
| 44 |
## Add the local folders The GUI should test that the clm is 10 digits and has hyphen.
|
| 45 |
template = os.path.join(self.casesDir,'_Template_')
|
| 46 |
new = os.path.join(self.casesDir, caseName + '_(%s)'%clientMatter)
|
| 47 |
if os.path.exists(new):
|
| 48 |
print "ERROR: This case already exists!!"
|
| 49 |
else:
|
| 50 |
#print template
|
| 51 |
#print new
|
| 52 |
os.mkdir(new)
|
| 53 |
for file in os.listdir(template):
|
| 54 |
shutil.copy2(os.path.join(template,file),new)
|
| 55 |
## Check the H drive for the supplemental folders and the matter folder, only if they select Concordance.
|
| 56 |
self.SetCaseNameAndCLM(caseName,clientMatter)
|
| 57 |
self.AddCaseToAccessDB(caseName,clientMatter)
|
| 58 |
|
| 59 |
def ChangeCaseName(self,caseName,newCaseName,newClientMatter):
|
| 60 |
"""This method will allow for editing the case name and number. This is different than settign the casename"""
|
| 61 |
## Test that there is only one entry for this clm in access.
|
| 62 |
clientMatter = caseName.split("_(")[1]
|
| 63 |
clientMatter = clientMatter[:-1]
|
| 64 |
clientMatter = clientMatter.replace('-','.')
|
| 65 |
accessCaseName = self.accessDB.GetCaseName(clientMatter)
|
| 66 |
localCasesPath = self.casesDir
|
| 67 |
if os.path.exists(os.path.join(localCasesPath,caseName)):
|
| 68 |
if clientMatter != newClientMatter:
|
| 69 |
if newCaseName != caseName.split("_("):
|
| 70 |
## change both
|
| 71 |
self.accessDB.UpdateCaseName(clientMatter,newCaseName)
|
| 72 |
self.accessDB.UpdateClientMatterNum(clientMatter,newClientMatter)
|
| 73 |
os.rename(os.path.join(localCasesPath,caseName),os.path.join(localCasesPath,newCaseName + '_(%s)'%newClientMatter.replace(".","-")))
|
| 74 |
else:
|
| 75 |
## change just client matter
|
| 76 |
self.accessDB.UpdateClientMatterNum(clientMatter,newClientMatter)
|
| 77 |
os.rename(os.path.join(localCasesPath,caseName),os.path.join(localCasesPath,caseName + '_(%s)'%newClientMatter.replace(".","-")))
|
| 78 |
elif newCaseName != caseName.split("_("):
|
| 79 |
## change just the casename
|
| 80 |
self.accessDB.UpdateCaseName(clientMatter,newCaseName)
|
| 81 |
os.rename(os.path.join(localCasesPath,caseName),os.path.join(localCasesPath,newCaseName + '_(%s)'%clientMatter.replace(".","-")))
|
| 82 |
|
| 83 |
## verify that the proposed name does not include characters that cant be used in a folder name.
|
| 84 |
## Change the name and or clm in access
|
| 85 |
|
| 86 |
## Test that it was changed in access
|
| 87 |
## change the folder name in cases.
|
| 88 |
else:
|
| 89 |
## That case dir cant be found. They can't change other's casenames.
|
| 90 |
err = 1
|
| 91 |
|
| 92 |
|
| 93 |
def AddCaseToAccessDB(self, caseName):
|
| 94 |
## First test to see if it's already in the DB.
|
| 95 |
fullClientMatterList = self.accessDB.RetrieveAllCaseList()
|
| 96 |
clientMatter = clientMatter.replace("-",".")
|
| 97 |
if clientMatter in fullClientMatterList:
|
| 98 |
print "This client matter already exists in the database. Skipping."
|
| 99 |
else:
|
| 100 |
print "New client matter. Adding."
|
| 101 |
self.accessDB.AddNewCase(caseName, clientMatter, self.tPMName,self.tPMID,responsibleOffice = self.tPMOffice)
|
| 102 |
print "Added!"
|
| 103 |
|
| 104 |
def EditCaseData(self,caseName,chargeableBool,respAttorney,respParalegal,respVendorTpl,revPlatform,respTPM,respOffice, caseStatus):
|
| 105 |
clientMatter = caseName.split("_(")[1]
|
| 106 |
clientMatter = clientMatter[:-1]
|
| 107 |
clientMatter = clientMatter.replace('-','.')
|
| 108 |
self.accessDB.UpdateChargable(clientMatter,chargeableBool)
|
| 109 |
self.accessDB.UpdateResponsibleAttorney(clientMatter,respAttorney)
|
| 110 |
self.accessDB.UpdateResponsibleParalegal(clientMatter,respParalegal)
|
| 111 |
self.accessDB.UpdateReviewPlatform(clientMatter,revPlatform)
|
| 112 |
self.accessDB.UpdateResponsibleTPM(clientMatter,respTPM)
|
| 113 |
self.accessDB.UpdatePrimaryOffice(clientMatter,respOffice)
|
| 114 |
self.accessDB.UpdateResponsibleVendors(clientMatter,respVendorTpl)
|
| 115 |
self.accessDB.UpdateCaseStatus(clientMatter, caseStatus)
|
| 116 |
|
| 117 |
def GetCaseData(self, caseName):
|
| 118 |
#use this to get the data on the selected case, to populate your GUI
|
| 119 |
clientMatter = caseName.split("_(")[1]
|
| 120 |
clientMatter = clientMatter[:-1]
|
| 121 |
clientMatter = clientMatter.replace('-','.')
|
| 122 |
chargeableBool = self.accessDB.GetChargable(clientMatter)
|
| 123 |
respAttorney = self.accessDB.GetResponsibleAttorney(clientMatter)
|
| 124 |
respParalegal = self.accessDB.GetResponsibleParalegal(clientMatter)
|
| 125 |
respVendorTpl = self.accessDB.GetResponsibleVendorTpl(clientMatter)
|
| 126 |
revPlatform = self.accessDB.GetReviewPlatform(clientMatter)
|
| 127 |
respTPM = self.accessDB.GetResponsibleTPM(clientMatter)
|
| 128 |
respOffice = self.accessDB.GetPrimaryOffice(clientMatter)
|
| 129 |
caseStatus = self.accessDB.GetCaseStatus(clientMatter)
|
| 130 |
uploadCost = self.accessDB.GetUploadCostRate(clientMatter)
|
| 131 |
storageCost = self.accessDB.GetStorageCostRate(clientMatter)
|
| 132 |
disclosureLetterBool,disclosureLetterPath = self.accessDB.GetDisclosureLetter(clientMatter)
|
| 133 |
return (chargeableBool,respAttorney,respParalegal,respVendorTpl,revPlatform,respTPM,respOffice,caseStatus,uploadCost,storageCost,disclosureLetterBool)
|
| 134 |
|
| 135 |
def GetPossibleProducedToEntities(self,caseName):
|
| 136 |
"""Returns the possible produced to entities for a case"""
|
| 137 |
clientMatter = caseName.split("_(")[1]
|
| 138 |
clientMatter = clientMatter[:-1]
|
| 139 |
clientMatter = clientMatter.replace('-','.')
|
| 140 |
possibleProducedToEntities = self.accessDB.GetProducedToEntities(clientMatter)
|
| 141 |
return possibleProducedToEntities
|
| 142 |
|
| 143 |
def GetPossibleProdReqByNames(self,caseName):
|
| 144 |
"""Returns the possible requested by names for a case"""
|
| 145 |
clientMatter = caseName.split("_(")[1]
|
| 146 |
clientMatter = clientMatter[:-1]
|
| 147 |
clientMatter = clientMatter.replace('-','.')
|
| 148 |
possibleProdReqByNames = self.accessDB.GetProductionRequestedByNames(clientMatter)
|
| 149 |
return possibleProdReqByNames
|
| 150 |
|
| 151 |
|
| 152 |
def AddProductionEntry(self, CLM,prodID,prodProcessedDate,begBates,endBates,prodDocCount, prodPageCount, prodNotes, prodTo, prodMedia,prodSource,prodReqBy,prodSentDate,prodMediaPassword):
|
| 153 |
"""This method adds one production entry to the case."""
|
| 154 |
errRpt = True
|
| 155 |
if CLM:
|
| 156 |
if prodID:
|
| 157 |
if prodProcessedDate:
|
| 158 |
if begBates:
|
| 159 |
if endBates:
|
| 160 |
if prodDocCount:
|
| 161 |
if prodPageCount:
|
| 162 |
if prodNotes:
|
| 163 |
self.accessDB.UpdateProductionDetail(CLM,prodID,prodProcessedDate,begBates,endBates,prodDocCount, prodPageCount, prodNotes, prodTo, prodMedia,prodSource,prodReqBy,prodSentDate,prodMediaPassword)
|
| 164 |
errRpt = False
|
| 165 |
return errRpt
|
| 166 |
|
| 167 |
def AddDataUpload(self,CLM, reviewPlatform, reportSize):
|
| 168 |
"""This method will add one case upload."""
|
| 169 |
## TODO: one day change it so that copy up requst calls this instead
|
| 170 |
## of it being internal to that prog.
|
| 171 |
epoch = str(int(time.time()))
|
| 172 |
self.accessDB.UpdateCaseUpload(CLM,reviewPlatform,{epoch:(time.strftime('%m/%d/%Y'),reportSize)})
|
| 173 |
|
| 174 |
def RemoveDataUpload(self,CLM,UEPOCH):
|
| 175 |
"""This method calls DeleteCaseUpload and removes just one case upload. """
|
| 176 |
err = self.accessDB.DeleteCaseUpload(CLM,UEPOCH)
|
| 177 |
if err:
|
| 178 |
print "ERROR: An Error occured and this value was not removed!"
|
| 179 |
else:
|
| 180 |
print "%s Removed"% UEPOCH
|
| 181 |
|
| 182 |
def GetUploadData(self, caseName):
|
| 183 |
# Used to get upload data, on the selected case, to populate the upload dialog
|
| 184 |
clientMatter = caseName.split("_(")[1]
|
| 185 |
clientMatter = clientMatter[:-1]
|
| 186 |
clientMatter = clientMatter.replace('-','.')
|
| 187 |
uploadList = self.accessDB.RetrieveUploadsByCLM(clientMatter)
|
| 188 |
return uploadList
|
| 189 |
|
| 190 |
def GetProductionData(self,caseName):
|
| 191 |
clientMatter = caseName.split("_(")[1]
|
| 192 |
clientMatter = clientMatter[:-1]
|
| 193 |
clientMatter = clientMatter.replace('-','.')
|
| 194 |
productionMatrix = self.accessDB.RetrieveProductionsByCLM(clientMatter)
|
| 195 |
return productionMatrix
|
| 196 |
|
| 197 |
def GetProductionTotal(self,productionList):
|
| 198 |
"""Using the above productionList, this returns the total docs and pages produced"""
|
| 199 |
pgCountTotal = 0
|
| 200 |
docCountTotal = 0
|
| 201 |
for i in productionList:
|
| 202 |
pageCount = i[-7]
|
| 203 |
docCount = i[-8]
|
| 204 |
if 'None' in pageCount:
|
| 205 |
pass
|
| 206 |
else:
|
| 207 |
#print pageCount
|
| 208 |
pgCountTotal = pgCountTotal+int(pageCount)
|
| 209 |
if 'None' in pageCount:
|
| 210 |
pass
|
| 211 |
else:
|
| 212 |
#print docCount
|
| 213 |
docCountTotal = docCountTotal+int(docCount)
|
| 214 |
return pgCountTotal,docCountTotal
|
| 215 |
|
| 216 |
def ExportProductionDataToExcel(self,CaseName,pathToCSV):
|
| 217 |
"""Exports the production data to a csv file"""
|
| 218 |
productionList = self.GetProductionData(CaseName)
|
| 219 |
#print productionList
|
| 220 |
outputFile = open(pathToCSV,'w')
|
| 221 |
outputFile.write('Production ID,Production Completed Date,Production Sent Date,Start Bates,End Bates,Document Count,Page Count,Produced To,Requested By,Production Media,ProductionMediaPassword,Production Sources,Notes\n')
|
| 222 |
for i in productionList:
|
| 223 |
for x in i:
|
| 224 |
outputFile.write(x+",")
|
| 225 |
outputFile.write("\n")
|
| 226 |
outputFile.close()
|
| 227 |
|
| 228 |
def GetUploadTotal(self,uploadList):
|
| 229 |
""" Using the above uploadList, this will return the total uploaded """
|
| 230 |
count = 0.
|
| 231 |
for i in uploadList:
|
| 232 |
size = i[-1]
|
| 233 |
|
| 234 |
if 'None' in size:
|
| 235 |
pass
|
| 236 |
else:
|
| 237 |
rawSize = directorySize2.prettyToUnpretty_Filesize(size)
|
| 238 |
count = count + rawSize
|
| 239 |
prettySizeFinal = directorySize2.pretty_filesize2(count)
|
| 240 |
return prettySizeFinal
|
| 241 |
|
| 242 |
def MakeCaseDormant(self, caseAndCLM):
|
| 243 |
"""Moves the case to the Dormant folder"""
|
| 244 |
## Dont do this, just hide from your view. Once archived, move off share.
|
| 245 |
print "Making %s case dormant..."
|
| 246 |
os.rename(os.path.join(self.casesDir,caseAndCLM),os.path.join(self.casesDir,os.path.join('zzzz_dormant_', caseAndCLM)))
|
| 247 |
print "Case has been archived."
|
| 248 |
|
| 249 |
|
| 250 |
def ViewCaseNotes(self,caseName,office):
|
| 251 |
"""Trys to open the case notes file,in the case folder, for the active case, regardless who owns it."""
|
| 252 |
caseFolderLocation = MCP_Lib.GetOtherCaseFolder(office)
|
| 253 |
clientMatter = caseName.split("_(")[1]
|
| 254 |
clientMatter = clientMatter[:-1]
|
| 255 |
if "." in clientMatter:
|
| 256 |
clientMatter = clientMatter.replace('.','-')
|
| 257 |
folderMatrix = {}
|
| 258 |
#caseFolderLocation = os.path.join(caseFolderLocation,case)
|
| 259 |
err = False
|
| 260 |
if caseFolderLocation:
|
| 261 |
if os.path.exists(caseFolderLocation):
|
| 262 |
for f in os.listdir(caseFolderLocation):
|
| 263 |
if "_(" in f:
|
| 264 |
folderClientMatter = f.split("_(")[1]
|
| 265 |
folderClientMatter = folderClientMatter[:-1]
|
| 266 |
folderMatrix[folderClientMatter] = f
|
| 267 |
try:
|
| 268 |
folderName = folderMatrix[clientMatter]
|
| 269 |
os.startfile(os.path.join(caseFolderLocation, folderName)+"/Gen_Notes.txt")
|
| 270 |
except:
|
| 271 |
err = True
|
| 272 |
else:
|
| 273 |
err = True
|
| 274 |
else:
|
| 275 |
print "A case folder for this case was not found."
|
| 276 |
err = True
|
| 277 |
return err
|
| 278 |
|
| 279 |
def ViewProdSpec(self,caseName,office):
|
| 280 |
"""Trys to open the prod spec file,in the case folder, for the active case, regardless who owns it."""
|
| 281 |
caseFolderLocation = MCP_Lib.GetOtherCaseFolder(office)
|
| 282 |
clientMatter = caseName.split("_(")[1]
|
| 283 |
clientMatter = clientMatter[:-1]
|
| 284 |
if "." in clientMatter:
|
| 285 |
clientMatter = clientMatter.replace('.','-')
|
| 286 |
folderMatrix = {}
|
| 287 |
#caseFolderLocation = os.path.join(caseFolderLocation,case)
|
| 288 |
err = False
|
| 289 |
if caseFolderLocation:
|
| 290 |
if os.path.exists(caseFolderLocation):
|
| 291 |
for f in os.listdir(caseFolderLocation):
|
| 292 |
if "_(" in f:
|
| 293 |
folderClientMatter = f.split("_(")[1]
|
| 294 |
folderClientMatter = folderClientMatter[:-1]
|
| 295 |
folderMatrix[folderClientMatter] = f
|
| 296 |
try:
|
| 297 |
folderName = folderMatrix[clientMatter]
|
| 298 |
os.startfile(os.path.join(caseFolderLocation, folderName+"/Production_Spec.txt"))
|
| 299 |
except:
|
| 300 |
err = True
|
| 301 |
else:
|
| 302 |
err = True
|
| 303 |
else:
|
| 304 |
print "A case folder for this case was not found."
|
| 305 |
err = True
|
| 306 |
return err
|
| 307 |
|
| 308 |
def CreateProductionReport(self,caseName,office):
|
| 309 |
"""Creates a html production report in the altMediaPath folder"""
|
| 310 |
err = False
|
| 311 |
clientMatter = caseName.split("_(")[1]
|
| 312 |
clientMatter = clientMatter[:-1]
|
| 313 |
clientMatter = clientMatter.replace('-','.')
|
| 314 |
altMediaPath = self.accessDB.GetAlternateMediaPath(clientMatter)
|
| 315 |
productionMatrix = self.GetProductionData(caseName)
|
| 316 |
if os.path.exists(os.path.join(altMediaPath,'__MCP_Data')):
|
| 317 |
pass
|
| 318 |
else:
|
| 319 |
os.mkdir(os.path.join(altMediaPath,'__MCP_Data'))
|
| 320 |
reportFile = open(os.path.join(os.path.join(altMediaPath,'__MCP_Data'),'MCP_Production_Report.html'),'w')
|
| 321 |
reportFile.write('''<html>\n<head>\n <title>MCP: %s Production Report</title>\n <style type="text/css" media="screen">\n\n'''%caseName)
|
| 322 |
reportFile.write(r'''div#Rsidebar {
|
| 323 |
float: right;
|
| 324 |
width: 20%;
|
| 325 |
}
|
| 326 |
div#Lsidebar {
|
| 327 |
float: left;
|
| 328 |
width:20%;
|
| 329 |
height:380px;
|
| 330 |
}
|
| 331 |
|
| 332 |
</style>''')
|
| 333 |
reportFile.write('''
|
| 334 |
<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
|
| 335 |
<meta name="author" content="Emanuel Borges">
|
| 336 |
</head>
|
| 337 |
<body>
|
| 338 |
|
| 339 |
<h3><br>
|
| 340 |
</h3>
|
| 341 |
<center><h2>%s Production Report</h2></center>'''%caseName)
|
| 342 |
reportFile.write(r'''<center><hr width="40%"></center>''')
|
| 343 |
for k in productionMatrix.keys():
|
| 344 |
productionList = productionMatrix[k]
|
| 345 |
reportFile.write("<h4>%s Productions</h3>" % k)
|
| 346 |
reportFile.write('''<center><table border=1 cellspacing=0 cellpadding=5 width=1800>\n<tr><th>Production ID</th><th>Processed Date</th><th>Sent Date</th><th>Start Bates</th><th>End Bates</th><th>Document Count</th><th>Page Count</th><th>Requested By</th><th>Production Media</th><th>Media Password</th><th>Production Sources</th><th>Notes</th></tr>''')
|
| 347 |
for i in productionList:
|
| 348 |
reportFile.write("<tr>")
|
| 349 |
count = 1
|
| 350 |
for x in i:
|
| 351 |
if count == 8:
|
| 352 |
count = count + 1
|
| 353 |
else:
|
| 354 |
reportFile.write("<td>%s</td>"%x)
|
| 355 |
count = count +1
|
| 356 |
reportFile.write("</tr>")
|
| 357 |
|
| 358 |
reportFile.write('</table></center>\n\n')
|
| 359 |
reportFile.write('''<div id="footer">
|
| 360 |
<p><span>© 2012 <a href="#">Emanuel Borges</a></span><br />
|
| 361 |
Website automatically generated by the MCP program.</p></div>''')
|
| 362 |
reportFile.write('</body></html>\n')
|
| 363 |
reportFile.close()
|
| 364 |
return err
|
| 365 |
|
| 366 |
def OpenAlternateMediaFolder(self,caseName,office,testOnly=False):
|
| 367 |
"""Trys to open the Alternate media folder, for the active case, regardless who owns it.
|
| 368 |
If testOnly is set to True, it will only test that it exists and not open the folder."""
|
| 369 |
clientMatter = caseName.split("_(")[1]
|
| 370 |
clientMatter = clientMatter[:-1]
|
| 371 |
clientMatter = clientMatter.replace('-','.')
|
| 372 |
altMediaPath = self.accessDB.GetAlternateMediaPath(clientMatter)
|
| 373 |
err = False
|
| 374 |
if altMediaPath:
|
| 375 |
if os.path.exists(altMediaPath):
|
| 376 |
if testOnly:
|
| 377 |
pass
|
| 378 |
else:
|
| 379 |
os.startfile(altMediaPath)
|
| 380 |
else:
|
| 381 |
print "An alternate media folder for this case was not found."
|
| 382 |
err = True
|
| 383 |
else:
|
| 384 |
err = True
|
| 385 |
return err
|
| 386 |
|
| 387 |
def SetAlternateMediaFolder(self,caseName,altMediaPath):
|
| 388 |
"""Sets the alternate Media Path"""
|
| 389 |
clientMatter = caseName.split("_(")[1]
|
| 390 |
clientMatter = clientMatter[:-1]
|
| 391 |
clientMatter = clientMatter.replace('-','.')
|
| 392 |
self.accessDB.UpdateAlternateMediaPath(clientMatter,altMediaPath)
|
| 393 |
|
| 394 |
def GetVendorFolders(self,caseName):
|
| 395 |
"""Returns the current list of vendor folders, for one case"""
|
| 396 |
clientMatter = caseName.split("_(")[1]
|
| 397 |
clientMatter = clientMatter[:-1]
|
| 398 |
clientMatter = clientMatter.replace('-','.')
|
| 399 |
vendorFolders = self.accessDB.GetVendorFolderPath(clientMatter)
|
| 400 |
#print "V%s "%vendorFolders
|
| 401 |
return vendorFolders
|
| 402 |
|
| 403 |
def SetVendorFolders(self,caseName, vendorFolders):
|
| 404 |
"""Sets the Vendor Folder"""
|
| 405 |
clientMatter = caseName.split("_(")[1]
|
| 406 |
clientMatter = clientMatter[:-1]
|
| 407 |
clientMatter = clientMatter.replace('-','.')
|
| 408 |
self.accessDB.UpdateVendorFolderPath(clientMatter,vendorFolders)
|
| 409 |
|
| 410 |
def GetVendorFoldersList(self):
|
| 411 |
"""Returns a list of all vendorFolders"""
|
| 412 |
## Change this so that it actually grabs the current ones from ln. Dont know if I should grab from a table in access.
|
| 413 |
vendorFolderList = ["None"]
|
| 414 |
for n in range(1,61):
|
| 415 |
vendorFolderList.append("mwevendor%0*d"%(2,n))
|
| 416 |
return vendorFolderList
|
| 417 |
|
| 418 |
def GetDisclosureLetterData(self,caseName):
|
| 419 |
"""Returns the the bool of if a case has a disclosure letter and if so the path."""
|
| 420 |
clientMatter = caseName.split("_(")[1]
|
| 421 |
clientMatter = clientMatter[:-1]
|
| 422 |
clientMatter = clientMatter.replace('-','.')
|
| 423 |
disclosureLetterSet, disclosureLetterPath = self.accessDB.GetDisclosureLetter(clientMatter)
|
| 424 |
return disclosureLetterSet, disclosureLetterPath
|
| 425 |
|
| 426 |
def SetDisclosureLetterData(self,caseName,disclosureLetterPath):
|
| 427 |
"""Sets the disclosure letter path and checks it as true in the database"""
|
| 428 |
clientMatter = caseName.split("_(")[1]
|
| 429 |
clientMatter = clientMatter[:-1]
|
| 430 |
clientMatter = clientMatter.replace('-','.')
|
| 431 |
self.accessDB.UpdateDisclosureLetter(clientMatter,True,disclosureLetterPath)
|
| 432 |
|
| 433 |
def GetCasePathsData(self,caseName, office):
|
| 434 |
clientMatter = caseName.split("_(")[1]
|
| 435 |
clientMatter = clientMatter[:-1]
|
| 436 |
clientMatter = clientMatter.replace('-','.')
|
| 437 |
altMediaPath = self.accessDB.GetAlternateMediaPath(clientMatter)
|
| 438 |
caseFolderLocation = MCP_Lib.GetOtherCaseFolder(office)
|
| 439 |
caseFolderLocation = os.path.join(caseFolderLocation,caseName)
|
| 440 |
return altMediaPath, caseFolderLocation
|
| 441 |
|
| 442 |
def SetUploadAndStorageCosts(self, caseName,uploadCost,storageCost):
|
| 443 |
clientMatter = caseName.split("_(")[1]
|
| 444 |
clientMatter = clientMatter[:-1]
|
| 445 |
clientMatter = clientMatter.replace('-','.')
|
| 446 |
if uploadCost:
|
| 447 |
self.accessDB.UpdateUploadCostRate(clientMatter,uploadCost)
|
| 448 |
if storageCost:
|
| 449 |
self.accessDB.UpdateStorageCostRate(clientMatter,storageCost)
|
| 450 |
|
| 451 |
def OpenCaseFolder(self,caseName,office):
|
| 452 |
"""Trys to open the case folder for the active case, regardless who owns it."""
|
| 453 |
caseFolderLocation = MCP_Lib.GetOtherCaseFolder(office)
|
| 454 |
clientMatter = caseName.split("_(")[1]
|
| 455 |
clientMatter = clientMatter[:-1]
|
| 456 |
if "." in clientMatter:
|
| 457 |
clientMatter = clientMatter.replace('.','-')
|
| 458 |
folderMatrix = {}
|
| 459 |
#caseFolderLocation = os.path.join(caseFolderLocation,case)
|
| 460 |
err = False
|
| 461 |
if caseFolderLocation:
|
| 462 |
if os.path.exists(caseFolderLocation):
|
| 463 |
for f in os.listdir(caseFolderLocation):
|
| 464 |
if "_(" in f:
|
| 465 |
folderClientMatter = f.split("_(")[1]
|
| 466 |
folderClientMatter = folderClientMatter[:-1]
|
| 467 |
folderMatrix[folderClientMatter] = f
|
| 468 |
try:
|
| 469 |
folderName = folderMatrix[clientMatter]
|
| 470 |
os.startfile(os.path.join(caseFolderLocation, folderName))
|
| 471 |
except:
|
| 472 |
err = True
|
| 473 |
else:
|
| 474 |
err = True
|
| 475 |
else:
|
| 476 |
print "A case folder for this case was not found."
|
| 477 |
err = True
|
| 478 |
return err
|
| 479 |
|
| 480 |
|
| 481 |
def SetCaseNameAndCLM(self, newCaseName, newClientMatterNumber):
|
| 482 |
"""Used when setting up a new case. Should have both or nothing"""
|
| 483 |
self.caseName = newCaseName
|
| 484 |
self.clientMatter = newClientMatterNumber
|
| 485 |
#print self.clientMatter
|
| 486 |
|
| 487 |
def SetChargableCase(self, chargBool):
|
| 488 |
"""sets or clears the chargable case settings"""
|
| 489 |
pass
|
| 490 |
def SetResponsibleVendor(self, vendorInfo):
|
| 491 |
"""Sets the vendor name that is responsible for the case"""
|
| 492 |
pass
|
| 493 |
def SetReviewPlatform(self, reviewPlatform):
|
| 494 |
"""Sets the review platform chosen for this case"""
|
| 495 |
if reviewPlatform == "Concordance":
|
| 496 |
print "Concordance selected. Creating DIS directories..."
|
| 497 |
hDrivePath = ConcordanceHelperTools.ParseClientMatter(self.clientMatter)
|
| 498 |
os.mkdir(hDrivePath)
|
| 499 |
print "Matter folder created."
|
| 500 |
os.mkdir(os.path.join(hDrivePath,'Match'))
|
| 501 |
os.mkdir(os.path.join(hDrivePath,'Tag_Databases'))
|
| 502 |
print "Supplemental folders created."
|
| 503 |
print "DIS directories done!"
|
| 504 |
|
| 505 |
def GetDatabaseList(self,caseName):
|
| 506 |
"""Returns the list of databases in the database list file."""
|
| 507 |
return ['datbase1','database2','database3']
|
| 508 |
|
| 509 |
def SyncWithAccessDB(self,case = 'ALL'):
|
| 510 |
"""Syncs your cases with the access database. This might only get run once when you first install
|
| 511 |
the program though..."""
|
| 512 |
## So this syncs 'your' databases only. even though you are looking at a list of eeryone's databases
|
| 513 |
## it will only sync yours. even if you did an upload for another tpm, that wouldnt get synced unles
|
| 514 |
## the owner did a sync all. for 2 way sync to work, you should check, in access, that they have the case name
|
| 515 |
## (with no funky characters) populated, before they run this for the first time.
|
| 516 |
if case == 'ALL':
|
| 517 |
## verify that all your cases are up there, if not add it. but have support for cases where is should be
|
| 518 |
## yours but is assigned to someone else...
|
| 519 |
fullClientMatterList = self.accessDB.RetrieveAllCaseList()
|
| 520 |
myAccessClientMatterList = self.accessDB.RetrieveMyCaseList(self.tPMID)
|
| 521 |
myLocalClientMatterList = []
|
| 522 |
|
| 523 |
## Sync cases from my local to access
|
| 524 |
for case in self.responsibleCasesList:
|
| 525 |
localCaseName,clientMatter = case.split("_(")
|
| 526 |
clientMatter = clientMatter.replace(")","")
|
| 527 |
clientMatter = clientMatter.replace("-",".")
|
| 528 |
myLocalClientMatterList.append(clientMatter)
|
| 529 |
for clm in myLocalClientMatterList:
|
| 530 |
if clm in myAccessClientMatterList:
|
| 531 |
print "%s exists"% clm
|
| 532 |
elif clm in fullClientMatterList:
|
| 533 |
print "%s cant be added to your cases because it's owned by someone else..."% clm
|
| 534 |
else:
|
| 535 |
print "%s does not exist in the database. Adding it..."% clm
|
| 536 |
self.AddCaseToAccessDB(localCaseName,clientMatter)
|
| 537 |
|
| 538 |
## Sync cases from Access to my local
|
| 539 |
|
| 540 |
|
| 541 |
uploadReportMatrix = {}
|
| 542 |
for caseName in self.responsibleCasesList:
|
| 543 |
print "now processing %s"% caseName
|
| 544 |
casePath = os.path.join(self.casesDir,caseName)
|
| 545 |
if os.path.exists(os.path.join(casePath,"UploadReport.txt")):
|
| 546 |
print "yup"
|
| 547 |
caseUploadContents = open(os.path.join(casePath,"UploadReport.txt")).readlines()
|
| 548 |
clientMatter = caseName.split("_(")[1]
|
| 549 |
clientMatter = clientMatter.replace(")","")
|
| 550 |
clientMatter = clientMatter.replace("-",".")
|
| 551 |
for i in caseUploadContents:
|
| 552 |
i = i.replace("\n","")
|
| 553 |
i = i.replace(" | ","|")
|
| 554 |
try:
|
| 555 |
uploadReportMatrix[clientMatter].append(("%s"%i.split("|")[0],"%s"%i.split("|")[1],"%s"%i.split("|")[2],"%s"%i.split("|")[3]))
|
| 556 |
except:
|
| 557 |
uploadReportMatrix[clientMatter] = [("%s"%i.split("|")[0],"%s"%i.split("|")[1],"%s"%i.split("|")[2],"%s"%i.split("|")[3])]
|
| 558 |
#print uploadReportMatrix
|
| 559 |
|
| 560 |
accessMyCaseUploads = self.accessDB.RetrieveMyCaseUploads('09756')
|
| 561 |
for x in uploadReportMatrix.keys():
|
| 562 |
localCaseUploadList = uploadReportMatrix[x]
|
| 563 |
tempMatrix = {}
|
| 564 |
try:
|
| 565 |
accessCaseUploadList = accessMyCaseUploads[x]
|
| 566 |
#print accessCaseUploadList
|
| 567 |
for y in localCaseUploadList:
|
| 568 |
epoch = y[0]
|
| 569 |
if int(epoch) > 1298462400:
|
| 570 |
#print epoch
|
| 571 |
reviewPlatform = y[1]
|
| 572 |
reportSize = y[3]
|
| 573 |
#print "."
|
| 574 |
#print accessCaseUploadList
|
| 575 |
if epoch in accessCaseUploadList:
|
| 576 |
print "%s, in the %s case, is already in there, skipping."%(y,x)
|
| 577 |
else:
|
| 578 |
print "%s, in the %s case, is missing. Will be added..."%(y,x)
|
| 579 |
date = y[2]
|
| 580 |
date = "%s/%s/%s"%(date[4:6],date[6:],date[:4])
|
| 581 |
|
| 582 |
self.accessDB.UpdateCaseUpload(x,reviewPlatform,{epoch:(date,reportSize)})
|
| 583 |
#tempMatrix[epoch] = [platform,(date,size)]
|
| 584 |
else:
|
| 585 |
#print "This entry is pre cutover"
|
| 586 |
pass
|
| 587 |
except KeyError:
|
| 588 |
print "nothing for this one"
|
| 589 |
for z in localCaseUploadList:
|
| 590 |
print "%s, in the %s case, is missing. Will be added..."%(z,x)
|
| 591 |
date = z[0]
|
| 592 |
date = "%s/%s/%s"%(date[4:6],date[6:],date[:4])
|
| 593 |
#try:
|
| 594 |
# tempMatrix[date].append(z[1])
|
| 595 |
#except:
|
| 596 |
# tempMatrix[date] = [z[1]]
|
| 597 |
#print tempMatrix
|
| 598 |
#if tempMatrix:
|
| 599 |
# #print tempMatrix
|
| 600 |
# self.accessDB.UpdateCaseUpload(x,'Concordance DIS', tempMatrix)
|
| 601 |
#pass
|
| 602 |
|
| 603 |
|
| 604 |
#print myLocalClientMatterList
|
| 605 |
## verify that all of your uploads are up there, if not, add it.
|
| 606 |
self.accessDB.CloseAccessConnection()
|
| 607 |
|
| 608 |
else:
|
| 609 |
fullClientMatterList = self.accessDB.RetrieveAllCaseList()
|
| 610 |
myAccessClientMatterList = self.accessDB.RetrieveMyCaseList(self.tPMID)
|
| 611 |
|
| 612 |
|