Exemplo n.º 1
0
 def get(self, request, id):
     pluginsessionid = self.request.GET.get('pluginsessionid', None)
     if not pluginsessionid:
         raise ErrorResponse(statuscodes.HTTP_400_BAD_REQUEST,
             {'detail': '``pluginsessionid`` is a required parameter'})
     period = get_object_or_404(Period, pk=id)
     previewdata = self.request.session[create_sessionkey(pluginsessionid)]
     grouper = GroupsGroupedByRelatedStudentAndAssignment(period)
     return {
         'perioddata': grouper.serialize(),
         'pluginoutput': previewdata
     }
Exemplo n.º 2
0
 def get(self, request, id):
     pluginsessionid = self.request.GET.get("pluginsessionid", None)
     if not pluginsessionid:
         raise ErrorResponse(
             statuscodes.HTTP_400_BAD_REQUEST, {"detail": "``pluginsessionid`` is a required parameter"}
         )
     period = get_object_or_404(Period, pk=id)
     previewdata = self.request.session[create_sessionkey(pluginsessionid)]
     if not isinstance(previewdata, PreviewData):
         raise ErrorResponse(
             statuscodes.HTTP_400_BAD_REQUEST, {"detail": "The session data must be a PreviewData object."}
         )
     grouper = GroupsGroupedByRelatedStudentAndAssignment(period)
     return {"perioddata": grouper.serialize(), "pluginoutput": previewdata.serialize()}
Exemplo n.º 3
0
    def _get_instance(self, id):
        try:
            qry = Period.objects.select_related("parentnode")
            period = qry.get(id=id)
        except Period.DoesNotExist:
            raise ErrorResponse(
                statuscodes.HTTP_404_NOT_FOUND, {"detail": "The period with ID {id} does not exist".format(id=id)}
            )

        self._permissioncheck(period)

        statusQry = period.qualifiedforexams_status.all()
        if len(statusQry) == 0:
            raise ErrorResponse(statuscodes.HTTP_404_NOT_FOUND, {"detail": "The period has no statuses"})

        grouper = GroupsGroupedByRelatedStudentAndAssignment(period)
        out = self._serialize_period(period)
        out.update(
            {"perioddata": grouper.serialize(), "statuses": [self._serialize_status(status) for status in statusQry]}
        )
        return out
Exemplo n.º 4
0
    def _get_instance(self, id):
        try:
            qry = Period.objects.select_related('parentnode')
            period = qry.get(id=id)
        except Period.DoesNotExist:
            raise ErrorResponse(statuscodes.HTTP_404_NOT_FOUND,
                {'detail': 'The period with ID {id} does not exist'.format(id=id)})

        self._permissioncheck(period)

        statusQry = period.qualifiedforexams_status.all()
        if statusQry.count() == 0:
            raise ErrorResponse(statuscodes.HTTP_404_NOT_FOUND,
                {'detail': 'The period has no statuses'})
        statusQry = statusQry.select_related(
                'period', 'user', 'user__devilryuserprofile')

        grouper = GroupsGroupedByRelatedStudentAndAssignment(period)
        out = self._serialize_period(period)
        out.update({
            'perioddata': grouper.serialize(),
            'statuses': [self._serialize_status(status) for status in statusQry]
        })
        return out
 def get(self, request, id=None):
     period = Period.objects.get(id=id) # NOTE: We know the period exists because of IsPeriodAdmin
     grouper = GroupsGroupedByRelatedStudentAndAssignment(period)
     return grouper.serialize()