• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python models.Project类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: import_projects

def import_projects(projects=projects):
    from models import Project, ProjectPhoto, ProjectFloorPlan
    for p in projects:
        project = Project(title=p['title'],
            subtitle=p['subtitle'],
            slogan=p['slogan'],
            location=p['location'],
            cover_picture_url=p['cover_picture_url'],
            cover_thumb_url=p['cover_thumb_url'],
            development_status=p['development_status'],
            description=p['description'])
        project.put()
        fps = []
        for fp in p['floor_plans']:
            floor_plan = ProjectFloorPlan(caption=fp['caption'],
                thumb_url=fp['thumb_url'],
                picture_url=fp['picture_url'],
                project=project)
            fps.append(floor_plan)
        db.put(fps)
        photos = []
        for fp in p['photos']:
            photo = ProjectPhoto(caption=fp['caption'],
                thumb_url=fp['thumb_url'],
                picture_url=fp['picture_url'],
                project=project)
            photos.append(photo)
        db.put(photos)
开发者ID:aswadrangnekar,项目名称:khandelwal,代码行数:28,代码来源:initial_data.py


示例2: project_new

	def project_new( self, name, settings ):
		owner = current_handler.auth.user.auth_id
		project = Project( name=name, owner=owner, settings=settings )
		project.put()
		return {
			'key': str( project.key() )
		}
开发者ID:geary,项目名称:claslite,代码行数:7,代码来源:handlers.py


示例3: post

 def post(self):
   title = self.request.POST.get('title')
   code = self.request.POST.get('code')
   admins = [Util.getUsernameFromEmail(users.get_current_user().email())]
   project = Project(title=title, code=code, admins=admins)
   project.put()
   self.redirect('/' + project.code + '/organize')
开发者ID:lmanul,项目名称:awty,代码行数:7,代码来源:createproject.py


示例4: project_add_typed

def project_add_typed(request, project_id, response_format='html'):
    """Project add to preselected parent project"""

    parent_project = None
    if project_id:
        parent_project = get_object_or_404(Project, pk=project_id)
        if not request.user.profile.has_permission(parent_project, mode='x'):
            parent_project = None

    if request.POST:
        if 'cancel' not in request.POST:
            project = Project()
            form = ProjectForm(
                request.user.profile, project_id, request.POST, instance=project)
            if form.is_valid():
                project = form.save()
                project.set_user_from_request(request)
                return HttpResponseRedirect(reverse('projects_project_view', args=[project.id]))
        else:
            return HttpResponseRedirect(reverse('projects'))
    else:
        form = ProjectForm(request.user.profile, project_id)

    context = _get_default_context(request)
    context.update({'form': form, 'project': parent_project})

    return render_to_response('projects/project_add_typed', context,
                              context_instance=RequestContext(request), response_format=response_format)
开发者ID:tovmeod,项目名称:anaf,代码行数:28,代码来源:views.py


示例5: create_project

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,代码行数:33,代码来源:views.py


示例6: edit_project

def edit_project(request, project_id=None):
    # http://wiki.ddenis.com/index.php?title=Django,_add_and_edit_object_together_in_the_same_form

    if project_id:
        print "exists"
        project = get_object_or_404(Project, pk=project_id)
        if request.user not in project.users.all():
            return HttpResponseForbidden()
    else:
        print "doesn't exist"
        project = Project()

    if request.method == "POST":

        form = ProjectForm(request.POST, instance=project)

        if form.is_valid():

            form.save()

            return HttpResponseRedirect(project.get_absolute_url())

    else:

        form = ProjectForm(instance=project)

    if project_id:
        template_name = "edit_project.html"
    else:
        template_name = "new_project.html"

    return render(request, template_name, {"form": form, "project": project})
开发者ID:joinEF,项目名称:people,代码行数:32,代码来源:views.py


示例7: register

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,代码行数:34,代码来源:views.py


示例8: create_project

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,代码行数:25,代码来源:views.py


