How to use the devilry.apps.core.models.Assignment.objects.get function in devilry

To help you get started, we’ve selected a few devilry examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github devilry / devilry-django / devilry / project / develop / management / commands / devilry_developer_create_deliveries_from_filesystemtree.py View on Github external
def _find_assignment(self):
        from devilry.apps.core.models import Assignment
        subject_short_name, period_short_name, assignment_short_name = self.assignmentpath.split('.')
        self.assignment = Assignment.objects.get(
            short_name=assignment_short_name,
            parentnode__short_name=period_short_name,
            parentnode__parentnode__short_name=subject_short_name)
github devilry / devilry-django / devilry / devilry_subjectadmin / rest / createnewassignment.py View on Github external
setupexaminers_mode, copyfromassignment_id=None,
                        user=None, only_copy_passing_groups=False):
        if setupstudents_mode == 'do_not_setup':
            return
        if not first_deadline and assignment.delivery_types != NON_ELECTRONIC:
            raise BadRequestFieldError('first_deadline',
                                       _('Required when adding students.'))
        if setupstudents_mode == 'allrelated':
            autosetup_examiners = setupexaminers_mode == 'bytags'
            self._add_all_relatedstudents(assignment, first_deadline,
                                          autosetup_examiners)
        elif setupstudents_mode == 'copyfromassignment':
            if not isinstance(copyfromassignment_id, int):
                raise BadRequestFieldError('copyfromassignment_id', 'Must be an int, got {0!r}'.format(copyfromassignment_id))
            try:
                copyfromassignment = Assignment.objects.get(id=copyfromassignment_id,
                                                            parentnode=assignment.parentnode)
            except Assignment.DoesNotExist:
                raise BadRequestFieldError('copyfromassignment_id', 'Assignment with id={0} does not exist in this period.'.format(copyfromassignment_id))
            else:
                copy_examiners = False
                if setupexaminers_mode == 'copyfromassignment':
                    copy_examiners = True

                self._copy_students_from_assignment(assignment, first_deadline,
                                                    copyfromassignment,
                                                    copy_examiners=copy_examiners,
                                                    only_copy_passing_groups=only_copy_passing_groups)

        else:
            raise BadRequestFieldError('setupexaminers_mode', 'Invalid value: {0}'.format(setupstudents_mode))
github devilry / devilry-django / src / devilry_subjectadmin / devilry_subjectadmin / rest / createnewassignment.py View on Github external
setupexaminers_mode, copyfromassignment_id=None,
                        user=None, only_copy_passing_groups=False):
        if setupstudents_mode == 'do_not_setup':
            return
        if not first_deadline and assignment.delivery_types != NON_ELECTRONIC:
            raise BadRequestFieldError('first_deadline',
                                       _('Required when adding students.'))
        if setupstudents_mode == 'allrelated':
            autosetup_examiners = setupexaminers_mode == 'bytags'
            self._add_all_relatedstudents(assignment, first_deadline,
                                          autosetup_examiners)
        elif setupstudents_mode == 'copyfromassignment':
            if not isinstance(copyfromassignment_id, int):
                raise BadRequestFieldError('copyfromassignment_id', 'Must be an int, got {0!r}'.format(copyfromassignment_id))
            try:
                copyfromassignment = Assignment.objects.get(id=copyfromassignment_id,
                                                            parentnode=assignment.parentnode)
            except Assignment.DoesNotExist:
                raise BadRequestFieldError('copyfromassignment_id', 'Assignment with id={0} does not exist in this period.'.format(copyfromassignment_id))
            else:
                copy_examiners = False
                if setupexaminers_mode == 'copyfromassignment':
                    copy_examiners = True

                self._copy_students_from_assignment(assignment, first_deadline,
                                                    copyfromassignment,
                                                    copy_examiners=copy_examiners,
                                                    only_copy_passing_groups=only_copy_passing_groups)

        else:
            raise BadRequestFieldError('setupexaminers_mode', 'Invalid value: {0}'.format(setupstudents_mode))
github devilry / devilry-django / devilry / devilry_admin / views / assignment / students / delete_groups.py View on Github external
def dispatch(self, request, *args, **kwargs):
        try:
            self.from_assignment = Assignment.objects.get(id=kwargs.get('from_assignment_id'))
        except Assignment.DoesNotExist:
            raise Http404()
        return super(ConfirmView, self).dispatch(request, *args, **kwargs)
github devilry / devilry-django / src / devilry_subjectadmin / devilry_subjectadmin / rest / relateduser_assignment_ro.py View on Github external
def get_period_id(self):
        assignment_id = self.kwargs['assignment_id']
        assignment = Assignment.objects.get(id=assignment_id)
        return assignment.parentnode_id
github devilry / devilry-django / devilry / apps / gradeeditors / simplified / examiner.py View on Github external
def read_authorize(cls, user, obj):
        try:
            Assignment.objects.get(Assignment.q_is_examiner(user) & Q(id=obj.id))
        except Assignment.DoesNotExist:
            raise PermissionDenied()
github devilry / devilry-django / devilry / devilry_examiner / views / allgroupsoverview.py View on Github external
def _get_assignment_type(self, *args, **kwargs):
        assignmentid = kwargs.get('assignmentid')
        assignment = Assignment.objects.get(id=assignmentid)
        assignment_type = "normal"
        if assignment.anonymous:
            assignment_type = "anonymous"
        return assignment_type
github devilry / devilry-django / src / devilry_subjectadmin / devilry_subjectadmin / rest / passedinpreviousperiod.py View on Github external
def _get_assignment(self, id):
        try:
            return Assignment.objects.get(id=id)
        except Assignment.DoesNotExist:
            raise NotFoundError('Assignment with id={0} not found'.format(id))