当前位置: 首页>>代码示例>>Python>>正文


Python Project.save方法代码示例

本文整理汇总了Python中models.Project.save方法的典型用法代码示例。如果您正苦于以下问题:Python Project.save方法的具体用法?Python Project.save怎么用?Python Project.save使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在models.Project的用法示例。


在下文中一共展示了Project.save方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: addproject

# 需要导入模块: from models import Project [as 别名]
# 或者: from models.Project import save [as 别名]
def addproject(request):
    # If a user is authenticated and this is a post request, then
    # we proceed. Otherwise return an invalid page
    U = request.user
    if request.user.is_authenticated() and request.POST:
        deadline = request.POST.get('deadline')
        pid = int(request.POST.get('parentid'))
        projectname = request.POST.get('projectname')
        projectColor = taskViews.genRandomColor();


        P = Project(user=U,name=projectname,date_started=timezone.now(),deadline=deadline,date_finished=timezone.now(),parentid=pid,color=projectColor)
        P.save()

        # Loop through all the tasks posted with this project and create them as
        # unassigned tasks if they don't have deadlines

        index = 1;
        while not (request.POST.get(str(index)) is None):
            newTaskName = request.POST.get(str(index))
            taskDeadline = request.POST.get("time"+str(index))
            timeRequired = request.POST.get("timeReq"+str(index))
            index = index + 1
            if newTaskName == "":
                continue
            else:
                taskViews.createTaskForUserFromList(newTaskName,U,P,taskDeadline,timeRequired)

            
            

        return HttpResponseRedirect('/todolist/projects'+str(U.id))
    else :
        return HttpResponseRedirect('/todolist/invalid_project_add')
开发者ID:jhb563,项目名称:ProductivityApp,代码行数:36,代码来源:projectViews.py

示例2: parse_project

# 需要导入模块: from models import Project [as 别名]
# 或者: from models.Project import save [as 别名]
def parse_project(filepath, uploaddate, Document, p_uuid):
    f = csv.DictReader(Document, delimiter=',')
    Document.close()
    for row in f:
        row_dict = row
        m = Project(projectid=p_uuid, path=filepath, upload_date=uploaddate, **row_dict)
        m.save()
开发者ID:EntzeChong,项目名称:PhyloDB,代码行数:9,代码来源:parsers.py

示例3: newProject

# 需要导入模块: from models import Project [as 别名]
# 或者: from models.Project import save [as 别名]
def newProject(request, projectname, monthlygoal):
	print projectname
	project = Project()
	project.user = request.user
	project.name = projectname
	if monthlygoal != "":
		project.monthlygoal = int(monthlygoal)
		goal = project.monthlygoal
	else:
		goal = "-"
	print project
	project.save()
	print "qwe"
	dajax = Dajax()
	dajax.remove("#newrow")
	row = """<tr id="project{0}">
		<td>{1}</td>
		<td>{2}</td>
		<td>0</td>
		<td><a href="javascript:void(0)" onClick="Dajaxice.timemanager.removeProject(removeRow, {{'project': '{0}'}});" class="remove"><i class="icon-remove pull-right"></i></a>  <a href="javascript:void(0)" onClick="" class="edit"><i class="icon-pencil pull-right"></i></a></td>
	</tr>""".format(project.id, projectname, goal)
	print row
	dajax.append("#projecttable", "innerHTML", row)
	dajax.script("$('#newprojectbutton').show();")
	return dajax.json()
开发者ID:laerador,项目名称:octo-time,代码行数:27,代码来源:ajax.py

示例4: register

# 需要导入模块: from models import Project [as 别名]
# 或者: from models.Project import save [as 别名]
def register():
	
	if request.method=='POST' and request.form['company']:

		#deal with uploaded files
		full_path = ''
		if request.files['file_path']:
			file_obj = request.files['file_path']
			file_name = file_obj.filename
			full_path = os.path.join(app.config['PROJECT_FOLDER'], file_name)
			file_obj.save(full_path)

		#insert a new project
		project = Project(company = request.form['company'],
			address = request.form['address'],
			invest = request.form['invest'],
			time = request.form['time'],
			name = request.form['name'],
			major = request.form['major'],
			phone = request.form['phone'],
			email = request.form['email'],
			position = request.form['position'],
			holds = request.form['holds'],
			introduction = request.form['introduction'],
			team = request.form['team'],
			business = request.form['business'],
			file_path = full_path
		)
		project.save()
		msg = 'success'

		return render_template('register.html', msg = msg)
	print 'not'
	return render_template('register.html')
