Skip to content
Snippets Groups Projects
Commit d0636e54 authored by Carlos Vega's avatar Carlos Vega
Browse files

show error message if the user attempts to add a visit to a marked subject...

show error message if the user attempts to add a visit to a marked subject (deceased, resigned, excluded, etc)
parent f4c04684
No related branches found
No related tags found
2 merge requests!224Feature/selectable redcap fields,!222Fix/avoid appointments if subject is marked
Pipeline #9921 passed
......@@ -103,10 +103,15 @@ def visit_add(request, subject_id=-1):
subject = None
if len(subjects) > 0:
subject = subjects[0]
if Visit.objects.filter(subject=subject, is_finished=False).count() > 0:
messages.add_message(request, messages.WARNING, 'The subject has unfinished visits, please, finish them before adding new visits.')
return redirect('web.views.subject_visit_details', id=subject_id)
if not subject.can_schedule():
messages.error(request, "Visit cannot be added because the subject status is: {}".format(subject.status))
return redirect('web.views.subject_visit_details', id=subject_id)
if request.method == 'POST':
form = VisitAddForm(request.POST, request.FILES)
args = {'form': form}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment