How to use the devilry.apps.core.models.Delivery 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 / devilryadmin / create_random_exampledata.py View on Github external
def autocreate_delivery(group):
    active_deadline = group.get_active_deadline()

    cand = group.candidates.all()[0]
    delivery = active_deadline.deliveries.create(delivered_by=cand, successful=True)
    delivery.add_file('helloworld.txt', ['hello cruel world'])
    delivery.add_file('helloworld.py', ['print "hello world"'])
    delivery.add_file('helloworld.java', [
        '// Too much code for a sane "hello world"'])

    others = Delivery.objects.filter(deadline__assignment_group=group).order_by("-number")
    if others.count() == 1:
        if active_deadline.deadline < datetime.now():
            if randint(0, 100) <= 30:
                # 30% chance to get the first delivery after the deadline
                offset = timedelta(minutes=-randint(1, 20))
                logging.info("                (deliveries after deadline)")
            else:
                offset = timedelta(hours=randint(0, 15),
                        minutes=randint(0, 59))
            delivery.time_of_delivery = active_deadline.deadline - offset
        else:
            # Deadline is in the future. Deliver a random time before
            # "now". They can not deliver more than 5 deliveries (see
            # create_example_deliveries_and_feedback), so if
            # we say 5*3 hours in the past as a minimum for the first
            # delivery, we will never get deliveries in the future
github devilry / devilry-django / devilry / apps / gradeeditors / models.py View on Github external
config = assignment.gradeeditor_config
    except Config.DoesNotExist:
        config = Config(assignment=assignment,
                        gradeeditorid=gradeeditor_registry.getdefaultkey(),
                        config='')
        config.save()

post_save.connect(create_gradeconfig_for_assignment,
                  sender=Assignment)


class FeedbackDraft(models.Model):
    """
    Stored by examiners.
    """
    delivery = models.ForeignKey(Delivery)
    draft = models.TextField()
    save_timestamp = models.DateTimeField(auto_now=True, blank=False, null=False,
                                          help_text='Time when this feedback was saved. Since FeedbackDraft '
                                                    'is immutable, this never changes.')
    saved_by = models.ForeignKey(settings.AUTH_USER_MODEL)
    published = models.BooleanField(default=False,
                                    help_text='Has this draft been published as a StaticFeedback? Setting this to true on create automatically creates a StaticFeedback.')
    staticfeedback = models.OneToOneField(StaticFeedback, blank=True, null=True,
                                          related_name='gradeeditor_feedbackdraft',
                                          help_text='The StaticFeedback where this was published if this draft has been published.')

    def _get_config(self):
        return self.delivery.deadline.assignment_group.parentnode.gradeeditor_config

    def clean(self):
        if self.id == None: # If creating a new FeedbackDraft
github devilry / devilry-django / devilry / devilry_gradingsystem / models.py View on Github external
available in the context where you use this method, and should not require
        an extra query to lookup.
        """
        queryset = self.get_queryset().filter(delivery=delivery)
        if not assignment.feedback_workflow_allows_shared_feedback_drafts():
            queryset = queryset.filter(saved_by=user)
        return queryset


class FeedbackDraftFile(models.Model):
    """
    A file that is part of the current draft.

    Unlike :class:`.FeedbackDraft`, we only keep one copy of the files.
    """
    delivery = models.ForeignKey(Delivery, related_name='+')
    saved_by = models.ForeignKey(User, related_name='+')

    #: The original filename.
    filename = models.TextField(blank=False, null=False)

    #: The uploaded file.
    file = models.FileField(
        upload_to=feedback_draft_file_upload_to
    )

    objects = FeedbackDraftFileManager()

    def get_download_url(self):
        return reverse('devilry_gradingsystem_feedbackdraftfile', kwargs={
            'pk': self.pk,
            'asciifilename': self.get_ascii_filename()
github devilry / devilry-django / src / devilry_student / devilry_student / rest / recent_deliveries.py View on Github external
def get_queryset(self):
        qry = Delivery.where_is_candidate(self.request.user)
        qry = qry.order_by('-time_of_delivery')
        qry = qry.select_related('deadline', 'deadline__assignment_group',
                                 'deadline__assignment_group__parentnode',
                                 'deadline__assignment_group__parentnode__parentnode',
                                 'deadline__assignment_group__parentnode__parentnode__parentnode')
        return qry[:6]
github devilry / devilry-django / devilry / apps / examiner / views.py View on Github external
@login_required
def edit_feedback(request, delivery_id, is_admin=None):
    delivery_obj = get_object_or_404(Delivery, pk=delivery_id)
    if not delivery_obj.assignment_group.can_examine(request.user):
        return HttpResponseForbidden("Forbidden")
    _handle_is_admin(request, is_admin)
    key = delivery_obj.assignment_group.parentnode.grade_plugin
    return gradeplugin.registry.getitem(key).view(request, delivery_obj)
github devilry / devilry-django / devilry / devilry_student / cradmin_group / deliveriesapp.py View on Github external
def __create_delivery(self):
        delivery = Delivery(
            deadline_id=self.group.last_deadline_id,
            successful=True,
            delivered_by=self.__get_canidate(),
            time_of_delivery=datetime.now())
        delivery.set_number()
        delivery.full_clean()
        delivery.save()
        return delivery
github devilry / devilry-django / src / devilry_examiner / devilry_examiner / views / singledelivery.py View on Github external
def get_queryset(self):
        return Delivery.objects.filter_examiner_has_access(self.request.user)\
            .select_related( # Use select_related to lookup all the related objects in the query
                'deadline',
                'deadline__assignment_group',
                'deadline__assignment_group__parentnode', # Assignment
                'deadline__assignment_group__parentnode__parentnode', # Period
                'deadline__assignment_group__parentnode__parentnode__parentnode', # Subject
                )
github devilry / devilry-django / devilry / devilry_subjectadmin / rest / group.py View on Github external
def serialize_model(self, instance):
        data = super(GroupResource, self).serialize_model(instance)
        if not 'num_deliveries' in data:
            # This is used when working directly with the instance. The listing
            # (query) annotates this field instead of querying for each object
            data['num_deliveries'] = Delivery.objects.filter(deadline__assignment_group=instance).count()
        return data
github devilry / devilry-django / src / devilry_examiner / devilry_examiner / views / singledelivery.py View on Github external
from django.views.generic import DetailView
from django.shortcuts import redirect
#from django.http import Http404

from devilry.apps.core.models import Delivery
from .singlegroupoverview import get_previous_and_next_group_waiting_for_feedback


class SingleDeliveryView(DetailView):
    template_name = "devilry_examiner/singledelivery.django.html"
    model = Delivery
    pk_url_kwarg = 'deliveryid'
    context_object_name = 'delivery'

    def get_queryset(self):
        return Delivery.objects.filter_examiner_has_access(self.request.user)\
            .select_related( # Use select_related to lookup all the related objects in the query
                'deadline',
                'deadline__assignment_group',
                'deadline__assignment_group__parentnode', # Assignment
                'deadline__assignment_group__parentnode__parentnode', # Period
                'deadline__assignment_group__parentnode__parentnode__parentnode', # Subject
                )

    def get(self, *args, **kwargs):
        edit_feedback = self.request.GET.get('edit_feedback', False) == 'true'
        if edit_feedback: