-
Notifications
You must be signed in to change notification settings - Fork 5
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
Make some views use URL query parameters instead of distinct paths #650
Make some views use URL query parameters instead of distinct paths #650
Conversation
Codecov Report
@@ Coverage Diff @@
## dev #650 +/- ##
=======================================
Coverage 87.72% 87.72%
=======================================
Files 148 148
Lines 5937 5937
=======================================
Hits 5208 5208
Misses 729 729 |
{{ ticket.timeplace.start_time.date }} | ||
</a> | ||
{% else %} | ||
<a href="{% url 'admin_event_ticket_list' ticket.event.pk %}" target="_blank"> |
Check warning
Code scanning / CodeQL
Potentially unsafe external link
{% for ticket in user.tickets %} | ||
<li class="{% if not ticket.active %}canceled{% endif %}"> | ||
{% if ticket.timeplace %} | ||
<a href="{% url 'admin_time_place_ticket_list' ticket.timeplace.event.pk ticket.timeplace.pk %}" |
Check warning
Code scanning / CodeQL
Potentially unsafe external link
Also replaced the required `make_queue.add_printer3dcourse` permission with `users.view_user`, which all active members currently have.
9608bda
to
a9a1b1f
Compare
a9a1b1f
to
1b80ab4
Compare
This can make it easier for views to use forms for validating and cleaning URL query parameters.
...instead of a distinct path, for listing the quotas of a specific user. This should make it easier to potentially extend the code in the future.
Also removed its inheritance of `CustomFieldsetFormMixin`, as that mixin class isn't suited for `GET` forms, and because `AdminEventParticipantsSearchView` previously needed heavy customization of `CustomFieldsetFormMixin`'s default fields anyway. Also, there wasn't much code needed to be added to `admin_event_participants_search.html`.
They both performed the same basic task (listing reservations using the same template), so this reduces code duplication and makes it easier to potentially extend the code in the future.
...instead of having the year and week as part of the path. This should make it easier to potentially extend the code in the future.
Also added the search query to the page title in the template.
...instead of having the excluded reservation PK as part of the path. This should make it easier to potentially extend the code in the future.
The tests now use the more standard approach of comparing the context data of responses from test clients, instead of using mock requests. Also made the previously named `test_inherited_permissions()` properly test which inherited permissions are listed, as the tests previously didn't add any permissions to any of the groups (i.e. `dev.inherited_permissions` was empty). Also removed some comments from `test_models.py` that were accidentally added in 144e4ef from another, unfinished commit.
1b80ab4
to
f70538e
Compare
Merging without explicit approval from another member, as the Dev committee previously agreed to merge these changes and assume they're relatively bug-free, simply to get things done quicker. |
Proposed changes
Changed multiple pages' URLs to use query parameters, instead of having multiple distinct paths for practically the same page.
Here's an exhaustive list of all affected URLs:
/reservation/quota/<int:pk>/
→/reservation/quota/?user=<int:pk>
(4fcb275)POST
form data withsearch_string
field to/admin/news/events/participants/search/
→GET
to/admin/news/events/participants/search/?search_string=<search_string>
(cf2063d)/reservation/me/
→/reservation/reservations/?owner=me
(c729089)/reservation/admin/
→/reservation/reservations/?owner=MAKE
(c729089)/reservation/<int:year>/<int:week>/<int:pk>/
→/reservation/machines/<int:pk>/?calendar_year=<int:year>&calendar_week=<int:week>
(0ca0e06)/reservation/json/<int:pk>/<int:reservation_pk>/
→/reservation/json/<int:pk>/?exclude_reservation=<int:reservation_pk>
(ccded76)Also refactored the following views to use the newly added
QueryParameterFormMixin
(bca8946):DocumentationPageSearchView
[/search/?query=<query>&page=<page>
] (727aadc)APIReservationListView
[/reservation/calendar/<int:pk>/reservations/?start_date=<start_date>&end_date=<end_date>
] (23d2acd)startDate
query param tostart_date
, andendDate
toend_date
Also made all
JsonResponse
s use UTF8 as encoding instead of ASCII (28f86df).Areas to review closely
That all the changed views still work as intended, and that changing the encoding of
JsonResponse
s to UTF8 doesn't cause any unforeseen bugs.Checklist
(If any of the points are not relevant, mark them as checked)