Esempio n. 1
0
	def save(self):
		t = Ticket.objects.get(pk=self.cleaned_data['ticket'])
		
		f = FollowUp(ticket=t, title='Comment from %s' % self.cleaned_data['email'], comment=self.cleaned_data['comment'], public=True)
		f.save()
		
		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)
			
		return t
Esempio n. 2
0
	def save(self):
		t = Ticket(title=self.cleaned_data['title'], submitter_email=self.cleaned_data['submitter_email'], status=Ticket.NEW_STATUS, queue=self.cleaned_data['queue'], description=self.cleaned_data['description'], priority=self.cleaned_data['priority'])
		t.save()
		
		f = FollowUp(ticket=t, title='Ticket opened via web', public=True, comment='Ticket opened via the web.')
		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)
			
			# if file.size < getattr(settings, 'MAX_EMAIL_ATTACHMENT_SIZE', 1024000):
			# 	files.append(a.file.path)
			
		return t