Ejemplo n.º 1
0
Archivo: tests.py Proyecto: eykanal/pm
    def test_new_project_form(self):
        # test full submit
        data1 = {
            'name': 'test',
            'requester': People.objects.values_list('pk', flat=True).get(name__username='******'),
            'project_manager': People.objects.values_list('pk', flat=True).get(name__username='******'),  # Kanal
            'description': 'Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.',
            'start_date': date.today(),
            'due_date': date.today(),
            'date_complete': date.today(),
            'sharepoint_ticket': 'http://www.example.com/',
            'priority': Project.STANDARD,
            'status': Project.ACTIVE,
            'program': Program.objects.values_list('pk', flat=True).get(name="None"),
            'workers': tuple(People.objects.values_list('pk', flat=True).filter(Q(name__username="******") | Q(name__username="******"))),
        }
        p1 = ProjectForm(data1)
        self.assertTrue(p1.is_valid())

        # test only required fields
        data2 = {
            'name': 'test',
            'requester': People.objects.values_list('pk', flat=True).get(name__username='******'),
            'project_manager': People.objects.values_list('pk', flat=True).get(name__username='******'),  # Kanal
            'description': 'Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.',
            'start_date': date.today(),
            'priority': Project.STANDARD,
            'status': Project.ACTIVE,
            'program': Program.objects.values_list('pk', flat=True).get(name="None"),
            'workers': tuple(People.objects.values_list('pk', flat=True).filter(Q(name__username="******") | Q(name__username="******"))),
        }
        p2 = ProjectForm(data2)
        self.assertTrue(p2.is_valid())
Ejemplo n.º 2
0
def add_new_project(request):
	project_form = ProjectForm(request.POST or None)
	if project_form.is_valid():
		project = project_form.save(commit=False)
		project.client = project_form.cleaned_data['client']
		project.save()
		return redirect(projects)
	messages.warning(request, u', '.join(project_form.errors))
	return render(request, 'add_new_project.html', {'form':project_form})
Ejemplo n.º 3
0
def add_new_project(request):
    project_form = ProjectForm(request.POST or None)
    if project_form.is_valid():
        project = project_form.save(commit=False)
        project.client = project_form.cleaned_data['client']
        project.save()
        return redirect(projects)
    messages.warning(request, u', '.join(project_form.errors))
    return render(request, 'add_new_project.html', {'form': project_form})
Ejemplo n.º 4
0
def create_project(request):
    context = RequestContext(request)

    if request.method == 'POST':
        form = ProjectForm(request.POST)
        if form.is_valid():
            p = Project(
                name=form.cleaned_data['name'],
                requester=form.cleaned_data['requester'],
                project_manager=form.cleaned_data['project_manager'],
                program=form.cleaned_data['program'],
                description=form.cleaned_data['description'],
                start_date=form.cleaned_data['start_date'],
                due_date=form.cleaned_data['due_date'],
                date_complete=form.cleaned_data['date_complete'],
                sharepoint_ticket=form.cleaned_data['sharepoint_ticket'],
                priority=form.cleaned_data['priority'],
                status=form.cleaned_data['status'])
            p.save()

            for w in form.cleaned_data['workers']:
                w = Worker(
                    project=Project.objects.get(pk=p.id),
                    person=w,
                )
                w.save()

            return redirect('pm:index')
        else:
            # handle errors
            print form.cleaned_data
            pass
    else:
        form = ProjectForm(initial={'program': Program.objects.get(name="None")})

    return render_to_response("pm/project_new.html", {'form': form}, context)
Ejemplo n.º 5
0
Archivo: tests.py Proyecto: eykanal/pm
    def test_new_project_form(self):
        # test full submit
        data1 = {
            'name':
            'test',
            'requester':
            People.objects.values_list(
                'pk', flat=True).get(name__username='******'),
            'project_manager':
            People.objects.values_list(
                'pk', flat=True).get(name__username='******'),  # Kanal
            'description':
            'Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.',
            'start_date':
            date.today(),
            'due_date':
            date.today(),
            'date_complete':
            date.today(),
            'sharepoint_ticket':
            'http://www.example.com/',
            'priority':
            Project.STANDARD,
            'status':
            Project.ACTIVE,
            'program':
            Program.objects.values_list('pk', flat=True).get(name="None"),
            'workers':
            tuple(
                People.objects.values_list('pk', flat=True).filter(
                    Q(name__username="******")
                    | Q(name__username="******"))),
        }
        p1 = ProjectForm(data1)
        self.assertTrue(p1.is_valid())

        # test only required fields
        data2 = {
            'name':
            'test',
            'requester':
            People.objects.values_list(
                'pk', flat=True).get(name__username='******'),
            'project_manager':
            People.objects.values_list(
                'pk', flat=True).get(name__username='******'),  # Kanal
            'description':
            'Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.',
            'start_date':
            date.today(),
            'priority':
            Project.STANDARD,
            'status':
            Project.ACTIVE,
            'program':
            Program.objects.values_list('pk', flat=True).get(name="None"),
            'workers':
            tuple(
                People.objects.values_list('pk', flat=True).filter(
                    Q(name__username="******")
                    | Q(name__username="******"))),
        }
        p2 = ProjectForm(data2)
        self.assertTrue(p2.is_valid())