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

Python models.Event类代码示例

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

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



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

示例1: test_hold_and_restore

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


示例2: test_model_event

    def test_model_event(self):
        """Test Event model"""
        event = Event(name="Test", end=datetime.now())
        event.save()
        self.assertNotEquals(event.id, None)

        event.delete()
开发者ID:tovmeod,项目名称:anaf,代码行数:7,代码来源:tests.py


示例3: event

def event(id, name):
    time_now = (int)(time.time())
    hourly = time_now - (time_now % 3600)
    key = ndb.Key("Agent",id, "EventType", name, "Script", "random.py", "Hourly", hourly, "Event", time_now)
    event = Event(key=key, name=name, script="random.py", timestamp=datetime.utcfromtimestamp(time_now), body="Test")
    event.put()
    return "OK"
开发者ID:ridnarong,项目名称:flasky,代码行数:7,代码来源:main.py


示例4: save_event

def save_event(request):
	if request.method == 'GET':
		q = request.GET.get("js_kind_value")
		if q:
			pkind = transform_text(q)
			kind = verify_kind_exists('kind_value',pkind)
			if kind is None:
				if (verify_get_param(request,'js_gender_value') and verify_get_param(request,'js_age_value')):
					new_kind = Kind(kind_value= pkind,gender_target=request.GET.get('js_gender_value'), age_target=request.GET.get('js_age_value'))
					new_kind.save()
					kind = Kind.objects.get(kind_value=pkind)
		elif request.GET.get('kind_choice'):
			kind = verify_kind_exists('id',request.GET.get('kind_choice'))
			print kind
		else:
			pass	
		event_name_value = request.GET.get("js_event_name")
		description_event_value = request.GET.get("js_event_description")
		if event_name_value is not '' and description_event_value is not '':
			event_name_value = transform_text(event_name_value)
			existent_name = verify_event_properties_exists('name', event_name_value)
			description_event_value = transform_text(description_event_value)
			existent_description = verify_event_properties_exists('description', description_event_value)
			# An event with the passed name or description could not be already stored..
			if existent_description is None  and existent_name is None:
				new_event = Event(name=event_name_value, description=description_event_value, creation_date = datetime.now, kind_event = kind)
				new_event.save()
				return determine_interested_people(request, new_event)			
			return render_to_response('event_creation/home.html', {'email_address' : request.session['email_address_user'],'error_message' : 'Event name/description already exist','kind_form' : KindEventForm(request.GET)}, RequestContext(request))
		return render_to_response('event_creation/home.html', {'email_address' : request.session['email_address_user'],'error_message' : 'An error has occurred','kind_form' : KindEventForm(request.GET)}, RequestContext(request))
	return render_to_response('event_creation/home.html', {'email_address' : request.session['email_address_user'],'error_message': 'An error has occurred','kind_form' : KindEventForm(request.GET)}, RequestContext(request))
开发者ID:jrm2k6,项目名称:EventMailer,代码行数:31,代码来源:views.py


示例5: get

    def get(self, format):
        events = Event.all().filter("status IN", ["approved", "canceled"]).order("start_time")
        if format == "ics":
            cal = Calendar()
            for event in events:
                cal.add_component(event.to_ical())
            self.response.headers["content-type"] = "text/calendar"
            self.response.out.write(cal.as_string())
        elif format == "json":
            self.response.headers["content-type"] = "application/json"
            events = map(lambda x: x.to_dict(summarize=True), Event.get_approved_list())
            self.response.out.write(simplejson.dumps(events))
        elif format == "rss":
            url_base = "http://" + self.request.headers.get("host", "events.hackerdojo.com")
            rss = PyRSS2Gen.RSS2(
                title="Hacker Dojo Events Feed",
                link=url_base,
                description="Upcoming events at the Hacker Dojo in Mountain View, CA",
                lastBuildDate=datetime.now(),
                items=[
                    PyRSS2Gen.RSSItem(
                        title=event.name,
                        link=url_base + event_path(event),
                        description=event.details,
                        guid=url_base + event_path(event),
                        pubDate=event.updated,
                    )
                    for event in events
                ],
            )

            self.response.headers["content-type"] = "application/xml"
            self.response.out.write(rss.to_xml())
开发者ID:deanmao,项目名称:hd-events,代码行数:33,代码来源:main.py


示例6: index

