Marthee commited on
Commit
9b4cb90
·
verified ·
1 Parent(s): 616d0b9

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +70 -7
app.py CHANGED
@@ -52,8 +52,8 @@ def getprjnamesfromTestAPI():
52
 
53
  @app.route('/getprojectparts/<jsdata>',methods=['GET'])
54
  def getprjpartsfromTestAPI(jsdata):
55
- prjparts=API.getprjParts(jsdata)
56
- return prjparts
57
 
58
  @app.route('/getprojectsections/<jsdata>',methods=['GET'])
59
  def getprjSectionsfromTestAPI(jsdata):
@@ -416,6 +416,7 @@ def returnAPITables():
416
  def checktables():
417
  projectname = request.args.get('prjname')
418
  projectpart = request.args.get('prjpart')
 
419
  print('hgh',projectname , projectpart)
420
  table1,table2,table3=API.GenerateTables()
421
  url_1 = prjnamesURL.replace('/edit#gid=', '/export?format=csv&gid=')
@@ -451,9 +452,10 @@ def checktables():
451
  a1 = table1N.to_numpy()
452
  row1 = np.where(a1 == projectname)
453
  prjid=a1[row1[0]][0][0]
454
- a2 = table2N.to_numpy()
455
- row2 = np.where(a2 == projectpart)
456
- partid=a2[row2[0]][0][1]
 
457
 
458
  t3Diff1=table3[~table3.isin(table3N)].dropna()
459
  t3Diff=table3N[~table3N.isin(table3)].dropna()
@@ -481,8 +483,8 @@ def checktables():
481
  differentSections=[]
482
  if projectpart and projectname:
483
  print(t3Diff1)
484
- print(prjid,partid)
485
- roww=t3Diff1.iloc[np.where((t3Diff1['ProjectId']==str(prjid) ) & (t3Diff1['ProjectPartId']==str(partid)) ) ]
486
  # print(prjid,partid,roww.shape[0] )
487
  for i in range(len(roww['ProjectId'].values)):
488
  if roww.shape[0]>0:
@@ -493,9 +495,70 @@ def checktables():
493
  returnString=['Changes have been made in Sections. Would you like to retrieve them in the console?','section',differentSections]
494
  print(differentSections)
495
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
496
  print(returnString)
 
 
 
 
 
497
  return jsonify(returnString)
498
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
499
 
500
  @app.route('/refreshDropbox',methods=["GET", "POST"])
501
  def checkdropbox():
 
52
 
53
  @app.route('/getprojectparts/<jsdata>',methods=['GET'])
54
  def getprjpartsfromTestAPI(jsdata):
55
+ prjparts,partsIds=API.getprjParts(jsdata)
56
+ return jsonify([prjparts,partsIds])
57
 
58
  @app.route('/getprojectsections/<jsdata>',methods=['GET'])
59
  def getprjSectionsfromTestAPI(jsdata):
 
416
  def checktables():
417
  projectname = request.args.get('prjname')
418
  projectpart = request.args.get('prjpart')
419
+ projectpartid = request.args.get('prjpartid')
420
  print('hgh',projectname , projectpart)
421
  table1,table2,table3=API.GenerateTables()
422
  url_1 = prjnamesURL.replace('/edit#gid=', '/export?format=csv&gid=')
 
452
  a1 = table1N.to_numpy()
453
  row1 = np.where(a1 == projectname)
454
  prjid=a1[row1[0]][0][0]
455
+ # a2 = table2N.to_numpy()
456
+ # row2 = np.where(a2 == projectpart)
457
+
458
+ # partid=a2[row2[0]][0][1]
459
 
460
  t3Diff1=table3[~table3.isin(table3N)].dropna()
461
  t3Diff=table3N[~table3N.isin(table3)].dropna()
 
483
  differentSections=[]
484
  if projectpart and projectname:
485
  print(t3Diff1)
486
+
487
+ roww=t3Diff1.iloc[np.where((t3Diff1['ProjectId']==str(prjid) ) & (t3Diff1['ProjectPartId']==str(projectpartid)) ) ]
488
  # print(prjid,partid,roww.shape[0] )
489
  for i in range(len(roww['ProjectId'].values)):
490
  if roww.shape[0]>0:
 
495
  returnString=['Changes have been made in Sections. Would you like to retrieve them in the console?','section',differentSections]
496
  print(differentSections)