开发者ID:sparkmorry,项目名称:zaec,代码行数:36,代码来源:views.py

示例5: addProject

# 需要导入模块: from models import Project [as 别名]
# 或者: from models.Project import save [as 别名]
def addProject(request):
    """
        Creates a new project in the database
        Returns a JSON thingied thing with the
        id on success, or an error message
        otherwise
    """
    if request.method == "POST":
        try:
            inputData = json.loads(request.POST['DATA'])
            newProject = Project()
            newProject.name = inputData['name']
            newProject.save()
            if len(inputData['components']) > 0:
                #We have to ensure we have these components in the linker table
                for component_id, quantity in inputData['components']:
                    component = Component.objects.filter(id=component_id).get()
                    newBOMQuant = BOMQuant.objects.create(project=newProject, component=component, quantity=quantity)
            if len(inputData['notes']) > 0:
                #add lots of notes if we have any
                for note_id in inputData['notes']:
                    newNote = Note.objects.filter(id=note_id).get()
                    newProject.notes.add(newNote)
            newProject.save()
            json_data = json.dumps({"HTTPRESPONSE": newProject.id})
        except Exception, e:
            json_data = json.dumps({"ERROR": e.message})
开发者ID:daubers,项目名称:ComponentStock,代码行数:29,代码来源:views.py

示例6: promoteTask

# 需要导入模块: from models import Project [as 别名]
# 或者: from models.Project import save [as 别名]
def promoteTask(request):
    # Deletes this task, and instead makes it into a project with the same deadline
    U = request.user
    if request.user.is_authenticated() and request.POST:
        # Get task, turn into projects
        taskID = request.POST.get('taskid','')
        taskID = int(taskID)
        Ts = Task.objects.filter(user = U, id = taskID)
        if len(Ts) <= 0:
            # TODO Should bring up a warning box, will be fixed
            # in new layout
            return HttpResponseRedirect('/todolist/invalid_task_access/')
        T = Ts[0]
        # Get name
        tName = T.name
        # Get deadline
        tDeadline = T.deadline
        # Get started, finished
        tStart = T.date_started
        tFinish = T.date_finished
        # Get parentID
        parentID = T.parent_project.id
        T.delete()
        projectColor = genRandomColor();
        P = Project(user = U, name = tName, deadline = tDeadline, date_started = tStart, date_finished = tFinish, parentid = parentID, color = projectColor)
        P.save()
        # TODO Should include new project stuff as well, at least ID
        if request.is_ajax():
            return HttpResponse('Success')
        else :
            return HttpResponseRedirect('/todolist/projects'+str(U.id))
    else :
        return HttpResponseRedirect('todolist/invalid_task_access/')
开发者ID:jhb563,项目名称:ProductivityApp,代码行数:35,代码来源:taskViews.py

示例7: update_project

# 需要导入模块: from models import Project [as 别名]
# 或者: from models.Project import save [as 别名]
def update_project(project_id):
    """Updates the project matching the id project_id.
    Only the parameters to update or to add should be passed in the request body.
    """
    project = Project.objects(id=project_id).get()
    patched = Project(**dict(chain(project.to_dict().items(), request.get_json().items())))
    patched.save()

    return jsonify(patched.to_dict())
开发者ID:fendgroupproject,项目名称:backend,代码行数:11,代码来源:main.py

示例8: register

# 需要导入模块: from models import Project [as 别名]
# 或者: from models.Project import save [as 别名]
def register(request):
    if request.method == 'POST':
        a = request.POST.get('action')
        if a == 'register':
            register_f = RegisterForm(request.POST)
            login_f = LoginForm()
            if register_f.is_valid():
                try:
                    User.objects.create_user(
                        register_f.cleaned_data['username'],
                        register_f.cleaned_data['email'],
                        register_f.cleaned_data['password'])
                except IntegrityError, e:
                    if 'username' in str(e):
                        register_f.add_error('username',
                                             'Username is taken')
                    elif 'email' in str(e):
                        register_f.add_error('email',
                                             'Email is already registered')
                    else:
                        raise e
                else:
                    user = authenticate(
                        username=register_f.cleaned_data['username'],
                        password=register_f.cleaned_data['password'])
                    login(request, user)
                    Timezone.objects.create(user=user)
                    project = Project()
                    project.user = user
                    project.name = 'default project'
                    project.description = 'default project description'
                    project.color = Project.DEFAULT_COLOR
                    project.save()
                    return redirect('dashboard')
        elif a == 'login':
            register_f = RegisterForm()
            login_f = LoginForm(request.POST)
            if login_f.is_valid():
                user = authenticate(
                    username=login_f.cleaned_data['username'],
                    password=login_f.cleaned_data['password'])
                if user is None:
                    login_f.add_error('username',
                                      'Wrong credentials')
                else:
                    login(request, user)
                    return redirect('dashboard')
        else:
            register_f = RegisterForm()
            login_f = LoginForm()
开发者ID:DataScientists,项目名称:GOHDS,代码行数:52,代码来源:views.py

示例9: post_project

# 需要导入模块: from models import Project [as 别名]
# 或者: from models.Project import save [as 别名]
def post_project(request):
    if request.method == 'POST':
        form = ProjectForm(request.POST, request.FILES)
        if form.is_valid():
            m = Project()
            m.project_id = form.cleaned_data['projectid']
            m.project_name = form.cleaned_data['projectname']
            m.client_name = form.cleaned_data['clientname']
            m.deadline = form.cleaned_data['deadline']
            #TODO: needs a fixin'
            m.project_type = 1
            m.poster = form.cleaned_data['poster']
            m.save()
            #TODO: dont redirect here send through ajax
            return render(request, 'index.html', {'STATIC_URL': settings.STATIC_URL})
        print form.errors
开发者ID:adaro,项目名称:aws-django,代码行数:18,代码来源:views.py

示例10: create_project

# 需要导入模块: from models import Project [as 别名]
# 或者: from models.Project import save [as 别名]
def create_project():
    # with lock:
    # form = CreateProjectForm(request.form)
    # if request.method == 'POST' and form.validate_on_submit():
    debug_set = current_app.config["DEBUG"]
    if debug_set == True:
        print "\n\n\n==========> account->views.py -> create_project() "
        # print "=====> is_private() :", form.is_private.data

    form = CreateProjectForm()
    if form.validate_on_submit():
        new_proj = Project(
            prj_name=form.name.data,
            prj_desc=form.desc.data,
            is_private=form.is_private.data,
            owner=current_user.get_id(),
        )
        prj_id = new_proj.save()
        # Add a user as an owner of a project
        proj = Project.get_project_for_projectid(prj_id)
        print "project.is_private 2:", proj.is_private
        owner_name = current_user.firstname + " " + current_user.lastname
        proj.add_member(name=owner_name, email=current_user.get_id(), role=Project.ROLE_OWNER)
        flash("New project has been created.", category="index_page")
        # Generate a project owner's appkey & save it to ProjectMemberKey coll.
        # keygen = KeyGenerator()
        # key = keygen.getkey(settings.APPKEY_LENGTH)
        key = utils.generate_key()
        prjmemkey = ProjectMemberKey(prj_id=proj.prj_id, appkey=key, member_email=proj.owner)
        prjmemkey.save()
        return redirect(url_for(".list_projects"))

    return render_template("create_project.html", form=form)
开发者ID:koasys,项目名称:flask_scaffold,代码行数:35,代码来源:views.py

示例11: create_project

# 需要导入模块: from models import Project [as 别名]
# 或者: from models.Project import save [as 别名]
def create_project(request):
    name = request.POST.get('name')
    repository = request.POST.get('repository')
    build_command = request.POST.get('build_command')
    # validate
    if not name or not repository or not build_command:
        messages.error(request, _('You must specify a name, repository,'
                                  ' and build command.'))
    else:
        # create project
        project = Project(name=name, repository=repository,
                          build_command=build_command, created_by=request.user)
        project.save()
        messages.success(request,
                         '{} {}'.format(name, _('project created...')))
    return redirect(reverse('dashboard'))
开发者ID:honza,项目名称:wharf-ci,代码行数:18,代码来源:views.py

