示例#1
0
文件: views.py 项目: dreamyman/phase
    def post(self, request, *args, **kwargs):
        if not self.request.user.is_external:
            return HttpResponseForbidden(
                'Only contractors can acknowledge receipt of transmittals')

        document_ids = request.POST.getlist('document_ids')
        transmittals = self.get_queryset() \
            .filter(document_id__in=document_ids) \
            .filter(ack_of_receipt_date__isnull=True)
        revision_ids = list(
            transmittals.values_list('latest_revision_id', flat=True))

        # Update transmittal data
        transmittals.update(ack_of_receipt_date=timezone.now(),
                            ack_of_receipt_author=self.request.user)

        # Update ES index
        _revision_class = self.category.revision_class()
        revisions = _revision_class.objects.filter(id__in=revision_ids)
        index_revisions(revisions)

        update_count = len(revision_ids)

        if update_count > 0:
            msg = _('You have successfully acknowledged receipt '
                    'of %s transmittals.') % update_count
        else:
            msg = _('We failed to acknowledge receipt of any transmittal.')

        notify(self.request.user, msg)

        return HttpResponseRedirect(self.get_redirect_url())
示例#2
0
文件: views.py 项目: providenz/phase
    def post(self, request, *args, **kwargs):
        if not self.request.user.is_external:
            return HttpResponseForbidden(
                'Only contractors can acknowledge receipt of transmittals')

        document_ids = request.POST.getlist('document_ids')
        transmittals = self.get_queryset() \
            .filter(document_id__in=document_ids) \
            .filter(ack_of_receipt_date__isnull=True)
        revision_ids = list(
            transmittals.values_list('latest_revision_id', flat=True))

        # Update transmittal data
        transmittals.update(
            ack_of_receipt_date=timezone.now(),
            ack_of_receipt_author=self.request.user)

        # Update ES index
        _revision_class = self.category.revision_class()
        revisions = _revision_class.objects.filter(id__in=revision_ids)
        index_revisions(revisions)

        update_count = len(revision_ids)

        if update_count > 0:
            msg = _('You have successfully acknowledged receipt '
                    'of %s transmittals.') % update_count
        else:
            msg = _('We failed to acknowledge receipt of any transmittal.')

        notify(self.request.user, msg)

        return HttpResponseRedirect(self.get_redirect_url())
示例#3
0
文件: views.py 项目: dreamyman/phase
    def post(self, request, *args, **kwargs):
        qs = self.get_queryset()
        document_ids = request.POST.getlist('document_ids')
        rev_ids = qs.filter(id__in=document_ids) \
            .values_list('latest_revision_id', flat=True)

        _class = self.category.revision_class()
        revisions = _class.objects.filter(id__in=rev_ids)
        revisions.update(under_preparation_by=self.request.user)

        index_revisions(revisions)
        return HttpResponseRedirect(self.get_redirect_url())
示例#4
0
文件: views.py 项目: providenz/phase
    def post(self, request, *args, **kwargs):
        qs = self.get_queryset()
        document_ids = request.POST.getlist('document_ids')
        rev_ids = qs.filter(id__in=document_ids) \
            .values_list('latest_revision_id', flat=True)

        _class = self.category.revision_class()
        revisions = _class.objects.filter(id__in=rev_ids)
        revisions.update(under_preparation_by=self.request.user)

        index_revisions(revisions)
        return HttpResponseRedirect(self.get_redirect_url())
示例#5
0
文件: views.py 项目: dreamyman/phase
    def post(self, request, *args, **kwargs):
        if not self.request.user.is_external:
            return HttpResponseForbidden(
                'Only contractors can acknowledge receipt of transmittals')

        transmittal = self.get_object()

        if transmittal.ack_of_receipt_date is not None:
            return HttpResponseForbidden('Receipt already acknowledged')

        transmittal.ack_receipt(self.request.user, save=True)

        # Update ES index
        revisions = transmittal.get_all_revisions()
        index_revisions(revisions)

        return HttpResponseRedirect(transmittal.document.get_absolute_url())