How to use the devilry.devilry_group.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_merge_v3database / utils / comment_merger.py View on Github external
def start_migration(self, from_db_object):
        comment = self.__get_comment_from_temp_merge_id(from_db_obj=from_db_object)
        commentedithistory = self.__get_commentedithistory_from_temp_merge_id(from_db_obj=from_db_object)
        if comment:
            group_comment_edit_history_kwargs = model_to_dict(from_db_object, exclude=[
                'id', 'pk', 'group_comment', 'group_comment_id', 'comment', 'comment_id', 'commentedithistory_ptr_id',
                'commentedithistory_ptr', 'edited_by'])
            group_comment_edit_history = group_models.GroupCommentEditHistory(**group_comment_edit_history_kwargs)
            group_comment_edit_history.group_comment_id = comment.id
            group_comment_edit_history.comment_id = comment.id
            group_comment_edit_history.edited_by_id = commentedithistory.edited_by.id
            group_comment_edit_history.commentedithistory_ptr_id = commentedithistory.id
            self.save_object(obj=group_comment_edit_history)
        else:
            raise ValueError('Comments and GroupComments must be imported before GroupCommentEditHistory')
github devilry / devilry-django / devilry / devilry_cradmin / devilry_listbuilder / feedbackfeed_sidebar.py View on Github external
"""Appends renderables to this list.

        Appends the ``published_date`` of a GroupComment and adds a list of CommentFiles for that GroupComment.
        See :class:`~GroupCommentDateTimeItemValue` and :class:`~FileListBuilderList`.

        Args:
            assignment (:class:`~.devilry.apps.core.models.assignment.Assignment`):
            comment_dict (dict): Dictionary of ``GroupComment``s and ``CommentFile``s.
            devilryrole (str): The viewrole for the user.

        Args:
            comment_dict (dict): Dictionary for a GroupComment.
        """
        group_comment = comment_dict.get('group_comment')
        user_obj = None
        if group_comment.user_role == group_models.GroupComment.USER_ROLE_STUDENT:
            user_obj = comment_dict.get('candidate')
        elif group_comment.user_role == group_models.GroupComment.USER_ROLE_EXAMINER:
            user_obj = comment_dict.get('examiner')
        self.append(renderable=GroupCommentItemValue(
            value=group_comment,
            user_obj=user_obj,
            devilryrole=devilryrole,
            assignment=assignment))
        valuerenderer = FileListBuilderList.from_files(comment_dict['files'])
        self.append(renderable=valuerenderer)
github devilry / devilry-django / devilry / devilry_statistics / management / commands / devilry_statistics_make_assignment_with_graded_groups.py View on Github external
relatedstudent.save()
        coremodels.Candidate(
            relatedstudent=relatedstudent,
            assignment_group=assignment_group
        ).save()

        # Create examiner
        coremodels.Examiner(
            relatedexaminer=relatedexaminer,
            assignmentgroup=assignment_group
        ).save()

        # publish grading
        if grading_points is not None:
            grading_published_datetime = assignment.publishing_time + timezone.timedelta(days=8)
            feedbackset = group_models.FeedbackSet.objects.get(group_id=assignment_group.id)
            feedbackset.grading_published_datetime = grading_published_datetime
            feedbackset.grading_points = grading_points
            feedbackset.save()
github devilry / devilry-django / devilry / devilry_group / views / examiner / feedbackfeed_examiner.py View on Github external
def dispatch(self, request, *args, **kwargs):
        group = self.request.cradmin_role
        self.feedbackset = group_models.FeedbackSet.objects.get(group=group, id=kwargs.get('pk'))
        if group.cached_data.last_feedbackset != self.feedbackset or \
                not group.cached_data.last_published_feedbackset_is_last_feedbackset:
            raise Http404()
        return super(ExaminerEditGradeView, self).dispatch(request, *args, **kwargs)
