本文整理汇总了Python中event.models.Event类的典型用法代码示例。如果您正苦于以下问题:Python Event类的具体用法?Python Event怎么用?Python Event使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Event类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: add_event
def add_event(request):
if not users.is_current_user_admin():
return HttpResponseRedirect('/')
if request.method == 'POST':
is_public = request.POST['is_public'] =='1'
event = Event(
title=request.POST['title'],
desc=request.POST['desc'],
publish_date=today(),
is_public=is_public)
event.put()
return HttpResponseRedirect( '../event/?event=%s' % str(event.key()) )
#except:
# return...error
else:
c = Context({
'logouturl':LOGOUT,
'loginurl':LOGIN,
'cur_user':CURUSER,
'is_admin':users.is_current_user_admin(),
'is_admin':True,
'event':Event(),
})
return render_to_response( 'newevent.htm',c )
示例2: EventManageAddView
def EventManageAddView(request, username=''):
user = User.objects.get(username=username)
form = EventForm(request.POST or None)
if form.is_valid():
thisDate = form.cleaned_data['date']
thisStarttime = form.cleaned_data['starttime']
thisEndtime = form.cleaned_data['endtime']
thisEvent = form.cleaned_data['event']
thisLocation = form.cleaned_data['location']
thisOrganization = form.cleaned_data['organization']
thisSpeakers = form.cleaned_data['speakers']
thisRating = form.cleaned_data['rating']
thisFeedback = form.cleaned_data['feedback']
thisUser = User.objects.get(username=username)
event = Event(user=thisUser,
date=thisDate, starttime=thisStarttime, endtime=thisEndtime,
event=thisEvent, location=thisLocation, organization=thisOrganization,
speakers=thisSpeakers, rating=thisRating, feedback=thisFeedback)
event.save()
return HttpResponseRedirect(URL_DASHBOARD(user.username))
return HttpResponseRedirect(URL_DASHBOARD(username))
示例3: test_references_coherence
def test_references_coherence(self):
"""
Check the pending_event and the event_action always refers to the same event.
"""
e2 = Event(
name="Event 2",
slug="event_2",
category=self.c,
text="Event 2",
)
e2.save()
pe = PendingEvent(
event=e2,
kingdom=self.k,
)
pe.save()
pea = PendingEventAction(
pending_event=pe,
event_action=self.a,
)
self.assertRaises(IntegrityError, pea.save)
示例4: create_event_with_details
def create_event_with_details(event):
"""
Creates and returns event with passed name and dates
"""
e1 = Event(name=event[0], start_date=event[1], end_date=event[2])
e1.save()
return e1
示例5: _create_events
def _create_events(self):
prefec_list = list(self.prefectures)
#ポイント稼ぎ用ボランティア
random.seed(1)
for i in range(1,21):
for j in range(1,4):
name = "【第%d回】"%j + eventname_sample[i]["name"]
host_user = User.objects.get(username="demo_user_%d"%i)
past_or_future = 1 if i < 10 else -1
demoevent = Event(
name=name,
start_time=timezone.now() + timezone.timedelta(days=301) * past_or_future,
end_time = timezone.now() + timezone.timedelta(days=302) * past_or_future,
meeting_place="池袋駅東口母子像前",
contact="[email protected]",
details=eventdetail_sample,
host_user=host_user,
region=prefec_list[i%47],
longitude=139.7191 + 0.01 * random.uniform(-2.0,2.0),
latitude=35.7291 + 0.01 * random.uniform(-2.0,2.0)
)
demoevent.save()
demoevent.admin = User.objects.filter(pk=i)
示例6: test_get_shift_slots_remaining
def test_get_shift_slots_remaining(self):
""" Test get_shift_slots_remaining(s_id) """
e1 = Event(name="Open Source Event", start_date="2012-10-22", end_date="2012-10-23")
e1.save()
j1 = Job(
name="Software Developer",
start_date="2012-10-22",
end_date="2012-10-23",
description="A software job",
event=e1,
)
j1.save()
s1 = Shift(date="2012-12-10", start_time="9:00", end_time="3:00", max_volunteers=1, job=j1)
s2 = Shift(date="2012-6-25", start_time="10:00", end_time="4:00", max_volunteers=2, job=j1)
s3 = Shift(date="2012-1-9", start_time="12:00", end_time="6:00", max_volunteers=4, job=j1)
s1.save()
s2.save()
s3.save()
self.assertIsNotNone(get_shift_slots_remaining(s1.id))
self.assertIsNotNone(get_shift_slots_remaining(s2.id))
self.assertIsNotNone(get_shift_slots_remaining(s3.id))
示例7: test_get_event_by_shift_id
def test_get_event_by_shift_id(self):
e1 = Event(
name="Open Source Event",
start_date="2012-10-22",
end_date="2012-10-23"
)
e1.save()
j1 = Job(
name="Software Developer",
start_date="2012-10-22",
end_date="2012-10-23",
description="A software job",
event=e1
)
j2 = Job(
name="Systems Administrator",
start_date="2012-9-1",
end_date="2012-10-26",
description="A systems administrator job",
event=e1
)
j1.save()
j2.save()
s1 = Shift(
date="2012-10-23",
start_time="9:00",
end_time="3:00",
max_volunteers=1,
job=j1
)
s2 = Shift(
date="2012-10-23",
start_time="10:00",
end_time="4:00",
max_volunteers=2,
job=j1
)
s3 = Shift(
date="2012-10-23",
start_time="12:00",
end_time="6:00",
max_volunteers=4,
job=j2
)
s1.save()
s2.save()
s3.save()
self.assertIsNotNone(get_event_by_shift_id(s1.id))
self.assertIsNotNone(get_event_by_shift_id(s2.id))
self.assertIsNotNone(get_event_by_shift_id(s3.id))
示例8: test_event_not_empty
def test_event_not_empty(self):
""" Test event_not_empty(event_id) """
e1 = Event(
name="Open Source Event",
start_date="2012-10-22",
end_date="2012-10-23"
)
e2 = Event(
name="Python Event",
start_date="2013-11-12",
end_date="2013-11-13"
)
e3 = Event(
name="Django Event",
start_date="2015-07-07",
end_date="2015-07-08"
)
e1.save()
e2.save()
e3.save()
self.assertTrue(event_not_empty(e1.id))
self.assertTrue(event_not_empty(e2.id))
self.assertTrue(event_not_empty(e3.id))
self.assertFalse(event_not_empty(100))
self.assertFalse(event_not_empty(200))
self.assertFalse(event_not_empty(300))
示例9: test_get_job_by_id
def test_get_job_by_id(self):
e1 = Event(name = "Software Conference",
start_date = "2012-10-22",
end_date = "2012-10-25")
e1.save()
j1 = Job(name = "Software Developer",
start_date = "2012-10-22",
end_date = "2012-10-23",
description = "A software job",
event = e1)
j2 = Job(name = "Systems Administrator",
start_date = "2012-9-1",
end_date = "2012-10-26",
description = "A systems administrator job",
event = e1)
j3 = Job(name = "Project Manager",
start_date = "2012-1-2",
end_date = "2012-2-2",
description = "A management job",
event = e1)
j1.save()
j2.save()
j3.save()
#test typical cases
self.assertIsNotNone(get_job_by_id(j1.id))
self.assertIsNotNone(get_job_by_id(j2.id))
self.assertIsNotNone(get_job_by_id(j3.id))
self.assertEqual(get_job_by_id(j1.id), j1)
self.assertEqual(get_job_by_id(j2.id), j2)
self.assertEqual(get_job_by_id(j3.id), j3)
#test non-existant cases
self.assertIsNone(get_job_by_id(100))
self.assertIsNone(get_job_by_id(200))
self.assertIsNone(get_job_by_id(300))
self.assertIsNone(get_job_by_id(400))
self.assertNotEqual(get_job_by_id(100), j1)
self.assertNotEqual(get_job_by_id(100), j2)
self.assertNotEqual(get_job_by_id(100), j3)
self.assertNotEqual(get_job_by_id(200), j1)
self.assertNotEqual(get_job_by_id(200), j2)
self.assertNotEqual(get_job_by_id(200), j3)
self.assertNotEqual(get_job_by_id(300), j1)
self.assertNotEqual(get_job_by_id(300), j2)
self.assertNotEqual(get_job_by_id(300), j3)
示例10: post_event
def post_event(request):
if request.method == 'POST':
form = EventForm(request.POST)
if form.is_valid():
e = Event(title = form.cleaned_data['title'],
date = form.cleaned_data['date'],
location = form.cleaned_data['location'],
description = form.cleaned_data['description'])
e.save()
return HttpResponseRedirect('/events/')
示例11: ScriptTest
class ScriptTest(TestCase):
"""
Unit tests for event app
"""
def setUp(self):
self.k = Kingdom()
self.k.save()
self.c = EventCategory(
frequency=1,
timeout=1,
)
self.c.save()
self.e = Event(
name="Event 1",
slug="event_1",
category=self.c,
text="Event 1",
on_fire=""
)
self.e.save()
self.a = EventAction(
event=self.e,
text="some text",
on_fire="",
)
self.a.save()
def test_kingdom_create_pending_event(self):
"""
Check the pending event is created and not started
"""
pe = self.k.create_pending_event("event_1")
self.assertIsNone(pe.started)
self.assertEqual(pe.event_id, self.e.pk)
self.assertEqual(self.k.pendingevent_set.count(), 1)
def test_kingdom_start_pending_event(self):
"""
Check the pending event is created and started
"""
pe = self.k.start_pending_event("event_1")
self.assertIsNotNone(pe.started)
self.assertEqual(pe.event_id, self.e.pk)
self.assertEqual(self.k.pendingevent_set.count(), 1)
示例12: test_get_shifts_with_open_slots
def test_get_shifts_with_open_slots(self):
""" Test get_shifts_with_open_slots(j_id) """
u1 = User.objects.create_user("Yoshi")
v1 = Volunteer(
first_name="Yoshi",
last_name="Turtle",
address="Mario Land",
city="Nintendo Land",
state="Nintendo State",
country="Nintendo Nation",
phone_number="2374983247",
email="[email protected]",
user=u1,
)
v1.save()
e1 = Event(name="Open Source Event", start_date="2012-10-22", end_date="2012-10-23")
e1.save()
j1 = Job(
name="Software Developer",
start_date="2012-10-22",
end_date="2012-10-23",
description="A software job",
event=e1,
)
j2 = Job(
name="Systems Administrator",
start_date="2012-9-1",
end_date="2012-10-26",
description="A systems administrator job",
event=e1,
)
j1.save()
j2.save()
s1 = Shift(date="2012-10-23", start_time="9:00", end_time="3:00", max_volunteers=1, job=j1)
s2 = Shift(date="2012-10-23", start_time="10:00", end_time="4:00", max_volunteers=2, job=j1)
s3 = Shift(date="2012-10-23", start_time="12:00", end_time="6:00", max_volunteers=4, job=j2)
s1.save()
s2.save()
s3.save()
self.assertIsNotNone(get_shifts_with_open_slots(j1.id))
self.assertIsNotNone(get_shifts_with_open_slots(j2.id))
示例13: add_event
def add_event(request):
if request.method == 'POST':
e = Event(
evt_name=request.POST['name'],
evt_place=request.POST['place'],
evt_start_time=request.POST['start_time'],
evt_end_time=request.POST['end_time'],
evt_date=request.POST['date'],
evt_note=request.POST['note'],
owner=request.user)
e.save()
return HttpResponseRedirect('/')
return render_to_response('add_event.html', context_instance=RequestContext(request))
示例14: get_shifts_ordered_by_date
def get_shifts_ordered_by_date(self):
e1 = Event(name = "Open Source Event",
start_date = "2012-10-22",
end_date = "2012-10-23")
e1.save()
j1 = Job(name = "Software Developer",
start_date = "2012-10-22",
end_date = "2012-10-23",
description = "A software job",
event = e1)
j1.save()
s1 = Shift(date = "2012-1-10",
start_time = "9:00",
end_time = "3:00",
max_volunteers = 1,
job = j1)
s2 = Shift(date = "2012-6-25",
start_time = "10:00",
end_time = "4:00",
max_volunteers = 2,
job = j1)
s3 = Shift(date = "2012-12-9",
start_time = "12:00",
end_time = "6:00",
max_volunteers = 4,
job = j1)
s1.save()
s2.save()
s3.save()
#test typical case
shift_list = get_shifts_ordered_by_date(j1.id)
self.assertIsNotNone(shift_list)
self.assertNotEqual(shift_list, False)
self.assertEqual(len(shift_list), 3)
self.assertIn(s1, shift_list)
self.assertIn(s2, shift_list)
self.assertIn(s3, shift_list)
#test order
self.assertEqual(shift_list[0].date, s1.date)
self.assertEqual(shift_list[1].date, s2.date)
self.assertEqual(shift_list[2].date, s3.date)
示例15: test_get_jobs_ordered_by_title
def test_get_jobs_ordered_by_title(self):
e1 = Event(
name="Software Conference",
start_date="2012-10-22",
end_date="2012-10-25"
)
e1.save()
j1 = Job(
name="Software Developer",
start_date="2012-10-22",
end_date="2012-10-23",
description="A software job",
event=e1
)
j2 = Job(
name="Systems Administrator",
start_date="2012-9-1",
end_date="2012-10-26",
description="A systems administrator job",
event=e1
)
j3 = Job(
name="Project Manager",
start_date="2012-1-2",
end_date="2012-2-2",
description="A management job",
event=e1
)
j1.save()
j2.save()
j3.save()
# test typical case
job_list = get_jobs_ordered_by_title()
self.assertIsNotNone(job_list)
self.assertNotEqual(job_list, False)
self.assertEqual(len(job_list), 3)
self.assertIn(j1, job_list)
self.assertIn(j2, job_list)
self.assertIn(j3, job_list)
# test order
self.assertEqual(job_list[0].name, j3.name)
self.assertEqual(job_list[1].name, j1.name)
self.assertEqual(job_list[2].name, j2.name)