-
Notifications
You must be signed in to change notification settings - Fork 3
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
DRY common response object database fields #107
Conversation
contact_title = Column(String(256), nullable=True) | ||
contact_email = Column(String(256), nullable=False) | ||
# how do i make it a minimum of 3 tags? | ||
tags = Column(String, nullable=False) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@rmarow I'm not sure I understand this. I looked in the glossary and didn't see anything about a minimum number of tags. I think this should be an Array column (sqlalchemy)!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If this is hard to code, we can just add explanatory text that says "recommend three or more tags." Sandy had suggested this last week, and I added a note in the front-end document, which @rmarow noted. I think the explanatory text is a good way to go. If we do some testing and folks aren't responding to that request, we can adjust.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree, let's go with explanatory text and treat the actual validation as icing for later :)
usaon_vta_survey/forms.py
Outdated
only=['name', 'performance_rating'], | ||
only=[ | ||
'short_name', | ||
'full_name', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@MattF-NSIDC is there a way to reduce the repetitiveness here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could save these as a re-usable list of strings!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, just a few comments to address that I think shouldn't require a second review :) Let me know if you want me to take a look again before the merge though! Happy to do it :)
usaon_vta_survey/forms.py
Outdated
@@ -29,6 +29,21 @@ | |||
User, | |||
) | |||
|
|||
response_object_fields = [ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe common_response_object_fields
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, is there a way we can generate this list from the mixin class? There are many ways to get the "fields" out of a class, but they're all pretty messy. We could make ResponseObjectFieldMixin
a pydantic class, and then I think we have more intuitive access to its fields. Or we could use one of these methods:
https://stackoverflow.com/questions/9058305/getting-attributes-of-a-class
I don't feel we need to address this in this PR, except to leave a comment for future us that some DRYing needs to be done.
@@ -213,14 +226,6 @@ class ResponseObservingSystem(BaseModel, IORelationshipMixin): | |||
'polymorphic_on': type, | |||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
id
and response_id
are also common fields. Can those go in the mixin as well?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sqlalchemy did not like when i tried to do this.
resolves #103