コード例 #1
0
ファイル: forms.py プロジェクト: sobkulir/web
 def save(self, task):
     users = get_latest_submits_for_task(task)
     for form_data in self.cleaned_data:
         user = form_data["user"]
         if user in users:
             value = users[user]
             if form_data["points"] is not None:
                 if "review" in value:
                     edit_review(
                         None,
                         None,
                         value["review"],
                         user,
                         form_data["points"],
                         form_data["reviewer_comment"],
                     )
                 else:
                     submit_review(
                         None,
                         None,
                         task,
                         user,
                         form_data["points"],
                         form_data["reviewer_comment"],
                         value["description"],
                     )
             else:
                 if "review" in value:
                     submit = value["review"]
                     submit.points = 0
                     submit.testing_status = SUBMIT_STATUS_IN_QUEUE
                     submit.save()
コード例 #2
0
ファイル: forms.py プロジェクト: sobkulir/web
    def save(self, archive_path, task):
        with zipfile.ZipFile(archive_path) as archive:
            for form in self:
                user = form.cleaned_data["user"]

                if user is None:
                    continue

                fname = form.cleaned_data["filename"]
                points = form.cleaned_data["points"]
                comment = form.cleaned_data["comment"]

                submit_review(archive.read(fname), os.path.basename(fname),
                              task, user, points, comment)

        os.remove(archive_path)
コード例 #3
0
ファイル: forms.py プロジェクト: sobkulir/web
    def save(self, submit, create=False):
        """If creating a new submit, point to user's submit.
        if not, point to existing reviewed submit.
        """
        user = self.cleaned_data["user"]

        if self.cleaned_data.get("file"):
            filecontent = self.cleaned_data["file"]
            filename = self.cleaned_data["file"].name
        else:
            filecontent = None
            filename = None
        points = self.cleaned_data["points"]
        comment = self.cleaned_data["comment"]

        if create:
            submit_review(filecontent, filename, submit.task, user, points,
                          comment, submit)
        else:
            edit_review(filecontent, filename, submit, user, points, comment)
コード例 #4
0
 def save(self, task):
     users = get_latest_submits_for_task(task)
     for form_data in self.cleaned_data:
         user = form_data['user']
         if user in users:
             value = users[user]
             if form_data['points'] is not None:
                 if 'review' in value:
                     edit_review(None, None, value['review'], user,
                                 form_data['points'],
                                 form_data['reviewer_comment'])
                 else:
                     submit_review(None, None, task, user,
                                   form_data['points'],
                                   form_data['reviewer_comment'],
                                   value['description'])
             else:
                 if 'review' in value:
                     submit = value['review']
                     submit.points = 0
                     submit.testing_status = SUBMIT_STATUS_IN_QUEUE
                     submit.save()