Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Db change/race transcription field #220

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions disa_app/disa_app_templates/forms/person.html
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,10 @@ <h3>Demographics</h3>
<label for="formInputDISAPersonRace">Race</label>
</div>
</div>
<div class="form-floating my-2">
<input type="text" class="form-control" id="formInputDISAPersonRace_text" aria-label="Person's race transcription" placeholder="Transcript of person's race" v-model="currentReferent.race_text" v-on:blur="saveReferentDataToServer">
<label for="formInputDISAPersonRace_text">Race (as recorded in text)</label>
</div>
<div class="form-group my-2">
<div class="form-floating">
<disa-tags class="form-control" v-model="currentReferent.tribes" v-bind:suggestions="MENU_OPTIONS.formInputDISAPersonTribe" v-on:blur="saveReferentDataToServer" id="formInputDISAPersonTribe"></disa-tags>
Expand Down
2 changes: 2 additions & 0 deletions disa_app/lib/view_data_entrant_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ def prep_get_response( self, rfrnt: models_alch.Referent ) -> dict:
data['ent']['races'] = [
{ 'label': r.name, 'value': r.name,
'id': r.name } for r in rfrnt.races ]
data['ent']['race_text'] = rfrnt.race_text
data['ent']['tribes'] = [
{ 'label': t.name, 'value': t.name,
'id': t.name } for t in rfrnt.tribes ]
Expand Down Expand Up @@ -202,6 +203,7 @@ def execute_details_update( self, user_id: int, data: dict, rfrnt_id: str ) -> d
rfrnt.primary_name = rfrnt.names[0]
rfrnt.races = [ self.common.get_or_create_referent_attribute( ra, models_alch.Race, self.session )
for ra in data['races'] ]
rfrnt.race_text = data['race_text']
rfrnt.tribes = [ self.common.get_or_create_referent_attribute( tr, models_alch.Tribe, self.session )
for tr in data['tribes'] ]
rfrnt.origins = [ self.common.get_or_create_referent_attribute( ori, models_alch.Location, self.session )
Expand Down
1 change: 1 addition & 0 deletions disa_app/models_sqlalchemy.py
Original file line number Diff line number Diff line change
Expand Up @@ -550,6 +550,7 @@ class Referent(Base):
'Race',
secondary=has_race,
back_populates='referents')
race_text = Column(String(500))
titles = relationship('Title',
secondary=has_title, back_populates='referents')
vocations = relationship('Vocation',
Expand Down
10 changes: 1 addition & 9 deletions disa_app/static/js/entry_form_component_id-badge.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,21 +19,13 @@ const componentDefinition = {
return longId.toString().slice(0,5);
},
optionsMenu: function(x, e) {
console.log('options!', x, e);
//console.log('options!', x, e);
}
},
mounted: function () {
const tooltip = new bootstrap.Tooltip(this.$el);
tooltip.html = true;
tooltip.title = "YES and <em>yes</em>!";
console.log('MOUNTED', tooltip);
/*
var tooltipTriggerList = [].slice.call(
document.querySelectorAll('[data-bs-toggle="tooltip"]')
);
var tooltipList = tooltipTriggerList.map(function (tooltipTriggerEl) {
return new bootstrap.Tooltip(tooltipTriggerEl)
}); */
}
};

Expand Down
1 change: 1 addition & 0 deletions disa_app/static/js/entry_form_data_templates.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ const REFERENT_TEMPLATE = {
occupation_text: undefined,
origins:'[]', // Tagify
races:'[]', // Tagify
race_text: undefined,
record_id: undefined,
roles:'[]', // Tagify
sex:'',
Expand Down
1 change: 1 addition & 0 deletions disa_app/static/js/entry_form_vue-item_mixin_save.js
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ async function saveReferentDataToServer() {
occupation_text: this.currentReferent.occupation_text || '',
origins: convertFromTagify(this.currentReferent.origins),
races: convertFromTagify(this.currentReferent.races),
race_text: this.currentReferent.race_text || '',
roles: [], // @todo ?? this.currentReferent.roles,
sex: this.currentReferent.sex,
statuses: convertFromTagify(this.currentReferent.status),
Expand Down
6 changes: 5 additions & 1 deletion disa_app/tests/test_data_referent.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ def test_get_good(self):
rfrnt_data_keys = sorted( resp_dct['ent'].keys() )
# self.assertEqual( ['method', 'payload', 'timestamp', 'url'], req_keys )
self.assertEqual(
['age_category', 'age_number', 'age_text', 'enslavements', 'id', 'names', 'occupation_text', 'origins', 'races', 'sex', 'titles', 'tribes', 'uuid', 'vocations'],
['age_category', 'age_number', 'age_text', 'enslavements', 'id', 'names', 'occupation_text', 'origins', 'races', 'race_text', sex', 'titles', 'tribes', 'uuid', 'vocations'],
rfrnt_data_keys
)
## cleanup
Expand Down Expand Up @@ -213,6 +213,7 @@ def test_put_details_good(self):
random_tribe_partA = secrets.choice( ['Bocotora', 'Eastern Pequot'] )
random_tribe_partB = secrets.choice( ['Mohegan', 'Wampanoag'] )
occupation_text = 'a job description ' + str(random.uniform(1, 20))
race_text = 'a racial transcription ' + str(random.uniform(1, 20))

## create a random float with one decimal point
random_age_number = round(random.uniform(1, 20), 1)
Expand All @@ -232,6 +233,7 @@ def test_put_details_good(self):
# 'races': [ {'id': 'India', 'name': 'India'}, {'id': 'Mustee', 'name': 'Mustee'} ],
'races': [ {'id': random_race_partA, 'name': random_race_partA}, {'id': random_race_partB, 'name': random_race_partB} ],
# 'tribes': [ {'id': 'Bocotora', 'name': 'Bocotora'}, {'id': 'Eastern Pequot', 'name': 'Eastern Pequot'} ],
'race_text': race_text,
'tribes': [ {'id': random_tribe_partA, 'name': random_tribe_partA}, {'id': random_tribe_partB, 'name': random_tribe_partB} ],
'origins': [],
'statuses': [],
Expand Down Expand Up @@ -274,6 +276,8 @@ def test_put_details_good(self):
self.assertEqual( random_uuid, get_resp_dct['ent']['age_category'] )
## test occupation
self.assertEqual( occupation_text, get_resp_dct['ent']['occupation_text'] )
## test race transcript
self.assertEqual( race_text, get_resp_dct['ent']['race_text'] )
## cleanup
# self.delete_new_referent() -- eventually

Expand Down
Loading