Ejemplo n.º 1
0
 def test_ticket__unicode__(self):
     tt = TicketType()
     tt.name = 'Test1'
     tt.description = "A description"
     w = Workflow.objects.get(id=1)
     tt.workflow = w
     tt.save()
     p = Project.objects.get(id=1)
     c = Component.objects.get(id=1)
     u = User.objects.get(id=1)
     wm = WorkflowManager()
     wm.workflow = w
     wm.created_by = u 
     wm.save()
     t = Ticket()
     t.ticket_type = tt
     t.project = p
     t.component = c
     t.summary = "Summary"
     t.description = "Description"
     t.created_by = u
     t.updated_by = u
     t.workflow_manager = wm
     t.save()
     self.assertEquals(u'Summary', t.__unicode__())
Ejemplo n.º 2
0
def new_ticket(request, *arg):
    """
    For generating new tickets
    """
    if request.method == 'POST':
        form = TicketForm(request.POST)
        if form.is_valid():
            t = Ticket()
            t.ticket_type = form.cleaned_data['ticket_type']
            t.project = form.cleaned_data['project']
            t.component = form.cleaned_data['component']
            t.summary = form.cleaned_data['summary']
            t.description = form.cleaned_data['description']
            t.created_by = request.user
            t.updated_by = request.user
            # workflow related stuff
            ticket_type = t.ticket_type
            wm = WorkflowManager()
            wm.workflow = ticket_type.workflow
            wm.created_by = request.user
            wm.save()
            r = Role.objects.get(id=settings.ROLE_SUBMITTER)
            p = Participant()
            p.user = request.user
            p.role = r
            p.workflowmanager=wm
            p.save()
            t.workflow_manager=wm
            t.save()
            wm.start(p)
            # Generates a confirmation email to send to the new user
            current_site = Site.objects.get_current() 
            site_name = current_site.name
            domain = current_site.domain
            tplt = loader.get_template(settings.NEW_TICKET_EMAIL_TEMPLATE)
            c = {
                'email': request.user.email,
                'domain': domain,
                'site_name': site_name,
                'user': request.user,
                'protocol': settings.REGISTRATION_USE_HTTPS and 'https' or 'http',
                'ticket': t,
            }
            send_mail(_("Confirmation of new ticket on IssueTracker"),
                tplt.render(Context(c)), None, [request.user.email])
            
            request.user.message_set.create(message=_("The ticket has been"\
                    " successfully created."))
            return HttpResponseRedirect('/ticket/%d'%t.id)
    else:
        form = TicketForm()
    c = RequestContext(request, {'form': form})
    return render_to_response('new.html', c) 
Ejemplo n.º 3
0
 def test_state_form_init(self):
     """
     As the __init__ method is overridden - we need to check the form is
     set up properly
     """
     tt = TicketType()
     tt.name = 'Test1'
     tt.description = "A description"
     w = Workflow.objects.get(id=1)
     tt.workflow = w
     tt.save()
     p = Project.objects.get(id=1)
     c = Component.objects.get(id=1)
     u = User.objects.get(id=1)
     wm = WorkflowManager()
     wm.workflow = w
     wm.created_by = u 
     wm.save()
     t = Ticket()
     t.ticket_type = tt
     t.project = p
     t.component = c
     t.summary = "Summary"
     t.description = "Description"
     t.created_by = u
     t.updated_by = u
     t.workflow_manager = wm
     t.save()
     r = Role.objects.get(id=1)
     p = Participant(
             role=r,
             user=u,
             workflowmanager=wm
             )
     p.save()
     wm.start(p)
     sf = StateForm(workflow_manager=wm)
     self.assertEqual(sf.fields['transition'].queryset[0],
             wm.current_state().state.transitions_from.all()[0])