Skip to content

Commit

Permalink
Merge pull request #43 from BuildingSync/develop
Browse files Browse the repository at this point in the history
Prep for release 1.1.0
  • Loading branch information
nllong authored Dec 20, 2019
2 parents c1eecf6 + 8c1caf9 commit 0c6ee0f
Show file tree
Hide file tree
Showing 48 changed files with 45,571 additions and 17,987 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -95,4 +95,7 @@ mapping_template*
template_*
bedes-mappings-*.csv
bsyncviewer/lib/bedes/v2.2/schema0.0.1/
bsyncviewer/lib/bedes/*/schema*/bedes-mappings-enumerations.csv
bsyncviewer/lib/bedes/*/schema*/bedes-mappings-terms.csv
bsyncviewer/lib/bedes/*/schema*/bsync_unique_words.csv

18 changes: 18 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,23 @@
# BuildingSync Use Case Selection Tool

## Version 1.1.0

Date Range: 11/19/19 - 12/20/19

Closed Issues and Features:
- Feature [#38]( https://github.com/BuildingSync/selection-tool/issues/38 ), New Test Suite Page (<url>/examples)
- Feature [#22]( https://github.com/BuildingSync/selection-tool/issues/22 ), Add selection-tool version to the webpage
- Fixed [#23]( https://github.com/BuildingSync/selection-tool/issues/23 ), Support unusual characters in use case names
- Fixed [#25]( https://github.com/BuildingSync/selection-tool/issues/25 ), test out script to generate permission schematron document
- Fixed [#31]( https://github.com/BuildingSync/selection-tool/issues/31 ), Remove Bedes CSVs from repo
- Fixed [#32]( https://github.com/BuildingSync/selection-tool/issues/32 ), Store XML example files for each schema version
- Fixed [#33]( https://github.com/BuildingSync/selection-tool/issues/33 ), make schematron use case files downloadable on public use cases
- Fixed [#34]( https://github.com/BuildingSync/selection-tool/issues/34 ), Document instructions for adding a new schema
- Fixed [#35]( https://github.com/BuildingSync/selection-tool/issues/35 ), Rename Data Dictionary to Schema Viewer
- Fixed [#36]( https://github.com/BuildingSync/selection-tool/issues/36 ), Rework home page
- Fixed [#37]( https://github.com/BuildingSync/selection-tool/issues/37 ), change site name
- Fixed [#39]( https://github.com/BuildingSync/selection-tool/issues/39 ), BEDES Email Address has raw python object

## Version 1.0

Date Range: Initial Commit - 11/15/19
Expand Down
20 changes: 20 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -171,3 +171,23 @@ To parse and map a new BEDES version:
```
Note that you must run this command without the --save_to_db flag first, in order to create the CSV files.

### Adding a new BuildingSync Schema Version

Follow these steps to add a new schema version to the selection tool:

1. Add the schema file in the admin interface. Must have admin privileges. The schema will get automatically parsed.
1. Convert existing use cases schematron files to the new schema. Add the new use cases.
1. When the use cases have been reviewed, make them public in the admin interface.
1. Create XML example files and place them in the `lib/validator/examples/schema<VERSION>` directory.
1. Test the validator with the new XML example files.
1. Reparse bedes terms to map them to the new schema following the steps in the BEDES section above.

### Adding Examples from the TestSuite

Follow these steps to add new example tables from the TestSuite

1. Clone the [TestSuite](https://github.com/BuildingSync/TestSuite) repo
2. Install [pandoc](https://pandoc.org/installing.html)
3. Convert the TestSuite README to html:
``` pandoc README.md -s -o README.html ```
4. Copy the tables part of the README.html and paste to replace the old content in ```bsyncviewer/templates/examples.html```.
1 change: 1 addition & 0 deletions app_version.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
1.1.0
10 changes: 5 additions & 5 deletions bsyncviewer/forms.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import os

from django import forms
from django.conf import settings

from .models.schema import Schema

SCHEMA_DEFAULT_VERSION = 0.3
DEFAULT_SCHEMA_VERSION = settings.DEFAULT_SCHEMA_VERSION


class LoadXMLFile(forms.Form):
schema_version = forms.ModelChoiceField(queryset=Schema.objects.all(), empty_label=None,
to_field_name='version', initial=SCHEMA_DEFAULT_VERSION, required=True)
to_field_name='version', initial=DEFAULT_SCHEMA_VERSION, required=True)
file = forms.FileField(label='XML File', required=True)
form_type = forms.CharField(widget=forms.HiddenInput(), initial='file')

Expand All @@ -18,10 +18,10 @@ class LoadXMLExample(forms.Form):
schema_version = forms.ModelChoiceField(queryset=Schema.objects.all(),
empty_label=None,
to_field_name='version',
initial=SCHEMA_DEFAULT_VERSION)
initial=DEFAULT_SCHEMA_VERSION)
file_name = forms.FilePathField(
path=os.path.join(
os.path.abspath(os.path.dirname(__file__)), 'lib', 'validator', 'examples'
os.path.abspath(os.path.dirname(__file__)), 'lib', 'validator', 'examples', 'schema' + str(DEFAULT_SCHEMA_VERSION)
),
recursive=False,
match=r'\.xml$',
Expand Down
18 changes: 16 additions & 2 deletions bsyncviewer/lib/bedes/bedes_parser.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import json
import os
from collections import defaultdict, OrderedDict
from collections import defaultdict, OrderedDict, Mapping

import xmltodict

Expand Down Expand Up @@ -108,7 +108,21 @@ def _cache_terms(self):
assembled['Term-Definition'] = None
if t['Definition']:
if t['Definition'].get('p'):
assembled['Term-Definition'] = t['Definition']['p']
# remove html tags if they happen to be in the definition (ex: email address)
the_def = t['Definition']['p']
# check for ordered dict (when html elements are found in the definition)
if isinstance(the_def, Mapping):
# print("EDGE CASE: definition is a dict: {}".format(the_def))
if 'a' in the_def.keys():
# edge case: <a>. grab text element
assembled['Term-Definition'] = the_def['#text'] + ' ' + the_def['a']['#text']
# print("DEF: {}".format(the_def['#text'] + ' ' + the_def['a']['#text']))
elif 'span' in the_def.keys():
# edge case: <span>. grab span.text element
assembled['Term-Definition'] = the_def['span']['#text']
# print("DEF: {}".format(the_def['span']['#text']))
else:
assembled['Term-Definition'] = the_def
self.terms.append(assembled)

def _cache_enumerations(self):
Expand Down
Loading

0 comments on commit 0c6ee0f

Please sign in to comment.