本文整理汇总了Python中events.models.Event类的典型用法代码示例。如果您正苦于以下问题:Python Event类的具体用法?Python Event怎么用?Python Event使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Event类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_was_published_recently_with_future_event
def test_was_published_recently_with_future_event(self):
"""
was_published_recently() should return False for events whose
pub_date is in the future
"""
future_event = Event(pub_date=timezone.now() + datetime.timedelta(days=30))
self.assertEqual(future_event.was_published_recently(), False)
示例2: test_has_not_registration_limit
def test_has_not_registration_limit(self):
event = Event("Name", "name", "Location", EventType("Type"),
starts = datetime(2009, 1, 6, 12, 0),
ends = datetime(2009, 1, 6, 12, 42),
registration_starts = datetime(2009, 1, 6, 11, 30),
registration_limit = 0)
self.assertEqual(event.has_registration_limit(), False)
示例3: test_event_visibility
def test_event_visibility(self):
response = testing.get_public_client().get(reverse('event_index'))
self.assertEqual(200, response.status_code)
author = testing.create_user()
venue = Venue.create_for_testing()
event_a = Event.create_for_testing(author, venue)
event_a.reviewed = True
event_a.save()
event_b = Event.create_for_testing(author, venue)
event_b.reviewed = False
event_b.save()
# The general public should see only the reviewed event.
response = testing.get_public_client().get(reverse('event_index'))
self.assertEqual(200, response.status_code)
self.assertEqual(1, len(response.context['events']))
# The author should see both.
response = testing.get_user_client(author).get(reverse('event_index'))
self.assertEqual(200, response.status_code)
self.assertEqual(2, len(response.context['events']))
# Another regular user should also see both.
response = testing.get_user_client().get(reverse('event_index'))
self.assertEqual(200, response.status_code)
self.assertEqual(2, len(response.context['events']))
示例4: test_was_published_recently_with_recent_event
def test_was_published_recently_with_recent_event(self):
"""
was_published_recently() should return True for events whose pub_date
is within the last day
"""
recent_event = Event(pub_date=timezone.now() - datetime.timedelta(hours=1))
self.assertEqual(recent_event.was_published_recently(), True)
示例5: active
def active(request):
"""
Renders default/program template:
The list of all active (published and not yet expired) news,
"""
news = News.get_frontpage_news()
events = Event.get_frontpage_events()
daytime_events = Event.get_frontpage_daytime_events()
sticky_news = News.get_sticky_news()
# get latest albums from gallery
latest = Album.objects.filter(category=Album.LIVE).order_by("-date_of_event")[:3]
return render(
request,
"news.html",
{
"news": news,
"events": events,
"daytime_events": daytime_events,
"latest": latest,
"sticky_news": sticky_news,
},
)
示例6: new_event_submit
def new_event_submit(request):
checked_checklist_items = request.POST.getlist('checklist_items')
name = request.POST['name']
description = request.POST['description']
price = request.POST['price']
try:
event = Event(
name=name,
description=description,
price=price
)
event.save()
for item in checked_checklist_items:
event.checklist_items.add(item)
messages.success(request, "Your event was saved successfully.")
except:
e = sys.exc_info()[0]
messages.error(request, "There was an error saving your event.")
print(e)
return redirect('events:index')
示例7: set_rating
def set_rating(self, user, val, activity):
"""
Set a user's Vote on a certain object. If the user has previously voted
on that object, it removes the old vote.
"""
Vote.objects.record_vote(self, user, val)
Event.record_event(self, user, activity)
示例8: setUp
def setUp(self):
weekly = Rule(frequency="WEEKLY")
weekly.save()
daily = Rule(frequency="DAILY")
daily.save()
cal = Calendar(name="MyCal")
cal.save()
self.event1 = Event(**{
'title': 'Weekly Event',
'start': datetime.datetime(2009, 4, 1, 8, 0),
'end': datetime.datetime(2009, 4, 1, 9, 0),
'end_recurring_period': datetime.datetime(2009, 10, 5, 0, 0),
'rule': weekly,
'calendar': cal
})
self.event1.save()
self.event2 = Event(**{
'title': 'Recent Event',
'start': datetime.datetime(2008, 1, 5, 9, 0),
'end': datetime.datetime(2008, 1, 5, 10, 0),
'end_recurring_period': datetime.datetime(2009, 5, 5, 0, 0),
'rule': daily,
'calendar': cal
})
self.event2.save()
示例9: save_event
def save_event(request):
""" Create a new event """
print "In Save Event"
if request.method != "POST":
print "Save brew received a non post"
return HttpResponseRedirect(reverse("events_userhome"))
name = request.POST.get('event_name')
description = request.POST.get("event_description")
# On empty POST request, return to user home.
if(name.strip() == "" and description.strip() == ""):
print "Empty form received"
return HttpResponseRedirect(reverse("events_userhome"))
# Create a new event and save it.
new_event = Event()
new_event.name = name
new_event.description = description
new_event.save()
print "New Event Created ", new_event.ident
print type(new_event.ident), str(new_event.ident)
# Save the user as the host of the new event
user = request.user.get_profile()
admin = Host()
admin.uid = user
admin.eid = new_event
admin.save()
return HttpResponseRedirect(reverse("events.views.event",
args=(new_event.ident,)))
示例10: TestOccurrencePool
class TestOccurrencePool(TestCase):
def setUp(self):
rule = Rule(frequency="WEEKLY")
rule.save()
cal = Calendar(name="MyCal")
cal.save()
data = {
'title': 'Recent Event',
'start': datetime.datetime(2008, 1, 5, 8, 0),
'end': datetime.datetime(2008, 1, 5, 9, 0),
'end_recurring_period': datetime.datetime(2008, 5, 5, 0, 0),
'rule': rule,
'calendar': cal
}
self.recurring_event = Event(**data)
self.recurring_event.save()
def testPeriodFromPool(self):
"""
Test that period initiated with occurrence_pool returns the same occurrences as "straigh" period
in a corner case whereby a period's start date is equal to the occurrence's end date
"""
start = datetime.datetime(2008, 1, 5, 9, 0)
end = datetime.datetime(2008, 1, 5, 10, 0)
parent_period = Period(Event.objects.all(), start, end)
period = Period(parent_period.events, start, end, parent_period.get_persisted_occurrences(), parent_period.occurrences)
self.assertEquals(parent_period.occurrences, period.occurrences)
示例11: event
def event(request):
model = Event
event = Event.objects.all()
# Handle file upload
if request.method == 'POST':
form = EventForm(request.POST , request.FILES)
if form.is_valid():
event = Event(user=request.user, snap=request.FILES['snap'], eventtype = request.POST['eventtype'],duration = request.POST['duration'],dresscode = request.POST['duration'],date_event = request.POST['date_event'], description = request.POST['description'], place = request.POST['place'],)
event.save()
# Redirect to the document list after POST
return redirect('/events/')
else:
form = EventForm() # A empty, unbound form
event = Event.objects.all()
# Load documents for the list page
# Render list page with the documents and the form
return render_to_response(
'events/event.html',
{ 'event': event,'form': form,},
context_instance=RequestContext(request)
)
示例12: test_was_published_recently_with_old_event
def test_was_published_recently_with_old_event(self):
"""
was_published_recently() should return False for events whose pub_date
is older than 1 day
"""
old_event = Event(pub_date=timezone.now() - datetime.timedelta(days=30))
self.assertEqual(old_event.was_published_recently(), False)
示例13: test_has_passed_with_future_event
def test_has_passed_with_future_event(self):
"""
should return false for events in the future
"""
time = timezone.now() + datetime.timedelta(days=10)
future_event = Event(starts_at=time)
self.assertEqual(future_event.has_passed(), False)
示例14: events_list
def events_list(request):
func_return = _init_facebook_app(request)
if(func_return != False):
return func_return
try:
graph, user, sys_user = _get_facebook_app(request)
if sys_user is None:
return HttpResponseRedirect("/facebook/setup/")
except facebook.GraphAPIError:
del request.session["access_token"]
return HttpResponseRedirect("http://apps.facebook.com/"+ settings.FACEBOOK_APP_ID +"/")
if request.method == 'POST':
events_ids = request.POST.getlist("object_events")
for event_id in events_ids:
event = graph.get_object(event_id)
image_url = "https://graph.facebook.com/" + event["id"] + "/picture?type=large"
img_temp = NamedTemporaryFile(delete=True)
img_temp.write(urllib2.urlopen(image_url).read())
img_temp.flush()
user_event = Event(
title = event["name"],
from_date = dateutil.parser.parse(event["start_time"]),
to_date = dateutil.parser.parse(event["end_time"]),
address = event["location"],
user = sys_user.username,
add_user = sys_user,
category = EventCategory.objects.get(id=1),
status = 2,
)
if "description" in event:
user_event.description = event["description"]
user_event.image.save(event["id"] + ".jpg", File(img_temp));
user_event.slug = SlugifyUniquely( event["name"], user_event.__class__)
user_event.save()
if len(events_ids) > 0:
_add_flash_message(request, "Your events has been added")
return HttpResponseRedirect( reverse('facebook_events_list') )
events = graph.get_connections(user["id"], "events")
for event in events["data"]:
event["start_time"] = dateutil.parser.parse(event["start_time"])
event["end_time"] = dateutil.parser.parse(event["end_time"])
event["picture_url"] = "https://graph.facebook.com/" + event["id"] + "/picture?type=normal"
return dict(
user = user,
events = events,
message = _get_flash_message(request),
)
示例15: get
def get(self):
self.response.out.write("Creating New Event")
e=Event(title="GDG Meetup", details="Final Google Technology User group Hackup Meetup",
datetime=datetime.datetime.today())
self.response.out.write("Begin Saving New Event")
e.put()
self.response.out.write("Complete Saving New Event")
pass