示例12: create_project

# 需要导入模块: from models import Project [as 别名]
# 或者: from models.Project import save [as 别名]
def create_project():
    #with lock:
    form = CreateProjectForm(request.form)
    if request.method == 'POST' and form.validate():
        new_proj = Project(prj_name=form.name.data, prj_desc=form.desc.data,
            is_private=form.is_private.data, owner=current_user.get_id())
        print 'project.is_private:', new_proj.is_private
        prj_id = new_proj.save()
        # Add a user as an owner of a project
        proj = Project.get_project_for_projectid(prj_id)
        print 'project.is_private 2:', proj.is_private
        owner_name = current_user.firstname + ' ' + current_user.lastname
        proj.add_member(name=owner_name, email=current_user.get_id(), 
            role=Project.ROLE_OWNER)
        flash("New project has been created.", category='index_page')
        # Generate a project owner's appkey & save it to ProjectMemberKey coll.
        #keygen = KeyGenerator()
        #key = keygen.getkey(APPKEY_LENGTH)
        key = utils.generate_key()
        prjmemkey = ProjectMemberKey(prj_id=proj.prj_id, appkey=key, 
            member_email=proj.owner)
        prjmemkey.save()
        return redirect(url_for('.list_projects'))

    return render_template('create_project.html', form=form)
开发者ID:YongHoJang,项目名称:GeoTagger-Server,代码行数:27,代码来源:views.py

示例13: create_project

# 需要导入模块: from models import Project [as 别名]
# 或者: from models.Project import save [as 别名]
def create_project(request):
    project = Project(user_id=request.__user__.id, user_name=request.__user__.name, user_image=request.__user__.image, title='', summary='', status=False)
    yield from project.save()
    return {
        '__template__': 'project_edit.html',
        'id': project.id,
        'action': '/api/project/save/'
    }
开发者ID:TBBack,项目名称:dvplatform,代码行数:10,代码来源:handlers.py

示例14: add_project

# 需要导入模块: from models import Project [as 别名]
# 或者: from models.Project import save [as 别名]
def add_project(request):
    if request.method == 'POST':
        form = ProjectForm(request.POST)

        if form.is_valid():
            package = form.cleaned_data['package']
            username = form.cleaned_data['username']
            repository = form.cleaned_data['repository']
            branch = form.cleaned_data['branch']
            cargo_support = form.cleaned_data['cargo_support']
            categories = form.cleaned_data['categories']

            repo = travisclient.get_repo(username, repository)

            if not repo:
                error_message = 'Unable to get Travis CI repo: {}/{}'.\
                    format(username, repository)
                return index(request, error_message)

            project = Project(package = package, username = username,
                    repository = repository, branch = branch,
                    cargo_support = cargo_support)
           
            if('description' in repo and repo['description']):
                project.description = repo['description']
            else:
                project.description = ''
            project.save()

            # Set categories
            project.categories = categories
            project.save()

            return authenticate_with_github(request, project.id,
                    'add_project')

    else:
        form = ProjectForm(initial={'branch': 'master'})

    context = {
            'title': private_settings.APP_TITLE,
            'form': form,
            'categories': ProjectCategory.objects.all()
    }
    return render(request, 'ppatrigger/project_form.html', context)
开发者ID:dcbishop,项目名称:rust-ci,代码行数:47,代码来源:views.py

示例15: create_project

# 需要导入模块: from models import Project [as 别名]
# 或者: from models.Project import save [as 别名]
def create_project(request):
	c=None
	if request.method =='POST':
		name = request.POST.get('projectname','')
	#	print 'course name is : ',request.session['course']
		if 'course' in request.session:
			c = Course.objects.get(name=request.session['course'])
		if c :
			w = Project.objects.filter(course = c.id ,name = name )
			if len(w):
				return HttpResponse('project already exists')
			else:
				w = Project(name=name,course=c.id,pid=10,status = 0)
				w.save()
				c.number_project +=1
				c.save()
				return HttpResponseRedirect(reverse('teacher_course',args=(c.name,)))
		else :
			return HttpResponse('course not exist')
开发者ID:CharlesCliff,项目名称:SC,代码行数:21,代码来源:teacherViews.py


注:本文中的models.Project.save方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。