497
 
498
+ # if not t2Diff.empty:
499
+ # newvalues= t2Diff['ProjectName'].values
500
+ # else:
501
+ # newvalues= t2Diff1['ProjectName'].values
502
+ # returnString=''
503
+ # returnString=['Changes have been made in Parts. Would you like to retrieve them in the console? By saying yes, you may need to repeat the website related processes(if any).','part']
504
+ # elif (not t3Diff.empty) or (not t3Diff1.empty):
505
+ # returnString=''
506
+
507
+ # returnString=['Changes have been made in Sections. Would you like to retrieve them in the console? By saying yes, you may need to repeat the website related processes(if any).','section']
508
+ # elif ((not t1Diff.empty) or (not t1Diff1.empty)) and ((not t2Diff.empty) or ( not t2Diff1.empty)):
509
+ # returnString=''
510
+ # returnString=['Changes have been made in Projects and Parts. Would you like to retrieve them in the console? By saying yes, you may need to repeat the website related processes(if any).','projectpart']
511
+ # elif ((not t1Diff.empty) or (not t1Diff1.empty)) and ((not t3Diff.empty) or (not t3Diff1.empty) ):
512
+ # returnString=''
513
+ # returnString=['Changes have been made in Projects and Sections. Would you like to retrieve them in the console? By saying yes, you may need to repeat the website related processes(if any).','projectsection']
514
+ # elif ((not t2Diff.empty) or (not t2Diff1.empty)) and ((not t3Diff.empty) or (not t3Diff1.empty)):
515
+ # returnString=''
516
+ # returnString=['Changes have been made in Parts and Sections. Would you like to retrieve them in the console? By saying yes, you may need to repeat the website related processes(if any).','partsection']
517
+ # elif ((not t1Diff.empty) or (not t1Diff1.empty)) and ((not t2Diff.empty) or (not t2Diff1.empty)) and ((not t3Diff.empty) or (not t3Diff1.empty)):
518
+ # returnString=''
519
+ # returnString=['Changes have been made in Projects, Parts and Sections. Would you like to retrieve them in the console? By saying yes, you may need to repeat the website related processes(if any).','project']
520
  print(returnString)
521
+ # if sectionData!='noSectionYet':
522
+ # return jsonify([returnString,DictionaryOfTemplates])
523
+ # else:
524
+ # returnString=prjpartsRefreshAPItable2(table2,projectname)
525
+
526
  return jsonify(returnString)
527
 
528
+ # @app.route('/getnewparts',methods=["GET", "POST"])
529
+
530
+
531
+ def prjsectionsRefreshAPItable3(table3,projectname,projectpart):
532
+ # table1,table2,table3=API.GenerateTables()
533
+ # projectname = request.args.get('prjname')
534
+
535
+ url_1 = prjnamesURL.replace('/edit#gid=', '/export?format=csv&gid=')
536
+ table1N = pd.read_csv(url_1)
537
+
538
+ url_2 = prjpartsURL.replace('/edit#gid=', '/export?format=csv&gid=')
539
+ table2N = pd.read_csv(url_2)
540
+
541
+ url_3 = prjsectionsURL.replace('/edit#gid=', '/export?format=csv&gid=')
542
+ table3N = pd.read_csv(url_3)
543
+
544
+ differentSections=[]
545
+ returnString=''
546
+ t3Diff1=table3[~table3.isin(table3N)].dropna()
547
+ t3Diff=table3N[~table3N.isin(table3)].dropna()
548
+
549
+ a1 = table1N.to_numpy()
550
+ row = np.where(a1 == projectname)
551
+ prjid=a1[row[0]][0][0]
552
+ a2 = table2N.to_numpy()
553
+ row2 = np.where(a2 == projectpart)
554
+ partid=a2[row2[0]][0][1]
555
+
556
+ for i in range(len(t3Diff['ProjectId'].values)):
557
+ roww=table3N.iloc[np.where((table3N['ProjectId']==prjid) & (table3N['ProjectPartId']==partid) ) ]
558
+ differentSections.append(roww['ProjectSection'].iloc[i])
559
+ # returnString=['Changes have been made in Parts. Would you like to retrieve them in the console?','part',differentParts]
560
+ print(differentSections)
561
+ return returnString
562
 
563
  @app.route('/refreshDropbox',methods=["GET", "POST"])
564
  def checkdropbox():