Skip to content

Commit

Permalink
fix: edit research line page bug
Browse files Browse the repository at this point in the history
  • Loading branch information
francesco-filicetti committed Dec 14, 2024
1 parent 8ca99c9 commit 6748c98
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 10 deletions.
9 changes: 5 additions & 4 deletions research_lines/management/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@
path('baseresearchlines/<int:rline_id>/', base_research_line, name='base-research-line-edit'),
path('baseresearchlines/<int:rline_id>/delete/', base_research_line_delete, name='base-research-line-delete'),

path('baseresearchlines/<int:rline_id>/teacher/new/', base_research_line_teacher_new, name='base-research-line-teacher-new'),
path('baseresearchlines/<int:rline_id>/teacher/<int:teacher_rline_id>/', base_research_line_teacher_edit, name='base-research-line-teacher-edit'),
path('baseresearchlines/<int:rline_id>/teacher/<int:teacher_rline_id>/delete/', base_research_line_teacher_delete, name='base-research-line-teacher-delete'),

path('appliedresearchlines/', applied_research_lines, name='applied-research-lines'),
path('appliedresearchlines/new/', applied_research_lines_new, name='applied-research-line-new'),
path('appliedresearchlines/<int:rline_id>/', applied_research_line, name='applied-research-line-edit'),
Expand All @@ -34,7 +38,4 @@
path('appliedresearchlines/<int:rline_id>/teacher/<int:teacher_rline_id>/', applied_researchline_teacher_edit, name='applied-research-line-teacher-edit'),
path('appliedresearchlines/<int:rline_id>/teacher/<int:teacher_rline_id>/delete/', applied_researchline_teacher_delete, name='applied-research-line-teacher-delete'),

path('baseresearchlines/<int:rline_id>/teacher/new/', base_research_line_teacher_new, name='base-research-line-teacher-new'),
path('baseresearchlines/<int:rline_id>/teacher/<int:teacher_rline_id>/', base_research_line_teacher_edit, name='base-research-line-teacher-edit'),
path('baseresearchlines/<int:rline_id>/teacher/<int:teacher_rline_id>/delete/', base_research_line_teacher_delete, name='base-research-line-teacher-delete'),
]
]
12 changes: 6 additions & 6 deletions research_lines/management/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -568,18 +568,18 @@ def base_research_line_teacher_edit(
RicercaDocenteLineaBase.objects.select_related("personale"), pk=teacher_rline_id
)
teacher = teacher_rline.personale
teacher_rline_id = encrypt(teacher.matricola)
teacher_matricola = encrypt(teacher.matricola)
teacher_data = f"{teacher.nome} {teacher.cognome}"
form = RicercaDocenteLineaBaseForm(
instance=teacher_rline, initial={"choosen_person": teacher_rline_id}
instance=teacher_rline, initial={"choosen_person": teacher_matricola}
)

if request.POST:
form = RicercaDocenteLineaBaseForm(instance=teacher_rline, data=request.POST)
if form.is_valid():
form.save(commit=False)
teacher_rline_id = decrypt(form.cleaned_data["choosen_person"])
new_teacher = get_object_or_404(Personale, matricola=teacher_rline_id)
new_teacher = get_object_or_404(Personale, matricola=teacher_matricola)
teacher_rline.user_mod = request.user
teacher_rline.personale = new_teacher
teacher_rline.save()
Expand Down Expand Up @@ -639,10 +639,10 @@ def applied_researchline_teacher_edit(
pk=teacher_rline_id,
)
teacher = teacher_rline.personale
teacher_rline_id = encrypt(teacher.matricola)
teacher_matricola = encrypt(teacher.matricola)
teacher_data = f"{teacher.nome} {teacher.cognome}"
form = RicercaDocenteLineaApplicataForm(
instance=teacher_rline, initial={"choosen_person": teacher_rline_id}
instance=teacher_rline, initial={"choosen_person": teacher_matricola}
)

if request.POST:
Expand All @@ -652,7 +652,7 @@ def applied_researchline_teacher_edit(
if form.is_valid():
form.save(commit=False)
teacher_rline_id = decrypt(form.cleaned_data["choosen_person"])
new_teacher = get_object_or_404(Personale, matricola=teacher_rline_id)
new_teacher = get_object_or_404(Personale, matricola=teacher_matricola)
teacher_rline.user_mod = request.user
teacher_rline.personale = new_teacher
teacher_rline.save()
Expand Down

0 comments on commit 6748c98

Please sign in to comment.