Hide keyboard shortcuts

Hot-keys on this page

r m x p   toggle line displays

j k   next/prev highlighted chunk

0   (zero) top of page

1   (one) first highlighted chunk

1#!/usr/local/bin/python 

2# encoding: utf-8 

3""" 

4*Template for the transients view* 

5 

6:Author: 

7 David Young 

8""" 

9from __future__ import division 

10from builtins import zip 

11from builtins import object 

12from past.utils import old_div 

13import sys 

14import os 

15import re 

16from marshall_webapp.models.transients import models_transients_get 

17from pyramid.path import AssetResolver 

18import khufu 

19 

20 

21class templates_resources_transients(object): 

22 """ 

23 The worker class for the templates_resources_transients module 

24 

25 **Key Arguments** 

26 

27 - ``log`` -- logger 

28 - ``request`` -- the pyramid/WebObs request object 

29 - ``elementId`` -- the specific element requested (or False) 

30 - ``search`` -- is this a search? (boolean) 

31 - ``tcsCatalogueId`` -- tcs catalogue Id (for catalogue match views) 

32 

33 """ 

34 

35 def __init__( 

36 self, 

37 log, 

38 request, 

39 elementId=False, 

40 search=False, 

41 tcsCatalogueId=False 

42 ): 

43 self.log = log 

44 self.request = request 

45 log.debug("instansiating a new 'templates_transients' object") 

46 self.elementId = elementId 

47 self.search = search 

48 self.tcsCatalogueId = tcsCatalogueId 

49 

50 # xt-self-arg-tmpx 

51 

52 # GRAB THE REQUIRED DATA FROM THE DATABASE AND ADD IT AS ATTRIBUTES TO 

53 # THIS OBJECT 

54 transientModal = models_transients_get( 

55 log=self.log, 

56 request=self.request, 

57 elementId=self.elementId, 

58 search=self.search, 

59 tcsCatalogueId=tcsCatalogueId 

60 ) 

61 self.qs, self.transientData, self.transientAkas, self.transientLightcurveData, self.transientAtelMatches, self.transients_comments, self.totalTicketCount, self.transientHistories, self.transientCrossmatches = transientModal.get( 

62 ) 

63 

64 if tcsCatalogueId: 

65 sqlQuery = u""" 

66 select table_name from tcs_stats_catalogues where table_id = %(tcsCatalogueId)s 

67 """ % locals() 

68 objectDataTmp = self.request.db.execute(sqlQuery).fetchall() 

69 objectData = [] 

70 objectData[:] = [dict(list(zip(list(row.keys()), row))) 

71 for row in objectDataTmp] 

72 table_name = objectData[0]["table_name"] 

73 table_name = table_name.replace( 

74 "tcs_cat_", "").replace("_", " ") 

75 regex = re.compile(r'(v\d{1,3}) (\d{1,3})( (\d{1,3}))?') 

76 self.tcsCatalogueName = regex.sub( 

77 "\g<1>.\g<2>", table_name) 

78 else: 

79 self.tcsCatalogueName = False 

80 

81 return None 

82 

83 def get(self): 

84 """get the templates_resources_transients object 

85 

86 **Return** 

87 

88 - ``webpage`` -- the webapge HTML 

89 

90 """ 

91 self.log.debug('starting the ``get`` method') 

92 

93 # CHOOSE WHICH FORMAT OF THE CONTENT TO DISPLAY 

94 if self.qs["format"] == "html_table": 

95 maincontent = self._get_object_table() 

96 else: 

97 maincontent = self._get_object_tickets() 

98 

99 from marshall_webapp.templates.commonelements.pagetemplates import defaultpagetemplate 

100 

101 if self.tcsCatalogueId: 

102 sideBar = "xmatches" 

103 else: 

104 sideBar = False 

105 

106 pageTitle = "ePESSTO+ Marshall" 

107 if "q" in self.qs: 

108 pageTitle = self.qs["q"] 

109 

110 webpage = defaultpagetemplate( 

111 log=self.log, 

112 request=self.request, 

113 bodyId=False, 

114 pageTitle=pageTitle, 

115 topNavBar=False, 

116 sideBar=sideBar, 

117 mainContent=maincontent, 

118 relativePathFromDocRoot=False, 

119 thisPageName=self._get_page_name() 

120 ) 

