예제 #1
0
    def save(self, *args, **kwargs):

        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)
                try:
                    cfv = TicketCustomFieldValue.objects.get(
                        ticket=self.instance, field=customfield)
                except ObjectDoesNotExist:
                    cfv = TicketCustomFieldValue(ticket=self.instance,
                                                 field=customfield)

                # Convert date/time data type to known fixed format string.
                if datetime is type(value):
                    cfv.value = value.strftime(CUSTOMFIELD_DATETIME_FORMAT)
                elif date is type(value):
                    cfv.value = value.strftime(CUSTOMFIELD_DATE_FORMAT)
                elif time is type(value):
                    cfv.value = value.strftime(CUSTOMFIELD_TIME_FORMAT)
                else:
                    cfv.value = value
                cfv.save()

        return super(EditTicketForm, self).save(*args, **kwargs)
예제 #2
0
 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)
예제 #3
0
    def save(self, *args, **kwargs):

        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)
                try:
                    cfv = TicketCustomFieldValue.objects.get(ticket=self.instance, field=customfield)
                except ObjectDoesNotExist:
                    cfv = TicketCustomFieldValue(ticket=self.instance, field=customfield)
                cfv.value = value
                cfv.save()

        return super(EditTicketForm, self).save(*args, **kwargs)