Skip to content

Commit

Permalink
feat: Undeprecated and removed fields are prohibited and no longer su…
Browse files Browse the repository at this point in the history
…pported
  • Loading branch information
jpmckinney committed Dec 13, 2024
1 parent 14433bf commit 77140d0
Show file tree
Hide file tree
Showing 8 changed files with 4 additions and 101 deletions.
2 changes: 0 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,6 @@ The automated tests provide full code coverage, but you might still want to chec
* The "Description" column:
* renders Markdown <https://extensions.open-contracting.org/en/extensions/lots/master/schema/#Lot.status>
* displays deprecation message
* indicates whether undeprecated <https://extensions.open-contracting.org/en/extensions/milestone_documents/master/schema/#Milestone.documents>
* indicates multilingual support <https://extensions.open-contracting.org/en/extensions/budget_project/master/schema/#Project.title>
* indicates whether it overrides:
* the standard <https://extensions.open-contracting.org/en/extensions/ppp/master/schema/#.tag>
Expand All @@ -110,7 +109,6 @@ The automated tests provide full code coverage, but you might still want to chec
* the standard <https://extensions.open-contracting.org/en/extensions/location/master/schema/>
* other extensions <https://extensions.open-contracting.org/en/extensions/transaction_milestones/master/schema/>
* Types of arrays indicate the types of items <https://extensions.open-contracting.org/en/extensions/location/master/schema/#Location.geometry.coordinates>
* Removed fields are listed, grouped by deprecation <https://extensions.open-contracting.org/en/extensions/ppp/master/schema/#removed-fields>
* Codelists
* Additional columns are shown <https://extensions.open-contracting.org/en/extensions/ppp/master/codelists/#documentType.csv>
* URLs are hyperlinked <https://extensions.open-contracting.org/en/extensions/location/master/codelists/#geometryType.csv>
Expand Down
1 change: 0 additions & 1 deletion extension_explorer/data/tags.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ profile:
- finance
- location
- metrics
- milestone_documents
- performance_failures
- process_title
- qualification
Expand Down
4 changes: 0 additions & 4 deletions extension_explorer/locale/es/LC_MESSAGES/messages.po
Original file line number Diff line number Diff line change
Expand Up @@ -198,10 +198,6 @@ msgstr "Documentación de los campos en la extensión %(name)s"
msgid "Schema"
msgstr "Esquema"

#: templates/extension_schema.html:24 templates/extension_schema.html:126
msgid "Removed fields"
msgstr "Quitar campos"

#: templates/extension_schema.html:38
#, python-format
msgid ""
Expand Down
4 changes: 0 additions & 4 deletions extension_explorer/messages.pot
Original file line number Diff line number Diff line change
Expand Up @@ -170,10 +170,6 @@ msgstr ""
msgid "Schema"
msgstr ""

#: templates/extension_schema.html:24 templates/extension_schema.html:126
msgid "Removed fields"
msgstr ""

#: templates/extension_schema.html:38
#, python-format
msgid ""
Expand Down
35 changes: 0 additions & 35 deletions extension_explorer/templates/extension_schema.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,6 @@
</a>
</li>
{% endfor %}
{% if removed_fields %}
<li>
<a href="#removed-fields">
{{ _("Removed fields") }}
</a>
</li>
{% endif %}
</ul>
</div>
{% endblock %}
Expand Down Expand Up @@ -98,18 +91,12 @@ <h3 id="{{ definition|lower }}">
</p>
{% endif %}
{% if 'deprecated' in field.schema %}
{% if field.schema.deprecated %}
<p>
<strong>
{{ _('Deprecated in OCDS %(deprecatedVersion)s:', deprecatedVersion=field.schema.deprecated.deprecatedVersion) }}
</strong>
{{ field.schema.deprecated.description }}
</p>
{% else %}
<p class="fst-italic">
{{ _('The extension undoes the deprecation of this field.') }}
</p>
{% endif %}
{% endif %}
</td>
<td>
Expand All @@ -120,28 +107,6 @@ <h3 id="{{ definition|lower }}">
</tbody>
</table>
{% endfor %}

{% if removed_fields %}
<h3 id="removed-fields">
{{ _("Removed fields") }}
</h3>

{% if 'active' in removed_fields %}
<p>
{{ _("The extension removes these fields from the release schema:") }}
</p>

{{ field_list(removed_fields.active) }}
{% endif %}

