django-cookie-consent
django-cookie-consent copied to clipboard
Clean up accept/decline view interface
From: https://github.com/jazzband/django-cookie-consent/pull/100#discussion_r1333622823
The cookie (group) accept/decline views now get their varnames from the Django URL patterns, where the varnames are a comma-separated string. Reversing this URL for all groups leads to double final slashes: accept//
because there are no items. Validating this input is also harder than it should be.
Instead, these views should always be POST
-ed to, never GET
(since they need to be CSRF protected) and therefore we should use proper form data for this purposes. This in turn also allows us to clean up the URL patterns a bit and simplify the cookie bar Javascript.
:boom: NOTE this is a potential breaking changes for those users that have set up custom templates to accept/decline cookie groups. It is expected that they use the template tags to craft the appropriate URLs, so perhaps we can provide a backwards compatible approach where the query params are added to the URL, which should then still end up in the POST data. We can then deprecate those templatetags but keep them around until 2.0 to minimize impact?
### Tasks
- [ ] Use proper `django.forms.Form` for cookie group `varname` input
- [ ] Use proper form handling instead of URL params to accept/decline cookie groups
- [ ] Perhaps make it an explicit input that all groups are accepted/declined?
- [ ] Update documentation and example/reference project