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

Add helper for standard voting input parameters, add Parameters class #112

Merged
merged 7 commits into from
Aug 12, 2021

Conversation

gigxz
Copy link
Collaborator

@gigxz gigxz commented Aug 11, 2021

  • Adds a helper for defining standard voting input parameters, as discussed with @shaunagm.
  • Pass parameters to process.start(params) as a class object with dynamically defined attributes, instead of a dict.
  • I also consolidated most of the relevant imports for plugin into one file (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..

  • test slack vote
  • test discourse vote
  • test loomio vote
  • test github vote
  • test oc vote

@gigxz gigxz changed the title Add Add helper for standard voting input types Aug 11, 2021
@gigxz gigxz changed the title Add helper for standard voting input types Add helper for standard voting input parameters, add Parameters class Aug 11, 2021
Comment on lines +24 to +53
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
Copy link
Collaborator Author

@gigxz gigxz Aug 11, 2021

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.

Comment on lines +268 to +270
input_schema = VotingStandard.create_input_schema(
include=["title", "options", "details", "closing_at"],
extra_properties={
Copy link
Collaborator Author

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

@gigxz gigxz requested a review from shaunagm August 11, 2021 21:41
@shaunagm
Copy link
Collaborator

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.

@gigxz
Copy link
Collaborator Author

gigxz commented Aug 12, 2021

Yeah the other edits mostly pertain to this:

I also consolidated most of the relevant imports for plugin into one file (plugin_manager.py) so that plugin authors don't need to import from multiple files.

You can feel free to ignore this pieces or comment on it, it's mostly unrelated

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants