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


Python Project.put方法代码示例

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


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

示例1: add_project

# 需要导入模块: from models import Project [as 别名]
# 或者: from models.Project import put [as 别名]
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,代码行数:27,代码来源:views.py

示例2: import_google_events

# 需要导入模块: from models import Project [as 别名]
# 或者: from models.Project import put [as 别名]
    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,代码行数:62,代码来源:profile.py

示例3: post

# 需要导入模块: from models import Project [as 别名]
# 或者: from models.Project import put [as 别名]
	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,代码行数:30,代码来源:ProjectsHandler.py

示例4: post

# 需要导入模块: from models import Project [as 别名]
# 或者: from models.Project import put [as 别名]
 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,代码行数:9,代码来源:createproject.py

示例5: post

# 需要导入模块: from models import Project [as 别名]
# 或者: from models.Project import put [as 别名]
 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,代码行数:29,代码来源:main.py

示例6: import_projects

# 需要导入模块: from models import Project [as 别名]
# 或者: from models.Project import put [as 别名]
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,代码行数:30,代码来源:initial_data.py

示例7: project_new

# 需要导入模块: from models import Project [as 别名]
# 或者: from models.Project import put [as 别名]
	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,代码行数:9,代码来源:handlers.py

示例8: save_projects

# 需要导入模块: from models import Project [as 别名]
# 或者: from models.Project import put [as 别名]
def save_projects(project_list):
    for p in project_list:
        project = Project()
        project.link = p['link']
        project.left = p['left']
        project.end = p['end']
        project.saved = CRAWL_TIME
        project.put()
开发者ID:ecmendenhall,项目名称:Kicksaver,代码行数:10,代码来源:kickparser.py

示例9: post

# 需要导入模块: from models import Project [as 别名]
# 或者: from models.Project import put [as 别名]
    def post(self):
        user = users.get_current_user()

        title = self.request.get('title')
        if title:
            new_project = Project(
                owner=user.user_id(),
                title=title,
            )
            new_project.put()

            self.redirect(new_project.permalink)
            return

        self.redirect('/')
开发者ID:git2samus,项目名称:tamarindo-web,代码行数:17,代码来源:dashboard.py

示例10: loadprojects

# 需要导入模块: from models import Project [as 别名]
# 或者: from models.Project import put [as 别名]
def loadprojects():
    """ Yo this needs some work..."""
    
    project_dir = "./data/projects/"
    
    for filename in os.listdir(project_dir):
        
        with open(project_dir + filename, "rb") as f:
            p = json.load(f)
            
            name = p['name']
            link = p['link']
            description = p['description']
            
            project = Project(name=name, link=link, description=description)
            project.put()
            
            logging.info("Putting project '{}' into the datastore...".format(name))
开发者ID:rlmv,项目名称:mysite,代码行数:20,代码来源:db.py

示例11: create

# 需要导入模块: from models import Project [as 别名]
# 或者: from models.Project import put [as 别名]
def create():
    """Create project route.
    
    Accepts submitted forms to create a new managed project.
    This will insert the project into the database and redirect
    the user to the project page afterwards.
    """
    
    name = request.form['name'].strip()
    if (name == ''): abort(400)

    url = request.form['url'].strip()
    if (url == ''): abort(400)

    desc = request.form['desc'].strip()

    project = Project(name=name, url=url, desc=desc)
    project.put()
    
    return redirect('/a/' + str(project.key.id()))
开发者ID:bruxr,项目名称:Sirius2,代码行数:22,代码来源:projects.py

示例12: get

# 需要导入模块: from models import Project [as 别名]
# 或者: from models.Project import put [as 别名]
 def get(self, projectname, projectdesc, jobtypecsv, budgetoption,
         duration):
     user_id = get_account().key.id()
     end_date = datetime.datetime.now()
     end_date = end_date + datetime.timedelta(days=int(duration))
     project = Project(
         name=projectname,
         price=budgetoption,
         description=projectdesc,
         job_type=jobtypecsv,
         end_date=end_date,
         owner=user_id
     )
     project.put()  # do error checking on puts later
     account = get_account()
     account.projects_posted.append(project.key.id())
     account.put()
     if account == None:
         response = 'No logged in account.'
     else:
         response = 'Logged in account found. Project Posted'
     account.projects_posted.append(project)
     self.response.headers['Content-Type'] = 'application/json'
     self.response.write(json.dumps(response))
开发者ID:N0tinuse,项目名称:senior_project,代码行数:26,代码来源:actions.py

示例13: import_timely_events

