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


Python Event.get_by_id方法代码示例

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


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

示例1: test_hold_and_restore

# 需要导入模块: from models import Event [as 别名]
# 或者: from models.Event import get_by_id [as 别名]
  def test_hold_and_restore(self):
    # Put the event on hold.
    response = self.test_app.post("/api/v1/status_change", self.params)
    self.assertEqual(200, response.status_int)

    event = Event.get_by_id(self.event_id)
    self.assertEqual("onhold", event.status)
    self.assertNotEqual(None, event.owner_suspended_time)
    self.assertEqual("pending", event.original_status)

    # Check that it was logged.
    log_event = self.__get_latest_log(event)
    self.assertIn("event on hold", log_event.description)

    # Restore the event.
    params = self.params.copy()
    params["status"] = "active"
    response = self.test_app.post("/api/v1/status_change", params)
    self.assertEqual(200, response.status_int)

    event = Event.get_by_id(self.event_id)
    self.assertEqual("pending", event.status)
    self.assertEqual(None, event.owner_suspended_time)
    self.assertEqual(None, event.original_status)

    log_event = self.__get_latest_log(event)
    self.assertIn("Restoring event", log_event.description)
开发者ID:hackerdojo,项目名称:hd-events,代码行数:29,代码来源:test_api.py

示例2: test_expires_events

# 需要导入模块: from models import Event [as 别名]
# 或者: from models.Event import get_by_id [as 别名]
  def test_expires_events(self):
    # Run the cron and make sure it expires.
    response = self.test_app.get("/expire_suspended")
    self.assertEqual(200, response.status_int)

    # One should expire.
    event = Event.get_by_id(self.event_id)
    self.assertEqual("expired", event.status)

    # The other one shouldn't.
    other_event = Event.get_by_id(self.other_event_id)
    self.assertEqual("onhold", other_event.status)
开发者ID:jayjay2016,项目名称:hd-events,代码行数:14,代码来源:test_main.py

示例3: view_favourite_toggle

# 需要导入模块: from models import Event [as 别名]
# 或者: from models.Event import get_by_id [as 别名]
def view_favourite_toggle(request):
    """AJAX"""

    # login is required here
    if not (request.user and request.user.is_authenticated()):
        return HttpResponseNotFound()

    result = "0"

    if request.method == "POST":
        key_id = request.POST.get("key_id", None)
        if key_id:
            event = Event.get_by_id(int(key_id, 10))
            if not event:
                return HttpResponseNotFound()

            # check this favourite exists and toggle it
            fav = Favourite.all().filter("event =", event).filter("user =", request.user).get()
            if fav:
                fav.delete()
            else:
                f = Favourite(user=request.user, event=event)
                f.put()
                result = "1"

    return HttpResponse(result)
开发者ID:fikander,项目名称:aolevents,代码行数:28,代码来源:views.py

示例4: post

# 需要导入模块: from models import Event [as 别名]
# 或者: from models.Event import get_by_id [as 别名]
  def post(self, event_id):
    """save the new order into db

    all items in the event have been confirmed by the contact person.. we need:
    - close the current event
    - create a new order
    """
    event = Event.get_by_id(event_id)
    if not event:
      self.error(404)
      return
    event.status = 'ordered'
    json = self.request.get('json')
    json = simplejson.loads(json)
    purchases = []
    for p in json['purchases']:
      purchase = Purchase.get(p['key'])
      purchase.item = Item.get(p['item'])
      purchase.status = 'collected'
      purchases.append(purchase.put())
    order = Order(contact=users.get_current_user(),
                  vendor=event.vendor,
                  purchases=purchases)
    order.put()
    event.put()
开发者ID:tchaikov,项目名称:beanfs,代码行数:27,代码来源:order.py

示例5: post

