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


Python Event.query方法代码示例

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


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

示例1: event_examples

# 需要导入模块: from models import Event [as 别名]
# 或者: from models.Event import query [as 别名]
def event_examples():
    """List all events"""
    event = Event.query()
    form = EventForm()
    if form.validate_on_submit():
        event = Event(
            #event_id=
            title=form.title.data,
            day=form.day.data,
            location=form.location.data,
            description=form.descrtiption.data,
            anchor_amount=form.anchor_amount.data,
            amount_min=form.amount_min.data,
            max_attendees=form.max_attendees.data,
            registration_start=form.registration_start.data,
            registration_end=form.registration_end.data,
            added_by=users.get_current_user()
        )
        try:
            event.put()
            event_id = event.key.id()
            flash(u'Event %s successfully saved.' % event_id, 'success')
            return redirect(url_for('event_examples'))
        except CapabilityDisabledError:
            flash(u'App Engine Datastore is currently in read-only mode.', 'info')
            return redirect(url_for('event_examples'))
    return render_template('event_gae.html', event=event, form=form)
开发者ID:meyilmaz,项目名称:rsvplus,代码行数:29,代码来源:views.py

示例2: get_project

# 需要导入模块: from models import Event [as 别名]
# 或者: from models.Event import query [as 别名]
    def get_project(self, project_key):
        try:
            project_key = ndb.Key(urlsafe=project_key)
        except Exception as e:
            logging.warn(e)
            self.response.set_status(404)
            self.render_template("errors/404.html")
            return
        project = Project.query(ancestor=self.user.key).filter(Project.key == project_key).get()

        events = Event.query(ancestor=project.key).fetch()
        total_mins = 0
        billed_mins = 0
        for ev in events:
            total_mins = total_mins + ev.elapsed_time
            if ev.billed:
                billed_mins = billed_mins + ev.elapsed_time

        params = {
            'project': project,
            'events': events,
            'total_mins': total_mins,
            'billed_mins': billed_mins,
            'google_login': True if self.user.google_credentials else False
        }
        self.render_template('project-details.html', params)
开发者ID:giovamo,项目名称:Sar,代码行数:28,代码来源:projects.py

示例3: event_list

# 需要导入模块: from models import Event [as 别名]
# 或者: from models.Event import query [as 别名]
def event_list(id):
    key = ndb.Key("Agent", id)
    query = Event.query(ancestor=key)
    out = []
    for event in query:
        out.append({'name': event.name})
    return json.dumps(out)
开发者ID:ridnarong,项目名称:flasky,代码行数:9,代码来源:main.py

示例4: get

# 需要导入模块: from models import Event [as 别名]
# 或者: from models.Event import query [as 别名]
    def get(self):
        self.response.headers['Content-Type'] = "application/rss+xml; charset=utf-8"

        host = self.request.headers.get('host', 'nohost')
        base_url = self.request.scheme + "://" + host

        events = []
        query = Event.query().order(-Event.start)

        # Filter query by requested services, if specified in the 'service' URL parameter.
        service_list = []
        for service_arg in self.request.get_all('services'):
            service_list.extend(service_arg.split(','))
        service_list = map(lambda serv_slug: Service.get_by_slug(serv_slug), service_list)
        # filter out any non-existent services
        service_list = filter(lambda service: not service is None, service_list)

        service_string = 'all services'
        if len(service_list) > 0:
            query.filter('service IN', service_list)
            if len(service_list) == 1:
                service_string = 'the %s service' % service_list[0].name
            elif len(service_list) == 2:
                service_string = 'the %s and %s services' % (service_list[0].name, service_list[1].name)
            else:
                service_string = 'the %s, and %s services' % (', '.join([service.name for service in service_list[:-1]]), service_list[-1].name)

        # Create the root 'rss' element
        rss_xml = et.Element('rss')
        rss_xml.set('version', '2.0')

        # Create the channel element and its metadata elements
        channel = et.SubElement(rss_xml, 'channel')
        title = et.SubElement(channel, 'title')
        title.text = '%s Service Events' % settings.SITE_NAME
        description = et.SubElement(channel, 'description')
        description.text = 'This feed shows the last %d events on %s on %s.' % (settings.RSS_NUM_EVENTS_TO_FETCH, service_string, settings.SITE_NAME)
        link = et.SubElement(channel, 'link')
        link.text = base_url

        # Create each of the feed events.
        item_subelements = {
            'title': lambda(event): '[%s - %s] %s' % (event.service.name, event.status.name, unicode(event.message)),
            'description': lambda(event): '%s' % unicode(event.message),
            'link': lambda(event): '%s/services/%s' % (base_url, event.service.slug),
            'category': lambda(event): event.service.name,
            'pubDate': lambda(event): format_date_time(mktime(event.start.timetuple())),
            'guid': lambda(event): '%s/api/v1/services/%s/events/%s' % (base_url, event.service.slug, unicode(event.key))
        }

        for event in query.fetch(settings.RSS_NUM_EVENTS_TO_FETCH):
            item = et.SubElement(channel, 'item')
            for tag, text_func in item_subelements.iteritems():
                subelement = et.SubElement(item, tag)
                subelement.text = text_func(event)

        self.response.out.write('<?xml version="1.0" encoding="UTF-8"?>\n')
        self.response.out.write(et.tostring(rss_xml))