{% if 'deprecated' in removed_fields %}
<p>
{{ _("The extension removes these <em>deprecated</em> fields from the release schema:") }}
</p>

{{ field_list(removed_fields.deprecated) }}
{% endif %}
{% endif %}
{% endblock %}

{% macro field_list(fields) -%}
Expand Down
32 changes: 3 additions & 29 deletions extension_explorer/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ def set_tags(extensions):

for extension in extensions.values():
extension['tags'] = set()
if extension['core'] and extension['id'] != 'milestone_documents':
if extension['core']:
extension['tags'].add('recommended')

groups = {}
Expand Down Expand Up @@ -227,36 +227,10 @@ def get_codelist_tables(extension_version, lang):
return tables


def get_removed_fields(extension_version, lang):
"""
Return a dictionary of deprecation status and field tables. Each table is a list of fields. Each field is a
dictionary with "definition_path", "path" and "url" (if available) keys. All values are translated.
"""
tables = defaultdict(list)

schema = _patch_schema(extension_version, 'en', include_test_dependencies=True)
sources = _get_sources(schema, lang)

for field in get_schema_fields(extension_version['schemas']['release-schema.json'][lang]):
# If the field isn't removed.
if field.schema is not None:
continue

original_field = _add_link_to_original_field(field, schema, sources)

group = 'deprecated' if original_field.get('deprecated') else 'active'

d = field.asdict(exclude=('definition_pointer', 'pointer', 'schema', 'required', 'deprecated', 'multilingual'))
tables[group].append(d)

return tables


def get_schema_tables(extension_version, lang):
"""
Return a dictionary of definition names and field tables. Each table is a list of fields. Each field is a
dictionary with "definition_path", "path", "schema", "multilingual", "title", "description", "types" and "source"
(if available) keys. All values are translated.
Return a dictionary of definition names and field tables. Each table is a list of fields.
All values are translated.
The "description" (rendered from Markdown) and "types" values may contain HTML. The "description" includes any
deprecation information.
Expand Down
5 changes: 1 addition & 4 deletions extension_explorer/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
get_extension_explorer_data_filename,
get_extensions,
get_present_and_historical_versions,
get_removed_fields,
get_schema_tables,
highlight_json,
identify_headings,
Expand Down Expand Up @@ -162,12 +161,10 @@ def extension_schema(lang, identifier, version):

present_versions, historical_versions = get_present_and_historical_versions(extension)
tables = get_schema_tables(extension_version, lang)
removed_fields = get_removed_fields(extension_version, lang)

return render_template('extension_schema.html', lang=lang, identifier=identifier, version=version,
extension=extension, extension_version=extension_version, present_versions=present_versions,
historical_versions=historical_versions, default_master=default_master, tables=tables,
removed_fields=removed_fields)
historical_versions=historical_versions, default_master=default_master, tables=tables)


@app.route('/<lang>/extensions/<identifier>/<version>/codelists/')
Expand Down
22 changes: 0 additions & 22 deletions tests/test_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
get_codelist_tables,
get_extensions,
get_present_and_historical_versions,
get_removed_fields,
get_schema_tables,
highlight_json,
identify_headings,
Expand Down Expand Up @@ -337,27 +336,6 @@ def test_get_present_and_historical_versions_live():
assert historical_versions == [('live', '')]


def test_get_removed_fields(client):
extension_version = deepcopy(extension_version_template)
extension_version['schemas']['release-schema.json']['en'] = release_schema

fields = get_removed_fields(extension_version, 'en')

assert fields == {
'active': [
{'definition_path': '', 'path': 'buyer',
'url': 'https://standard.open-contracting.org/1.1/en/schema/reference/#release-schema.json,,buyer'},
{'definition_path': 'Tender', 'path': 'description',
'url': 'https://standard.open-contracting.org/1.1/en/schema/reference/#release-schema.json,/definitions/Tender,description'},
{'definition_path': 'Location', 'path': 'description',
'url': '/en/extensions/location/v1.1.3/schema/#Location.description'},
],
'deprecated': [
{'definition_path': 'OrganizationReference', 'path': 'address'},
],
}


def test_get_schema_tables(client):
extension_version = deepcopy(extension_version_template)
extension_version['schemas']['release-schema.json']['en'] = release_schema
Expand Down

0 comments on commit 77140d0

Please sign in to comment.