-
Notifications
You must be signed in to change notification settings - Fork 172
Simple fix for the CfP proposal progress issue #1551
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
base: dev
Are you sure you want to change the base?
Changes from 4 commits
3df7224
8ea953d
420f0e7
a9d6497
39f554f
8f0d4f5
24869d4
949fc09
4cb8aa5
6df7d43
1cc125e
97be255
f0274a4
c335825
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -13,6 +13,7 @@ | |||||||||||||||||||||||||||||||||||||||||||||||||||
| from django.db.models import Q | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| from django.forms import ValidationError | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| from django.http import HttpResponseNotAllowed | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| from django.utils.datastructures import MultiValueDict | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| from django.shortcuts import redirect | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| from django.urls import reverse | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| from django.utils.functional import Promise, cached_property | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -219,14 +220,40 @@ def get_form_initial(self): | |||||||||||||||||||||||||||||||||||||||||||||||||||
| return copy.deepcopy({**initial_data, **previous_data}) | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
| def get_form(self, from_storage=False): | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| if self.request.method == 'GET' or from_storage: | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| # Cache form initial data to avoid repeated work | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| form_initial = self.get_form_initial() | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
| if self.request.method == 'GET': | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| # For GET requests, use unbound forms with initial data | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| # This correctly displays saved values from the session | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| return self.form_class( | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| data=self.get_form_initial() if from_storage else None, | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| initial=self.get_form_initial(), | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| data=None, | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| initial=form_initial, | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| files=None, | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| **self.get_form_kwargs(), | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| if from_storage: | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| # For validation checks, create a bound form with session data | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| return self.form_class( | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| data=form_initial, | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| initial=form_initial, | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| files=self.get_files(), | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| **self.get_form_kwargs(), | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| return self.form_class(data=self.request.POST, files=self.request.FILES, **self.get_form_kwargs()) | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| # For POST requests, merge new uploads with existing session files | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| # This allows users to navigate back without losing previously uploaded files | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| session_files = self.get_files() or {} | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
| # Preserve MultiValueDict semantics for proper multi-file field support | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| files = MultiValueDict() | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| # Add session files first | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| for field, file_obj in session_files.items(): | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| files[field] = file_obj | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| # New uploads take precedence over session files | ||||||||||||||||||||||||||||||||||||||||||||||||||||
norbusan marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
| for field, file_list in self.request.FILES.lists(): | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| files.setlist(field, file_list) | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
| return self.form_class(data=self.request.POST, files=files, **self.get_form_kwargs()) | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
243
to
257
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
| # For POST requests, merge new uploads with existing session files | |
| # This allows users to navigate back without losing previously uploaded files | |
| session_files = self.get_files() or {} | |
| # Preserve MultiValueDict semantics for proper multi-file field support | |
| files = MultiValueDict() | |
| # Add session files first | |
| for field, file_obj in session_files.items(): | |
| files[field] = file_obj | |
| # New uploads take precedence over session files | |
| for field, file_list in self.request.FILES.lists(): | |
| files.setlist(field, file_list) | |
| return self.form_class(data=self.request.POST, files=files, **self.get_form_kwargs()) | |
| # For POST requests, only use newly uploaded files from the request. | |
| # Previously uploaded files are preserved in session storage and | |
| # should not be passed back as fresh uploads to avoid re-saving | |
| # already stored temporary files. | |
| files = self.request.FILES or None | |
| return self.form_class( | |
| data=self.request.POST, | |
| files=files, | |
| **self.get_form_kwargs(), | |
| ) |
norbusan marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
Outdated
Copilot
AI
Dec 18, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The comment mentions filtering out non-field data, but the implementation only filters based on whether field_name is in request.POST. This doesn't actually filter out non-field POST data like 'csrfmiddlewaretoken' or 'action'. Consider adding a check to exclude these special fields, or the comment should be updated to accurately reflect what the code does.
norbusan marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -71,6 +71,10 @@ def dispatch(self, request, *args, **kwargs): | |||||||||
| or step.identifier == 'user' | ||||||||||
| ], | ||||||||||
| ) | ||||||||||
| if request.method == 'POST' and request.POST.get('action') == 'back': | ||||||||||
| # When clicking Back, the step's POST handler has already saved the data | ||||||||||
| # Now redirect to the previous step | ||||||||||
|
Comment on lines
+75
to
+76
|
||||||||||
| # When clicking Back, the step's POST handler has already saved the data | |
| # Now redirect to the previous step | |
| # When clicking Back, the step's POST handler has already processed the data | |
| # (and, if valid, saved it). Now redirect to the previous step. |
Uh oh!
There was an error while loading. Please reload this page.