当前位置: 首页>>代码示例>>Python>>正文


Python models.TicketCustomFieldValue类代码示例

本文整理汇总了Python中helpdesk.models.TicketCustomFieldValue的典型用法代码示例。如果您正苦于以下问题:Python TicketCustomFieldValue类的具体用法?Python TicketCustomFieldValue怎么用?Python TicketCustomFieldValue使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了TicketCustomFieldValue类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: _create_custom_fields

 def _create_custom_fields(self, ticket):
     for field, value in self.cleaned_data.items():
         if field.startswith("custom_"):
             field_name = field.replace("custom_", "", 1)
             custom_field = CustomField.objects.get(name=field_name)
             cfv = TicketCustomFieldValue(ticket=ticket, field=custom_field, value=value)
             cfv.save()
开发者ID:ajatamayo,项目名称:django-helpdesk,代码行数:7,代码来源:forms.py

示例2: save

 def save(self, *args, **kwargs):
     for field, value in self.cleaned_data.items():
         if field.startswith('custom_'):
             field_name = field.replace('custom_', '')
             customfield = CustomField.objects.get(name=field_name)
             try:
                 cfv = TicketCustomFieldValue.objects.get(ticket=self.instance, field=customfield)
             except TicketCustomFieldValue.DoesNotExist:
                 cfv = TicketCustomFieldValue(ticket=self.instance, field=customfield)
             cfv.value = value
             cfv.save()
     return super(EditTicketForm, self).save(*args, **kwargs)
开发者ID:chrisspen,项目名称:django-helpdesk3000,代码行数:12,代码来源:forms.py

示例3: save

    def save(self, user):
        """
        Writes and returns a Ticket() object
        """

        q = Queue.objects.get(id=int(self.cleaned_data['queue']))

        t = Ticket( title = self.cleaned_data['title'],
                    submitter_email = self.cleaned_data['submitter_email'],
                    created = timezone.now(),
                    status = Ticket.OPEN_STATUS,
                    queue = q,
                    description = self.cleaned_data['body'],
                    error_msg = self.cleaned_data['error_msg'],
                    priority = self.cleaned_data['priority'],
                    type = self.cleaned_data['type'],
                    due_date = self.cleaned_data['due_date'],
                )

        t.assigned_to = None

        if self.cleaned_data['assigned_to']:
            try:
                u = User.objects.get(id=self.cleaned_data['assigned_to'])
                t.assigned_to = u
            except User.DoesNotExist:
                pass
        t.save()

        for field, value in self.cleaned_data.items():
            if field.startswith('custom_'):
                field_name = field.replace('custom_', '', 1)
                customfield = CustomField.objects.get(name=field_name)
                cfv = TicketCustomFieldValue(ticket=t,
                            field=customfield,
                            value=value)
                cfv.save()

        ticket = t
        user = None
        try:
            user = t.assigned_to
        except Exception, e:
            pass
开发者ID:toladata,项目名称:TolaWork,代码行数:44,代码来源:forms.py