121 

122 self.log.debug('completed the ``get`` method') 

123 return webpage 

124 

125 def _get_list_of_transient_tickets( 

126 self): 

127 """ get list of transient tickets 

128 

129 **Return** 

130 

131 - ``ticketList`` -- a list of HTML tickets to display in the webapp 

132 

133 """ 

134 from marshall_webapp.templates.commonelements.tickets.single_ticket import single_ticket 

135 from astrocalc.coords import unit_conversion 

136 

137 self.log.debug( 

138 'starting the ``_get_list_of_transient_tickets`` method') 

139 

140 # ASTROCALC UNIT CONVERTER OBJECT 

141 converter = unit_conversion( 

142 log=self.log 

143 ) 

144 

145 # for each transient build a ticket to be presented in the browser 

146 ticketList = [] 

147 for discoveryDataDictionary in self.transientData: 

148 if discoveryDataDictionary["raDeg"]: 

149 discoveryDataDictionary["raSex"] = converter.ra_decimal_to_sexegesimal( 

150 ra=discoveryDataDictionary["raDeg"], 

151 delimiter=":" 

152 ) 

153 else: 

154 discoveryDataDictionary["raSex"] = None 

155 if discoveryDataDictionary["decDeg"]: 

156 discoveryDataDictionary["decSex"] = converter.dec_decimal_to_sexegesimal( 

157 dec=discoveryDataDictionary["decDeg"], 

158 delimiter=":" 

159 ) 

160 else: 

161 discoveryDataDictionary["decSex"] = None 

162 transientBucketId = discoveryDataDictionary["transientBucketId"] 

163 observationPriority = discoveryDataDictionary[ 

164 "observationPriority"] 

165 

166 self.log.debug( 

167 """transientBucketId, observationPriority: `%(transientBucketId)s` %(observationPriority)s""" % locals()) 

168 

169 thisTicket = single_ticket( 

170 log=self.log, 

171 request=self.request, 

172 discoveryDataDictionary=discoveryDataDictionary, 

173 objectComments=self.transients_comments, 

174 objectAkas=self.transientAkas, 

175 lightcurveData=self.transientLightcurveData, 

176 atelData=self.transientAtelMatches, 

177 objectHistories=self.transientHistories, 

178 transientCrossmatches=self.transientCrossmatches 

179 ) 

180 ticketList.append(thisTicket) 

181 

182 self.log.debug( 

183 'completed the ``_get_list_of_transient_tickets`` method') 

184 return ticketList 

185 

186 def _get_sort_dropdown( 

187 self): 

188 """ get sort dropdown 

189 

190 **Return** 

191 

192 - ``sort`` -- the sort dropdown for the transient listings toolbar 

193 - ``filtering`` -- the filter dropdown for the trasnsient listings toolbar 

194 

195 """ 

196 self.log.debug('starting the ``_get_sort_dropdown`` method') 

197 

198 from marshall_webapp.templates.commonelements.sorting.ticket_table_sorting_dropdown import ticket_table_sorting_dropdown 

199 

200 sort = ticket_table_sorting_dropdown( 

201 log=self.log, 

202 request=self.request, 

203 sortBy=self.qs["sortBy"], 

204 sortDesc=self.qs["sortDesc"] 

205 ) 

206 

207 from marshall_webapp.templates.commonelements.filtering.ticket_table_filter_dropdown import ticket_table_filter_dropdown 

208 

209 if "filterBy2" not in self.qs: 

210 self.qs["filterBy2"] = False 

211 self.qs["filterValue2"] = False 

212 self.qs["filterOp2"] = False 

213 

214 filtering = ticket_table_filter_dropdown( 

215 log=self.log, 

216 request=self.request, 

217 filterBy=self.qs["filterBy2"], 

218 filterValue=self.qs["filterValue2"], 

219 filterOp=self.qs["filterOp2"] 

220 ) 

221 

222 self.log.debug('completed the ``_get_sort_dropdown`` method') 

223 return sort, filtering 

224 

225 def _get_notification( 

226 self): 

227 """ get notification for the page 

228 

229 **Return** 

230 

231 - ``notification`` -- notifcation to append to the top of the transient listing page 

232 

233 """ 

234 self.log.debug('starting the ``_get_notification`` method') 