# 需要导入模块: from models import Event [as 别名]
# 或者: from models.Event import get_by_id [as 别名]
    def post(self, id):
        event = Event.get_by_id(int(id))
        user = users.get_current_user()
        access_rights = UserRights(user, event)

        state = self.request.get("state")
        if state:
            desc = ""
            if state.lower() == "approve" and access_rights.can_approve:
                event.approve()
                desc = "Approved event"
            if state.lower() == "staff" and access_rights.can_staff:
                event.add_staff(user)
                desc = "Added self as staff"
            if state.lower() == "unstaff" and access_rights.can_unstaff:
                event.remove_staff(user)
                desc = "Removed self as staff"
            if state.lower() == "cancel" and access_rights.can_cancel:
                event.cancel()
                desc = "Cancelled event"
            if state.lower() == "delete" and access_rights.is_admin:
                event.delete()
                desc = "Deleted event"
            if state.lower() == "undelete" and access_rights.is_admin:
                event.undelete()
                desc = "Undeleted event"
            if state.lower() == "expire" and access_rights.is_admin:
                event.expire()
                desc = "Expired event"
            if event.status == "approved":
                notify_owner_approved(event)
            if desc != "":
                log = HDLog(event=event, description=desc)
                log.put()
        self.redirect(event_path(event))
开发者ID:deanmao,项目名称:hd-events,代码行数:37,代码来源:main.py

示例6: post

# 需要导入模块: from models import Event [as 别名]
# 或者: from models.Event import get_by_id [as 别名]
 def post(self, id):
     event = Event.get_by_id(int(id))
     user = users.get_current_user()
     access_rights = UserRights(user, event)
     if access_rights.can_edit:
       try:
           if not self.request.get('estimated_size').isdigit():
             raise ValueError('Estimated number of people must be a number')
           if not int(self.request.get('estimated_size')) > 0:
             raise ValueError('Estimated number of people must be greater then zero')
           if (  self.request.get( 'contact_phone' ) and not is_phone_valid( self.request.get( 'contact_phone' ) ) ):
               raise ValueError( 'Phone number does not appear to be valid' )
           else:
               event.name = self.request.get('name')
               event.estimated_size = cgi.escape(self.request.get('estimated_size'))
               event.contact_name = cgi.escape(self.request.get('contact_name'))
               event.contact_phone = cgi.escape(self.request.get('contact_phone'))
               event.details = cgi.escape(self.request.get('details'))
               event.url = cgi.escape(self.request.get('url'))
               event.fee = cgi.escape(self.request.get('fee'))
               event.notes = cgi.escape(self.request.get('notes'))
               event.rooms = self.request.get('rooms').strip().split("\n")
               event.put()
               self.redirect(event_path(event))
       except Exception, e:
           error = str(e)
           self.response.out.write(template.render('templates/error.html', locals()))
开发者ID:jonhull,项目名称:hd-events,代码行数:29,代码来源:main.py

示例7: get

# 需要导入模块: from models import Event [as 别名]
# 或者: from models.Event import get_by_id [as 别名]
 def get(self, id):
   event = Event.get_by_id(int(id))
   rules = memcache.get("rules")
   if(rules is None):
     rules = urlfetch.fetch("http://wiki.hackerdojo.com/api_v2/op/GetPage/page/Event+Policies/_type/html", "GET").content      
     memcache.add("rules", rules, 86400)
   self.response.out.write(template.render('templates/confirmation.html', locals()))
开发者ID:bluehat,项目名称:hd-events,代码行数:9,代码来源:main.py

示例8: delete

# 需要导入模块: from models import Event [as 别名]
# 或者: from models.Event import get_by_id [as 别名]
    def delete(self, version, service_slug, sid):
        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


        try:
            event = Event.get_by_id(sid)
        except datastore_errors.BadKeyError:
            self.error(404, "Event %s not found" % sid)
            return

        if not event or service.key != event.service.key:
            self.error(404, "No event for Service %s with sid = %s" \
                           % (service_slug, sid))
            return

        event.delete()
        invalidate_cache()

        # Why not JSON?
        self.success(event.rest(self.base_url(version)))
开发者ID:Labgoo,项目名称:stashboard,代码行数:30,代码来源:api.py

示例9: view_event_moderate_toggle

# 需要导入模块: from models import Event [as 别名]
# 或者: from models.Event import get_by_id [as 别名]
def view_event_moderate_toggle(request):
    """
    hybrid AJAX
    """
    # result in case of ajax query
    result = 0

    if request.method == "POST":
        key_id = request.POST.get("key_id", None)
    elif request.method == "GET":
        key_id = request.GET.get("key_id", None)
    else:
        key_id = None

    if key_id:
        event = Event.get_by_id(int(key_id, 10))
        if not event:
            return HttpResponseNotFound()

        event.moderated = not event.moderated
        event.put()

        result = int(event.moderated)

    if not request.is_ajax():
        next = request.GET.get("next", None)
        if not next:
            next = reverse("view_event_nonmoderated")

        return HttpResponseRedirect(next)
    else:
        return HttpResponse(result)
