예제 #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
예제 #2
0
 def create_project(self, new_name=None):
     """ Create the project defined by self.dataset.project_data in the
     database. If new_name is provided, the name of the project will be this
     value instead of *test_project*."""
     project = ChartProject(**self.dataset.project_data)
     if new_name:
         project.name = new_name
     project.admin = self.dataset.user
     project.save()
     return project
예제 #3
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)