235 

236 if "notification" in self.qs: 

237 notification = khufu.alert( 

238 alertText=self.qs["notification"], 

239 alertHeading='notification: ', 

240 extraPadding=False, 

241 # [ "warning" | "error" | "success" | "info" ] 

242 alertLevel='info' 

243 ) 

244 else: 

245 notification = "" 

246 

247 self.log.debug('completed the ``_get_notification`` method') 

248 return notification 

249 

250 def _get_pagination( 

251 self): 

252 """ get pagination for the page 

253 

254 **Return** 

255 

256 - ``pagination`` -- pagination options for the toolbar of the transient listing pages 

257 

258 """ 

259 self.log.debug('starting the ``_get_pagination`` method') 

260 

261 from marshall_webapp.templates.commonelements.pagination.ticket_table_pagination import ticket_table_pagination 

262 

263 pagination = ticket_table_pagination( 

264 log=self.log, 

265 totalTickets=self.totalTicketCount, 

266 request=self.request, 

267 limit=self.qs["limit"], 

268 previousPageStart=self.qs["pageStart"] 

269 ) 

270 

271 self.log.debug('completed the ``_get_pagination`` method') 

272 return pagination 

273 

274 def _get_view_switcher_buttons( 

275 self): 

276 """ get view switcher buttons for the page 

277 

278 **Return** 

279 

280 - ``view_switcher_buttons`` -- the view switcher and download formats buttons with popovers 

281 

282 """ 

283 self.log.debug('starting the ``_get_view_switcher_buttons`` method') 

284 

285 from marshall_webapp.templates.commonelements.view_switcher_buttons import view_switcher_buttons 

286 

287 if self.tcsCatalogueId: 

288 elementId = self.tcsCatalogueId 

289 else: 

290 elementId = self.elementId 

291 

292 view_switcher_buttons = view_switcher_buttons( 

293 log=self.log, 

294 params=self.qs, 

295 request=self.request, 

296 elementId=elementId, 

297 tcsTableName=self.tcsCatalogueName 

298 ) 

299 

300 self.log.debug('completed the ``_get_view_switcher_buttons`` method') 

301 return view_switcher_buttons 

302 

303 def _get_ntt_view_button( 

304 self): 

305 """ get button that hides sources with dec > 30. 

306 

307 **Return** 

308 

309 - ``view_switcher_buttons`` -- the view switcher and download formats buttons with popovers 

310 

311 """ 

312 self.log.debug('starting the ``_get_ntt_view_button`` method') 

313 

314 from marshall_webapp.templates.commonelements.view_switcher_buttons import ntt_view_button 

315 

316 if self.tcsCatalogueId: 

317 elementId = self.tcsCatalogueId 

318 else: 

319 elementId = self.elementId 

320 

321 ntt_view_button = ntt_view_button( 

322 log=self.log, 

323 params=self.qs.copy(), 

324 elementId=elementId, 

325 request=self.request 

326 ) 

327 

328 self.log.debug('completed the ``_get_ntt_view_button`` method') 

329 return ntt_view_button 

330 

331 def _get_object_limit_dropdown( 

332 self): 

333 """ get object limit dropdown for the page 

334 

335 **Return** 

336 

337 - ``objectsPerPageDropdown`` -- options to display certain numbers of transients on a single webpage (for top toolbar of transient listing page) 

338 

339 """ 

340 self.log.debug('starting the ``_get_object_limit_dropdown`` method') 

341 

342 from marshall_webapp.templates.commonelements.sorting.number_of_objects_dropdown import number_of_objects_dropdown 

343 

344 objectsPerPageDropdown = number_of_objects_dropdown( 

345 log=self.log, 

346 request=self.request, 

347 limit=self.qs["limit"], 

348 tableView=self.qs["format"] 

349 ) 

350 

351 self.log.debug('completed the ``_get_object_limit_dropdown`` method') 

352 return objectsPerPageDropdown 

353 

354 def _get_object_table( 

355 self): 

356 """get a table of transients 

357 

358 **Return** 

359 

360 - ``object_table`` -- the table view content for the transient listing pages 

361 

362 """ 

363 self.log.debug('starting the ``_get_object_table`` method') 

364 

365 # ASSOICATE THE CORRECT COLUMN NAME TO MYSQL DATABASE COLUMN NAME 