# 需要导入模块: from models import Project [as 别名]
# 或者: from models.Project import put [as 别名]
    def import_timely_events(self):

        if not self.user.timely_token:
            self.response.status = 501
            return

        header = {
            'Authorization': 'Bearer ' + self.user.timely_token,
            'Content-Type': 'application/json'
        }

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

        # importo l'utente
        result = urlfetch.fetch(url='https://api.timelyapp.com/1.0/accounts',
                                headers=header,
                                method=urlfetch.GET)

        if result.status_code != 200:
            self.response.set_status(501)
            return

        result = json.loads(result.content)

        selected_proj = json.loads(self.request.get('selected_proj'))
        since = self.request.get('since')
        up_to = self.request.get('up_to')

        if since != '' and not datetime.strptime(since, '%Y-%m-%d'):
            self.response.set_status(201)
            self.response.write('Since time is not correct')
            return
        if up_to != '' and not datetime.strptime(up_to, '%Y-%m-%d'):
            self.response.set_status(201)
            self.response.write('Up_to time is not correct')
            return
        num_imported = 0
        for proj_id in selected_proj:

            if since != '' and up_to != '':
                timely_events_url = 'https://api.timelyapp.com/1.0/%s/projects/%s/events?since=%s&upto=%s' % \
                                    (result[0]['id'], proj_id, since, up_to)
            else:
                timely_events_url = 'https://api.timelyapp.com/1.0/%s/projects/%s/events' % (result[0]['id'], proj_id)

            logging.warn(timely_events_url + " " + self.user.timely_token)
            events = urlfetch.fetch(
                url=timely_events_url,
                headers=header,
                method=urlfetch.GET)

            if events.status_code != 200:
                self.response.set_status(501)
                return

            events = json.loads(events.content)
            if len(events) > 0:
                num_imported += len(events)
                # create project
                new_proj = Project(parent=self.user.key)
                new_proj.name = events[0]['project']['name'][0:25]
                new_proj.hourly_rate = events[0]['project']['hour_rate']
                new_proj.put()

                self.user.num_projects += 1
                self.user.put()
                for event in events:

                    if event['duration']['total_minutes'] > 0:
                        start_time = datetime.strptime((event['day'] + ' 00:00'), '%Y-%m-%d %H:%M')
                        end_time = start_time + timedelta(minutes=(event['duration']['total_minutes']))
                        event_title = event['note'][0:25]
                        event_description = event['note']
                        billed = True
                        self.save_imported_event(new_proj.key, start_time, end_time, event_title, event_description,
                                                 billed)

                    if self.request.get('import_planned') == 'true':
                        if (event['estimated_duration']['total_minutes'] - event['duration']['total_minutes']) > 0:
                            start_time = datetime.strptime((event['day'] + ' 00:00'), '%Y-%m-%d %H:%M')
                            end_time = start_time + timedelta(
                                minutes=(event['estimated_duration']['total_minutes'] - event['duration']['total_minutes']))
                            event_title = 'planned-' + event['note'][0:25]
                            event_description = event['note']
                            billed = False
                            self.save_imported_event(new_proj.key, start_time, end_time, event_title,
                                                     event_description, billed)

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

示例14: post

# 需要导入模块: from models import Project [as 别名]
# 或者: from models.Project import put [as 别名]
    def post(self):
        if not self.user.administrator:
            return webapp2.redirect("/")

        mode = self.request.POST["mode"]

        if mode == "0":
            # Institution
            institution = Institution(name=self.request.POST["name"], website=self.request.POST["website"])
            institution.put()
        elif mode == "1":
            thumbnail_url = self.request.POST["thumbnail"]
            try:
                content = urllib2.urlopen(thumbnail_url)
                image = content.read()
            except urllib2.HTTPError:
                logging.warning("URL: " + thumbnail_url + "was not found.")
                image = ""

            institution = ndb.Key(urlsafe=self.request.POST["institution"])

            author = Author(
                name=self.request.POST["name"],
                website=self.request.POST["website"],
                thumbnail=image,
                institution=institution,
            )
            author.put()
        elif mode == "2":
            # Conference
            conference = Conference(name=self.request.POST["name"], acronym=self.request.POST["acronym"])
            conference.put()
            pass
        elif mode == "3":
            # Publication
            date = datetime.strptime(self.request.POST["date"], "%Y-%m-%d")

            # A bit messy, does author order
            authors = self.request.params.getall("authors")
            idx = 0
            author_order = [int(order_idx) for order_idx in self.request.POST["order"].split(",")]
            ordered_authors = []
            for author_idx in range(len(authors)):
                ordered_authors.append(ndb.Key(urlsafe=authors[author_order[author_idx] - 1]))

            conference = ndb.Key(urlsafe=self.request.POST["conference"])

            pdf_image_url = self.request.POST["pdfimage"]
            image = ""
            if pdf_image_url:
                try:
                    content = urllib2.urlopen(pdf_image_url)
                    image = content.read()
                except urllib2.HTTPError:
                    logging.warning("URL: " + pdf_image_url + "was not found.")

            publication = Publication(
                title=self.request.POST["title"],
                abstract=self.request.POST["abstract"],
                date=date,
                authors=ordered_authors,
                citation=self.request.POST["citation"],
                conference=conference,
                pdf=self.request.POST["pdf"],
                pdf_image=image,
                arxiv_link=self.request.POST["arxiv"],
                project_page=self.request.POST["projectpage"],
            )
            publication.put()
        elif mode == "4":
            # Content
            content = Content(name=self.request.POST["name"], content=self.request.POST["content"])
            content.put()
        elif mode == "5":
            # Project
            authors = []
            for author in self.request.params.getall("authors"):
                authors.append(ndb.Key(urlsafe=author))

            image_url = self.request.POST["image"]
            if image_url:
                try:
                    content = urllib2.urlopen(image_url)
                    image = content.read()
                except urllib2.HTTPError:
                    logging.warning("URL: " + image_url + "was not found.")
                    image = ""
            else:
                image = ""

            publications = []
            for publication in self.request.params.getall("publications"):
                publications.append(ndb.Key(urlsafe=publication))

            contents = []
            for content in self.request.params.getall("contents"):
                contents.append(ndb.Key(urlsafe=content))

            tags = []
            for tag in self.request.POST["tags"].split(","):
#.........这里部分代码省略.........
开发者ID:dcastro9,项目名称:personal_site,代码行数:103,代码来源:admin.py


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