Example #1
0
    def __init__(self, docstring, restfulcls, httpmethod, itemurl):
        self.docstring = Template(docstring)
        self.restfulcls = restfulcls
        self.httpmethod = httpmethod
        self.itemurl = itemurl
        if itemurl.endswith('id**'):
            self.itemexampleurl = itemurl[:-4] + '10'
        else:
            self.itemexampleurl = itemurl
        simplified = restfulcls._meta.simplified
        model = simplified._meta.model

        self.modelclspath = get_model_clspath(model)
        self.model_verbose_name = model._meta.verbose_name
        self.model_verbose_name_plural = model._meta.verbose_name_plural
        self.model = model

        self.result_fieldgroups = self._create_fieldgroup_overview(simplified._meta.resultfields.additional_fieldgroups)
        self.result_fieldgroups_example = self._create_jslist(simplified._meta.resultfields.additional_fieldgroups.keys())
        self.search_fieldgroups = self._create_fieldgroup_overview(simplified._meta.searchfields.additional_fieldgroups)
        self.search_fieldgroups_example = self._create_jslist(simplified._meta.searchfields.additional_fieldgroups.keys())

        self.searchfields = self._create_fieldinfolist(simplified._meta.searchfields.always_available_fields)
        self.resultfields = self._create_fieldinfolist(simplified._meta.resultfields.always_available_fields)
        self.editablefields = self._create_fieldinfolist(simplified._meta.editablefields)
        self.editablefields_and_id = self._create_fieldinfolist(list(simplified._meta.editablefields) + ['id'])
        self._create_filter_docattrs()

        self.orderby_example = self._create_orderby_jslist(simplified._meta.resultfields.aslist())

        self.simplifiedclspath = get_clspath(simplified)
        #for method in simplified._meta.methods:
            #setattr(self, 'simplified_{0}methodpath'.format(method), )

        self.context = Context(dict(doc=self))
Example #2
0
def field_to_help_text(field):
    if isinstance(field, fields.related.AutoField):
        return 'Autogenerated identifier.'
    elif isinstance(field, fields.related.ManyToManyField) or isinstance(field, fields.related.RelatedObject):
        return 'List of many values.'
    help_text = field.help_text
    if not help_text or help_text.strip() == '':
        raise ValueError('Missing help for: {0}.{1}'.format(get_clspath(field.model), field.name))
    return help_text
Example #3
0
def field_to_help_text(field):
    if isinstance(field, fields.related.AutoField):
        return 'Autogenerated identifier.'
    elif isinstance(field, fields.related.ManyToManyField) or isinstance(
            field, fields.related.RelatedObject):
        return 'List of many values.'
    help_text = field.help_text
    if not help_text or help_text.strip() == '':
        raise ValueError('Missing help for: {0}.{1}'.format(
            get_clspath(field.model), field.name))
    return help_text
Example #4
0
    def __init__(self, docstring, restfulcls, httpmethod, itemurl):
        self.docstring = Template(docstring)
        self.restfulcls = restfulcls
        self.httpmethod = httpmethod
        self.itemurl = itemurl
        if itemurl.endswith('id**'):
            self.itemexampleurl = itemurl[:-4] + '10'
        else:
            self.itemexampleurl = itemurl
        simplified = restfulcls._meta.simplified
        model = simplified._meta.model

        self.modelclspath = get_model_clspath(model)
        self.model_verbose_name = model._meta.verbose_name
        self.model_verbose_name_plural = model._meta.verbose_name_plural
        self.model = model

        self.result_fieldgroups = self._create_fieldgroup_overview(
            simplified._meta.resultfields.additional_fieldgroups)
        self.result_fieldgroups_example = self._create_jslist(
            simplified._meta.resultfields.additional_fieldgroups.keys())
        self.search_fieldgroups = self._create_fieldgroup_overview(
            simplified._meta.searchfields.additional_fieldgroups)
        self.search_fieldgroups_example = self._create_jslist(
            simplified._meta.searchfields.additional_fieldgroups.keys())

        self.searchfields = self._create_fieldinfolist(
            simplified._meta.searchfields.always_available_fields)
        self.resultfields = self._create_fieldinfolist(
            simplified._meta.resultfields.always_available_fields)
        self.editablefields = self._create_fieldinfolist(
            simplified._meta.editablefields)
        self.editablefields_and_id = self._create_fieldinfolist(
            list(simplified._meta.editablefields) + ['id'])
        self._create_filter_docattrs()

        self.orderby_example = self._create_orderby_jslist(
            simplified._meta.resultfields.aslist())

        self.simplifiedclspath = get_clspath(simplified)
        #for method in simplified._meta.methods:
        #setattr(self, 'simplified_{0}methodpath'.format(method), )

        self.context = Context(dict(doc=self))