366 tableColumnNames = { 

367 "observationPriority": "priority", 

368 "masterName": "name", 

369 "raDeg": "ra", 

370 "decDeg": "dec", 

371 "recentClassification": "spectral classification", 

372 "currentMagnitude": "latest mag", 

373 "absolutePeakMagnitude": "abs peak mag", 

374 "best_redshift": "z", 

375 "distanceMpc": "mpc", 

376 "earliestDetection": "discovery date", 

377 "lastNonDetectionDate": "last non-detection date", 

378 "dateAdded": "added to marshall", 

379 "pi_name": "PI", 

380 "pi_email": "pi email", 

381 "sherlockClassification": "contextual classificaiton", 

382 "separationArcsec": "association separation" 

383 } 

384 

385 # A LIST OF NAMES FOR TABLE AND CSV VIEWS 

386 tableColumns = [ 

387 "observationPriority", 

388 "masterName", 

389 "raDeg", 

390 "decDeg", 

391 "recentClassification", 

392 "currentMagnitude", 

393 "absolutePeakMagnitude", 

394 "best_redshift", 

395 "distanceMpc", 

396 "earliestDetection", 

397 "lastNonDetectionDate", 

398 "dateAdded", 

399 "pi_name", 

400 "plainName", 

401 "sherlockClassification", 

402 "separationArcsec" 

403 ] 

404 

405 if "mwl" not in self.qs or self.qs["mwl"] not in ["pending observation", "following", "allObsQueue"]: 

406 tableColumns.remove("observationPriority") 

407 

408 # GET THE WEBPAGE COMPONENTS 

409 # tickets = self._get_list_of_transient_tickets() 

410 sort, filtering = self._get_sort_dropdown() 

411 count = self.totalTicketCount 

412 pagination = self._get_pagination() 

413 ntt_button = self._get_ntt_view_button() 

414 viewSwitcherButtons = self._get_view_switcher_buttons() 

415 objectsPerPageDropdown = self._get_object_limit_dropdown() 

416 notification = self._get_notification() 

417 pageviewInfo = self._get_page_view_info() 

418 

419 for obj in self.transientData: 

420 

421 for item in self.transientAkas: 

422 if item["transientBucketId"] == obj["transientBucketId"]: 

423 obj["masterName"] = item["name"] 

424 break 

425 

426 # CONVERT PRIORITIES TO WORDS 

427 if "marshallWorkflowLocation" in obj: 

428 if obj["marshallWorkflowLocation"] == "following": 

429 for n, w, c in zip([1, 2, 3, 4], ["CRITICAL", "IMPORTANT", "USEFUL", "NONE"], ["green", "yellow", "red", "blue"]): 

430 if obj["observationPriority"] == n: 

431 obj["observationPriority"] = w 

432 # add text color 

433 obj["observationPriority"] = khufu.coloredText( 

434 text=obj["observationPriority"], 

435 color=c, 

436 ) 

437 break 

438 obj["observationPriority"] = """<strong>""" + \ 

439 obj["observationPriority"] + """</strong>""" 

440 elif obj["marshallWorkflowLocation"] == "pending observation": 

441 for n, w, c in zip([1, 2, 3], ["HIGH", "MEDIUM", "LOW"], ["green", "yellow", "red"]): 

442 if obj["observationPriority"] == n: 

443 obj["observationPriority"] = w 

444 # add text color 

445 obj["observationPriority"] = khufu.coloredText( 

446 text=obj["observationPriority"], 

447 color=c, 

448 ) 

449 break 

450 obj["observationPriority"] = """<strong>""" + \ 

451 obj["observationPriority"] + """</strong>""" 

452 

453 # CLEAN DATA IN THE OBJ DICTIONARY 

454 # SET NAME FONT SIZES 

455 size = 3 

456 numerator = 30. 

457 if "mwl" not in self.qs or self.qs["mwl"] == "inbox": 

458 numerator = 40. 

459 test = int(old_div(numerator, len(obj["masterName"]))) 

460 if test < 3: 

461 size = test 

462 

463 # SET ICONS FOR OBJECT NAMES 

464 q = obj['marshallWorkflowLocation'].lower() 

465 icon = "" 

466 if q == "inbox": 