示例4: save

    def save(self):
        """
        Writes and returns a Ticket() object
        """

        q = Queue.objects.get(id=int(self.cleaned_data['queue']))

        t = Ticket(
            title = self.cleaned_data['title'],
            submitter_email = self.cleaned_data['submitter_email'],
            created = datetime.now(),
            status = Ticket.OPEN_STATUS,
            queue = q,
            description = self.cleaned_data['body'],
            priority = self.cleaned_data['priority'],
            due_date = self.cleaned_data['due_date'],
            )

        t.save()

        for field, value in self.cleaned_data.items():
            if field.startswith('custom_'):
                field_name = field.replace('custom_', '')
                customfield = CustomField.objects.get(name=field_name)
                cfv = TicketCustomFieldValue(ticket=t,
                            field=customfield,
                            value=value)
                cfv.save()

        f = FollowUp(
            ticket = t,
            title = _('Ticket Opened Via Web'),
            date = datetime.now(),
            public = True,
            comment = self.cleaned_data['body'],
            )

        f.save()

        files = []
        if self.cleaned_data['attachment']:
            import mimetypes
            file = self.cleaned_data['attachment']
            filename = file.name.replace(' ', '_')
            a = Attachment(
                followup=f,
                filename=filename,
                mime_type=mimetypes.guess_type(filename)[0] or 'application/octet-stream',
                size=file.size,
                )
            a.file.save(file.name, file, save=False)
            a.save()
            
            if file.size < getattr(settings, 'MAX_EMAIL_ATTACHMENT_SIZE', 512000):
                # Only files smaller than 512kb (or as defined in 
                # settings.MAX_EMAIL_ATTACHMENT_SIZE) are sent via email.
                files.append(a.file.path)

        context = safe_template_context(t)

        messages_sent_to = []

        send_templated_mail(
            'newticket_submitter',
            context,
            recipients=t.submitter_email,
            sender=q.from_address,
            fail_silently=True,
            files=files,
            )
        messages_sent_to.append(t.submitter_email)

        if q.new_ticket_cc and q.new_ticket_cc not in messages_sent_to:
            send_templated_mail(
                'newticket_cc',
                context,
                recipients=q.new_ticket_cc,
                sender=q.from_address,
                fail_silently=True,
                files=files,
                )
            messages_sent_to.append(q.new_ticket_cc)

        if q.updated_ticket_cc and q.updated_ticket_cc != q.new_ticket_cc and q.updated_ticket_cc not in messages_sent_to:
            send_templated_mail(
                'newticket_cc',
                context,
                recipients=q.updated_ticket_cc,
                sender=q.from_address,
                fail_silently=True,
                files=files,
                )

        return t
开发者ID:ailling,项目名称:django-helpdesk,代码行数:94,代码来源:forms.py

