Esempio n. 1
0
 def get_context_data(self, **kwargs):
     context = super(TalkDetails, self).get_context_data(**kwargs)
     current = self.event == Event.objects.current_event()
     context.update(
         {
             "speakers": context["talk"].published_speakers.all(),
             "event": self.event,
             "current": current,
         }
     )
     if self.request.user.is_authenticated:
         attendee = Attendee.objects.filter(
             event=self.event, user=self.request.user
         ).first()
         if attendee is not None:
             talk = context["talk"]
             context["reservation"] = SessionReservation.objects.filter(
                 talk=talk, attendee=attendee
             ).first()
             if talk.is_feedback_allowed or self.request.user.is_staff:
                 existing_feedback = AttendeeFeedback.objects.filter(
                     talk=talk, attendee=attendee
                 ).first()
                 context["feedback_form"] = AttendeeTalkFeedbackForm(
                     instance=existing_feedback, attendee=attendee, talk=talk
                 )
     return context
Esempio n. 2
0
 def test_score_is_restricted_to_range(self):
     form = AttendeeTalkFeedbackForm(
         instance=mock.MagicMock(),
         data={"score": "10"},
         talk=self.talk,
         attendee=self.attendee,
     )
     form.full_clean()
     self.assertEqual(form.cleaned_data["score"], 5)
     form = AttendeeTalkFeedbackForm(
         instance=mock.MagicMock(),
         data={"score": "3"},
         talk=self.talk,
         attendee=self.attendee,
     )
     form.full_clean()
     self.assertEqual(form.cleaned_data["score"], 3)
Esempio n. 3
0
 def test_init_creates_form_helper(self):
     form = AttendeeTalkFeedbackForm(
         instance=mock.MagicMock(), talk=self.talk, attendee=self.attendee
     )
     self.assertIsInstance(form.helper, FormHelper)
     self.assertEquals(
         form.helper.form_action,
         "/{}/talk/{}/feedback/".format(self.talk.event.slug, self.talk.slug),
     )
Esempio n. 4
0
 def test_init_creates_layout(self):
     form = AttendeeTalkFeedbackForm(
         instance=mock.MagicMock(), talk=self.talk, attendee=self.attendee
     )
     self.assertIsInstance(form.helper.layout, Layout)
     layout_fields = [name for [_, name] in form.helper.layout.get_field_names()]
     self.assertListEqual(["score", "comment"], layout_fields)
     self.assertEquals(
         len(form.helper.layout.get_layout_objects(Submit, greedy=True)), 1
     )
Esempio n. 5
0
 def test_fields(self):
     form = AttendeeTalkFeedbackForm(instance=mock.MagicMock(),
                                     talk=self.talk,
                                     attendee=self.attendee)
     self.assertListEqual(["score", "comment"], list(form.fields))