467 icon = """<i class="icon-inbox"></i>""" 

468 elif q == "review for followup": 

469 icon = """<i class="icon-eye"></i>""" 

470 elif q == "following": 

471 icon = """<i class="icon-pin"></i>""" 

472 elif q == "archive": 

473 icon = """<i class="icon-archive"></i>""" 

474 elif q == "pending observation": 

475 icon = """<i class="icon-target2"></i>""" 

476 elif q == "followup complete": 

477 icon = """<i class="icon-checkmark-circle"></i>""" 

478 thisName = khufu.a( 

479 content=obj["masterName"], 

480 href=obj["surveyObjectUrl"] 

481 ) 

482 thisName = khufu.coloredText( 

483 text=obj["masterName"], 

484 color="green", 

485 size=size 

486 ) 

487 icon = khufu.coloredText( 

488 text=icon, 

489 color="green", 

490 size=2, # 1-10 

491 pull=False, # "left" | "right" 

492 ) 

493 obj["plainName"] = obj["masterName"] 

494 obj["masterName"] = "%(icon)s %(thisName)s" % locals() 

495 

496 # SET MAILTO LINKS FOR PI 

497 if obj["pi_name"]: 

498 pi_name = obj["pi_name"] 

499 firstName = pi_name.split(' ', 1)[0] 

500 thisName = obj["plainName"] 

501 pi_email = obj["pi_email"] 

502 pi_name = khufu.a( 

503 content="""%(pi_name)s&nbsp<i class="icon-mail7"></i>""" % locals(), 

504 href="mailto:%(pi_email)s?subject=%(thisName)s&body=Hi %(firstName)s," % locals( 

505 ), 

506 tableIndex=False, 

507 triggerStyle=False, # [ False | "dropdown" | "tab" ], 

508 htmlClass=False, 

509 postInBackground=False 

510 ) 

511 obj["pi_name"] = pi_name 

512 

513 for i in self.transientData: 

514 if i["separationArcsec"] is not None: 

515 i["separationArcsec"] = "%(separationArcsec)4.2f''" % i 

516 

517 # CREATE THE SORTABLE TABLES OF OBJECTS 

518 if int(self.totalTicketCount) > 0: 

519 table = khufu.tables.sortable_table( 

520 currentPageUrl=self.request.path_qs, 

521 columnsToDisplay=tableColumns, 

522 tableRowsDictionary=self.transientData, 

523 log=self.log, 

524 defaultSort="dateAdded" 

525 ) 

526 nd = table.modifyDisplayNameDict 

527 nd["masterName"] = "name" 

528 nd["observationPriority"] = "priority" 

529 nd["raDeg"] = "ra" 

530 nd["decDeg"] = "dec" 

531 nd["recentClassification"] = "spectral classification" 

532 nd["currentMagnitude"] = "latest mag" 

533 nd["absolutePeakMagnitude"] = "abs peak mag" 

534 nd["best_redshift"] = "z" 

535 nd["distanceMpc"] = "mpc" 

536 nd["earliestDetection"] = "discovery date" 

537 nd["lastNonDetectionDate"] = "last non-detection date" 

538 nd["dateAdded"] = "added to marshall" 

539 nd["pi_name"] = "pi" 

540 nd["sherlockClassification"] = "contextual classification" 

541 nd["separationArcsec"] = "association separation" 

542 

543 table.searchKeyAndColumn = ("search?q", "plainName") 

544 

545 # hide columns depending on what list we are looking at 

546 if "mwl" not in self.qs or self.qs["mwl"] == "inbox": 

547 table.modifyColumnWidths = ["3", "1", "1", "2", 

548 "1", "1", "1", "1", "2", "2", "2", "2"] 

549 table.columnsToHide.append("recentClassification") 

550 table.columnsToHide.append("plainName") 

551 table = table.get() 

552 else: 

553 table = "" 

554 

555 # CREATE THE TABLE FUNCTION BAR 

556 space = "&nbsp" * 10 

557 smallspace = "&nbsp" * 1 

558 

559 pageviewInfo = khufu.p( 

560 content=pageviewInfo, 

561 lead=False, 

562 textAlign="right", # [ left | center | right ] 

563 color=False, # [ muted | warning | info | error | success ] 

564 navBar=False, 

565 onPhone=True, 

566 onTablet=True, 

567 onDesktop=True 

568 ) 