开发者ID:Labgoo,项目名称:stashboard,代码行数:60,代码来源:site.py

示例5: delete_project

# 需要导入模块: from models import Event [as 别名]
# 或者: from models.Event import query [as 别名]
    def delete_project(project_key_urlsafe, user):
        project_key = ndb.Key(urlsafe=project_key_urlsafe)
        events = Event.query(ancestor=project_key).fetch()

        for ev in events:
            ev.key.delete()

        project_key.delete()

        user.num_projects -= 1
        user.put()

        return project_key.urlsafe()
开发者ID:giovamo,项目名称:Sar,代码行数:15,代码来源:project_service.py

示例6: delete

# 需要导入模块: from models import Event [as 别名]
# 或者: from models.Event import query [as 别名]
    def delete(self, version, status_slug):
        if not self.valid_version(version):
            self.error(404, "API Version %s not supported" % version)
            return

        status = Status.get_by_slug(status_slug)

        if not status:
            self.error(404, "Status %s not found" % status_slug)
            return

        # We may want to think more about this
        delete_multi(Event.query().filter(Event.status == status))

        status.delete()
        self.json(status.rest(self.base_url(version)))
开发者ID:Labgoo,项目名称:stashboard,代码行数:18,代码来源:api.py

示例7: post

# 需要导入模块: from models import Event [as 别名]
# 或者: from models.Event import query [as 别名]
 def post(self):
     user = users.get_current_user()
     memento_name = self.request.get("name")
     event_name = self.request.get("event_input")
     item_name = self.request.get("item_input")
     memento_user_query = ndb.gql("SELECT * from MementoUser WHERE user_name = :1", user.nickname())
     
     curr_memento_user = memento_user_query.get()
     curr_memento_user_key = curr_memento_user.key
     
     event = Event.query(ancestor=curr_memento_user_key).filter(ndb.GenericProperty("event_name") == event_name).get()
     item = Item.query(ancestor=MEMENTO_USER_KEY).filter(ndb.GenericProperty("item_name") == item_name).get()
     existing_mementos = Memento.query(ancestor=curr_memento_user_key)
     alreadyExists = existing_mementos.filter(ndb.GenericProperty("memento_name") == memento_name)
     if not self.request.get("entity_key"):
         new_memento = Memento(parent = curr_memento_user_key, memento_name = memento_name, event = event.key, item = item.key)
         new_memento.put()
         
         existing_orders = Order.query(ancestor=MEMENTO_USER_KEY)
         orderAlreadyExists = existing_orders.filter(ndb.GenericProperty("to_company") == curr_memento_user_key)
         hasOrders = False
         existing_order = None
         for order in orderAlreadyExists:
             if (order.key.parent() == item.key.parent()):
                 existing_order = order
                 hasOrders = True
                 break
         if hasOrders:
             existing_order.memento.append(new_memento.key)
             existing_order.put()
             print "Memento Keys:" + str(existing_order.memento)
         else:
             new_order = Order(parent = item.key.parent(), to_company = curr_memento_user_key, memento=[new_memento.key])
             print "SHOULD BE PUTTING NEW ORDER"
             new_order.put()
     else:
         memento_key = ndb.Key(urlsafe=self.request.get("entity_key"))
         memento = memento_key.get()
         memento.memento_name = memento_name
         memento.event = event.key
         memento.item = item.key
         memento.put()
     self.redirect("/HRHub")
开发者ID:,项目名称:,代码行数:45,代码来源:

示例8: export_project

# 需要导入模块: from models import Event [as 别名]
# 或者: from models.Event import query [as 别名]
    def export_project(self):
        try:
            project_key = ndb.Key(urlsafe=self.request.get('project_id'))
        except Exception as e:
            logging.warn(e)
            self.response.set_status(404)
            self.render_template("errors/404.html")
            return

        selected_cal = self.request.get('selected_cal')

        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)

        events = Event.query(ancestor=project_key).fetch()

        events_number = 0
        for ev in events:
            event = {
                'summary': ev.title,
                'description': ev.description,
                'start': {
                    'dateTime': datetime.strftime(ev.start_time, '%Y-%m-%dT%H:%M:00+02:00')
                },
                'end': {
                    'dateTime': datetime.strftime(ev.end_time, '%Y-%m-%dT%H:%M:00+02:00')
                }
            }

            event = service.events().insert(calendarId=selected_cal, body=event).execute()
            if event:
                events_number += 1

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

示例9: get_events_from_project

# 需要导入模块: from models import Event [as 别名]
# 或者: from models.Event import query [as 别名]
    def get_events_from_project(project_key):
        project_key = ndb.Key(urlsafe=project_key)
        events = Event.query(ancestor=project_key).fetch()

        events_array = []
        for ev in events:
            e = {}
            e['id'] = ev.key.urlsafe()
            e['title'] = ev.title
            e['description'] = ev.description
            e['start_time'] = datetime.strftime(ev.start_time, '%Y-%m-%dT%H:%M:00+02:00')
            e['end_time'] = datetime.strftime(ev.end_time, '%Y-%m-%dT%H:%M:00+02:00')
            e['billed'] = ev.billed
            if ev.url:
                e['url'] = ev.url
            else:
                e['url'] = ''
            e['creation_time'] = datetime.strftime(ev.creation_time, '%Y-%m-%dT%H:%M:00+02:00')

            events_array.append(e)
        logging.warn(events_array)
        return events_array
开发者ID:giovamo,项目名称:Sar,代码行数:24,代码来源:event_service.py

示例10: get

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


        
        memento_user_query = ndb.gql("SELECT * from MementoUser WHERE user_name = :1", user.nickname())
        curr_memento_user = memento_user_query.get()
        curr_memento_user_key = curr_memento_user.key
        
        greeting = ('Welcome to HR Page, %s! (<a href="%s">sign out</a>)' %
                    (user.nickname(), users.create_logout_url('/')))
        logout_url = users.create_logout_url('/')
        template = jinja_env.get_template("templates/hrhub.html")
        all_mementos = Memento.query(ancestor=curr_memento_user_key)
        all_vendors = Vendor.query(ancestor=MEMENTO_USER_KEY)
        all_events = Event.query(ancestor=curr_memento_user_key)
        sample_employee = ndb.gql("SELECT * FROM Employee").get()
        model_fields = sample_employee.to_dict()
        jsonStr = json.dumps({"foo":"bar"})
        print(jsonStr)
        jsonDic = json.loads(jsonStr)
        print(jsonDic["foo"])
        self.response.write(template.render({"user":user, "logout_url": logout_url, "all_mementos": all_mementos, "all_events":all_events, "all_vendors":all_vendors, "model_fields":model_fields}))
        self.response.out.write(greeting)
开发者ID:,项目名称:,代码行数:26,代码来源:

示例11: get

# 需要导入模块: from models import Event [as 别名]
# 或者: from models.Event import query [as 别名]
    def get(self, version, service_slug):
        if not self.valid_version(version):
            self.error(404, "API Version %s not supported" % version)
            return

        service = Service.get_by_slug(service_slug)

        if not service:
            self.error(404, "Service %s not found" % service_slug)
            return

        start = self.request.get('start', default_value=None)
        end = self.request.get('end', default_value=None)

        query = Event.query().filter(Event.service == service.key)

        if start:
            try:
                _start = aware_to_naive(parse(start))
                query.filter(Event.start >= _start)
            except:
                self.error(400, "Invalid Date: %s" % start)
                return

        if end:
            try:
                _end = aware_to_naive(parse(end))
                query.filter(Event.start <= _end)
            except:
                self.error(400, "Invalid Date: %s" % end)
                return

        query.order(-Event.start)

        data = [s.rest(self.base_url(version)) for s in query]
        self.json({"events": data})
开发者ID:Labgoo,项目名称:stashboard,代码行数:38,代码来源:api.py

示例12: get

