def asdict(self, include_project=False, include_labels=True): ''' Return issue as a dictionary with some properties tweaked ''' issue_dict = db.Model.asdict(self) if include_project: issue_dict['project'] = db.session.query(Project).filter( Project.id == self.project_id).first().asdict( include_organization=False, include_issues=False) del issue_dict['project_id'] # remove fields that don't need to be public del issue_dict['keep'] # manually convert dates to ISO 8601 issue_dict['created_at'] = convert_datetime_to_iso_8601( issue_dict['created_at']) issue_dict['updated_at'] = convert_datetime_to_iso_8601( issue_dict['updated_at']) # set the API URL issue_dict['api_url'] = self.api_url() if include_labels: issue_dict['labels'] = [l.asdict() for l in self.labels] return issue_dict
def asdict(self, include_project=False): ''' Return issue as a dictionary with some properties tweaked ''' issue_dict = db.Model.asdict(self) # TODO: Also paged_results assumes asdict takes this argument, should be checked and fixed later if include_project: issue_dict['project'] = db.session.query(Project).filter(Project.id == self.project_id).first().asdict() del issue_dict['project']['issues'] del issue_dict['project_id'] # remove fields that don't need to be public del issue_dict['keep'] # manually convert dates to ISO 8601 issue_dict['created_at'] = convert_datetime_to_iso_8601(issue_dict['created_at']) issue_dict['updated_at'] = convert_datetime_to_iso_8601(issue_dict['updated_at']) issue_dict['api_url'] = self.api_url() issue_dict['labels'] = [l.asdict() for l in self.labels] return issue_dict
def asdict(self, include_project=False, include_labels=True): ''' Return issue as a dictionary with some properties tweaked ''' issue_dict = db.Model.asdict(self) if include_project: issue_dict['project'] = db.session.query(Project).filter(Project.id == self.project_id).first().asdict(include_organization=False, include_issues=False) del issue_dict['project_id'] # remove fields that don't need to be public del issue_dict['keep'] # manually convert dates to ISO 8601 issue_dict['created_at'] = convert_datetime_to_iso_8601(issue_dict['created_at']) issue_dict['updated_at'] = convert_datetime_to_iso_8601(issue_dict['updated_at']) # set the API URL issue_dict['api_url'] = self.api_url() if include_labels: issue_dict['labels'] = [l.asdict() for l in self.labels] return issue_dict