def format_for_template(self, version=None):
    d = self.to_dict()
    if (version == 2):
        if self.is_saved():
            d['id'] = self.key().id()
        else:
            d['id'] = None
        d['category'] = FEATURE_CATEGORIES[self.category]
        if (self.intent_stage is not None):
            d['intent_stage'] = INTENT_STAGES[self.intent_stage]
        d['created'] = {'by': d.pop('created_by', None), 'when': d.pop('created', None)}
        d['updated'] = {'by': d.pop('updated_by', None), 'when': d.pop('updated', None)}
        d['standards'] = {'spec': d.pop('spec_link', None), 'status': {'text': STANDARDIZATION[self.standardization], 'val': d.pop('standardization', None)}, 'visibility': {'text': VISIBILITY_CHOICES[self.visibility], 'val': d.pop('visibility', None)}, 'footprint': {'val': d.pop('footprint', None)}}
        d['resources'] = {'samples': d.pop('sample_links', []), 'docs': d.pop('doc_links', [])}
        d['tags'] = d.pop('search_tags', [])
        d['browsers'] = {'chrome': {'bug': d.pop('bug_url', None), 'blink_components': d.pop('blink_components', []), 'owners': d.pop('owner', []), 'origintrial': (self.impl_status_chrome == ORIGIN_TRIAL), 'intervention': (self.impl_status_chrome == INTERVENTION), 'prefixed': d.pop('prefixed', False), 'flag': (self.impl_status_chrome == BEHIND_A_FLAG), 'status': {'text': IMPLEMENTATION_STATUS[self.impl_status_chrome], 'val': d.pop('impl_status_chrome', None)}, 'desktop': d.pop('shipped_milestone', None), 'android': d.pop('shipped_android_milestone', None), 'webview': d.pop('shipped_webview_milestone', None), 'ios': d.pop('shipped_ios_milestone', None)}, 'ff': {'view': {'text': VENDOR_VIEWS[self.ff_views], 'val': d.pop('ff_views', None), 'url': d.pop('ff_views_link', None), 'notes': d.pop('ff_views_notes', None)}}, 'edge': {'view': {'text': VENDOR_VIEWS[self.ie_views], 'val': d.pop('ie_views', None), 'url': d.pop('ie_views_link', None), 'notes': d.pop('ie_views_notes', None)}}, 'safari': {'view': {'text': VENDOR_VIEWS[self.safari_views], 'val': d.pop('safari_views', None), 'url': d.pop('safari_views_link', None), 'notes': d.pop('safari_views_notes', None)}}, 'webdev': {'view': {'text': WEB_DEV_VIEWS[self.web_dev_views], 'val': d.pop('web_dev_views', None), 'url': d.pop('web_dev_views_link', None), 'notes': d.pop('web_dev_views_notes', None)}}}
        if self.shipped_milestone:
            d['browsers']['chrome']['status']['milestone_str'] = self.shipped_milestone
        elif ((self.shipped_milestone is None) and self.shipped_android_milestone):
            d['browsers']['chrome']['status']['milestone_str'] = self.shipped_android_milestone
        else:
            d['browsers']['chrome']['status']['milestone_str'] = d['browsers']['chrome']['status']['text']
        del d['created']
        del_none(d)
    else:
        if self.is_saved():
            d['id'] = self.key().id()
        else:
            d['id'] = None
        d['category'] = FEATURE_CATEGORIES[self.category]
        if (self.intent_stage is not None):
            d['intent_stage'] = INTENT_STAGES[self.intent_stage]
        d['visibility'] = VISIBILITY_CHOICES[self.visibility]
        d['impl_status_chrome'] = IMPLEMENTATION_STATUS[self.impl_status_chrome]
        d['meta'] = {'origintrial': (self.impl_status_chrome == ORIGIN_TRIAL), 'intervention': (self.impl_status_chrome == INTERVENTION), 'needsflag': (self.impl_status_chrome == BEHIND_A_FLAG)}
        if self.shipped_milestone:
            d['meta']['milestone_str'] = self.shipped_milestone
        elif ((self.shipped_milestone is None) and self.shipped_android_milestone):
            d['meta']['milestone_str'] = self.shipped_android_milestone
        else:
            d['meta']['milestone_str'] = d['impl_status_chrome']
        d['ff_views'] = {'value': self.ff_views, 'text': VENDOR_VIEWS[self.ff_views]}
        d['ie_views'] = {'value': self.ie_views, 'text': VENDOR_VIEWS[self.ie_views]}
        d['safari_views'] = {'value': self.safari_views, 'text': VENDOR_VIEWS[self.safari_views]}
        d['standardization'] = {'value': self.standardization, 'text': STANDARDIZATION[self.standardization]}
        d['web_dev_views'] = {'value': self.web_dev_views, 'text': WEB_DEV_VIEWS[self.web_dev_views]}
    return d
