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

Repeated boilerplate code between upload to database forms #16046

Closed
exemplary-citizen opened this issue Aug 3, 2021 · 0 comments · Fixed by #16756
Closed

Repeated boilerplate code between upload to database forms #16046

exemplary-citizen opened this issue Aug 3, 2021 · 0 comments · Fixed by #16756
Assignees
Labels
dropbox Dropbox related

Comments

@exemplary-citizen
Copy link
Contributor

Is your feature request related to a problem? Please describe.

class CsvToDatabaseForm(DynamicForm):
    # pylint: disable=E0211
    def csv_allowed_dbs() -> List[Database]:  # type: ignore
        csv_enabled_dbs = (
            db.session.query(Database).filter_by(allow_csv_upload=True).all()
        )
        return [
            csv_enabled_db
            for csv_enabled_db in csv_enabled_dbs
            if CsvToDatabaseForm.at_least_one_schema_is_allowed(csv_enabled_db)
        ]

There's unnecessary duplication here between CSV and other forms.

Describe the solution you'd like
We should abstract this into a class UploadToDatabaseForm(DynamicForm) with all the repeated boilerplate and then extend those into class CsvToDatabaseForm(UploadToDatabaseForm), class ExcelToDatabaseForm(UploadToDatabaseForm) etc.

cc: @villebro

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

Successfully merging a pull request may close this issue.

3 participants