github devilry / devilry-django / devilry / devilry_group / views / cradmin_feedbackfeed_base.py View on Github external
def __should_disable_comment_form(self, request):
        """
        Check if the file upload and comment form should be disabled.

        Returns a message string or None.
        """
        group = self.assignment_group
        user_role = request.cradmin_instance.get_devilryrole_for_requestuser()
        if user_role.endswith('admin'):
            user_role = group_models.GroupComment.USER_ROLE_ADMIN
        try:
            group.cached_data.last_feedbackset.can_add_comment(assignment=group.parentnode, comment_user_role=user_role)
        except (group_models.HardDeadlineExpiredException, group_models.PeriodExpiredException) as e:
            return e.message
        return None
github devilry / devilry-django / devilry / devilry_group / timeline_builder / feedbackfeed_timeline_builder.py View on Github external
def __get_feedbackset_queryset(self):
        """
        Retrieves the comments a user has access to.
        This function must be implemented by subclasses of :class:`~.FeedbackFeedBaseView`

        :param group:
            The :class:`devilry.apps.core.models.AssignmentGroup` the user belongs to.

        Returns:
            List of :class:`devilry.devilry_group.models.GroupComment` objects.

        """
        commentfile_queryset = CommentFile.objects\
            .select_related('comment__user')\
            .order_by('filename')
        groupcomment_queryset = group_models.GroupComment.objects\
            .exclude_private_comments_from_other_users(user=self.requestuser)\
            .select_related(
                'user',
                'feedback_set__created_by',
                'feedback_set__grading_published_by')\
            .prefetch_related(models.Prefetch('commentfile_set', queryset=commentfile_queryset))
        if self.devilryrole == 'student':
            groupcomment_queryset = groupcomment_queryset\
                .filter(visibility=group_models.GroupComment.VISIBILITY_VISIBLE_TO_EVERYONE)\
                .exclude_is_part_of_grading_feedbackset_unpublished()
        return group_models.FeedbackSet.objects\
            .filter(group=self.group)\
            .prefetch_related(models.Prefetch('groupcomment_set', queryset=groupcomment_queryset))\
            .order_by('created_datetime')
github devilry / devilry-django / devilry / devilry_merge_v3database / utils / comment_merger.py View on Github external
def __get_feedback_set_from_temp_merge_id(self, from_db_obj):
        temp_merge_id = TempMergeId.objects.get_from_label_and_merge_from_obj_id(
            model_name='devilry_group_feedbackset',
            from_id=from_db_obj.feedback_set_id
        )
        try:
            return group_models.FeedbackSet.objects.get(id=temp_merge_id.to_id)
        except group_models.FeedbackSet.DoesNotExist:
            return None
github devilry / devilry-django / devilry / devilry_group / feedbackfeed_builder / builder_base.py View on Github external
'group__parentnode__parentnode',
            'group__parentnode__parentnode__parentnode')\
        .filter(group=group)\
        .prefetch_related(
            models.Prefetch(
                'groupcomment_set',
                queryset=groupcomment_queryset))\
        .prefetch_related(
            models.Prefetch(
                'feedbacksetdeadlinehistory_set',
                queryset=feedbackset_deadline_history_queryset)
        )\
        .prefetch_related(
            models.Prefetch(
                'grading_update_histories',
                queryset=group_models.FeedbackSetGradingUpdateHistory.objects.all(),
                to_attr='grading_updates'
            )
        )\
        .order_by('created_datetime')
github devilry / devilry-django / devilry / devilry_group / views / download_files / feedbackfeed_bulkfiledownload.py View on Github external
def get_queryset(self, request):
        return group_models.FeedbackSet.objects.filter(group=request.cradmin_role)
github devilry / devilry-django / devilry / devilry_group / views / download_files / batch_download_api.py View on Github external
def new_files_added(self, latest_compressed_datetime):
        group_comment_ids = group_models.GroupComment.objects \
            .filter(feedback_set=self.content_object).values_list('id', flat=True)
        if CommentFile.objects.filter(
                comment_id__in=group_comment_ids, created_datetime__gt=latest_compressed_datetime
        ).exists():
            return True