569 

570 ticketTableFunctionBar = khufu.navBar( 

571 brand='', 

572 contentList=[viewSwitcherButtons, ntt_button, smallspace, filtering, 

573 objectsPerPageDropdown, smallspace, space, pagination], 

574 contentListPull="right", 

575 dividers=False, 

576 forms=False, 

577 fixedOrStatic=False, 

578 location='top', 

579 responsive=False, 

580 dark=False, 

581 transparent=True 

582 ) 

583 if int(self.totalTicketCount) > 0: 

584 bottomTicketTableFunctionBar = ticketTableFunctionBar.replace( 

585 "btn-group", "btn-group dropup") 

586 else: 

587 bottomTicketTableFunctionBar = '<p style="text-align: center; font-size: 20em; color: #e5e0cc; margin-top: 20%;"><i class="icon-inbox" style="color: #e5e0cc;"></i><br><br><br><br><br><br><br><br>zero</p>' 

588 dynamicNotification = """<span id="dynamicNotification"></span>""" 

589 

590 content = """%(dynamicNotification)s %(notification)s %(ticketTableFunctionBar)s %(pageviewInfo)s %(table)s %(bottomTicketTableFunctionBar)s""" % locals( 

591 ) 

592 

593 object_table = khufu.grid_column( 

594 span=12, # 1-12 

595 offset=0, # 1-12 

596 content=content, 

597 htmlId="object_table", 

598 htmlClass=False, 

599 onPhone=True, 

600 onTablet=True, 

601 onDesktop=True 

602 ) 

603 

604 self.log.debug('completed the ``_get_object_table`` method') 

605 return object_table 

606 

607 def _get_page_name( 

608 self): 

609 """ get page name 

610 """ 

611 self.log.debug('starting the ``_get_page_name`` method') 

612 

613 thisPageName = "" 

614 if "snoozed" in self.qs: 

615 thisPageName = "snoozed" 

616 elif "cf" in self.qs and (self.qs["cf"] == 1 or self.qs["cf"] == "1"): 

617 thisPageName = "classified" 

618 elif "awl" in self.qs: 

619 thisPageName = self.qs["awl"] 

620 elif "mwl" in self.qs: 

621 thisPageName = self.qs["mwl"] 

622 

623 self.log.debug('completed the ``_get_page_name`` method') 

624 return thisPageName 

625 

626 def _get_object_tickets( 

627 self): 

628 """ get object tickets 

629 

630 **Return** 

631 

632 - ``ticket_table`` -- the ticket to display as the main content of the page 

633 

634 """ 

635 self.log.debug('starting the ``_get_object_tickets`` method') 

636 

637 # GET THE WEBPAGE COMPONENTS 

638 ticketList = self._get_list_of_transient_tickets() 

639 pagination = self._get_pagination() 

640 notification = self._get_notification() 

641 ticketsPerPageDropdown = self._get_object_limit_dropdown() 

642 ntt_button = self._get_ntt_view_button() 

643 view_switcher_buttons = self._get_view_switcher_buttons() 

644 

645 sort, filtering = self._get_sort_dropdown() 

646 pageviewInfo = self._get_page_view_info() 

647 

648 theseTickets = "" 

649 for ticket in ticketList: 

650 theseTickets = "%(theseTickets)s%(ticket)s" % locals() 

651 

652 space = "&nbsp" * 10 

653 smallspace = "&nbsp" * 1 

654 

655 ticketTableFunctionBar = khufu.navBar( 

656 brand='', 

657 contentList=[view_switcher_buttons, ntt_button, smallspace, sort, filtering, smallspace, 

658 ticketsPerPageDropdown, smallspace, space, pagination], 

659 contentListPull="right", 

660 dividers=False, 

661 forms=False, 

662 fixedOrStatic=False, 

663 location='top', 

664 responsive=False, 

665 dark=False, 

666 transparent=True 

667 ) 

668 

669 pageviewInfo = khufu.p( 

670 content=pageviewInfo, 

671 lead=False, 

672 textAlign="right", # [ left | center | right ] 

673 color=False, # [ muted | warning | info | error | success ] 

674 navBar=False, 

675 onPhone=True, 

676 onTablet=True, 

677 onDesktop=True 

678 ) 

679 

680 if int(self.totalTicketCount) > 0: 

681 bottomTicketTableFunctionBar = ticketTableFunctionBar.replace( 

682 "btn-group", "btn-group dropup").replace("""data-placement="bottom" """, """data-placement="top" """) 

683 else: 

684 

685 # add text color 

686 bottomTicketTableFunctionBar = '<p style="text-align: center; font-size: 20em; color: #e5e0cc; margin-top: 20%;"><i class="icon-inbox" style="color: #e5e0cc;"></i><br><br><br><br><br><br><br><br>zero</p>' 

687 

688 dynamicNotification = """<span id="dynamicNotification"></span>""" 

689 

690 ticket_table = khufu.grid_column( 

691 span=12, # 1-12 

692 offset=0, # 1-12 

693 content="""%(dynamicNotification)s %(notification)s %(ticketTableFunctionBar)s %(pageviewInfo)s %(theseTickets)s %(bottomTicketTableFunctionBar)s""" % locals( 

694 ), 

695 htmlId="ticket_table", 

696 htmlClass=False, 

697 onPhone=True, 

698 onTablet=True, 

699 onDesktop=True 

700 ) 

701 

702 self.log.debug('completed the ``_get_object_tickets`` method') 

703 return ticket_table 

704 

705 def _get_page_view_info( 

706 self): 

707 """ get page view info 

708 """ 

709 self.log.debug('starting the ``_get_page_view_info`` method') 

710 

711 # CRAFT SOME TEXT FROM THE DOWNLOAD FILENAME 

712 filename = self.qs["filename"] 

713 

714 thisListing = filename.replace("pessto_marshall", "").replace( 

715 "_", " ").strip() 

716 

717 limit = int(self.qs["limit"]) 

718 pageStart = int(self.qs["pageStart"]) + 1 

719 pageEnd = pageStart + limit - 1 

720 totalCount = int(self.totalTicketCount) 

721 if pageEnd > totalCount: 

722 pageEnd = totalCount 

723 

724 filterText1 = self.qs["filterText1"] 

725 filterText2 = self.qs["filterText2"] 

726 

727 tcsCatalogueId = self.tcsCatalogueId 

728 if self.tcsCatalogueName: 

729 table_name = self.tcsCatalogueName 

730 if "tcsRank" in self.qs: 

731 matches = "top-ranked matches" 

732 else: 

733 matches = "matched" 

734 

735 if totalCount == 0: 

736 thisListing = """<span id="pageinfo">no transients were found matched against the <strong>%(table_name)s</strong> catalogue<span>""" % locals( 

737 ) 

738 else: 

739 thisListing = """<span id="pageinfo">showing transients <strong>%(pageStart)s-%(pageEnd)s</strong> of <strong>%(totalCount)s</strong> %(matches)s against the <strong>%(table_name)s</strong> catalogue<span>""" % locals( 

740 ) 

741 elif "search" in thisListing: 

742 thisListing = thisListing.replace("search", "").strip() 

743 if totalCount == 0: 

744 thisListing = """<span id="pageinfo">no transients were found in the search for "<strong><em>%(thisListing)s</em></strong>"<span>""" % locals( 

745 ) 

746 else: 

747 thisListing = """<span id="pageinfo">showing transients <strong>%(pageStart)s-%(pageEnd)s</strong> of <strong>%(totalCount)s</strong> from the search for "<strong><em>%(thisListing)s</em></strong>"<span>""" % locals( 

748 ) 

749 elif "search" not in thisListing: 

750 if totalCount == 0: 

751 thisListing = """<span id="pageinfo">no transients were found %(filterText1)s%(filterText2)sin the <strong>%(thisListing)s</strong> list<span>""" % locals( 

752 ) 

753 else: 

754 thisListing = """<span id="pageinfo">showing transients <strong>%(pageStart)s-%(pageEnd)s</strong> of <strong>%(totalCount)s</strong> %(filterText1)s%(filterText2)sin the <strong>%(thisListing)s</strong> list<span>""" % locals( 

755 ) 

756 

757 else: 

758 thisListing = "" 

759 

760 self.log.debug('completed the ``_get_page_view_info`` method') 

761 return thisListing 

762 

763 # use the tab-trigger below for new method 

764 # xt-class-method