Exemplo n.º 1
0
 def _create_project(self):
     """Create and return a test project"""
     project = ChartProject();
     project.name = 'test'
     project.start_date = date.today()
     project.end_date = date.today() + timedelta(days=30)
     project.admin = self.user;
     project.save()
     return project
Exemplo n.º 2
0
def new_project(request, user_id):
    user = User.objects.get(pk=user_id)
    action_url = '/charts/project/new/%d' % user.id
    if request.method == 'POST':
        form = ProjectForm(request.POST)
        if form.is_valid():
            # TODO: what if the form is invalid?
            project = ChartProject(name = form.cleaned_data['name'])
            project.start_date = form.cleaned_data['start_date']
            project.end_date = form.cleaned_data['end_date']
            project.admin = user
            project.save()
            return HttpResponseRedirect('/charts/dashboard/%s' % user_id)
    else:
        form = ProjectForm()

    context = {'user': user, 'form': form, 'action_url': action_url}
    return render(request, 'create_project.htm', context)