def index(request, year, month):
    month = int(month)
    year = int(year)
    calendar = newcalendar.LinkyCalendar()
    calendar1 = CalendarVarOne()
    calendar2 = CalendarVarTwo()
    if request.method == "POST":
        form = eventform(request.POST)
        if form.is_valid():
            date = form.cleaned_data['date']
            description = form.cleaned_data['description']
            ev = Event(date=date, description=description)
            ev.save()
    data = {}

    for event in Event.objects.all():
        if event.date.year == year and \
           event.date.month == month:
                data[event.date.day] = fix_date(event.date.day)

    form = eventform() 
    firstmonth = calendar.formatmonth(year, month, data=data)
    secondmonth = calendar1.formatmonth(year, month, data=data)
    thirdmonth = calendar2.formatmonth(year, month, data=data)
    return render_to_response('index.html', {"calendar1":unicode(firstmonth),
                                             "calendar2":unicode(secondmonth),
                                             "calendar3":unicode(thirdmonth),
                                             "form":form,
                                            },
                              context_instance=RequestContext(request),
                             )
开发者ID:pgulley,项目名称:calendar_demo,代码行数:31,代码来源:views.py


示例7: save

    def save(self, request):
        event = Event()
        start_date = self.cleaned_data['start_date']
        start_time = self.cleaned_data['start_time']
        end_time = self.cleaned_data['end_time']
        event.start_time = datetime.combine(start_date, start_time)
        event.end_time = datetime.combine(start_date, end_time)
        event.event_name = self.cleaned_data['event_name']
        event.event_location = self.cleaned_data['event_location']
        event.event_organizer = self.cleaned_data['event_organizer']
        event.event_description = self.cleaned_data['event_description']
        event.event_website = self.cleaned_data['event_website']
        event.save()

        acl = ACLUserEvent()
        acl.user = request.user
        acl.event = event
        acl.save()

        discussiondefs = (
                            ('PR', _(u'Discussion of the upcoming %s'), _(u'Discuss the upcoming event %s before it actually happens.')), 
                            ('LI', _(u'Live discussion of %s'), _(u'Discuss the ongoing event %s live.')),
                            ('PO', _(u'Post-hoc discussion of %s'), _(u'Discuss %s after the facts.'))
                         )

        for s in discussiondefs:
            thread = Thread()
            thread.time = datetime.now()
            thread.user = request.user
            thread.event = event
            thread.thread_type = s[0];
            thread.title = s[1] % (event.event_name)
            thread.description = s[2] % (event.event_name)
            thread.save()
开发者ID:jeroen51,项目名称:Game-calendar,代码行数:34,代码来源:calendarForms.py


示例8: call_api

def call_api(service, data):
    '''Submit service status to API'''
    service = Service.get_by_slug(service)
    status = Status.get_by_slug(data['status'])
    e = Event(service=service, status=status, message=data['message'])
    print json.dumps(data, sort_keys=True, skipkeys=True)
    e.put()
开发者ID:OnePaaS,项目名称:docker-status,代码行数:7,代码来源:prodtool.py


示例9: event_examples

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


示例10: post

 def post(self):
     entity_key_urlsafe = self.request.get("entity_key")
     if (self.request.get('type') == 'Event'):
         if entity_key_urlsafe:
             event_key = ndb.Key(urlsafe=entity_key_urlsafe)
             event = event_key.get()
             timestamp = datetime.datetime.strptime(self.request.get("date"), "%Y-%m-%dT%H:%M")
             event.date = timestamp.date()
             event.time = timestamp.time()
             event.title = self.request.get("title")
             event.description = self.request.get("description")
             event.put()
         else:
             timestamp = datetime.datetime.strptime(self.request.get("date"), "%Y-%m-%dT%H:%M")
             new_event = Event(parent=PARENT_KEY,
                                    date=timestamp.date(),
                                    time=timestamp.time(),
                                    title=self.request.get('title'),
                                    description=self.request.get('description'))
             new_event.put()
     elif (self.request.get('type') == 'Announcement'):
         if entity_key_urlsafe:
             announcement_key = ndb.Key(urlsafe=entity_key_urlsafe)
             announcement = announcement_key.get()
             announcement.title = self.request.get("title")
             announcement.description = self.request.get("description")
             announcement.put()
         else:
             new_announcement = Announcement(parent=PARENT_KEY,
                                     title=self.request.get('title'),
                                     description=self.request.get('description'))
             new_announcement.put()
     self.redirect(self.request.referer)
开发者ID:burchtm,项目名称:UnhinderedProjectBackend,代码行数:33,代码来源:main.py


示例11: update

