コード例 #1
0
ファイル: handlers.py プロジェクト: natasha-white/treeio-1
    def create(self, request, *args, **kwargs):
        ticket = self.get_ticket(request, kwargs)
        if isinstance(ticket, Ticket):
            profile = request.user.get_profile()
            if profile.has_permission(ticket, mode='x'):
                context = _get_default_context(request)
                agent = context['agent']

                record = TicketRecord(sender=profile.get_contact())
                record.record_type = 'manual'
                if ticket.message:
                    record.message = ticket.message
                form = TicketRecordForm(agent,
                                        ticket,
                                        request.data,
                                        instance=record)
                if form.is_valid():
                    record = form.save()
                    record.save()
                    record.set_user_from_request(request)
                    record.about.add(ticket)
                    ticket.set_last_updated()
                    return record
                else:
                    self.status = 400
                    return form.errors
            else:
                return rc.FORBIDDEN
        else:
            return ticket
コード例 #2
0
ファイル: handlers.py プロジェクト: ctburley/treeio
    def create(self, request, *args, **kwargs):
        ticket = self.get_ticket(request, kwargs)
        if isinstance(ticket, Ticket):
            profile = request.user.get_profile()
            if profile.has_permission(ticket, mode="x"):
                context = _get_default_context(request)
                agent = context["agent"]

                record = TicketRecord(sender=profile.get_contact())
                record.record_type = "manual"
                if ticket.message:
                    record.message = ticket.message
                form = TicketRecordForm(agent, ticket, request.data, instance=record)
                if form.is_valid():
                    record = form.save()
                    record.save()
                    record.set_user_from_request(request)
                    record.about.add(ticket)
                    ticket.set_last_updated()
                    return record
                else:
                    self.status = 400
                    return form.errors
            else:
                return rc.FORBIDDEN
        else:
            return ticket
コード例 #3
0
ファイル: handlers.py プロジェクト: ctburley/treeio
    def check_create_permission(self, request, mode):
        request.context = _get_default_context(request)
        request.agent = request.context["agent"]
        request.profile = request.user.get_profile()

        request.queue = None
        if "queue_id" in request.GET:
            try:
                request.queue = TicketQueue.objects.get(pk=request.GET["queue_id"])
            except self.model.DoesNotExist:
                return False
            if not request.user.get_profile().has_permission(request.queue, mode="x"):
                request.queue = None
        return True
コード例 #4
0
ファイル: handlers.py プロジェクト: natasha-white/treeio-1
    def check_create_permission(self, request, mode):
        request.context = _get_default_context(request)
        request.agent = request.context['agent']
        request.profile = request.user.get_profile()

        request.queue = None
        if 'queue_id' in request.GET:
            try:
                request.queue = TicketQueue.objects.get(
                    pk=request.GET['queue_id'])
            except self.model.DoesNotExist:
                return False
            if not request.user.get_profile().has_permission(request.queue,
                                                             mode='x'):
                request.queue = None
        return True
コード例 #5
0
ファイル: handlers.py プロジェクト: natasha-white/treeio-1
 def check_instance_permission(self, request, inst, mode):
     context = _get_default_context(request)
     request.agent = context['agent']
     request.queue = None
     return request.user.get_profile().has_permission(inst, mode=mode)
コード例 #6
0
ファイル: handlers.py プロジェクト: ctburley/treeio
 def check_instance_permission(self, request, inst, mode):
     context = _get_default_context(request)
     request.agent = context["agent"]
     request.queue = None
     return request.user.get_profile().has_permission(inst, mode=mode)