本文整理汇总了Python中core.models.Event类的典型用法代码示例。如果您正苦于以下问题:Python Event类的具体用法?Python Event怎么用?Python Event使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Event类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_or_create_dummy
def get_or_create_dummy(cls):
from django.contrib.auth.models import Group
from core.models import Event
group, unused = Group.objects.get_or_create(name='Dummy ticket admin group')
event, unused = Event.get_or_create_dummy()
return cls.objects.get_or_create(event=event, defaults=dict(admin_group=group))
示例2: get_or_create_dummies
def get_or_create_dummies(cls):
from core.models import Event
event, unused = Event.get_or_create_dummy()
jc1, unused = cls.objects.get_or_create(event=event, name="Dummy 1", slug='dummy-1')
jc2, unused = cls.objects.get_or_create(event=event, name="Dummy 2", slug='dummy-2')
return [jc1, jc2]
示例3: get_or_create_dummy
def get_or_create_dummy(cls):
from core.models import Event
event, unused = Event.get_or_create_dummy()
admin_group, hosts_group = cls.get_or_create_groups(event, ["admins", "hosts"])
return cls.objects.get_or_create(event=event, defaults=dict(admin_group=admin_group, public=True))
示例4: get_or_create_dummy
def get_or_create_dummy(cls):
from core.models import Event
event, unused = Event.get_or_create_dummy()
return cls.objects.get_or_create(
event=event,
name='Iso sali',
)
示例5: get_or_create_dummies
def get_or_create_dummies(cls):
from core.models import Event
event, unused = Event.get_or_create_dummy()
limit_saturday, unused = cls.objects.get_or_create(event=event, description='Testing saturday', defaults=dict(limit=5000))
limit_sunday, unused = cls.objects.get_or_create(event=event, description='Testing sunday', defaults=dict(limit=5000))
return [limit_saturday, limit_sunday]
示例6: get_or_create_dummy
def get_or_create_dummy(cls):
from core.models import Event
event, unused = Event.get_or_create_dummy()
admin_group, organizer_group = cls.get_or_create_groups(event, ['admins', 'organizers'])
return cls.objects.get_or_create(event=event, defaults=dict(
admin_group=admin_group,
organizer_group=organizer_group,
))
示例7: save_event_to_db
def save_event_to_db(event):
'''The function to save single event into DB (table: core_event)
'''
e = Event(
categoryID = parse_category_id(event['category_id']),
datePosted = parse_datetime(event['date_posted']),
description = event['description'],
distance = event['distance'],
distanceUnits = event['distance_units'],
endDate = parse_date(event['end_date']),
endTime = parse_time(event['end_time']),
geoCodingAmbig = event['geocoding_ambiguous'],
geoCodingPrec = event['geocoding_precision'],
eventID = event['id'],
latitude = event['latitude'],
longitude = event['longitude'],
metroID = event['metro_id'],
name = event['name'],
numFutureEvents = event['num_future_events'],
personal = event['personal'],
photoURL = event['photo_url'],
selfPromotion = event['selfpromotion'],
startDate = parse_date(event['start_date']),
startDateLastRendition = event['start_date_last_rendition'],
startTime = parse_time(event['start_time']),
ticketFree = parse_int(event['ticket_free']),
ticketPrice = event['ticket_price'],
ticketURL = event['ticket_url'],
URL = event['url'],
userID = event['user_id'],
utcEnd = parse_datetime(event['utc_end']),
utcStart = parse_datetime(event['utc_start']),
venueAddr = event['venue_address'],
venueCity = event['venue_city'],
venueCountryCode = event['venue_country_code'],
venueCountryID = event['venue_country_id'],
venueCountryName = event['venue_country_name'],
venueID = event['venue_id'],
venueName = event['venue_name'],
venueStateCode = event['venue_state_code'],
venueStateID = event['venue_state_id'],
venueStateName = event['venue_state_name'],
venueZip = str(event['venue_zip']),
watchListCount = event['watchlist_count'])
e.save()
示例8: test_event_filter
def test_event_filter(self):
event, unused = Event.get_or_create_dummy()
event2, unused = Event.get_or_create_dummy(name='Dummy event 2')
kwargs = dict(
channel='callback',
callback_code=f'{__name__}:notification_callback',
)
subscription_with_event_filter, unused = Subscription.get_or_create_dummy(event_filter=event, **kwargs)
subscription_without_event_filter, unused = Subscription.get_or_create_dummy(event_filter=None, **kwargs)
entry_type = subscription_with_event_filter.entry_type
emit(entry_type, event=event)
emit(entry_type, event=event2)
assert len(notifications) == 3
示例9: setUp
def setUp(self):
app = get_application()
self.client = Client(app, BaseResponse)
self.test_values = {
'date': datetime.datetime(2016, 5, 20, 15, 0),
'title': 'THIS IS TITLE',
'description': 'THIS IS TITLE',
}
eve = Event(
event_date=self.test_values['date'],
title=self.test_values['title'],
description=self.test_values['description'],
)
eve.put()
events = Event.all().fetch(100)
self.assertEquals(len(events), 1)
self.assertEquals(events[0].title, 'THIS IS TITLE')
self.event_key = str(events[0].key())
示例10: get_or_create_dummy
def get_or_create_dummy(cls, app_label='labour', name='Smallfolk', priority=0):
from core.models import Event
event, unused = Event.get_or_create_dummy()
return PersonnelClass.objects.get_or_create(
event=event,
slug=slugify(name),
app_label=app_label,
defaults=dict(
name=app_label,
priority=priority,
)
)
示例11: events
def events(request):
if request.user.is_anonymous():
return JsonResponse({'error': 'loggedOut'})
if request.method == 'POST':
event_data = convert_dict_keys_deep(json.loads(request.body))['event']
if (not event_data['name'] or not event_data['date_from'] or not event_data['type'] or not event_data['color']):
return JsonResponse({'error': 'badRequest'})
if (not event_data['id']):
event = Event(
name=event_data['name'],
date_from=event_data['date_from'],
date_to=event_data['date_to'],
type=event_data['type'],
color=event_data['color'],
)
event.save()
return JsonResponse({'event': serialize_event(event)})
events = [serialize_event(event) for event in Event.objects.order_by('date_from').all()]
return JsonResponse({'events': events})
示例12: get_or_create_dummy
def get_or_create_dummy(cls, event=None):
from django.contrib.auth.models import Group
from core.models import Event
if event is None:
event, unused = Event.get_or_create_dummy()
group, = PaymentsEventMeta.get_or_create_groups(event, ['admins'])
return cls.objects.get_or_create(event=event, defaults=dict(
EVENT_META_DEFAULTS,
admin_group=group,
))
示例13: get_or_create_dummy
def get_or_create_dummy(cls):
from core.models import Event
from django.utils.timezone import now
event, unused = Event.get_or_create_dummy()
admin_group, hosts_group = cls.get_or_create_groups(event, ['admins', 'hosts'])
return cls.objects.get_or_create(
event=event,
defaults=dict(
admin_group=admin_group,
public_from=now(),
)
)
示例14: ical
def ical(request, event_key):
event = Event.get(event_key)
if event is None:
return render_json_response({'error': '404 not found'}, mimetype='application/json', status=404)
cal = icalendar.Calendar()
eve = icalendar.Event()
eve['dtstart'] = event.event_date.strftime('%Y%m%dT%H%M%S')
eve['created'] = event.created_at.strftime('%Y%m%dT%H%M%S')
eve['last-modified'] = event.updated_at.strftime('%Y%m%dT%H%M%S')
eve['summary'] = event.title
eve['description'] = event.description
eve['event_key'] = event_key
eve['updated_log'] = event.updated_log
cal.add_component(eve)
return Response(cal.to_ical(), status=200, mimetype="text/calendar",
headers={'Content-Disposition': 'inline; filename=event.ics'})
示例15: api_event_add
def api_event_add(request):
response = {}
header = request.POST['header']
category = request.POST['category']
plan_id = request.POST['plan_id']
plan = Plan.objects.get(id=plan_id)
new_event = Event()
new_event.header = header
new_event.category = category
new_event.plan = plan
new_event.order = len(plan.get_events())
new_event.save()
response['event_id'] = new_event.id
response['collaborator_id'] = request.user.id
return response, 201