|
4 | 4 |
|
5 | 5 | from django.conf import settings |
6 | 6 | from django.contrib.auth.decorators import login_required |
| 7 | +from django.contrib.auth.models import AnonymousUser |
7 | 8 | from django.contrib import messages |
8 | 9 | from django.core.urlresolvers import reverse |
9 | 10 | from django.http import Http404, HttpResponseRedirect, HttpResponseForbidden |
|
25 | 26 | MergeForm, NomComTemplateForm, PositionForm, |
26 | 27 | PrivateKeyForm, EditNomcomForm, EditNomineeForm, |
27 | 28 | PendingFeedbackForm, ReminderDatesForm, FullFeedbackFormSet, |
28 | | - FeedbackEmailForm) |
| 29 | + FeedbackEmailForm, NominationResponseCommentForm) |
29 | 30 | from ietf.nomcom.models import Position, NomineePosition, Nominee, Feedback, NomCom, ReminderDates, FeedbackLastSeen |
30 | 31 | from ietf.nomcom.utils import (get_nomcom_by_year, store_nomcom_private_key, |
31 | 32 | get_hash_nominee_position, send_reminder_to_nominees, |
@@ -546,23 +547,43 @@ def process_nomination_status(request, year, nominee_position_id, state, date, h |
546 | 547 | state = get_object_or_404(NomineePositionStateName, slug=state) |
547 | 548 | message = ('warning', |
548 | 549 | ("Click on 'Save' to set the state of your nomination to %s to %s (this"+ |
549 | | - "is not a final commitment - you can notify us later if you need to change this)") % |
| 550 | + " is not a final commitment - you can notify us later if you need to change this).") % |
550 | 551 | (nominee_position.position.name, state.name)) |
551 | 552 | if request.method == 'POST': |
552 | | - nominee_position.state = state |
553 | | - nominee_position.save() |
554 | | - need_confirmation = False |
555 | | - message = message = ('success', 'Your nomination on %s has been set as %s' % (nominee_position.position.name, |
556 | | - state.name)) |
557 | | - |
| 553 | + form = NominationResponseCommentForm(request.POST) |
| 554 | + if form.is_valid(): |
| 555 | + nominee_position.state = state |
| 556 | + nominee_position.save() |
| 557 | + need_confirmation = False |
| 558 | + if form.cleaned_data['comments']: |
| 559 | + # This Feedback object is of type comment instead of nomina in order to not |
| 560 | + # make answering "who nominated themselves" harder. |
| 561 | + who = request.user |
| 562 | + if isinstance(who,AnonymousUser): |
| 563 | + who = None |
| 564 | + f = Feedback.objects.create(nomcom = nomcom, |
| 565 | + author = nominee_position.nominee.email, |
| 566 | + subject = '%s nomination %s'%(nominee_position.nominee.name(),state), |
| 567 | + comments = form.cleaned_data['comments'], |
| 568 | + type_id = 'comment', |
| 569 | + user = who, |
| 570 | + ) |
| 571 | + f.positions.add(nominee_position.position) |
| 572 | + f.nominees.add(nominee_position.nominee) |
| 573 | + |
| 574 | + message = ('success', 'Your nomination on %s has been set as %s' % (nominee_position.position.name, |
| 575 | + state.name)) |
| 576 | + else: |
| 577 | + form = NominationResponseCommentForm() |
558 | 578 | return render_to_response('nomcom/process_nomination_status.html', |
559 | 579 | {'message': message, |
560 | 580 | 'nomcom': nomcom, |
561 | 581 | 'year': year, |
562 | 582 | 'nominee_position': nominee_position, |
563 | 583 | 'state': state, |
564 | 584 | 'need_confirmation': need_confirmation, |
565 | | - 'selected': 'feedback'}, RequestContext(request)) |
| 585 | + 'selected': 'feedback', |
| 586 | + 'form': form }, RequestContext(request)) |
566 | 587 |
|
567 | 588 |
|
568 | 589 | @role_required("Nomcom") |
|
0 commit comments