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

Refactor to builtin generic views where appropriate #1964

Merged
merged 39 commits into from
Oct 9, 2023

Conversation

niklasmohrin
Copy link
Member

Closes #1754

@niklasmohrin
Copy link
Member Author

Linting is currently failing for some complicated views like UploadGradesView, I think I will just revert this one instead of trying to make the class based one work

@niklasmohrin niklasmohrin marked this pull request as ready for review July 17, 2023 16:37
Copy link
Member

@richardebeling richardebeling left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good stuff

evap/evaluation/auth.py Outdated Show resolved Hide resolved
evap/grades/views.py Show resolved Hide resolved
evap/grades/views.py Outdated Show resolved Hide resolved
evap/staff/tests/test_views.py Show resolved Hide resolved
evap/staff/views.py Outdated Show resolved Hide resolved
evap/staff/views.py Outdated Show resolved Hide resolved
evap/staff/views.py Outdated Show resolved Hide resolved
evap/staff/views.py Show resolved Hide resolved
evap/staff/views.py Show resolved Hide resolved
evap/staff/views.py Show resolved Hide resolved
@richardebeling
Copy link
Member

Linting is currently failing for some complicated views like UploadGradesView, I think I will just revert this one instead of trying to make the class based one work

Overall, I'd be fine with having grade upload remain a function-based view. From the current CI linting output:

evap/staff/views.py:692:8: W0201: Attribute 'object' defined outside init (attribute-defined-outside-init)

I'd be fine with adding exceptions for these, i.e. telling pylint that dispatch (and, if necessary, form_valid) may define new attributes.

evap/grades/views.py:116:4: W0221: Number of parameters was 4 in 'View.dispatch' and is now 3 in overriding 'UploadGradesView.dispatch' method (arguments-differ)

Why is that? What additional two arguments does View.dispatch offer? Couldn't we just also take *args and **kwargs and simply pass them on?
(similar thing for get_object)

@niklasmohrin
Copy link
Member Author

Lints are all fixed, reverted some views to functions, FormSetView now has more niceties

Copy link
Member

@richardebeling richardebeling left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good at a quick glance, but I'll have to go through it carefully once more. You can rebase / prepare a merge if you want.

evap/evaluation/auth.py Show resolved Hide resolved
evap/grades/views.py Outdated Show resolved Hide resolved
evap/evaluation/auth.py Show resolved Hide resolved
evap/grades/views.py Outdated Show resolved Hide resolved
evap/staff/views.py Outdated Show resolved Hide resolved
Copy link
Collaborator

@Kakadus Kakadus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the forms are definitely more readable now

evap/evaluation/tools.py Show resolved Hide resolved
evap/evaluation/tools.py Outdated Show resolved Hide resolved
@niklasmohrin niklasmohrin merged commit ebc5110 into e-valuation:main Oct 9, 2023
@niklasmohrin niklasmohrin deleted the generic-views branch October 9, 2023 18:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

Use django's generic views to reduce boilerplate code
4 participants