本文整理汇总了Python中app.models.Event类的典型用法代码示例。如果您正苦于以下问题:Python Event类的具体用法?Python Event怎么用?Python Event使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Event类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_create_event_model
def test_create_event_model(self):
"""Test creating an event with the proper data"""
self.assertEqual(Event.objects(creator=self.USER).count(), 0)
e = self.make_event()
e.save()
self.assertEqual(Event.objects(creator=self.USER).count(), 1)
self.assertEqual(Event.objects().get(creator=self.USER), e)
示例2: events
def events():
"""View the latest events.
**Route:** ``/events``
**Methods:** ``GET``
"""
today = date.today()
last_sunday = datetime.combine(today - timedelta(days=today.isoweekday()+7),
datetime.min.time())
next_sunday = datetime.combine(today + timedelta(days=7-today.isoweekday()),
datetime.min.time())
recent_and_upcoming = Event.objects(published=True,
start_date__gt=last_sunday).order_by('start_date',
'start_time')
recent_events = recent_and_upcoming.filter(end_date__lt=today)
events_this_week = recent_and_upcoming.filter(end_date__gte=today,
start_date__lt=next_sunday)
upcoming_events = recent_and_upcoming.filter(start_date__gt=next_sunday)[:4]
more_past_events = bool(Event.objects(published=True,
start_date__lte=last_sunday).count())
return render_template('events/events.html',
recent_events=recent_events,
events_this_week=events_this_week,
upcoming_events=upcoming_events,
more_past_events=more_past_events)
示例3: create_single_event
def create_single_event(cls, form, creator):
"""Creates a non-recurring Mongoengine and Google Calendar event from
form data.
:param form: The WTForms form.
:type form: :class:`CreateEventForm` or a subclass.
:param creator: The user that is currently logged in.
:type creator: :class:`~app.models.User`
:raises: :class:`GoogleCalendarAPIError` and it's subclasses
:returns: Response from the Google Calendar API.
:rtype: dict
"""
# Generate the event and date data
event_and_date_data = DataBuilder.event_and_date_data_from_form(
form,
creator=creator
)
event_and_date_data = cls._remove_none_fields(event_and_date_data)
event = Event(**event_and_date_data)
event.save()
# Return the Google Calendar response
return gcal_client.create_event(event)
示例4: event
def event(slug):
"""View a specific non-recurring event, or the next upcoming instance of
a recurring event.
**Route:** ``/events/<slug>``
**Methods:** ``GET``
:param str slug: The unique slug ID for the post.
"""
if Event.objects(published=True, slug=slug).count() == 0:
abort(404) # Either invalid event ID or duplicate IDs.
event = Event.objects(published=True, slug=slug)[0]
if event.is_recurring:
upcoming_event_instances = (Event.objects(published=True,
start_date__gte=date.today(),
slug=slug)
.order_by('start_date'))
if upcoming_event_instances:
event = upcoming_event_instances[0]
else:
event = event.parent_series.events[-1]
return render_template('events/event.html',
event=event,
now=now,
upcoming_events=_upcoming_events_triple(event))
示例5: new
def new(request):
selected_players = None
if request.method == 'POST':
selected_players = Player.objects.filter(pk__in=request.POST.getlist('players'))
if selected_players.count() == 4:
event = Event()
event.save()
for player in selected_players:
EventResult(player=player, event=event).save()
request.session['event_pk'] = event.pk
return redirect("race-start")
else:
messages.error(request, 'Please select exactly 4 players')
# Order player list by race_count
player_list = Player.objects.order_by('-race_count').all()
if not selected_players:
# Auto select most fanatic players
selected_players = player_list[:4]
return render(request, 'new.html', { 'player_list': player_list, 'selected_players': selected_players })
示例6: recurring_event
def recurring_event(slug, index):
"""View a specific instance of a recurring event.
**Route:** ``/events/<slug>/<index>``
**Methods:** ``GET``
:param str slug: The unique slug ID for the post.
:param int index: The instance of the event to fetch.
"""
if Event.objects(published=True, slug=slug).count() == 0:
abort(404) # Either invalid event ID or duplicate IDs.
event = Event.objects(published=True, slug=slug)[0]
if not event.is_recurring or not event.parent_series:
return redirect(url_for('.event', slug=slug))
if len(event.parent_series.events) <= index:
abort(404)
event = event.parent_series.events[index]
return render_template('events/event.html',
event=event,
now=now,
upcoming_events=_upcoming_events_triple(event))
示例7: test_event_start_datetimes
def test_event_start_datetimes(self):
"""Test that when events are created with both start_date and
start_time, start_datetime() is their value combined.
"""
e = Event(title=self.TITLE, creator=self.USER,
start_date=self.START.date(),
start_time=self.START.time())
self.assertEqual(e.start_datetime(), self.START)
示例8: test_event_end_datetimes
def test_event_end_datetimes(self):
"""Test that when events are created with both end_date and
end_time, end_datetime() is their value combined.
"""
e = Event(title=self.TITLE, creator=self.USER,
end_date=self.END.date(),
end_time=self.END.time())
self.assertEqual(e.end_datetime(), self.END)
示例9: test_One
def test_One(self):
tperformer = add_performer(bandname ="testband" )
tvenue = Venue(name ="Stereo")
tvenue.save()
my_datetime = timezone.make_aware(datetime.now(), timezone.get_current_timezone())
event_one = Event(time =my_datetime,media='https://www.youtube.com/watch?v=eh7lp9umG2I',venue=tvenue,performer=tperformer,no_tickets=-1)
event_one.save()
self.assertEqual((event_one.no_tickets >=0),True)
示例10: addevent
def addevent():
form = EventForm(request.form)
if request.method == 'POST' and form.validate():
event = Event(name=form.name.data,
intervalMinutes=form.intervalMinutes.data,
type=form.type.data, priority=form.priority.data)
event.save()
session['current_event'] = event
return redirect(url_for('views.selecttime'))
return render_template('addevent.html',session=session, form=form)
示例11: add_event
def add_event(request):
if request.method == 'POST':
event_form = AddEventForm(data=request.POST)
if event_form.is_valid():
event = Event()
event.name =event_form.cleaned_data['name']
dT = datetime.combine(event_form.cleaned_data['eventDate'], event_form.cleaned_data['eventTime'])
event.time = dT
event.no_tickets = event_form.cleaned_data['no_tickets']
event.price = event_form.cleaned_data['price']
vname = event_form.cleaned_data['venueName']
vAddress = event_form.cleaned_data['address']
vcontact = event_form.cleaned_data['contact']
vlocation =event_form.cleaned_data['location']
try:
v = Venue.objects.get(name=vname)
except:
v = Venue.objects.create(name=vname,address=vAddress,contact=vcontact,location=vlocation)
event.venue = v
get_performer = User.objects.get(username=request.user.username)
performer = Performer.objects.get(performer=get_performer)
event.performer = performer
event.save()
return HttpResponseRedirect('/app/performer_profile/')
else:
print event_form.errors
else:
event_form = AddEventForm()
return render(request, 'Gigstop/add_event.html', {'event_form': event_form})
示例12: test_event_start_datetimes_none_with_incomplete_data
def test_event_start_datetimes_none_with_incomplete_data(self):
"""Test that when events are created without both of start_date and
start_time, start_datetime() returns None.
"""
e = Event(title=self.TITLE, creator=self.USER,
start_date=self.START.date())
self.assertIsNone(e.start_datetime())
f = Event(title=self.TITLE, creator=self.USER,
start_time=self.START.time())
self.assertIsNone(f.start_datetime())
示例13: create_single_event
def create_single_event(klass, form, creator):
""""""
# Generate the event and date data
event_and_date_data = DataBuilder.event_and_date_data_from_form(form, creator=creator)
event_and_date_data = klass._remove_none_fields(event_and_date_data)
event = Event(**event_and_date_data)
event.save()
# Return the Google Calendar response
return gcal_client.create_event(event)
示例14: test_event_end_datetimes_none_with_incomplete_data
def test_event_end_datetimes_none_with_incomplete_data(self):
"""Test that when events are created without both of end_date and
end_time, end_datetime() returns None.
"""
e = Event(title=self.TITLE, creator=self.USER,
end_date=self.END.date())
self.assertIsNone(e.end_datetime())
f = Event(title=self.TITLE, creator=self.USER,
end_time=self.END.time())
self.assertIsNone(f.end_datetime())
示例15: newevent
def newevent():
form = CreateEventForm()
event=Event()
if form.validate_on_submit():
form.populate_obj(event)
event.image=event.image.replace("https://www.dropbox.com","https://dl.dropboxusercontent.com/")
db.session.add(event)
db.session.commit()
flash("Event created succesfully")
return redirect(url_for("admin.index"))
return render_template('newevent.html',form=form)