def jsondict(self, tz): start = self.period.start if tz == 'UTC' else TimeAgent.utc2est(self.period.start) end = self.period.end() if tz == 'UTC' else TimeAgent.utc2est(self.period.end()) w = self.period.window # stakeholder want's 'T' or '' for this sponsored = self.period.session.project.is_sponsored() sponsored = '' if not sponsored else 'T' js = {"id" : self.period.id , "session" : SessionHttpAdapter(self.period.session).jsondict() , "session_name" : self.period.session.name , "handle" : self.period.toHandle() , "stype" : self.period.session.session_type.type[0].swapcase() , "end_date" : d2str(end) , "end_time" : t2str(end) , "date" : d2str(start) , "time" : t2str(start) , "lst" : str(TimeAgent.dt2tlst(self.period.start)) , "duration" : self.period.duration , "sscore" : self.period.score # scheduling score , "cscore" : -1.0 # current score , "forecast" : dt2str(self.period.forecast) , "backup" : self.period.backup , "moc_ack" : self.period.moc_ack if self.period.moc_ack is not None else False , "state" : self.period.state.abbreviation if self.period.state is not None else "" , "windowed" : True if w is not None else False , "wdefault" : self.period.is_windowed_default() \ if w is not None else None , "wstart" : d2str(w.start_date()) if w is not None else None , "wend" : d2str(w.last_date()) if w is not None else None , "sponsored" : sponsored , "sponsor" : self.period.session.project.sponsor_text() , "receivers" : self.period.get_rcvrs_json() } # include the accounting but keep the dict flat if self.period.accounting is not None: accounting_js = self.period.accounting.jsondict() # make sure the final jsondict has only one 'id' accounting_id = accounting_js.pop('id') accounting_js.update({'accounting_id' : accounting_id}) js.update(accounting_js) return js