本文整理汇总了Python中models.Event类的典型用法代码示例。如果您正苦于以下问题:Python Event类的具体用法?Python Event怎么用?Python Event使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Event类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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)
示例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()
示例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"
示例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))
示例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())
示例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),
)
示例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()
示例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()
示例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)
示例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)
示例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")
示例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)
示例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
示例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
示例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())