# 需要导入模块: from models import Event [as 别名]
# 或者: from models.Event import query [as 别名]
 def get(self):
     events = Event.query(ancestor=PARENT_KEY).order(-Event.date,-Event.time).fetch()
     announcements = Announcement.query(ancestor=PARENT_KEY).order(-Announcement.last_touch_date_time).fetch()
     template = jinja_env.get_template("templates/ministry.html")
     self.response.out.write(template.render({'events': events, 'announcements': announcements}))
开发者ID:burchtm,项目名称:UnhinderedProjectBackend,代码行数:7,代码来源:main.py

示例13: post

# 需要导入模块: from models import Event [as 别名]
# 或者: from models.Event import query [as 别名]
    def post(self):
       user_id = self.request.get('user_id')
       event_id = self.request.get('event_id')
       event = Event.get_by_id(int(event_id))
       operation = self.request.get('operation')
       if (operation == "load"):
          if (user_id == event.userId):

             template_values = {
                 'event': event
             }

             template = JINJA_ENVIRONMENT.get_template('event_update.html')
             self.response.write(template.render(template_values))
          else:
             template = JINJA_ENVIRONMENT.get_template('index.html')
             self.response.write(template.render())
       elif (operation == "people_for_event"):
            user_id = self.request.get('user_id')
            event_id = int(self.request.get('event_id'))
            event = Event.get_by_id(event_id)

            event_people = []
            for person_id in event.event_people:
                person = Person.get_by_id(int(person_id))
                event_people.append({"person_id": person_id, "display_name": person.display_name,
                                   "image_url": person.image_url })
            event_people_set = set(event.event_people)

            person_keys = (Person.query(Person.userId == user_id).fetch(keys_only=True))
            all_people = []
            for key in person_keys:
                all_people.append(key.id())
            clean_people = [x for x in all_people if x not in event_people_set]
            all_people = []
            for person_id in clean_people:
                person = Person.get_by_id(int(person_id))
                all_people.append({"person_id": person_id, "display_name": person.display_name,
                                   "image_url": person.image_url })

            event_sharing_set = set(event.event_sharing)
            my_key = Person.query(Person.plus_id == user_id).get(keys_only=True)
            event_sharing_set.add(my_key.id())
            available_sharing = []
            for key in person_keys:
                available_sharing.append(key.id())
            clean_sharing = [x for x in available_sharing if x not in event_sharing_set]
            available_sharing = []
            for person_id in clean_sharing:
                person = Person.get_by_id(int(person_id))
                available_sharing.append({"person_id": person_id, "display_name": person.display_name,
                                           "image_url": person.image_url, "email": person.email })
            event_sharing = []
            for person_id in event.event_sharing:
                person = Person.get_by_id(int(person_id))
                event_sharing.append({"person_id": person_id, "display_name": person.display_name,
                                        "image_url": person.image_url, "email": person.email })

            ret_data = { "all_people": all_people, "event_people": event_people, 
                         "available_sharing": available_sharing, "event_sharing": event_sharing }

            self.response.write(json.dumps(ret_data))
       elif (operation == "photos_for_event"):
            user_id = self.request.get('user_id')
            event_id = self.request.get('event_id')
            event = Event.get_by_id(int(event_id))

            photo_keys = (Photo.query(Photo.userId == user_id).fetch(keys_only=True))
            event_photos_set = set(event.event_photos)

            event_photos = []
            for photo_id in event.event_photos:
                photo = Photo.get_by_id(int(photo_id))
                event_photos.append({"photo_id": photo_id, "drive_id": photo.drive_id, 
                                       "thumbnailLink": photo.thumbnailLink })

            all_photos = []
            for photo_key in photo_keys:
                all_photos.append(photo_key.id())
            clean_photos = [x for x in all_photos if x not in event_photos_set]

            all_photos = []
            for photo_id in clean_photos:
                photo = Photo.get_by_id(int(photo_id))
                all_photos.append({"photo_id": photo_id, "drive_id": photo.drive_id, 
                                     "thumbnailLink": photo.thumbnailLink })
            ret_data = { "all_photos": all_photos, "event_photos": event_photos }

            self.response.write(json.dumps(ret_data))
       elif (operation == "change_people"):
            person_id = int(self.request.get('person_id'))
            change_to = self.request.get('change_to')
            if (change_to == "connected"):
                event.event_people.append(person_id)
                event.put()
            else:
               if person_id in event.event_people:
                   event.event_people.remove(person_id)
                   event.put()
               else:
#.........这里部分代码省略.........
开发者ID:ripplesphere,项目名称:sample_code,代码行数:103,代码来源:event_update.py


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