本文整理汇总了Python中models.Event.description方法的典型用法代码示例。如果您正苦于以下问题:Python Event.description方法的具体用法?Python Event.description怎么用?Python Event.description使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Event
的用法示例。
在下文中一共展示了Event.description方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _save_event
# 需要导入模块: from models import Event [as 别名]
# 或者: from models.Event import description [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 description [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 description [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: event_add_view
# 需要导入模块: from models import Event [as 别名]
# 或者: from models.Event import description [as 别名]
def event_add_view(request, calendar_id, year, month, day):
calendar = Calendar.objects.get(id=calendar_id)
if request.method == 'POST':
form = EventForm(request.POST)
if form.is_valid():
cd = form.cleaned_data
event = Event()
event.begin_date = cd['begin_date']
event.name = cd['name']
event.owned_by = request.user
event.calendar=calendar
event.description = cd['description']
event.end_date = cd['end_date']
event.save()
guests = []
for subscriber in calendar.subscribers.all():
guest = EventGuest(event=event, user=subscriber, notify_date=timezone.now())
guest.save()
guests.append(guest)
event.guests = guests
event.save()
return HttpResponseRedirect('/event/'+str(event.id))
else:
form = EventForm()
begin_date = datetime(year=int(year), month=int(month), day=int(day), hour=12)
end_date = datetime(year=int(year), month=int(month), day=int(day), hour=15)
# form.begin_date = begin_date
t = get_template('event_edit.html')
html = t.render( RequestContext(request, {'form': form, 'calendar': calendar, 'begin_date':begin_date, 'end_date': end_date, 'date': begin_date}))
return HttpResponse(html)
示例5: create_event
# 需要导入模块: from models import Event [as 别名]
# 或者: from models.Event import description [as 别名]
def create_event():
form = EventForm()
if form.validate_on_submit():
event = Event()
event.name = unicode(form.name.data)
event.description = unicode(form.description.data)
event.registration_opens = form.registration_opens.data
event.registration_closes = form.registration_closes.data
db_session.add(event)
db_session.commit()
return redirect(url_for('dashboard'))
return render_template("admin/create_event.html", form=form)
示例6: events
# 需要导入模块: from models import Event [as 别名]
# 或者: from models.Event import description [as 别名]
def events(id=None):
if id:
event = Event.objects.get(pk=id)
event.update_timezone()
add_form = EventForm(request.form, obj=event)
title_aside = u'Éditer l\'événement'
else:
event = Event()
add_form = EventForm()
title_aside = u'Créer un événement'
if add_form.organisations.data:
add_form.organisations.choices = make_choices(add_form.orgas_choices, selected=add_form.organisations.data, name='Organisations')
if add_form.places.data:
add_form.places.choices = make_choices(add_form.places_choices, selected=add_form.places.data, name='Lieux')
if add_form.validate_on_submit():
event.title = add_form.title.data
event.description = add_form.description.data
event.organisations = add_form.organisations.data
event.places = add_form.places.data
if not event.author:
event.author = current_user.to_dbref()
event.datetime_first = arrow.get(add_form.datetime_first.data).datetime
event.datetime_last = arrow.get(add_form.datetime_last.data).datetime
event.update_timezone()
if current_user.has_role('Administrateur') or current_user.has_role('Éditeur'):
event.status = 'published' if 'publish' in request.form else 'draft'
else:
event.status = 'validation' if 'publish' in request.form else 'draft'
event.save()
if id:
return redirect('/events')
# Filter the events for non-admin users
if not current_user.has_role('Administrateur'):
filter_role = {'organisations__in': current_user.associations}
else:
filter_role = {}
today = arrow.now().date()
events_draft = Event.objects(status='draft', **filter_role).order_by('datetime_first')
events_validation = Event.objects(status='validation', datetime_first__gte=today, **filter_role).order_by('datetime_first')
events_published = Event.objects(status='published', datetime_first__gte=today).order_by('datetime_first')
return render_template('events.html', events_draft=events_draft, events_validation=events_validation, events_published=events_published, add_form=add_form, title_aside=title_aside, icons=icons)
示例7: event
# 需要导入模块: from models import Event [as 别名]
# 或者: from models.Event import description [as 别名]
def event(request):
dbsession = DBSession()
event = Event()
event.entity_id = clean_param_value(request, 'entity_id')
event.action_id = clean_param_value(request, 'action_id')
event.quantity = clean_param_value(request, 'quantity')
event.description = clean_param_value(request, 'description')
event.timestamp = get_timestamp()
hash = hashlib.md5(event.entity_id + event.action_id + event.quantity + str(event.timestamp))\
.hexdigest()
event.hash = hash
dbsession.add(event)
transaction.commit()
event = dbsession.query(Event).filter(Event.hash == hash).one()
event_json = convert.decodeEvent(request, dbsession, event)
return {'status': 'success', 'event': event_json}
示例8: save_imported_event
# 需要导入模块: from models import Event [as 别名]
# 或者: from models.Event import description [as 别名]
def save_imported_event(project_key, start_time, end_time, event_title, event_description, billed, event_url=None):
new_ev = Event(parent=project_key)
new_ev.title = event_title
new_ev.start_time = start_time
new_ev.end_time = end_time
total_seconds = (end_time - start_time).total_seconds()
new_ev.elapsed_time = int(total_seconds // 60)
new_ev.description = event_description
new_ev.billed = billed
if event_url:
new_ev.url = event_url
new_ev.put()
return
示例9: add_event
# 需要导入模块: from models import Event [as 别名]
# 或者: from models.Event import description [as 别名]
def add_event(request):
date = request.POST.get('date')
time = request.POST.get('time')
event_type = request.POST.get('event_type')
description = request.POST.get('description')
dosage = request.POST.get('dosage')
medication_id = int(request.POST.get('select_med'))
user_id = request.user.pk
datetime = str(date) + " " + time
print "datetime", datetime
new_event_entry = Event()
new_event_entry.date = datetime
new_event_entry.event_type = event_type
new_event_entry.description = description
new_event_entry.dosage = dosage
new_event_entry.medication_id = medication_id
new_event_entry.user_id = user_id
new_event_entry.save()
#return render(request, 'med_tracker_app/user_dash.html', { 'new_event' : "You added a new event." })
return HttpResponseRedirect(reverse('med_tracker_app:user_dash'))
示例10: rest
# 需要导入模块: from models import Event [as 别名]
# 或者: from models.Event import description [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')