def update(request):
	xml = getXML()
	
	updateHour =  datetime.datetime.now()
	entry = Update.objects.get(id=1)
	entry.hour = updateHour
	entry.save()
	
	content = xml.findAll("contenido")
	
	events = Event.objects.all()
	
	for line in content:
		(title, dateTime, hourEnd, price, eventType, duration, description, url) = getEvent(line)
		
		found = False
		for event in events:
			if (event.title == title):
				if (str(event.date) == str(dateTime)):
					found = True

		if (found == False):
			entry = Event(title=title, date=dateTime, dateEnd=hourEnd, price=price, eventType=eventType, duration=duration, url=url, description=description, likes=0)
			entry.save()

	return HttpResponseRedirect("/todas")
开发者ID:LauraArteaga,项目名称:2015-sat-final,代码行数:26,代码来源:views.py


示例12: createEvent

 def createEvent(user_id, name, description, location, start_time, end_time, tags, is_private, invite_list):
     event = Event(user_id, name, description, location, start_time, end_time, tags, is_private, invite_list)
     new_event = event.save()
     event_id = new_event['_id']
     for invitee in invite_list:
         EventController.sendInvite(event_id, invitee)
     CalendarController.addEvent(event_id, user_id)
开发者ID:CICISUN,项目名称:ConnectMe,代码行数:7,代码来源:EventController.py


示例13: sheet_event

 def sheet_event (self, id):
     """ Create an event """
     sheet = Sheet.objects.get_or_404(id = id)
     if request.method == 'GET' :
         """ Get all events """
         #if 'from' not in  request.args or 'to' not in request.args:
         #   abort(400, error = 'missing arguments from and to ')
         
         _sheetEvents = Event.objects(sheet=sheet, alive=True)
         
         _events = [e.to_json() for e in _sheetEvents ]
         return jsonify(ok=True, objects=_events),200
     
     if request.method == 'POST':
         
         new_event = Event( 
                         dates = request.json.get('dates',[]),
                         name = request.json['name'],
                         event_date = request.json['event_date'],
                         description = request.json['description'],
                         location = request.json['location'],
                         public = request.json.get('public',True),
                         links = request.json.get('links',[]),
                         color = request.json.get('color','#fff'),
                         tags = request.json['tags'],
                         alive = True,
                         created_by = str(sheet.created_by),
                         sheet= sheet
                         )
         new_event.save()
         
         return jsonify(ok=True,objects=[new_event.to_json()]), 201
开发者ID:DeprecatedCode,项目名称:yearplan,代码行数:32,代码来源:sheet.py


示例14: save

 def save(self, user):
     utc = pytz.timezone('UTC')
     ltz = pytz.timezone(self.cleaned_data['market'].timezone)
     local_time = ltz.localize(self.cleaned_data['time'])
     time = local_time.astimezone(utc)
     thread = Thread(
         creator =   user,
         subject =   self.cleaned_data['title'],
         site    =   Site.objects.get_current(),
         )
     thread.save()
     post = Post(
         thread  =   thread,
         creator =   user,
         body    =   self.cleaned_data['post']
         )
     post.save()
     thread.last_post = post
     thread.save()
     event = Event(
         thread      =   thread,
         creator     =   user,
         description =   self.cleaned_data['description'],
         location    =   self.cleaned_data['location'],
         time        =   time,
         market      =   self.cleaned_data['market']
         )
     event.save()
     return event
开发者ID:adreyer,项目名称:arkestrator,代码行数:29,代码来源:forms.py


示例15: get

    def get(self, format):
        events = Event.all().filter('status IN', ['approved', 'canceled']).order('start_time')
        if format == 'ics':
            cal = Calendar()
            for event in events:
                cal.add_component(event.to_ical())
            self.response.headers['content-type'] = 'text/calendar'
            self.response.out.write(cal.as_string())
        elif format == 'json':
            self.response.headers['content-type'] = 'application/json'
            events = map(lambda x: x.to_dict(summarize=True), Event.get_approved_list())
            self.response.out.write(simplejson.dumps(events))
        elif format =='rss':
            url_base = 'http://' + self.request.headers.get('host', 'events.hackerdojo.com')
            rss = PyRSS2Gen.RSS2(
                title = "Hacker Dojo Events Feed",
                link = url_base,
                description = "Upcoming events at the Hacker Dojo in Mountain View, CA",
                lastBuildDate = datetime.now(),
                items = [PyRSS2Gen.RSSItem(
                            title = event.name,
                            link = url_base + event_path(event),
                            description = event.details,
                            guid = url_base + event_path(event),
                            pubDate = event.updated,
                         ) for event in events]
            )

            self.response.headers['content-type'] = 'application/xml'
            self.response.out.write(rss.to_xml())
开发者ID:jonhull,项目名称:hd-events,代码行数:30,代码来源:main.py


示例16: create_event

def create_event(user, **kwargs):
    """
    server endpoint for creation of events

    events are created by the user of the neuaer plugin. for example
    when the user wants to invoke the plugin event upon bluetooth disconnection
    """
    req = CreateEventRequest(request, settings.EVENT)

    if not req.is_valid():
        return jsonify(**req.error_message)

    event_props = {
        'slug' : req.event.get('event_id', None),
        'redirect': req.event.get('after_config_redirect', None),
        'user': user
        }

    event = Event.get_with_slug_user(**event_props)

    # create the event if it doesn't already exist
    if not event:
        event = Event(**event_props)
        event.put()
    else:
        return jsonify(**error_responses('create_event', 'event_exists'))

    return jsonify(success="created")
开发者ID:neuaer,项目名称:python-example,代码行数:28,代码来源:views.py


示例17: serverisdown

def serverisdown (service):
	# Create a new event with the given status and given service
	service = Service.get_by_slug(service)
	status = Status.get_by_slug("down")        

	e = Event(service=service, status=status, message="The server could not be reached")
	e.put()
开发者ID:StrataLabs,项目名称:status.justbooksclc.com,代码行数:7,代码来源:stashboard.py


示例18: event

def event(request):
    if request.method == "POST":
        try:
            user = None
            if not request.user.is_anonymous():
                user = request.user
            session_key = None
            if request.session is not None:
                session_key = request.session.session_key
            e = json.loads(request.body)
            details = json.dumps(e["details"])
            event = Event(
                dstamp=datetime.now(),
                app=e["app"],
                user=user,
                session=session_key,
                event_type=e["eventType"],
                details=details,
            )
            event.save()
            return HttpResponse("Success", content_type="text/plain", status=status.HTTP_200_OK)
        except ValueError, e:
            logger.error("Failed to parse event: " + str(request.body[0:1000]))
            return HttpResponse("Failed to parse event", content_type="text/plain", status=status.HTTP_400_BAD_REQUEST)
        except KeyError, e:
            logger.error("Missing event attributes: " + str(request.body[0:1000]))
            return HttpResponse(
                "Missing event attributes", content_type="text/plain", status=status.HTTP_400_BAD_REQUEST
            )
开发者ID:javicg,项目名称:codeforlife-portal,代码行数:29,代码来源:urls.py


示例19: logs

def logs(tenant_id):
    if request.method == 'POST':
        if isinstance(request.json, type('string')):
            request.json = json.loads(request.json)

        agent_id = uuid.UUID(request.json['agent_id'])
        received_on = parse(request.json['received_on'])
        key_id = uuid.UUID(request.json['key_id'])

        if request.json['severity'] in ['DEBUG', 'INFO', 'WARN', 'FATAL', 'PANIC']:
            severity = request.json['severity']
        else:
            severity = 'UNKNOWN'

        # Load the key and tenant
        tenant = Tenant.query.get(tenant_id)
        key = Key.query.filter_by(uuid=str(key_id)).first()

        ev = Event(tenant_id=tenant_id, agent_id=str(agent_id), received_on=received_on,
                   severity=severity, message=request.json['message'], tenant=tenant, key=key)
        db_session.add(ev)
        db_session.commit()

        return Response(json.dumps(ev.as_dict(), cls=DateTimeJsonEncoder), mimetype='application/json')
    else:
        events = Event.query.filter_by(tenant_id=tenant_id).order_by(Event.received_on)
        events_dicts = map(Event.as_dict, events.all())
        return Response(json.dumps(events_dicts, cls=DateTimeJsonEncoder), mimetype='application/json')
开发者ID:jarretraim,项目名称:barbican-poc,代码行数:28,代码来源:barbican_api.py


示例20: serverisup

def serverisup (service):
	# Create a new event with the given status and given service
	service = Service.get_by_slug(service)
	status = Status.get_by_slug("up")        

	e = Event(service=service, status=status, message="The server is responding.")
	e.put()
开发者ID:StrataLabs,项目名称:status.justbooksclc.com,代码行数:7,代码来源:stashboard.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python models.ExampleModel类代码示例发布时间:2022-05-27
下一篇:
Python models.Entry类代码示例发布时间: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