Skip to content

Commit

Permalink
Add role dropdown to profile page
Browse files Browse the repository at this point in the history
  • Loading branch information
rmarow committed Aug 17, 2023
1 parent 8b23d53 commit 9889676
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 8 deletions.
7 changes: 2 additions & 5 deletions usaon_vta_survey/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,8 @@ def conv_String(self, field_args, **extra):
FORMS_BY_MODEL: dict[BaseModel, Form] = {
User: model_form(
User,
only=['orcid', 'biography', 'affiliation', 'role_id'],
# Allows foreign key to be included in form.
exclude_fk=False,
only=['orcid', 'biography', 'affiliation', 'role'],
field_args={'role': {'get_label': 'id'}},
),
Survey: model_form(Survey, only=['title', 'notes']),
# Response entities ("nodes" from Sankey diagram perspective)
Expand Down Expand Up @@ -87,8 +86,6 @@ def conv_String(self, field_args, **extra):
ResponseSocietalBenefitArea: model_form(
ResponseSocietalBenefitArea,
only=['societal_benefit_area'],
exclude_fk=False,
# field_args={'get_label': 'id' },
field_args={'societal_benefit_area': {'get_label': 'id'}},
),
# Response relationships ("edges" from Sankey diagram perspective)
Expand Down
1 change: 1 addition & 0 deletions usaon_vta_survey/models/tables.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ class User(BaseModel, UserMixin):
String,
nullable=True,
)
role = relationship('Role')


class Survey(BaseModel):
Expand Down
6 changes: 3 additions & 3 deletions usaon_vta_survey/templates/macros/forms/user_profile.j2
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@
{% endif %}
<br /><br />

{{form.role_id.label}} {{form.role_id(size=50)}}
{% if form.role_id.errors %}
{{form.role.label}} {{form.role}}
{% if form.role.errors %}
<ul class="errors">
{% for error in form.role_id.errors %}
{% for error in form.role.errors %}
<li>{{ error }}</li>
{% endfor %}
</ul>
Expand Down

0 comments on commit 9889676

Please sign in to comment.