Esempio n. 1
0
def get_last_feedback_draft_for_group(context, group):
    """
    Very inefficient method of getting last feedback draft for a group.

    Should be removed when we implement :issue:`769`.
    """
    request = context['request']
    return FeedbackDraft.get_last_feedbackdraft_for_group(
        assignment=group.assignment, group=group, user=request.user)
Esempio n. 2
0
 def test_get_last_feedbackdraft_feedback_workflow_does_not_allow_shared_feedback_drafts(self):
     FeedbackDraft.objects.create(
         delivery=self.deliverybuilder.delivery,
         feedbacktext_raw='Test',
         feedbacktext_html='<p>Test</p>',
         points=30,
         saved_by=UserBuilder('otheruser').user)
     self.assertEquals(
         FeedbackDraft.get_last_feedbackdraft(assignment=self.assignment1builder.assignment,
                                              delivery=self.deliverybuilder.delivery,
                                              user=self.testexaminer),
         None)
Esempio n. 3
0
 def test_get_last_feedbackdraft_owned(self):
     feedbackdraft = FeedbackDraft.objects.create(
         delivery=self.deliverybuilder.delivery,
         feedbacktext_raw='Test',
         feedbacktext_html='<p>Test</p>',
         points=30,
         saved_by=self.testexaminer)
     self.assertEquals(
         FeedbackDraft.get_last_feedbackdraft(assignment=self.assignment1builder.assignment,
                                              delivery=self.deliverybuilder.delivery,
                                              user=self.testexaminer),
         feedbackdraft)
def get_last_feedback_draft_for_group(context, group):
    """
    Very inefficient method of getting last feedback draft for a group.

    Should be removed when we implement :issue:`769`.
    """
    request = context['request']
    return FeedbackDraft.get_last_feedbackdraft_for_group(
        assignment=group.assignment,
        group=group,
        user=request.user
    )
Esempio n. 5
0
 def test_get_last_feedbackdraft_owned(self):
     feedbackdraft = FeedbackDraft.objects.create(
         delivery=self.deliverybuilder.delivery,
         feedbacktext_raw='Test',
         feedbacktext_html='<p>Test</p>',
         points=30,
         saved_by=self.testexaminer)
     self.assertEquals(
         FeedbackDraft.get_last_feedbackdraft(
             assignment=self.assignment1builder.assignment,
             delivery=self.deliverybuilder.delivery,
             user=self.testexaminer), feedbackdraft)
Esempio n. 6
0
 def test_get_last_feedbackdraft_feedback_workflow_does_not_allow_shared_feedback_drafts(
         self):
     FeedbackDraft.objects.create(delivery=self.deliverybuilder.delivery,
                                  feedbacktext_raw='Test',
                                  feedbacktext_html='<p>Test</p>',
                                  points=30,
                                  saved_by=UserBuilder('otheruser').user)
     self.assertEquals(
         FeedbackDraft.get_last_feedbackdraft(
             assignment=self.assignment1builder.assignment,
             delivery=self.deliverybuilder.delivery,
             user=self.testexaminer), None)
    def create_feedbackdraft(self, points, feedbacktext_raw, feedbacktext_html,
                             feedbackfile_uploadedfile, feedbackfile_has_changed,
                             publish=False):
        draft = FeedbackDraft(
            delivery=self.delivery,
            points=points,
            feedbacktext_raw=feedbacktext_raw,
            feedbacktext_html=feedbacktext_html,
            saved_by=self.request.user
        )

        if feedbackfile_has_changed:
            if self.last_feedbackdraftfile:
                self.last_feedbackdraftfile.file.delete()
                self.last_feedbackdraftfile.delete()
            if feedbackfile_uploadedfile:
                feedbackdraftfile = FeedbackDraftFile(
                    delivery=self.delivery,
                    saved_by=self.request.user,
                    filename=feedbackfile_uploadedfile.name)
                feedbackdraftfile.file.save(feedbackfile_uploadedfile.name, feedbackfile_uploadedfile)
                self.last_feedbackdraftfile = feedbackdraftfile

        if publish:
            draft.published = True
            draft.staticfeedback = draft.to_staticfeedback()
            draft.staticfeedback.full_clean()
            draft.staticfeedback.save()
            if self.last_feedbackdraftfile:
                self.last_feedbackdraftfile.to_staticfeedbackfileattachment(
                    staticfeedback=draft.staticfeedback)
        draft.save()
        return draft
Esempio n. 8
0
 def test_get_last_feedbackdraft_for_group_feedback_workflow_allows_shared_feedback_drafts(self):
     self.assignment1builder.update(feedback_workflow='trusted-cooperative-feedback-editing')
     feedbackdraft = FeedbackDraft.objects.create(
         delivery=self.deliverybuilder.delivery,
         feedbacktext_raw='Test',
         feedbacktext_html='<p>Test</p>',
         points=30,
         saved_by=UserBuilder('otheruser').user)
     self.assertEquals(
         FeedbackDraft.get_last_feedbackdraft_for_group(assignment=self.assignment1builder.assignment,
                                                        group=self.groupbuilder.group,
                                                        user=self.testexaminer),
         feedbackdraft)
 def _setup_common_data(self):
     self.object = self.get_object()
     self.delivery = self.object
     self.assignment = self.delivery.deadline.assignment_group.assignment
     self.last_draft = FeedbackDraft.get_last_feedbackdraft(
         assignment=self.assignment,
         delivery=self.delivery,
         user=self.request.user)
     self.last_feedbackdraftfile = FeedbackDraftFile.objects\
         .filter_accessible_files(
             assignment=self.assignment,
             delivery=self.delivery,
             user=self.request.user)\
         .first()
