Ejemplo n.º 1
0
	def get(self, status = '', lang = '', output = 'html'):
		self.setLanguage(lang)
		self.current_user = users.GetCurrentUser()
		
		if not self.current_user:
			return self.toLogin()
		else:
			self.token = self.request.get('token')
			self.ManageAuth()
			self.LookupToken()
			
			if self.client.GetAuthSubToken() is None:
				return self.toAuthorize()
		
		tickets = [ {
			'id': t.key().id(),
			'url': '/ticket/%d' % t.key().id(),
			'project': t.project,
			'summary': t.summary,
			'description': t.description,
			'status': t.status.name,
			'severity': t.severity.name,
			'owner': t.author.nickname(),
			'solver': t.assignedUser.nickname() if t.assignedUser else '-'
		} for t in TicketService.getByStatus(status, 20, self.request.get('order'), self.request.get('orderdir')) ]

		statuses = [ {
			'id': s.key().id(),
			'name': s.name,
		} for s in StatusService.getAll() ]

		severities = [ {
			'id': s.key().id(),
			'name': s.name,
		} for s in SeverityService.getAll() ]

		self.values['tickets']    = tickets
		self.values['statuses']   = statuses
		self.values['severities'] = severities
		self.values['contacts'] = self.GetContacts()

		if output == 'html':
			self.render('ticket_list.html')
		if output == 'xml':
			self.render('ticket_list.xml')
		elif output == 'json':
			json.dump(tickets, self.response.out, indent = 4)
Ejemplo n.º 2
0
	def post(self, status = '', lang = '', output = 'html'):
		ticket = Ticket()

		user = users.get_current_user()
		if not user:
			self.redirect('/')

		ticket.author = user

		ticket.status = StatusService.getById(self.request.get('status'))
		ticket.severity = SeverityService.getById(self.request.get('severity'))
		if self.request.get('assignedUser'):
			ticket.assignedUser = users.User(self.request.get('assignedUser'))
		ticket.description = self.request.get('description')
		ticket.summary = self.request.get('summary')
		ticket.put()
		self.redirect('/')
Ejemplo n.º 3
0
	def post(self, ticketId, lang = 'en', output = 'html'):
		ticket = TicketService.getById(ticketId)

		user = users.get_current_user()
		if not user:
			self.redirect('/')

		self.current_user = users.GetCurrentUser()
		
		if not self.current_user:
			return self.toLogin()
		else:
			self.token = self.request.get('token')
			self.ManageAuth()
			self.LookupToken()

			if self.client.GetAuthSubToken() is None:
				return self.toAuthorize()

		ticket.author = user
		ticket.status = StatusService.getById(self.request.get('status'))
		ticket.severity = SeverityService.getById(self.request.get('severity'))
		ticket.summary = self.request.get('summary')
		ticket.description = self.request.get('description')
		if self.request.get('assignedUser'):
			if(ticket.assignedUser):
				if( ticket.assignedUser.email() != self.request.get('assignedUser') ):
					taskUrl = "%s/ticket/%s" % ('http://%s' % HOST_NAME, ticketId)
					mail.send_mail(
					sender= user.email(),
					to= self.request.get('assignedUser'),
					subject="Task assigned",
					body="""
%s  assigned you task %s

link: %s
""" % (user.nickname(),ticket.summary,taskUrl))
			ticket.assignedUser = users.User(self.request.get('assignedUser'))
		ticket.put()
		self.redirect('/ticket/%d' % ticket.key().id())
Ejemplo n.º 4
0
	def get(self, ticketId, lang = 'en', output = 'html'):
		self.setLanguage(lang)
		self.current_user = users.GetCurrentUser()
		
		if not self.current_user:
			return self.toLogin()
		else:
			self.token = self.request.get('token')
			self.ManageAuth()
			self.LookupToken()

			if self.client.GetAuthSubToken() is None:
				return self.toAuthorize()
		ticket = TicketService.getById(ticketId)

		ticketDict = {
			'id': ticket.key().id(),
			'project': ticket.project,
			'url': '/ticket/%d' % ticket.key().id(),
			'summary': ticket.summary,
			'description': ticket.description,
			'status': ticket.status.name,
			'severity': ticket.severity.name,
			'owner': ticket.author.nickname(),
			'solver': ticket.assignedUser.nickname() if ticket.assignedUser else '-',
			'solverEmail': ticket.assignedUser.email() if ticket.assignedUser else ''
		}

		statuses = [ {
			'id': s.key().id(),
			'name': s.name,
		} for s in StatusService.getAll() ]

		severities = [ {
			'id': s.key().id(),
			'name': s.name,
		} for s in SeverityService.getAll() ]

		comments = [ {
			'author': c.author.nickname(),
			'message': c.message,
			'date': c.date,
		} for c in CommentService.getByTicket(ticketId) ]

		contacts = self.GetContacts()
		if ticket.assignedUser:
			userEmail = ticket.assignedUser.email()
			index = [k for k, v in contacts.iteritems() if v == userEmail]
			if len(index):
				del contacts[index[0]]
				contacts['%s (now assigned)' % index[0]] = userEmail
			else:
				assignedUserName = '******' % (ticket.assignedUser.nickname(), userEmail)
				contacts[assignedUserName] = userEmail

		self.values['ticket'] = ticketDict
		self.values['statuses']   = statuses
		self.values['severities'] = severities
		self.values['comments'] = comments
		self.values['contacts'] = contacts

		if output == 'html':
			self.render('ticket_detail.html')
		if output == 'xml':
			self.render('ticket_detail.xml')
		elif output == 'json':
			json.dump(ticket, self.response.out, indent = 4)