def format_for_template(self, version=None):
    d = self.to_dict()
    if (version == 2):
        if self.is_saved():
            d['id'] = self.key().id()
        else:
            d['id'] = None
        d['category'] = FEATURE_CATEGORIES[self.category]
        if (self.intent_stage is not None):
            d['intent_stage'] = INTENT_STAGES[self.intent_stage]
        d['created'] = {'by': d.pop('created_by', None), 'when': d.pop('created', None)}
        d['updated'] = {'by': d.pop('updated_by', None), 'when': d.pop('updated', None)}
        d['standards'] = {'spec': d.pop('spec_link', None), 'status': {'text': STANDARDIZATION[self.standardization], 'val': d.pop('standardization', None)}, 'visibility': {'text': VISIBILITY_CHOICES[self.visibility], 'val': d.pop('visibility', None)}, 'footprint': {'val': d.pop('footprint', None)}}
        d['resources'] = {'samples': d.pop('sample_links', []), 'docs': d.pop('doc_links', [])}
        d['tags'] = d.pop('search_tags', [])
        d['browsers'] = {'chrome': {'bug': d.pop('bug_url', None), 'blink_components': d.pop('blink_components', []), 'owners': d.pop('owner', []), 'origintrial': (self.impl_status_chrome == ORIGIN_TRIAL), 'intervention': (self.impl_status_chrome == INTERVENTION), 'prefixed': d.pop('prefixed', False), 'flag': (self.impl_status_chrome == BEHIND_A_FLAG), 'status': {'text': IMPLEMENTATION_STATUS[self.impl_status_chrome], 'val': d.pop('impl_status_chrome', None)}, 'desktop': d.pop('shipped_milestone', None), 'android': d.pop('shipped_android_milestone', None), 'webview': d.pop('shipped_webview_milestone', None), 'ios': d.pop('shipped_ios_milestone', None)}, 'ff': {'view': {'text': VENDOR_VIEWS[self.ff_views], 'val': d.pop('ff_views', None), 'url': d.pop('ff_views_link', None), 'notes': d.pop('ff_views_notes', None)}}, 'edge': {'view': {'text': VENDOR_VIEWS[self.ie_views], 'val': d.pop('ie_views', None), 'url': d.pop('ie_views_link', None), 'notes': d.pop('ie_views_notes', None)}}, 'safari': {'view': {'text': VENDOR_VIEWS[self.safari_views], 'val': d.pop('safari_views', None), 'url': d.pop('safari_views_link', None), 'notes': d.pop('safari_views_notes', None)}}, 'webdev': {'view': {'text': WEB_DEV_VIEWS[self.web_dev_views], 'val': d.pop('web_dev_views', None), 'url': d.pop('web_dev_views_link', None), 'notes': d.pop('web_dev_views_notes', None)}}}
        if self.shipped_milestone:
            d['browsers']['chrome']['status']['milestone_str'] = self.shipped_milestone
        elif ((self.shipped_milestone is None) and self.shipped_android_milestone):
            d['browsers']['chrome']['status']['milestone_str'] = self.shipped_android_milestone
        else:
            d['browsers']['chrome']['status']['milestone_str'] = d['browsers']['chrome']['status']['text']
        del d['created']
        del_none(d)
    else:
        if self.is_saved():
            d['id'] = self.key().id()
        else:
            d['id'] = None
        d['category'] = FEATURE_CATEGORIES[self.category]
        if (self.intent_stage is not None):
            d['intent_stage'] = INTENT_STAGES[self.intent_stage]
        d['visibility'] = VISIBILITY_CHOICES[self.visibility]
        d['impl_status_chrome'] = IMPLEMENTATION_STATUS[self.impl_status_chrome]
        d['meta'] = {'origintrial': (self.impl_status_chrome == ORIGIN_TRIAL), 'intervention': (self.impl_status_chrome == INTERVENTION), 'needsflag': (self.impl_status_chrome == BEHIND_A_FLAG)}
        if self.shipped_milestone:
            d['meta']['milestone_str'] = self.shipped_milestone
        elif ((self.shipped_milestone is None) and self.shipped_android_milestone):
            d['meta']['milestone_str'] = self.shipped_android_milestone
        else:
            d['meta']['milestone_str'] = d['impl_status_chrome']
        d['ff_views'] = {'value': self.ff_views, 'text': VENDOR_VIEWS[self.ff_views]}
        d['ie_views'] = {'value': self.ie_views, 'text': VENDOR_VIEWS[self.ie_views]}
        d['safari_views'] = {'value': self.safari_views, 'text': VENDOR_VIEWS[self.safari_views]}
        d['standardization'] = {'value': self.standardization, 'text': STANDARDIZATION[self.standardization]}
        d['web_dev_views'] = {'value': self.web_dev_views, 'text': WEB_DEV_VIEWS[self.web_dev_views]}
    return d