示例5: save

    def save(self, user):
        """
        Writes and returns a Ticket() object
        """

        q = Queue.objects.get(id=int(self.cleaned_data['queue']))

        t = Ticket( title = self.cleaned_data['title'],
                    submitter_email = self.cleaned_data['submitter_email'],
                    created = timezone.now(),
                    status = Ticket.OPEN_STATUS,
                    queue = q,
                    description = self.cleaned_data['body'],
                    priority = self.cleaned_data['priority'],
                    due_date = self.cleaned_data['due_date'],
                  )

        if HAS_TAG_SUPPORT:
            t.tags = self.cleaned_data['tags']

        if self.cleaned_data['assigned_to']:
            try:
                u = User.objects.get(id=self.cleaned_data['assigned_to'])
                t.assigned_to = u
            except User.DoesNotExist:
                t.assigned_to = None
        t.save()
        
        for field, value in self.cleaned_data.items():
            if field.startswith('custom_'):
                field_name = field.replace('custom_', '')
                customfield = CustomField.objects.get(name=field_name)
                cfv = TicketCustomFieldValue(ticket=t,
                            field=customfield,
                            value=value)
                cfv.save()

        f = FollowUp(   ticket = t,
                        title = _('Ticket Opened'),
                        date = timezone.now(),
                        public = True,
                        comment = self.cleaned_data['body'],
                        user = user,
                     )
        if self.cleaned_data['assigned_to']:
            f.title = _('Ticket Opened & Assigned to %(name)s') % {
                'name': t.get_assigned_to
            }

        f.save()
        
        files = []
        if self.cleaned_data['attachment']:
            import mimetypes
            file = self.cleaned_data['attachment']
            filename = file.name.replace(' ', '_')
            a = Attachment(
                followup=f,
                filename=filename,
                mime_type=mimetypes.guess_type(filename)[0] or 'application/octet-stream',
                size=file.size,
                )
            a.file.save(file.name, file, save=False)
            a.save()
            
            if file.size < getattr(settings, 'MAX_EMAIL_ATTACHMENT_SIZE', 512000):
                # Only files smaller than 512kb (or as defined in 
                # settings.MAX_EMAIL_ATTACHMENT_SIZE) are sent via email.
                files.append(a.file.path)

        context = safe_template_context(t)
        context['comment'] = f.comment
        
        messages_sent_to = []

        if t.submitter_email:
            send_templated_mail(
                'newticket_submitter',
                context,
                recipients=t.submitter_email,
                sender=q.from_address,
                fail_silently=True,
                files=files,
                )
            messages_sent_to.append(t.submitter_email)

        if t.assigned_to and t.assigned_to != user and t.assigned_to.usersettings.settings.get('email_on_ticket_assign', False) and t.assigned_to.email and t.assigned_to.email not in messages_sent_to:
            send_templated_mail(
                'assigned_owner',
                context,
                recipients=t.assigned_to.email,
                sender=q.from_address,
                fail_silently=True,
                files=files,
                )
            messages_sent_to.append(t.assigned_to.email)

        if q.new_ticket_cc and q.new_ticket_cc not in messages_sent_to:
            send_templated_mail(
                'newticket_cc',
#.........这里部分代码省略.........
开发者ID:tclancy,项目名称:django-helpdesk,代码行数:101,代码来源:forms.py

示例6: save

    def save(self, user):
        """
        Writes and returns a Ticket() object
        """

        q = Queue.objects.get(id=int(self.cleaned_data["queue"]))

        t = Ticket(
            title=self.cleaned_data["title"],
            submitter_email=self.cleaned_data["submitter_email"],
            created=datetime.now(),
            status=Ticket.OPEN_STATUS,
            queue=q,
            description=self.cleaned_data["body"],
            priority=self.cleaned_data["priority"],
            due_date=self.cleaned_data["due_date"],
        )

        if HAS_TAG_SUPPORT:
            t.tags = self.cleaned_data["tags"]

        if self.cleaned_data["assigned_to"]:
            try:
                u = User.objects.get(id=self.cleaned_data["assigned_to"])
                t.assigned_to = u
            except User.DoesNotExist:
                t.assigned_to = None
        t.save()

        for field, value in self.cleaned_data.items():
            if field.startswith("custom_"):
                field_name = field.replace("custom_", "")
                customfield = CustomField.objects.get(name=field_name)
                cfv = TicketCustomFieldValue(ticket=t, field=customfield, value=value)
                cfv.save()

        f = FollowUp(
            ticket=t,
            title=_("Ticket Opened"),
            date=datetime.now(),
            public=True,
            comment=self.cleaned_data["body"],
            user=user,
        )
        if self.cleaned_data["assigned_to"]:
            f.title = _("Ticket Opened & Assigned to %(name)s") % {"name": t.get_assigned_to}

        f.save()

        files = []
        if self.cleaned_data["attachment"]:
            import mimetypes

            file = self.cleaned_data["attachment"]
            filename = file.name.replace(" ", "_")
            a = Attachment(
                followup=f,
                filename=filename,
                mime_type=mimetypes.guess_type(filename)[0] or "application/octet-stream",
                size=file.size,
            )
            a.file.save(file.name, file, save=False)
            a.save()

            if file.size < getattr(settings, "MAX_EMAIL_ATTACHMENT_SIZE", 512000):
                # Only files smaller than 512kb (or as defined in
                # settings.MAX_EMAIL_ATTACHMENT_SIZE) are sent via email.
                files.append(a.file.path)

        context = safe_template_context(t)
        context["comment"] = f.comment

        messages_sent_to = []

        if t.submitter_email:
            send_templated_mail(
                "newticket_submitter",
                context,
                recipients=t.submitter_email,
                sender=q.from_address,
                fail_silently=True,
                files=files,
            )
            messages_sent_to.append(t.submitter_email)

        if (
            t.assigned_to
            and t.assigned_to != user
            and getattr(t.assigned_to.usersettings.settings, "email_on_ticket_assign", False)
            and t.assigned_to.email
            and t.assigned_to.email not in messages_sent_to
        ):
            send_templated_mail(
                "assigned_owner",
                context,
                recipients=t.assigned_to.email,
                sender=q.from_address,
                fail_silently=True,
                files=files,
            )
#.........这里部分代码省略.........
开发者ID:patovala,项目名称:ptracker,代码行数:101,代码来源:forms.py

示例7: save

    def save(self):
        """
        Writes and returns a Ticket() object
        """

        q = Queue.objects.get(title = 'public')

        t = Ticket(
            title = self.cleaned_data['title'],
            submitter_email = self.cleaned_data['submitter_email'],
            created = timezone.now(),
            status = Ticket.OPEN_STATUS,
            queue = q,
            description = self.cleaned_data['body'],
            priority = 3,
            due_date = None,
            )

        t.save()

        for field, value in self.cleaned_data.items():
            if field.startswith('custom_'):
                field_name = field.replace('custom_', '')
                customfield = CustomField.objects.get(name=field_name)
                cfv = TicketCustomFieldValue(ticket=t,
                            field=customfield,
                            value=value)
                cfv.save()

        f = FollowUp(
            ticket = t,
            title = _('Ticket Opened Via Web'),
            date = timezone.now(),
            public = True,
            comment = self.cleaned_data['body'],
            )

        f.save()
        files = []

        context = safe_template_context(t)

        messages_sent_to = []

        send_templated_mail(
            'newticket_submitter',
            context,
            recipients=t.submitter_email,
            sender=q.from_address,
            fail_silently=True,
            files=files,
            )
        messages_sent_to.append(t.submitter_email)

        if q.new_ticket_cc and q.new_ticket_cc not in messages_sent_to:
            send_templated_mail(
                'newticket_cc',
                context,
                recipients=q.new_ticket_cc,
                sender=q.from_address,
                fail_silently=True,
                files=files,
                )
            messages_sent_to.append(q.new_ticket_cc)

        if q.updated_ticket_cc and q.updated_ticket_cc != q.new_ticket_cc and q.updated_ticket_cc not in messages_sent_to:
            send_templated_mail(
                'newticket_cc',
                context,
                recipients=q.updated_ticket_cc,
                sender=q.from_address,
                fail_silently=True,
                files=files,
                )

        return t
开发者ID:zippo2021,项目名称:django-helpdesk,代码行数:76,代码来源:forms.py

示例8: save

    def save(self):
        """
        Writes and returns a Ticket() object
        """

        q = self.cleaned_data["queue"]

        t = Ticket(
            title=self.cleaned_data["title"],
            submitter_email=self.cleaned_data["submitter_email"],
            created=timezone.now(),
            status=Ticket.OPEN_STATUS,
            queue=q,
            description=self.cleaned_data["body"],
            priority=self.cleaned_data["priority"],
            due_date=self.cleaned_data["due_date"],
        )

        t.save()

        for field, value in self.cleaned_data.items():
            if field.startswith("custom_"):
                field_name = field.replace("custom_", "", 1)
                customfield = CustomField.objects.get(name=field_name)
                cfv = TicketCustomFieldValue(ticket=t, field=customfield, value=value)
                cfv.save()

        f = FollowUp(
            ticket=t,
            title=_("Ticket Opened Via Web"),
            date=timezone.now(),
            public=True,
            comment=self.cleaned_data["body"],
        )

        f.save()

        files = []
        if self.cleaned_data["attachment"]:
            import mimetypes

            file = self.cleaned_data["attachment"]
            filename = file.name.replace(" ", "_")
            a = Attachment(
                followup=f,
                filename=filename,
                mime_type=mimetypes.guess_type(filename)[0] or "application/octet-stream",
                size=file.size,
            )
            a.file.save(file.name, file, save=False)
            a.save()

            if file.size < getattr(settings, "MAX_EMAIL_ATTACHMENT_SIZE", 512000):
                # Only files smaller than 512kb (or as defined in
                # settings.MAX_EMAIL_ATTACHMENT_SIZE) are sent via email.
                files.append([a.filename, a.file])

        context = safe_template_context(t)

        messages_sent_to = []

        send_templated_mail(
            "newticket_submitter",
            context,
            recipients=t.submitter_email,
            sender=q.from_address,
            fail_silently=True,
            files=files,
        )
        messages_sent_to.append(t.submitter_email)

        if q.new_ticket_cc and q.new_ticket_cc not in messages_sent_to:
            send_templated_mail(
                "newticket_cc",
                context,
                recipients=q.new_ticket_cc,
                sender=q.from_address,
                fail_silently=True,
                files=files,
            )
            messages_sent_to.append(q.new_ticket_cc)

        if (
            q.updated_ticket_cc
            and q.updated_ticket_cc != q.new_ticket_cc
            and q.updated_ticket_cc not in messages_sent_to
        ):
            send_templated_mail(
                "newticket_cc",
                context,
                recipients=q.updated_ticket_cc,
                sender=q.from_address,
                fail_silently=True,
                files=files,
            )

        return t
开发者ID:vladyslav2,项目名称:django-helpdesk-optimizated,代码行数:97,代码来源:public.py


注:本文中的helpdesk.models.TicketCustomFieldValue类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。