示例9: addproject

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,代码行数:34,代码来源:projectViews.py


示例10: import_google_events

    def import_google_events(self):

        if not self.request.get('selected_calendars'):
            self.response.status = 501
            return

        selected_calendars = json.loads(self.request.get('selected_calendars'))
        credentials = self.user.google_credentials

        if not credentials:
            self.response.status = 501
            return

        http = httplib2.Http()
        http = credentials.authorize(http)
        service = build('calendar', 'v3', http=http)

        page_token = None
        num_imported = 0
        for calendarId in selected_calendars:
            events = service.events().list(calendarId=calendarId, pageToken=page_token).execute()
            if len(events) > 0:
                # creating project
                new_proj = Project(parent=self.user.key)
                new_proj.name = events['summary'][0:25]
                new_proj.put()

                self.user.num_projects += 1
                self.user.put()
                while True:
                    for event in events['items']:
                        if 'dateTime' in event['start']:
                            start_time = datetime.strptime((event['start']['dateTime'])[0:16], '%Y-%m-%dT%H:%M')
                        else:
                            start_time = datetime.strptime((event['start']['date'] + 'T00:00'), '%Y-%m-%dT%H:%M')

                        if 'dateTime' in event['end']:
                            end_time = datetime.strptime((event['end']['dateTime'])[0:16], '%Y-%m-%dT%H:%M')
                        else:
                            end_time = datetime.strptime((event['end']['date'] + 'T00:00'), '%Y-%m-%dT%H:%M')

                        event_title = event['summary'][0:25]
                        event_description = (event['summary'])[0:200]
                        event_url = event['htmlLink']
                        if self.request.get('import_as_billed') == 'true':
                            billed = True
                        else:
                            billed = False
                        self.save_imported_event(new_proj.key, start_time, end_time, event_title, event_description,
                                                 billed, event_url)
                        num_imported += 1

                    page_token = events.get('nextPageToken')
                    if not page_token:
                        break
                    events = service.events().list(calendarId=calendarId, pageToken=page_token).execute()
                    if len(events) == 0:
                        break

        self.response.write(num_imported)
开发者ID:giovamo,项目名称:Sar,代码行数:60,代码来源:profile.py


示例11: add_project

def add_project(request, user):
    
    if request.method=="POST":
        # process form
        
        # fail if the name is blank
        name = request.POST['name'].strip()
        if name == "":
            return HttpResponseRedirect( "?error=the+name+needs+to+contain+letters" )
            
        # make and put project
        project = Project(user=user,name=name,updated=datetime.datetime.now())
        project.put()
        
        # increment project_count
        nickname = Nickname.all().filter("user =", user).get()
        nickname.project_count += 1
        nickname.put()
        
        logging.info( project.key().id() )
        
        # return rendered project div
        return render_to_response( "includes/project_div.html", {'project':{'name':project.name,'id':project.key().id()}} )
    
    return render_to_response( "add_project.html", {'error':request.GET.get('error',None)} )
开发者ID:bmander,项目名称:proje,代码行数:25,代码来源:views.py


示例12: delete

 def delete(self, key):
     if auth.user_is_admin():
         Project.get(key).delete()
     else:
         Messages.add('Only and administrator may delete projects. This ' +
                      'incident has been logged.')
     return self.redirect('/projects')
开发者ID:DanAlbert,项目名称:d20mgr,代码行数:7,代码来源:back.main.py


示例13: post

	def	post(self):
		action = self.request.get('action', 'add')
		if action == 'add':
			if len(self.request.get('name'))<2:
				raise Exception("project name must be at least 2 characters long")
			if len(self.request.get('currency'))<1:
				raise Exception("project currency must be at least one character long")
			# create the project and return the new location to go to
			project = Project(name=self.request.get('name'), currency=self.request.get('currency'))
			project.put()
			# add access rights for this user to the new project
			rights = ProjectRights(project=project, user=users.GetCurrentUser(), right=Security.Right_Owner)
			rights.put()
			# redirect to summary
			self.response.out.write("/summary?project=%(key)s" % {'key':project.key()})
		elif action == 'delete':
			# remove me from the projects right list
			project = Project.get(self.request.get('project', ''))
			if (not project):
				raise Exception("Unknown project!")
			# check rights of current user for this project, and deny access if not permitable
			rights = ProjectRights.gql("WHERE user=:user and project=:project", user=users.get_current_user(), project=project).get()
			if rights:
				rights.delete()
			# redirect to my page
			self.response.out.write("/")
		else:
			raise Exception("Unknown action '%(action)s'!" % {'action':action})
开发者ID:realthargor,项目名称:urlaubsabrechnung,代码行数:28,代码来源:ProjectsHandler.py


示例14: post

 def post(self):
     
     # if we don't have a user then throw
     # an unauthorised error
     user = users.get_current_user()
     if not user:
         self.render_403()
         return
     
     name = self.request.get("name")
     
     # check we have a value
     if name:
         # then check we have a value which isn't just spaces
         if name.strip():
             if Project.all().filter('name =', name).count() == 0:
                 # we also need to check if we have something with the same slug
                 if Project.all().filter('slug =', slugify(unicode(name))).count() == 0:
                     try:
                         project = Project(
                             name=name,
                             user=users.get_current_user(),       
                         )
                         project.put()
                         logging.info("project added: %s" % project.name)
                     except db.BadValueError, e:
                         logging.error("error adding project: %s" % e)
开发者ID:abazad,项目名称:appengine-bugs,代码行数:27,代码来源:main.py


示例15: create_project

def create_project():
    config.reload()
    form = ProjectForm()
    ds_forms = dict([
        (cls.populates, cls()) for cls in DataSourceForm.__subclasses__()])

    form.datasource_type.choices = [
        (cls.populates, cls.name) for cls in DataSourceForm.__subclasses__()]
    form.datasource_type.choices.insert(0, (None, "-- Select Data Source --"))
    new_project = Project()

    if form.validate_on_submit():
        form.populate_obj(new_project)
        ds_form = ds_forms[form.datasource_type.data]

        if ds_form.validate():
            new_project.datasource = \
                getattr(models, form.datasource_type.data)()
            ds_form.populate_obj(new_project.datasource)

            db.session.add(new_project)
            db.session.commit()
            flash("New project successfully created.")
            return redirect(url_for('view_project', id=new_project.id))

    return render_template("project/create.html",
                           form=form, ds_forms=ds_forms, project=new_project)
开发者ID:VaclavDedik,项目名称:triager,代码行数:27,代码来源:views.py


示例16: get

 def get(self):
     from models import Project
     completed_projects = Project.get_all_complete()
     ongoing_projects = Project.get_all_ongoing()
     self.render('projects.html', 
         completed_projects=completed_projects,
         ongoing_projects=ongoing_projects)
开发者ID:aswadrangnekar,项目名称:khandelwal,代码行数:7,代码来源:handlers.py


示例17: promoteTask

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,代码行数:33,代码来源:taskViews.py


示例18: parse_project

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,代码行数:7,代码来源:parsers.py


示例19: create_project

def create_project(project_id, project_description):
    """Takes arguments and create a new project."""
    db.connect()

    Project.create(project_id=project_id, project_description=project_description)

    db.close()
开发者ID:dsantosp12,项目名称:NapAdmin,代码行数:7,代码来源:project.py


示例20: remove_old_projects

def remove_old_projects():
    p = Project.all()
    old_project = p.order('-saved').get()
    if old_project:
        old_date = old_project.saved
        p = Project.all().filter('saved = ', old_date)
        db.delete(p)
开发者ID:ecmendenhall,项目名称:Kicksaver,代码行数:7,代码来源:kickparser.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python models.Publish类代码示例发布时间:2022-05-27
下一篇:
Python models.ProfileForm类代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap