|
27 | 27 |
|
28 | 28 | from django import forms |
29 | 29 | from django.shortcuts import render, redirect, get_object_or_404 |
30 | | -from django.http import HttpResponse, HttpResponseRedirect, HttpResponseForbidden, Http404 |
| 30 | +from django.http import HttpResponse, HttpResponseRedirect, HttpResponseForbidden, HttpResponseNotFound, Http404 |
31 | 31 | from django.conf import settings |
32 | 32 | from django.contrib import messages |
33 | 33 | from django.contrib.auth.decorators import login_required |
|
79 | 79 | from ietf.meeting.utils import current_session_status |
80 | 80 | from ietf.meeting.utils import data_for_meetings_overview |
81 | 81 | from ietf.message.utils import infer_message |
| 82 | +from ietf.name.models import SlideSubmissionStatusName |
82 | 83 | from ietf.secr.proceedings.utils import handle_upload_file |
83 | 84 | from ietf.secr.proceedings.proc_utils import (get_progress_stats, post_process, import_audio_files, |
84 | 85 | create_recording) |
@@ -1615,9 +1616,9 @@ def session_details(request, num, acronym): |
1615 | 1616 | pending_suggestions = None |
1616 | 1617 | if request.user.is_authenticated: |
1617 | 1618 | if can_manage: |
1618 | | - pending_suggestions = session.slidesubmission_set.all() |
| 1619 | + pending_suggestions = session.slidesubmission_set.filter(status__slug='pending') |
1619 | 1620 | else: |
1620 | | - pending_suggestions = session.slidesubmission_set.filter(submitter=request.user.person) |
| 1621 | + pending_suggestions = session.slidesubmission_set.filter(status__slug='pending', submitter=request.user.person) |
1621 | 1622 |
|
1622 | 1623 | return render(request, "meeting/session_details.html", |
1623 | 1624 | { 'scheduled_sessions':scheduled_sessions , |
@@ -3213,13 +3214,16 @@ def approve_proposed_slides(request, slidesubmission_id, num): |
3213 | 3214 | name, _ = os.path.splitext(submission.filename) |
3214 | 3215 | name = name[:name.rfind('-ss')] |
3215 | 3216 | existing_doc = Document.objects.filter(name=name).first() |
3216 | | - if request.method == 'POST': |
| 3217 | + if request.method == 'POST' and submission.status.slug == 'pending': |
3217 | 3218 | form = ApproveSlidesForm(show_apply_to_all_checkbox, request.POST) |
3218 | 3219 | if form.is_valid(): |
3219 | 3220 | apply_to_all = submission.session.type_id == 'regular' |
3220 | 3221 | if show_apply_to_all_checkbox: |
3221 | 3222 | apply_to_all = form.cleaned_data['apply_to_all'] |
3222 | 3223 | if request.POST.get('approve'): |
| 3224 | + # Ensure that we have a file to approve. The system gets cranky otherwise. |
| 3225 | + if submission.filename is None or submission.filename == '' or not os.path.isfile(submission.staged_filepath()): |
| 3226 | + return HttpResponseNotFound("The slides you attempted to approve could not be found. Please disapprove and delete them instead.") |
3223 | 3227 | title = form.cleaned_data['title'] |
3224 | 3228 | if existing_doc: |
3225 | 3229 | doc = Document.objects.get(name=name) |
@@ -3259,15 +3263,29 @@ def approve_proposed_slides(request, slidesubmission_id, num): |
3259 | 3263 | os.rename(submission.staged_filepath(), os.path.join(path, target_filename)) |
3260 | 3264 | post_process(doc) |
3261 | 3265 | acronym = submission.session.group.acronym |
3262 | | - submission.delete() |
| 3266 | + submission.status = SlideSubmissionStatusName.objects.get(slug='approved') |
| 3267 | + submission.doc = doc |
| 3268 | + submission.save() |
3263 | 3269 | return redirect('ietf.meeting.views.session_details',num=num,acronym=acronym) |
3264 | 3270 | elif request.POST.get('disapprove'): |
3265 | | - os.unlink(submission.staged_filepath()) |
| 3271 | + # Errors in processing a submit request sometimes result |
| 3272 | + # in a SlideSubmission object without a file. Handle |
| 3273 | + # this case and keep processing the 'disapprove' even if |
| 3274 | + # the filename doesn't exist. |
| 3275 | + try: |
| 3276 | + if submission.filename != None and submission.filename != '': |
| 3277 | + os.unlink(submission.staged_filepath()) |
| 3278 | + except (FileNotFoundError, IsADirectoryError): |
| 3279 | + pass |
3266 | 3280 | acronym = submission.session.group.acronym |
3267 | | - submission.delete() |
| 3281 | + submission.status = SlideSubmissionStatusName.objects.get(slug='rejected') |
| 3282 | + submission.save() |
3268 | 3283 | return redirect('ietf.meeting.views.session_details',num=num,acronym=acronym) |
3269 | 3284 | else: |
3270 | 3285 | pass |
| 3286 | + elif not submission.status.slug == 'pending': |
| 3287 | + return render(request, "meeting/previously_approved_slides.html", |
| 3288 | + {'submission': submission }) |
3271 | 3289 | else: |
3272 | 3290 | initial = { |
3273 | 3291 | 'title': submission.title, |
|
0 commit comments