本文整理汇总了Python中models.Event.location方法的典型用法代码示例。如果您正苦于以下问题:Python Event.location方法的具体用法?Python Event.location怎么用?Python Event.location使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Event
的用法示例。
在下文中一共展示了Event.location方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _save_event
# 需要导入模块: from models import Event [as 别名]
# 或者: from models.Event import location [as 别名]
def _save_event(self, event):
"""Save the given event"""
uid = event['id']
try:
local_event = Event.objects.get(uid=uid)
except:
local_event = Event(uid=uid)
local_event.calendar = self.gcal
local_event.author = event['creator']
local_event.title = event['summary']
local_event.description = event.get('description', None)
local_event.location = event.get('location', None)
try:
local_event.start = parse(event['start']['dateTime'])
except:
local_event.start = parse(event['start']['date'])
try:
local_event.end = parse(event['end']['dateTime'])
except:
local_event.end = parse(event['end']['date'])
status = 'active'
if event['status'] == 'cancelled':
status = 'cancelled'
local_event.status = status
local_event.save()
return local_event
示例2: saveEventToDB
# 需要导入模块: from models import Event [as 别名]
# 或者: from models.Event import location [as 别名]
def saveEventToDB(event_form,request):
event = Event()
event.category = models.CategoryOptions().get_category_by_id(int(event_form.cleaned_data['category']))
event.budget = event_form.cleaned_data['budget']
event.date = event_form.cleaned_data['date']
event.description = event_form.cleaned_data['description']
event.is_kosher = event_form.cleaned_data['is_kosher']
event.is_vegan = event_form.cleaned_data['is_vegan']
event.is_vegeterian = event_form.cleaned_data['is_vegeterian']
event.picture = event_form.cleaned_data['picture']
event.location = event_form.cleaned_data['location']
event.city = event_form.cleaned_data['city']
event.max_people = event_form.cleaned_data['max_people']
event.name = event_form.cleaned_data['name']
event.organizer_id = request.user.id
user = models.KitchenUser.objects.get(id=request.user.id)
event.save()
participant = models.EventParticipant(event = event, user = user, \
rsvp = models.RsvpOptions().get_rsvp_by_id(int(event_form.cleaned_data['rsvp'])))
participant.save()
return event.id
示例3: create
# 需要导入模块: from models import Event [as 别名]
# 或者: from models.Event import location [as 别名]
def create(request):
if request.method == 'POST':
# save new evento
title = request.POST['title']
description = request.POST['description']
date_start = request.POST['date_start']
date_end = request.POST['date_end']
lat = request.POST['lat']
lng = request.POST['lng']
#image = request.FILES['image']
event = Event(title=title)
event.last_update = datetime.datetime.now()
event.description = description
event.date_start = datetime.datetime.strptime(date_start, '%d/%m/%Y %H:%M')
if not date_end:
event.date_end = None
else:
event.date_end = datetime.datetime.strptime(date_end, '%d/%m/%Y %H:%M')
event.location = [float(lat),float(lng)]
user_id = request.session.get('userid')
user = Account.objects(id=user_id)[0]
event.user = user
event.user_going = [user]
#im = Image.open(image)
#event.image.put(open(im))
event.save()
Account.objects(id=user_id).update_one(push__event_going=event)
return HttpResponseRedirect(reverse('event-list'))
return render_to_response('event/event_create.html',{
'request':request},
context_instance=RequestContext(request))
示例4: convert_to_entity
# 需要导入模块: from models import Event [as 别名]
# 或者: from models.Event import location [as 别名]
def convert_to_entity(vevent):
# print vevent
event_key = get_key(find_pattern(uid_pattern, vevent))
event = Event(key=event_key)
event.title = find_pattern(summary_pattern, vevent)
event.content = find_pattern(content_pattern, vevent).replace('\r\n ', '')
date = find_pattern(time_added_pattern, vevent) # 20150527T131225Z
event.location = find_pattern(location_pattern, vevent)
event.time_added = datetime.strptime(date, '%Y%m%dT%H%M%SZ')
time = find_pattern(start_time_pattern, vevent) # 20150528T190000Z
event.start_time = datetime.strptime(time, '%Y%m%dT%H%M%SZ')
time = find_pattern(end_time_pattern, vevent) # 20150528T190000Z
event.end_time = datetime.strptime(time, '%Y%m%dT%H%M%SZ')
repeat = find_pattern(repeat_pattern, vevent)
until = find_pattern(until_pattern, vevent, 2)
seperator = ""
if until is not None:
seperator = ":"
event.repeat = to_string(repeat) + seperator + to_string(until)
return event
示例5: rest
# 需要导入模块: from models import Event [as 别名]
# 或者: from models.Event import location [as 别名]
def rest(request, event_id=None):
if request.method == 'POST':
title = request.POST['title']
description = request.POST['description']
date_start = request.POST['date_start']
date_end = request.POST.get('date_end', None)
lat = request.POST['lat']
lng = request.POST['lng']
#image = request.FILES['image']
event = Event(title=title)
event.last_update = datetime.datetime.now()
event.description = description
event.date_start = datetime.datetime.strptime(date_start, '%d/%m/%Y %H:%M')
if date_end:
event.date_end = datetime.datetime.strptime(date_end, '%d/%m/%Y %H:%M')
event.location = [float(lat),float(lng)]
user_id = request.session.get('userid')
user = Account.objects(id=user_id)[0]
event.user = user
event.user_going = [user]
#im = Image.open(image)
#event.image.put(open(im))
event.save()
Account.objects(id=user_id).update_one(push__event_going=event)
data = json.dumps({'status':'ok'})
elif event_id:
user = Account.objects(id=request.session.get('userid'))[0]
event = Event.objects(id=event_id, user=user)[0]
if request.method == 'PUT':
# update field values and save to mongo
data = JSONParser().parse(request)
title = data['title']
description = data['description']
date_start = data['date_start']
date_end = data['date_end']
lat = data['lat']
lng = data['lng']
#image = request.FILES['image']
event.title = title
event.last_update = datetime.datetime.now()
event.description = description
event.date_start = datetime.datetime.strptime(date_start, '%d/%m/%Y %H:%M')
if not date_end:
event.date_end = None
else:
event.date_end = datetime.datetime.strptime(date_end, '%d/%m/%Y %H:%M')
event.location = [float(lat),float(lng)]
event.user = user
#event.image = request.FILES['image']
event.save()
data = json.dumps({'status':'ok'})
elif request.method == 'GET':
data = {
'id': str(event.id),
'title': event.title,
'description': event.description,
'location': {
'lat': event.location[0],
'lng': event.location[1]
},
'date_start': str(event.date_start.strftime('%d/%m/%Y %H:%M')) if event.date_start else '',
'date_end': str(event.date_end.strftime('%d/%m/%Y %H:%M')) if event.date_end else ''
}
data = json.dumps(data)
elif request.method == 'DELETE':
Account.objects().update(pull__event_going=event)
Account.objects().update(pull__event_maybe=event)
event.delete()
data = json.dumps({'status':'ok'})
else:
data = json.dumps({'status':'error'})
return HttpResponse(data,content_type='application/json')