How to use the devilry.apps.core.models 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 / devilry_student / views / period / overview.py View on Github external
def get_url(self):
        return reverse_cradmin_url(
            instanceid='devilry_group_student',
            appname='feedbackfeed',
            roleid=self.group.id,
            viewname=crapp.INDEXVIEW_NAME,
        )

    def get_extra_css_classes_list(self):
        return ['devilry-student-listbuilder-grouplist-itemframe']


class PeriodOverviewView(listbuilderview.FilterListMixin,
                         listbuilderview.View):
    model = coremodels.AssignmentGroup
    value_renderer_class = devilry_listbuilder.assignmentgroup.StudentItemValue
    frame_renderer_class = GroupItemFrame
    paginate_by = 15
    template_name = 'devilry_student/period/overview.django.html'

    def __get_assignment_id_to_assignment_map(self):
        assignmentqueryset = Assignment.objects\
            .filter_student_has_access(user=self.request.user)\
            .filter(parentnode=self.request.cradmin_role)\
            .select_related('parentnode__parentnode')\
            .prefetch_point_to_grade_map()
        assignment_id_to_assignment_map = {}
        for assignment in assignmentqueryset:
            assignment_id_to_assignment_map[assignment.id] = assignment
        return assignment_id_to_assignment_map
github devilry / devilry-django / devilry / apps / administrator / simplified / simplifiedassignmentgroup.py View on Github external
def is_empty(cls, obj):
        """
        Return ``True`` if the given assignmentgroup contains no deliveries.
        """
        return models.Delivery.objects.filter(deadline__assignment_group=obj).count() == 0
github devilry / devilry-django / devilry / devilry_import_v2database / modelimporters / qualifiesforexam_importer.py View on Github external
def _get_period_from_id(self, period_id):
        try:
            period = core_models.Period.objects.get(id=period_id)
        except core_models.Period.DoesNotExist:
            raise modelimporter.ModelImporterException(
                'Period with id {} does not exist'.format(period_id)
            )
        return period
github devilry / devilry-django / src / devilry / apps / administrator / simplified / simplifiedcandidate.py View on Github external
def is_empty(cls, obj):
        """
        Return ``True`` if the given assignment contains no assignmentgroups.
        """
        return models.Delivery.objects.filter(deadline__assignment_group=obj.assignment_group, delivered_by=obj).count() == 0
github devilry / devilry-django / devilry / devilry_qualifiesforexam / cradmin_instances / crinstance.py View on Github external
def get_rolequeryset(self):
        """
        Get queryset of :class:`~devilry.apps.core.models.Period` with join on the ``Periods``s
        related :class:`~devilry.apps.core.models.Subject`.

        Returns:
            QuerySet: A queryset of :class:`~devilry.apps.core.models.Period`

        """
        return core_models.Period.objects\
            .select_related('parentnode')\
            .filter_user_is_admin(user=self.request.user)
github devilry / devilry-django / devilry / coreutils / simplified / metabases / delivery.py View on Github external
from devilry.apps.core import models
from devilry.simplified import FieldSpec, FilterSpec, FilterSpecs, ForeignFilterSpec



class SimplifiedDeliveryMetaMixin(object):
    """ Defines the django model to be used, resultfields returned by
    search and which fields can be used to search for a Delivery object
    using the Simplified API """
    model = models.Delivery
    editablefields = ('deadline', 'successful')
    resultfields = FieldSpec('id',
                             'number',
                             'time_of_delivery',
                             'deadline',
                             'successful',
                             'delivery_type', 'alias_delivery',
                             delivered_by=['delivered_by__identifier'],
                             candidates=['deadline__assignment_group__candidates__identifier'],
                             deadline=['deadline__deadline'],
                             assignment_group=['deadline__assignment_group',
                                               'deadline__assignment_group__name'],
                             assignment_group_users=['deadline__assignment_group__examiners__username',
                                                     'deadline__assignment_group__candidates__identifier'],
                             assignment=['deadline__assignment_group__parentnode',
                                         'deadline__assignment_group__parentnode__short_name',
github devilry / devilry-django / devilry / devilry_elasticsearch_cache / doctypes / elasticsearch_basenodes_doctypes.py View on Github external
class Subject(DocType):
    """
    Class to represent a Subject from :class:`devilry.apps.core.models.subject.Subject`
    """
    class Meta:
        index = 'basenodes'


class SubjectRegistryItem(AbstractBaseNodeRegistryItem):
    """
    A RegistryItem class of :class:`core.models.subject.Subject` that defines the properties of a :class:`.Subject` as DocType.

    Is added to the :file:`.elasticsearch_registry.registry` singleton.
    """
    modelclass = coremodels.Subject
    doctype_class = Subject

    def get_search_text(self, modelobject):
        subject = modelobject
        search_text = \
            u'{long_name} {short_name} ' \
            u'{parentnode_long_name} {parentnode_short_name}'.format(
                long_name=subject.long_name,
                short_name=subject.short_name,
                parentnode_long_name=subject.parentnode.long_name,
                parentnode_short_name=subject.parentnode.short_name)
        return search_text

    def get_all_modelobjects(self):
        return coremodels.Subject.objects.select_related('parentnode').all()
github devilry / devilry-django / devilry / coreutils / simplified / metabases / deadline.py View on Github external
from devilry.apps.core import models
from devilry.simplified import (FieldSpec, FilterSpec, FilterSpecs,
                                ForeignFilterSpec)



class SimplifiedDeadlineMetaMixin(object):
    """ Defines the django model to be used, resultfields returned by
    search and which fields can be used to search for a Deadline object
    using the Simplified API """
    model = models.Deadline
    annotated_fields = ('number_of_deliveries',)
    resultfields = FieldSpec('id',
                             'text',
                             'deadline',
                             'assignment_group',
                             'number_of_deliveries',
                             subject=['assignment_group__parentnode__parentnode__parentnode__id',
                                      'assignment_group__parentnode__parentnode__parentnode__short_name',
                                      'assignment_group__parentnode__parentnode__parentnode__long_name'],
                             period=['assignment_group__parentnode__parentnode__id',
                                     'assignment_group__parentnode__parentnode__short_name',
                                     'assignment_group__parentnode__parentnode__long_name'],
                             assignment=['assignment_group__parentnode__id',
                                         'assignment_group__parentnode__delivery_types',
                                         'assignment_group__parentnode__short_name',
                                         'assignment_group__parentnode__long_name'],