Beispiel #1
0
def cms_projects_new(request):
    if request.method == "POST":
        name = request.POST['name']
        description = request.POST['description']

        project = Project()
        project.name = name
        project.description = description
        project.date = datetime.now()
        project.save()

        return redirect('/cms/projects/')

    context = {'title': 'Новый проект'}
    return render(request, 'cms/new-project.html', context)
Beispiel #2
0
def read_projects_from_file(request):
    if isFileCorrect('projects_file', '.csv', request):
        file = TextIOWrapper(request.FILES['projects_file'].file,
                             encoding='utf-8')
        reader = csv.reader(file, delimiter=',')
        descriptions = []
        for row in reader:
            if (row):
                project = Project()
                project.name = 'Projekt'
                project.description = row
                saveProject(project, request)

        request.session['desc'] = descriptions
        return redirect('tutor_projects:projects')
    else:
        setWrongFileSessionParam(request)
        return redirect('tutor_projects:projects')
 def create_project(self, client):
     # List all current projects for this client to avoid clashes
     projects = client.projects.all()
     self.write("Current projects: %s" % ", ".join([p.name for p in projects]))
     
     project_name = raw_input("Name of new project? ")
     try:
         existing_project = client.projects.get(name=project_name)
         self.write("A project already exists with name '%s'" % project_name)
         return create_project(client)
     except Project.DoesNotExist:
         pass
     project_desc = raw_input("Description (optional)? ")
     
     self.write("    Creating project '%s'" % project_name)
     project = Project()
     project.client = client
     project.name = project_name
     project.description = project_desc
     project.save()
     return project