Fix five confirmed bugs: typo, field name, auth, success message, debug print

- Fix `fist_name` typo in CSV bulk upload (first_name was always None)
- Fix CSV file field name mismatch: `members_data` → `csv_file` (matches form + template)
- Add `@login_required` to backend index view (was unprotected)
- Move `messages.success` inside `if form.is_valid()` (was always shown)
- Remove debug `print(response.headers)` from HTMXViewMixin

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-06-01 14:56:51 +02:00
parent 236a28bb3d
commit a02f234411
3 changed files with 5 additions and 6 deletions

View File

@@ -131,14 +131,14 @@ class MemberLoadView(PermissionRequiredMixin, HTMXViewMixin, SuccessMessageMixin
return HttpResponseRedirect(reverse_lazy("backend:index"))
def form_valid(self, form: MassUploadForm) -> HttpResponse:
member_data = self.request.FILES["members_data"]
member_data = self.request.FILES["csv_file"]
with io.TextIOWrapper(member_data.file) as csvfile:
reader = csv.reader(csvfile)
for row in reader:
member_information = {"first_name": row[0], "last_name": row[1], "email": row[2], "birthday": row[3], "license": row[4]}
member = Member.create(first_name=member_information["fist_name"], last_name=member_information["last_name"], email=member_information["email"])
member = Member.create(first_name=member_information["first_name"], last_name=member_information["last_name"], email=member_information["email"])
member.license = member_information["license"]
if member_information["birthday"] is not None and member_information["birthday"] != "":

View File

@@ -66,8 +66,6 @@ class HTMXViewMixin:
# Push the current path unless overridden
response.headers["HX-Push-Url"] = self.htmx_push_url or request.get_full_path()
print(response.headers)
# Build HX-Trigger payload
trigger_payload = {}

View File

@@ -15,6 +15,7 @@ from backend.forms import ConfigurationForm
# Create your views here.
@login_required
def index(request):
return render(request, "backend/index.html")