本文整理汇总了Python中event.models.Event.poster方法的典型用法代码示例。如果您正苦于以下问题:Python Event.poster方法的具体用法?Python Event.poster怎么用?Python Event.poster使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类event.models.Event
的用法示例。
在下文中一共展示了Event.poster方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: eventHandler
# 需要导入模块: from event.models import Event [as 别名]
# 或者: from event.models.Event import poster [as 别名]
def eventHandler(request, event_id=None):
if request.method == 'GET':
query = request.GET.get('query', None)
if query:
limit = 50
param = request.GET.get('param')
if param == "artist": # search events by artist name
events = Event.objects.select_related().prefetch_related().filter(artists__name__icontains=query).order_by("on_date")[:limit]
elif param == "combined":
try:
filter = request.GET.get('filter')
#print "date_from" , request.GET.get('date_from')
date_from = datetime.strptime(request.GET.get('date_from'), '%d-%m-%Y')
try:
date_to = datetime.strptime(request.GET.get('date_to'), '%d-%m-%Y')
except:
# day overflow , client maybe?
norm = request.GET.get('date_to')
n = "30-" + "-".join(norm.split("-")[1:])
date_to = datetime.strptime(n, '%d-%m-%Y')
towns = request.GET.get('towns', None)
qargs = Q()
qargs = qargs & Q(on_date__gte=date_from) & Q(on_date__lte=date_to)
if towns:
# PURE DARK MAGIC
towns = json.loads(towns)
t = Q()
for x in towns:
t |= Q(venue__city__icontains=x)
qargs &= t
if filter == "all":
events = Event.objects.select_related().prefetch_related().filter(qargs).order_by("on_date")[:limit]
elif filter == "recommended":
# needs better implementation
events = Event.objects.select_related().prefetch_related().filter(qargs).order_by("on_date")[:limit]
elif filter == "popular":
events = Event.objects.select_related().prefetch_related().filter(qargs).order_by("-attends", "on_date")[:limit]
elif filter == "free":
qargs &= Q(price=0.0)
events = Event.objects.select_related().prefetch_related().filter(qargs).order_by("on_date")[:limit]
except:
print traceback.format_exc()
stuff = serialize_events(events=events)
return HttpResponse(stuff, mimetype="application/json")
event_id = request.GET.get('event_id', None)
if event_id is None:
event_form = EventForm()
artist_form = ArtistForm()
venue_form = VenueForm()
return render_to_response('add_event.html', locals(), context_instance=RequestContext(request))
else:
#event = Event.objects.get(pk=event_id)#.select_related().prefetch_related().filter(pk=event_id)[0]
event = Event.objects.select_related().prefetch_related().get(pk=event_id)
#print "lele", event, event.name
#return render_to_response('poster_view.html', locals(), context_instance=RequestContext(request))
stuff = serialize_events(events=[event])
return HttpResponse(stuff, mimetype="application/json")
if request.method == 'POST':
try:
date = datetime.strptime(request.POST.get('date'), '%d-%m-%Y %H:%M')
#date = datetime.strptime(request.POST.get('date'), '%d-%m-%Y')
description = request.POST.get('description')
price = request.POST.get('price')
artist_ids = json.loads(request.POST.get('artist_ids'))
venue_id = request.POST.get('venue_id')
poster_id = request.POST.get('poster_id')
venue = Venue.objects.get(id=venue_id)
try:
user = STUser.objects.get(user=request.user)
except:
user = STUser.objects.get(user=request.session['user_id'])
possible_name = venue.name + "-" + str(date) + "_" + str(artist_ids[0])
# print "description", description, "poster_id", poster_id, "venue_id", venue_id
try:
Event.objects.filter(name=possible_name)[0]
return HttpResponse(json.dumps({"success":False}), mimetype="application/json")
except:pass
event = Event()
event._by = user.user.id
#.........这里部分代码省略.........