开发者ID:fikander,项目名称:aolevents,代码行数:34,代码来源:views.py

示例10: get

# 需要导入模块: from models import Event [as 别名]
# 或者: from models.Event import get_by_id [as 别名]
 def get(self, id):
     user = users.get_current_user()
     event = Event.get_by_id(int(id))
     if user:
         logout_url = users.create_logout_url('/')
     else:
         login_url = users.create_login_url('/')
     self.response.out.write(template.render('templates/feedback.html', locals()))
开发者ID:jernst,项目名称:hd-events,代码行数:10,代码来源:main.py

示例11: get

# 需要导入模块: from models import Event [as 别名]
# 或者: from models.Event import get_by_id [as 别名]
 def get(self, event_id):
   event = Event.get_by_id(long(event_id))
   if event is None:
     self.error(404)
     return
   # TODO: allow user to edit the purchase items
   self.generate('close_event.html',
                 {'event':event,
                  'purchases':event.purchases})
开发者ID:tchaikov,项目名称:beanfs,代码行数:11,代码来源:purchase.py

示例12: get

# 需要导入模块: from models import Event [as 别名]
# 或者: from models.Event import get_by_id [as 别名]
 def get(self, id):
     user = users.get_current_user()
     event = Event.get_by_id(int(id))
     # this is not the permanent answer but just for now
     cdn = "http://cdn.hackerdojo.com"
     if user:
         logout_url = users.create_logout_url("/")
     else:
         login_url = users.create_login_url("/")
     self.response.out.write(template.render("templates/feedback.html", locals()))
开发者ID:billsaysthis,项目名称:hd-events,代码行数:12,代码来源:main.py

示例13: test_ignore_status

# 需要导入模块: from models import Event [as 别名]
# 或者: from models.Event import get_by_id [as 别名]
  def test_ignore_status(self):
    params = self.params.copy()
    params["status"] = "no_visits"
    response = self.test_app.post("/api/v1/status_change", params)
    self.assertEqual(200, response.status_int)

    event = Event.get_by_id(self.event_id)
    self.assertEqual("pending", event.status)
    self.assertEqual(None, event.owner_suspended_time)
    self.assertEqual(None, event.original_status)
开发者ID:hackerdojo,项目名称:hd-events,代码行数:12,代码来源:test_api.py

示例14: get

# 需要导入模块: from models import Event [as 别名]
# 或者: from models.Event import get_by_id [as 别名]
 def get(self, id):
     event = Event.get_by_id(int(id))
     user = users.get_current_user()
     access_rights = UserRights(user, event)
     if access_rights.can_edit:
       logout_url = users.create_logout_url('/')            
       rooms = '\n'.join(event.rooms)
       self.response.out.write(template.render('templates/edit.html', locals()))
     else:
       self.response.out.write("Access denied")
开发者ID:jonhull,项目名称:hd-events,代码行数:12,代码来源:main.py

示例15: test_hold_and_restore

# 需要导入模块: from models import Event [as 别名]
# 或者: from models.Event import get_by_id [as 别名]
  def test_hold_and_restore(self):
    # Put the event on hold.
    response = self.test_app.post("/api/v1/status_change", self.params)
    self.assertEqual(200, response.status_int)

    event = Event.get_by_id(self.event_id)
    self.assertEqual("onhold", event.status)
    self.assertNotEqual(None, event.owner_suspended_time)
    self.assertEqual("pending", event.original_status)

    # Restore the event.
    params = self.params.copy()
    params["status"] = "active"
    response = self.test_app.post("/api/v1/status_change", params)
    self.assertEqual(200, response.status_int)

    event = Event.get_by_id(self.event_id)
    self.assertEqual("pending", event.status)
    self.assertEqual(None, event.owner_suspended_time)
    self.assertEqual(None, event.original_status)
开发者ID:rahul4209,项目名称:hd-events,代码行数:22,代码来源:test_api.py


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