Esempio n. 10
0
 def _setup_common_data(self):
     self.object = self.get_object()
     self.delivery = self.object
     self.assignment = self.delivery.deadline.assignment_group.assignment
     self.last_draft = FeedbackDraft.get_last_feedbackdraft(
         assignment=self.assignment,
         delivery=self.delivery,
         user=self.request.user)
     self.last_feedbackdraftfile = FeedbackDraftFile.objects\
         .filter_accessible_files(
             assignment=self.assignment,
             delivery=self.delivery,
             user=self.request.user)\
         .first()
Esempio n. 11
0
 def test_get_last_feedbackdraft_for_group_feedback_workflow_allows_shared_feedback_drafts(
         self):
     self.assignment1builder.update(
         feedback_workflow='trusted-cooperative-feedback-editing')
     feedbackdraft = FeedbackDraft.objects.create(
         delivery=self.deliverybuilder.delivery,
         feedbacktext_raw='Test',
         feedbacktext_html='<p>Test</p>',
         points=30,
         saved_by=UserBuilder('otheruser').user)
     self.assertEquals(
         FeedbackDraft.get_last_feedbackdraft_for_group(
             assignment=self.assignment1builder.assignment,
             group=self.groupbuilder.group,
             user=self.testexaminer), feedbackdraft)
 def create_feedbackdrafts(self, groups, points, feedbacktext_raw, feedbacktext_html, publish=False):
     draft_ids = []
     for group in groups:
         delivery_id = group.last_delivery_id
         draft = FeedbackDraft(
             delivery_id=delivery_id,
             points=points,
             feedbacktext_raw=feedbacktext_raw,
             feedbacktext_html=feedbacktext_html,
             saved_by=self.request.user
         )
         if publish:
             draft.published = True
             draft.staticfeedback = draft.to_staticfeedback()
             draft.staticfeedback.full_clean()
             draft.staticfeedback.save()
         draft.save()
         draft_ids.append(draft.id)
     return draft_ids
 def create_feedbackdrafts(self, groups, points, feedbacktext_raw, feedbacktext_html, publish=False):
     draft_ids = []
     for group in groups:
         delivery_id = group.last_delivery_id
         draft = FeedbackDraft(
             delivery_id=delivery_id,
             points=points,
             feedbacktext_raw=feedbacktext_raw,
             feedbacktext_html=feedbacktext_html,
             saved_by=self.request.user
         )
         if publish:
             draft.published = True
             draft.staticfeedback = draft.to_staticfeedback()
             draft.staticfeedback.full_clean()
             draft.staticfeedback.save()
         draft.save()
         draft_ids.append(draft.id)
     return draft_ids
Esempio n. 14
0
    def create_feedbackdraft(self,
                             points,
                             feedbacktext_raw,
                             feedbacktext_html,
                             feedbackfile_uploadedfile,
                             feedbackfile_has_changed,
                             publish=False):
        draft = FeedbackDraft(delivery=self.delivery,
                              points=points,
                              feedbacktext_raw=feedbacktext_raw,
                              feedbacktext_html=feedbacktext_html,
                              saved_by=self.request.user)

        if feedbackfile_has_changed:
            if self.last_feedbackdraftfile:
                self.last_feedbackdraftfile.file.delete()
                self.last_feedbackdraftfile.delete()
            if feedbackfile_uploadedfile:
                feedbackdraftfile = FeedbackDraftFile(
                    delivery=self.delivery,
                    saved_by=self.request.user,
                    filename=feedbackfile_uploadedfile.name)
                feedbackdraftfile.file.save(feedbackfile_uploadedfile.name,
                                            feedbackfile_uploadedfile)
                self.last_feedbackdraftfile = feedbackdraftfile

        if publish:
            draft.published = True
            staticfeedback = draft.to_staticfeedback()
            staticfeedback.full_clean()
            staticfeedback.save()
            draft.staticfeedback = staticfeedback
            if self.last_feedbackdraftfile:
                self.last_feedbackdraftfile.to_staticfeedbackfileattachment(
                    staticfeedback=draft.staticfeedback)
        draft.save()
        return draft
Esempio n. 15
0
 def test_get_last_feedbackdraft_none(self):
     self.assertEquals(
         FeedbackDraft.get_last_feedbackdraft(
             assignment=self.assignment1builder.assignment,
             delivery=self.deliverybuilder.delivery,
             user=self.testexaminer), None)
Esempio n. 16
0
 def test_get_last_feedbackdraft_for_group_none(self):
     self.assertEquals(
         FeedbackDraft.get_last_feedbackdraft_for_group(
             assignment=self.assignment1builder.assignment,
             group=self.groupbuilder.group,
             user=self.testexaminer), None)
Esempio n. 17
0
 def test_get_last_feedbackdraft_for_group_none(self):
     self.assertEquals(
         FeedbackDraft.get_last_feedbackdraft_for_group(assignment=self.assignment1builder.assignment,
                                                        group=self.groupbuilder.group,
                                                        user=self.testexaminer),
         None)
Esempio n. 18
0
 def test_get_last_feedbackdraft_none(self):
     self.assertEquals(
         FeedbackDraft.get_last_feedbackdraft(assignment=self.assignment1builder.assignment,
                                              delivery=self.deliverybuilder.delivery,
                                              user=self.testexaminer),
         None)