-
Notifications
You must be signed in to change notification settings - Fork 16
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
Add helper for standard voting input parameters, add Parameters class #112
Conversation
class VotingStandard: | ||
INPUT_PARAMETERS = { | ||
"title": {"type": "string"}, | ||
"options": {"type": "array", "items": {"type": "string"}}, | ||
"details": {"type": "string"}, | ||
"closing_at": {"type": "string", "format": "date"}, | ||
} | ||
|
||
@staticmethod | ||
def create_input_schema(include=None, exclude=None, extra_properties=None, required=None): | ||
properties = {} | ||
|
||
if include and len(include) > 0: | ||
properties = {k: VotingStandard.INPUT_PARAMETERS[k] for k in include} | ||
else: | ||
properties = VotingStandard.INPUT_PARAMETERS | ||
|
||
if exclude: | ||
for prop in exclude: | ||
properties.pop(prop, None) | ||
|
||
if extra_properties: | ||
for (prop, definition) in extra_properties.items(): | ||
properties[prop] = definition | ||
|
||
schema = {"properties": properties} | ||
if required: | ||
schema["required"] = [prop for prop in required if prop in properties.keys()] | ||
|
||
return schema |
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.
New VotingStandard
class. Added a small subset of non-controversial params to INPUT_PARAMETERS
for now.
input_schema = VotingStandard.create_input_schema( | ||
include=["title", "options", "details", "closing_at"], | ||
extra_properties={ |
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.
Discourse updated to use VotingStandard
This looks good to me but I haven't done a deep dive. There's a bunch of extra stuff in the "files changed" - should I just ignore that, and focus on the parts that you've pulled out here? Also, if you like I can test by trying to incorporate this into the Github votes. |
Yeah the other edits mostly pertain to this:
You can feel free to ignore this pieces or comment on it, it's mostly unrelated |
process.start(params)
as a class object with dynamically defined attributes, instead of a dict.plugin_manager.py
) so that plugin authors don't need to import from multiple files.we dont have test coverage for most, so will test manually..